From 688b5f42e9bfe498d7af7075d4d8f4429867f3a3 Mon Sep 17 00:00:00 2001 From: Miles Macklin Date: Fri, 9 Jun 2017 13:41:15 +1200 Subject: 1.2.0.beta.1 --- .gitignore | 6 + README.md | 4 +- bin/linux64/NvFlexDemoDebugCUDA_x64 | Bin 11831737 -> 11999005 bytes bin/linux64/NvFlexDemoReleaseCUDA_x64 | Bin 8068141 -> 8171502 bytes bin/win32/NvFlexDebugCUDA_x86.dll | Bin 3747184 -> 3955568 bytes bin/win32/NvFlexDebugCUDA_x86.dll.pdb | Bin 4435968 -> 4411392 bytes bin/win32/NvFlexDebugD3D_x86.dll | Bin 1722736 -> 1921392 bytes bin/win32/NvFlexDebugD3D_x86.dll.pdb | Bin 5279744 -> 5287936 bytes bin/win32/NvFlexDemoDebugCUDA_x86.exe | Bin 1989632 -> 2028544 bytes bin/win32/NvFlexDemoDebugCUDA_x86.exe.pdb | Bin 8171520 -> 8343552 bytes bin/win32/NvFlexDemoDebugD3D_x86.exe | Bin 2057728 -> 2426368 bytes bin/win32/NvFlexDemoDebugD3D_x86.exe.pdb | Bin 8835072 -> 10891264 bytes bin/win32/NvFlexDemoReleaseCUDA_x86.exe | Bin 1009152 -> 1039872 bytes bin/win32/NvFlexDemoReleaseCUDA_x86.exe.pdb | Bin 9383936 -> 9629696 bytes bin/win32/NvFlexDemoReleaseD3D_x86.exe | Bin 1076736 -> 1300480 bytes bin/win32/NvFlexDemoReleaseD3D_x86.exe.pdb | Bin 10088448 -> 12193792 bytes bin/win32/NvFlexDeviceDebug_x86.dll | Bin 491888 -> 491888 bytes bin/win32/NvFlexDeviceDebug_x86.dll.pdb | Bin 2134016 -> 2134016 bytes bin/win32/NvFlexDeviceRelease_x86.dll | Bin 135024 -> 135024 bytes bin/win32/NvFlexDeviceRelease_x86.dll.pdb | Bin 1634304 -> 1634304 bytes bin/win32/NvFlexExtDebugCUDA_x86.dll | Bin 977776 -> 980848 bytes bin/win32/NvFlexExtDebugCUDA_x86.dll.pdb | Bin 4845568 -> 4845568 bytes bin/win32/NvFlexExtDebugD3D_x86.dll | Bin 830832 -> 833392 bytes bin/win32/NvFlexExtDebugD3D_x86.dll.pdb | Bin 4861952 -> 4870144 bytes bin/win32/NvFlexExtReleaseCUDA_x86.dll | Bin 514928 -> 519024 bytes bin/win32/NvFlexExtReleaseCUDA_x86.dll.pdb | Bin 5140480 -> 5148672 bytes bin/win32/NvFlexExtReleaseD3D_x86.dll | Bin 357744 -> 362352 bytes bin/win32/NvFlexExtReleaseD3D_x86.dll.pdb | Bin 5001216 -> 5017600 bytes bin/win32/NvFlexReleaseCUDA_x86.dll | Bin 878960 -> 905584 bytes bin/win32/NvFlexReleaseCUDA_x86.dll.pdb | Bin 4329472 -> 4313088 bytes bin/win32/NvFlexReleaseD3D_x86.dll | Bin 1070448 -> 1231216 bytes bin/win32/NvFlexReleaseD3D_x86.dll.pdb | Bin 5468160 -> 5484544 bytes bin/win32/nvToolsExt32_1.dll | Bin 0 -> 40960 bytes bin/win64/NvFlexDebugCUDA_x64.dll | Bin 4207984 -> 4440944 bytes bin/win64/NvFlexDebugCUDA_x64.dll.pdb | Bin 4337664 -> 4321280 bytes bin/win64/NvFlexDebugD3D_x64.dll | Bin 2020720 -> 2253680 bytes bin/win64/NvFlexDebugD3D_x64.dll.pdb | Bin 5345280 -> 5410816 bytes bin/win64/NvFlexDemoDebugCUDA_x64.exe | Bin 2471424 -> 2523648 bytes bin/win64/NvFlexDemoDebugCUDA_x64.exe.pdb | Bin 8507392 -> 8695808 bytes bin/win64/NvFlexDemoDebugD3D_x64.exe | Bin 2560512 -> 3018752 bytes bin/win64/NvFlexDemoDebugD3D_x64.exe.pdb | Bin 9162752 -> 11268096 bytes bin/win64/NvFlexDemoReleaseCUDA_x64.exe | Bin 1213440 -> 1247232 bytes bin/win64/NvFlexDemoReleaseCUDA_x64.exe.pdb | Bin 9342976 -> 9588736 bytes bin/win64/NvFlexDemoReleaseD3D_x64.exe | Bin 1295360 -> 1547776 bytes bin/win64/NvFlexDemoReleaseD3D_x64.exe.pdb | Bin 10072064 -> 12177408 bytes bin/win64/NvFlexDeviceDebug_x64.dll | Bin 604016 -> 604016 bytes bin/win64/NvFlexDeviceDebug_x64.dll.pdb | Bin 2109440 -> 2109440 bytes bin/win64/NvFlexDeviceRelease_x64.dll | Bin 145264 -> 145264 bytes bin/win64/NvFlexDeviceRelease_x64.dll.pdb | Bin 1462272 -> 1462272 bytes bin/win64/NvFlexExtDebugCUDA_x64.dll | Bin 1193840 -> 1197424 bytes bin/win64/NvFlexExtDebugCUDA_x64.dll.pdb | Bin 4894720 -> 4902912 bytes bin/win64/NvFlexExtDebugD3D_x64.dll | Bin 1036656 -> 1040240 bytes bin/win64/NvFlexExtDebugD3D_x64.dll.pdb | Bin 4894720 -> 4902912 bytes bin/win64/NvFlexExtReleaseCUDA_x64.dll | Bin 491376 -> 494960 bytes bin/win64/NvFlexExtReleaseCUDA_x64.dll.pdb | Bin 4861952 -> 4878336 bytes bin/win64/NvFlexExtReleaseD3D_x64.dll | Bin 426352 -> 429936 bytes bin/win64/NvFlexExtReleaseD3D_x64.dll.pdb | Bin 4829184 -> 4845568 bytes bin/win64/NvFlexReleaseCUDA_x64.dll | Bin 877936 -> 906096 bytes bin/win64/NvFlexReleaseCUDA_x64.dll.pdb | Bin 4124672 -> 4116480 bytes bin/win64/NvFlexReleaseD3D_x64.dll | Bin 1188208 -> 1382256 bytes bin/win64/NvFlexReleaseD3D_x64.dll.pdb | Bin 5369856 -> 5459968 bytes bin/win64/nvToolsExt64_1.dll | Bin 0 -> 48128 bytes core/core.h | 2 +- core/platform.cpp | 2 +- core/platform.h | 2 +- core/voxelize.cpp | 4 +- core/voxelize.h | 2 +- demo/benchmark.h | 444 +- demo/compiler/makeandroid/Makefile | 22 +- demo/compiler/makeandroid/Makefile.flexDemoCUDA.mk | 25 +- demo/compiler/makeandroid/Makefile.flexExtCUDA.mk | 48 +- demo/compiler/makelinux64/Makefile.flexDemoCUDA.mk | 4 +- demo/compiler/vc12win32/flexDemoCUDA.vcxproj | 8 +- .../vc12win32/flexDemoCUDA.vcxproj.filters | 6 +- demo/compiler/vc12win32/flexDemoD3D.vcxproj | 342 +- .../compiler/vc12win32/flexDemoD3D.vcxproj.filters | 304 +- demo/compiler/vc12win64/flexDemoCUDA.vcxproj | 8 +- .../vc12win64/flexDemoCUDA.vcxproj.filters | 6 +- demo/compiler/vc12win64/flexDemoD3D.vcxproj | 342 +- .../compiler/vc12win64/flexDemoD3D.vcxproj.filters | 304 +- demo/compiler/vc14win32/flexDemoCUDA.vcxproj | 8 +- .../vc14win32/flexDemoCUDA.vcxproj.filters | 6 +- demo/compiler/vc14win32/flexDemoD3D.vcxproj | 343 +- .../compiler/vc14win32/flexDemoD3D.vcxproj.filters | 304 +- demo/compiler/vc14win64/flexDemoCUDA.vcxproj | 8 +- .../vc14win64/flexDemoCUDA.vcxproj.filters | 6 +- demo/compiler/vc14win64/flexDemoD3D.vcxproj | 343 +- .../compiler/vc14win64/flexDemoD3D.vcxproj.filters | 304 +- demo/compiler/xpj/flexDemoCUDA.xpj | 82 +- demo/compiler/xpj/flexDemoD3D.xpj | 132 +- demo/d3d/appGraphCtx.h | 47 + demo/d3d/appGraphCtxLoader.cpp | 72 + demo/d3d/demoContext.h | 93 + demo/d3d/imguiGraph.cpp | 471 + demo/d3d/imguiGraph.h | 63 + demo/d3d/imguiGraphLoader.cpp | 84 + demo/d3d/loader.cpp | 27 + demo/d3d/loader.h | 24 + demo/d3d/loaderMacros.h | 65 + demo/d3d/renderParamsD3D.cpp | 178 + demo/d3d/renderParamsD3D.h | 248 + demo/d3d/shaderCommonD3D.h | 19 + demo/d3d/shaders/blurDepthPS.hlsl | 84 + demo/d3d/shaders/blurDepthPS.hlsl.h | 657 ++ demo/d3d/shaders/compositePS.hlsl | 182 + demo/d3d/shaders/compositePS.hlsl.h | 1642 +++ demo/d3d/shaders/debugLinePS.hlsl | 10 + demo/d3d/shaders/debugLinePS.hlsl.h | 121 + demo/d3d/shaders/debugLineVS.hlsl | 26 + demo/d3d/shaders/debugLineVS.hlsl.h | 213 + demo/d3d/shaders/diffuseGS.hlsl | 83 + demo/d3d/shaders/diffuseGS.hlsl.h | 973 ++ demo/d3d/shaders/diffusePS.hlsl | 29 + demo/d3d/shaders/diffusePS.hlsl.h | 216 + demo/d3d/shaders/diffuseVS.hlsl | 25 + demo/d3d/shaders/diffuseVS.hlsl.h | 425 + demo/d3d/shaders/ellipsoidDepthGS.hlsl | 65 + demo/d3d/shaders/ellipsoidDepthGS.hlsl.h | 372 + demo/d3d/shaders/ellipsoidDepthPS.hlsl | 88 + demo/d3d/shaders/ellipsoidDepthPS.hlsl.h | 643 ++ demo/d3d/shaders/ellipsoidDepthVS.hlsl | 118 + demo/d3d/shaders/ellipsoidDepthVS.hlsl.h | 935 ++ demo/d3d/shaders/imguiPS.hlsl | 22 + demo/d3d/shaders/imguiPS.hlsl.h | 197 + demo/d3d/shaders/imguiVS.hlsl | 31 + demo/d3d/shaders/imguiVS.hlsl.h | 248 + demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl | 3 + demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl.h | 1558 +++ demo/d3d/shaders/meshPS.hlsl | 123 + demo/d3d/shaders/meshPS.hlsl.h | 1558 +++ demo/d3d/shaders/meshShadowPS.hlsl | 12 + demo/d3d/shaders/meshShadowPS.hlsl.h | 139 + demo/d3d/shaders/meshVS.hlsl | 35 + demo/d3d/shaders/meshVS.hlsl.h | 625 ++ demo/d3d/shaders/passThroughVS.hlsl | 14 + demo/d3d/shaders/passThroughVS.hlsl.h | 155 + demo/d3d/shaders/pointGS.hlsl | 68 + demo/d3d/shaders/pointGS.hlsl.h | 713 ++ demo/d3d/shaders/pointPS.hlsl | 81 + demo/d3d/shaders/pointPS.hlsl.h | 947 ++ demo/d3d/shaders/pointShadowPS.hlsl | 17 + demo/d3d/shaders/pointShadowPS.hlsl.h | 157 + demo/d3d/shaders/pointVS.hlsl | 25 + demo/d3d/shaders/pointVS.hlsl.h | 374 + demo/d3d/shaders/shaderCommon.h | 254 + demo/d3d/shadersDemoContext.cpp | 184 + demo/d3d/shadersDemoContext.h | 21 + demo/d3d11/appD3D11Ctx.cpp | 303 +- demo/d3d11/appD3D11Ctx.h | 76 +- demo/d3d11/debugLineRender.h | 199 - demo/d3d11/debugLineRenderD3D11.cpp | 170 + demo/d3d11/debugLineRenderD3D11.h | 42 + demo/d3d11/demoContextD3D11.cpp | 1147 ++ demo/d3d11/demoContextD3D11.h | 113 + demo/d3d11/diffuseRender.cpp | 217 - demo/d3d11/diffuseRender.h | 69 - demo/d3d11/diffuseRenderD3D11.cpp | 182 + demo/d3d11/diffuseRenderD3D11.h | 76 + demo/d3d11/fluidRender.cpp | 458 - demo/d3d11/fluidRender.h | 126 - demo/d3d11/fluidRenderD3D11.cpp | 365 + demo/d3d11/fluidRenderD3D11.h | 109 + demo/d3d11/imguiGraph.cpp | 472 - demo/d3d11/imguiGraph.h | 29 - demo/d3d11/imguiGraphD3D11.cpp | 44 +- demo/d3d11/imguiGraphD3D11.h | 50 +- demo/d3d11/imguiInteropD3D11.cpp | 51 + demo/d3d11/meshRender.cpp | 221 - demo/d3d11/meshRender.h | 297 - demo/d3d11/meshRenderD3D11.cpp | 341 + demo/d3d11/meshRenderD3D11.h | 74 + demo/d3d11/pointRender.cpp | 206 - demo/d3d11/pointRender.h | 88 - demo/d3d11/pointRenderD3D11.cpp | 173 + demo/d3d11/pointRenderD3D11.h | 43 + demo/d3d11/renderTarget.cpp | 146 - demo/d3d11/renderTarget.h | 51 - demo/d3d11/renderTargetD3D11.cpp | 146 + demo/d3d11/renderTargetD3D11.h | 51 + demo/d3d11/shaders/blurDepthPS.hlsl | 91 - demo/d3d11/shaders/blurDepthPS.hlsl.h | 664 -- demo/d3d11/shaders/compositePS.hlsl | 194 - demo/d3d11/shaders/compositePS.hlsl.h | 1643 --- demo/d3d11/shaders/debugLinePS.hlsl | 10 - demo/d3d11/shaders/debugLinePS.hlsl.h | 121 - demo/d3d11/shaders/debugLineVS.hlsl | 26 - demo/d3d11/shaders/debugLineVS.hlsl.h | 213 - demo/d3d11/shaders/diffuseGS.hlsl | 176 - demo/d3d11/shaders/diffuseGS.hlsl.h | 973 -- demo/d3d11/shaders/diffusePS.hlsl | 37 - demo/d3d11/shaders/diffusePS.hlsl.h | 216 - demo/d3d11/shaders/diffuseVS.hlsl | 26 - demo/d3d11/shaders/diffuseVS.hlsl.h | 425 - demo/d3d11/shaders/ellipsoidDepthGS.hlsl | 127 - demo/d3d11/shaders/ellipsoidDepthGS.hlsl.h | 414 - demo/d3d11/shaders/ellipsoidDepthPS.hlsl | 108 - demo/d3d11/shaders/ellipsoidDepthPS.hlsl.h | 662 -- demo/d3d11/shaders/ellipsoidDepthVS.hlsl | 195 - demo/d3d11/shaders/ellipsoidDepthVS.hlsl.h | 940 -- demo/d3d11/shaders/imguiPS.hlsl | 22 - demo/d3d11/shaders/imguiPS.hlsl.h | 197 - demo/d3d11/shaders/imguiVS.hlsl | 31 - demo/d3d11/shaders/imguiVS.hlsl.h | 248 - demo/d3d11/shaders/meshPS.hlsl | 130 - demo/d3d11/shaders/meshPS.hlsl.h | 1553 --- demo/d3d11/shaders/meshShadowPS.hlsl | 11 - demo/d3d11/shaders/meshShadowPS.hlsl.h | 156 - demo/d3d11/shaders/meshVS.hlsl | 91 - demo/d3d11/shaders/meshVS.hlsl.h | 635 -- demo/d3d11/shaders/passThroughVS.hlsl | 26 - demo/d3d11/shaders/passThroughVS.hlsl.h | 145 - demo/d3d11/shaders/pointGS.hlsl | 84 - demo/d3d11/shaders/pointGS.hlsl.h | 740 -- demo/d3d11/shaders/pointPS.hlsl | 103 - demo/d3d11/shaders/pointPS.hlsl.h | 947 -- demo/d3d11/shaders/pointVS.hlsl | 26 - demo/d3d11/shaders/pointVS.hlsl.h | 374 - demo/d3d11/shaders/shaderCommon.h | 237 - demo/d3d11/shadersD3D11.cpp | 1041 -- demo/d3d11/shadowMap.cpp | 162 - demo/d3d11/shadowMap.h | 51 - demo/d3d11/shadowMapD3D11.cpp | 162 + demo/d3d11/shadowMapD3D11.h | 50 + demo/d3d12/NvCoDx12CircularResourceHeap.cpp | 204 + demo/d3d12/NvCoDx12CircularResourceHeap.h | 234 + demo/d3d12/NvCoDx12CounterFence.cpp | 71 + demo/d3d12/NvCoDx12CounterFence.h | 82 + demo/d3d12/NvCoDx12DescriptorHeap.cpp | 54 + demo/d3d12/NvCoDx12DescriptorHeap.h | 116 + demo/d3d12/NvCoDx12Handle.h | 162 + demo/d3d12/NvCoDx12HelperUtil.cpp | 89 + demo/d3d12/NvCoDx12HelperUtil.h | 52 + demo/d3d12/NvCoDx12RenderTarget.cpp | 324 + demo/d3d12/NvCoDx12RenderTarget.h | 122 + demo/d3d12/NvCoDx12Resource.cpp | 167 + demo/d3d12/NvCoDx12Resource.h | 140 + demo/d3d12/NvCoDx12ResourceScopeManager.cpp | 179 + demo/d3d12/NvCoDx12ResourceScopeManager.h | 100 + demo/d3d12/NvCoDxDebugUtil.cpp | 32 + demo/d3d12/NvCoDxDebugUtil.h | 37 + demo/d3d12/NvCoDxFormatUtil.cpp | 173 + demo/d3d12/NvCoDxFormatUtil.h | 41 + demo/d3d12/NvCoFreeList.cpp | 232 + demo/d3d12/NvCoFreeList.h | 154 + demo/d3d12/NvResult.h | 137 + demo/d3d12/appD3D12Ctx.cpp | 1210 +++ demo/d3d12/appD3D12Ctx.h | 181 + demo/d3d12/bufferD3D12.cpp | 118 + demo/d3d12/bufferD3D12.h | 38 + demo/d3d12/demoContextD3D12.cpp | 1410 +++ demo/d3d12/demoContextD3D12.h | 256 + demo/d3d12/diffusePointRenderPipelineD3D12.cpp | 223 + demo/d3d12/diffusePointRenderPipelineD3D12.h | 54 + demo/d3d12/fluidCompositeRenderPipelineD3D12.cpp | 166 + demo/d3d12/fluidCompositeRenderPipelineD3D12.h | 54 + demo/d3d12/fluidEllipsoidRenderPipelineD3D12.cpp | 176 + demo/d3d12/fluidEllipsoidRenderPipelineD3D12.h | 60 + demo/d3d12/fluidSmoothRenderPipelineD3D12.cpp | 158 + demo/d3d12/fluidSmoothRenderPipelineD3D12.h | 55 + demo/d3d12/imguiGraphD3D12.cpp | 667 ++ demo/d3d12/imguiGraphD3D12.h | 91 + demo/d3d12/imguiInteropD3D12.cpp | 61 + demo/d3d12/lineRenderPipelineD3D12.cpp | 140 + demo/d3d12/lineRenderPipelineD3D12.h | 65 + demo/d3d12/meshRenderPipelineD3D12.cpp | 284 + demo/d3d12/meshRenderPipelineD3D12.h | 66 + demo/d3d12/meshRenderer.cpp | 15 + demo/d3d12/meshRenderer.h | 194 + demo/d3d12/meshRendererD3D12.cpp | 419 + demo/d3d12/meshRendererD3D12.h | 175 + demo/d3d12/meshUtil.cpp | 33 + demo/d3d12/meshUtil.h | 26 + demo/d3d12/pipelineUtilD3D12.cpp | 78 + demo/d3d12/pipelineUtilD3D12.h | 37 + demo/d3d12/pointRenderPipelineD3D12.cpp | 227 + demo/d3d12/pointRenderPipelineD3D12.h | 60 + demo/d3d12/renderStateD3D12.cpp | 67 + demo/d3d12/renderStateD3D12.h | 74 + demo/helpers.h | 104 +- demo/imgui.cpp | 180 +- demo/imgui.h | 18 +- demo/main.cpp | 722 +- demo/opengl/shadersGL.cpp | 379 +- demo/scenes.h | 2 +- demo/scenes/adhesion.h | 1 - demo/scenes/armadilloshower.h | 1 - demo/scenes/bouyancy.h | 1 - demo/scenes/bunnybath.h | 1 - demo/scenes/ccdfluid.h | 1 - demo/scenes/dambreak.h | 1 - demo/scenes/debris.h | 7 +- demo/scenes/envcloth.h | 5 +- demo/scenes/fluidblock.h | 1 - demo/scenes/fluidclothcoupling.h | 1 - demo/scenes/forcefield.h | 2 +- demo/scenes/gamemesh.h | 3 - demo/scenes/googun.h | 1 - demo/scenes/granularpile.h | 7 +- demo/scenes/granularshape.h | 3 +- demo/scenes/inflatable.h | 2 +- demo/scenes/lighthouse.h | 1 - demo/scenes/localspacecloth.h | 1 - demo/scenes/localspacefluid.h | 1 - demo/scenes/lowdimensionalshapes.h | 1 - demo/scenes/melting.h | 3 +- demo/scenes/mixedpile.h | 7 +- demo/scenes/parachutingbunnies.h | 1 - demo/scenes/plasticstack.h | 50 - demo/scenes/player.h | 4 +- demo/scenes/rayleightaylor.h | 2 - demo/scenes/rigidfluidcoupling.h | 5 +- demo/scenes/rigidrotation.h | 20 +- demo/scenes/rockpool.h | 3 +- demo/scenes/shapechannels.h | 48 + demo/scenes/softbody.h | 350 +- demo/scenes/surfacetension.h | 1 - demo/scenes/tearing.h | 6 +- demo/scenes/thinbox.h | 1 - demo/scenes/triggervolume.h | 4 +- demo/scenes/viscosity.h | 3 +- demo/scenes/waterballoon.h | 8 +- demo/shaders.h | 108 +- doc/.buildinfo | 2 +- doc/_sources/manual.txt | 107 +- doc/_static/api/_nv_flex_8h.html | 942 +- doc/_static/api/_nv_flex_8h_source.html | 1227 ++- doc/_static/api/_nv_flex_device_8h.html | 4 +- doc/_static/api/_nv_flex_device_8h_source.html | 4 +- doc/_static/api/_nv_flex_ext_8h.html | 42 +- doc/_static/api/_nv_flex_ext_8h_source.html | 905 +- .../api/dir_d44c64559bbebec7f509842c48db8b23.html | 4 +- doc/_static/api/files.html | 4 +- doc/_static/api/globals.html | 121 +- doc/_static/api/globals_enum.html | 7 +- doc/_static/api/globals_eval.html | 49 +- doc/_static/api/globals_func.html | 73 +- doc/_static/api/globals_type.html | 4 +- doc/_static/api/index.html | 4 +- .../api/struct_nv_flex_solver_callback.html | 4 +- doc/_static/api/struct_nv_flex_vector.html | 48 +- doc/genindex.html | 33 +- doc/index.html | 33 +- doc/manual.html | 128 +- doc/objects.inv | Bin 604 -> 604 bytes doc/releasenotes.html | 99 +- doc/search.html | 33 +- doc/searchindex.js | 2 +- extensions/compiler/makeandroid/Makefile | 19 +- .../compiler/makeandroid/Makefile.flexExtCUDA.mk | 48 +- extensions/compiler/makeandroid_aarch64/Makefile | 202 + .../makeandroid_aarch64/Makefile.flexCUDA.mk | 227 + .../makeandroid_aarch64/Makefile.flexExtCUDA.mk | 207 + extensions/compiler/vc12win32/vc120.pdb | Bin 487424 -> 528384 bytes extensions/compiler/vc12win64/vc120.pdb | Bin 479232 -> 528384 bytes extensions/compiler/vc14win32/vc140.pdb | Bin 0 -> 405504 bytes extensions/compiler/xpj/flexExtCUDA.xpj | 44 +- extensions/compiler/xpj/flexExtD3D12.xpj | 170 + extensions/dx/flexExt.cpp | 2 +- extensions/flexExtContainer.cpp | 86 +- extensions/flexExtRigid.cpp | 51 +- extensions/flexExtSoft.cpp | 66 +- external/D3D12/include/PIXEventsCommon.h | 491 + external/D3D12/include/PIXEventsGenerated.h | 10754 +++++++++++++++++++ external/D3D12/include/dxgi.h | 2953 +++++ external/D3D12/include/dxgi1_2.h | 2474 +++++ external/D3D12/include/dxgi1_3.h | 2121 ++++ external/D3D12/include/dxgi1_4.h | 1494 +++ external/D3D12/include/dxgitype.h | 149 + external/D3D12/include/pix3.h | 126 + external/D3D12/include/pix3_win.h | 61 + .../cub/warp/specializations/warp_scan_smem.cuh | 3 +- include/NvFlex.h | 342 +- include/NvFlexExt.h | 17 +- lib/linux64/NvFlexDebugCUDA_x64.a | Bin 3566368 -> 3663958 bytes lib/linux64/NvFlexDeviceDebug_x64.a | Bin 21700 -> 21700 bytes lib/linux64/NvFlexDeviceRelease_x64.a | Bin 6188 -> 6188 bytes lib/linux64/NvFlexExtDebugCUDA_x64.a | Bin 4093552 -> 4101330 bytes lib/linux64/NvFlexExtReleaseCUDA_x64.a | Bin 276022 -> 282496 bytes lib/linux64/NvFlexReleaseCUDA_x64.a | Bin 3442176 -> 3539766 bytes lib/win32/NvFlexDebugCUDA_x86.lib | Bin 17800 -> 19860 bytes lib/win32/NvFlexDebugD3D_x86.lib | Bin 22558 -> 24802 bytes lib/win32/NvFlexDeviceDebug_x86.lib | Bin 2766 -> 2766 bytes lib/win32/NvFlexDeviceRelease_x86.lib | Bin 2796 -> 2796 bytes lib/win32/NvFlexExtDebugCUDA_x86.lib | Bin 11256 -> 11842 bytes lib/win32/NvFlexExtDebugD3D_x86.lib | Bin 11204 -> 11788 bytes lib/win32/NvFlexExtReleaseCUDA_x86.lib | Bin 11350 -> 11940 bytes lib/win32/NvFlexExtReleaseD3D_x86.lib | Bin 11298 -> 11886 bytes lib/win32/NvFlexReleaseCUDA_x86.lib | Bin 17958 -> 20034 bytes lib/win32/NvFlexReleaseD3D_x86.lib | Bin 22742 -> 25004 bytes lib/win64/NvFlexDebugCUDA_x64.lib | Bin 17466 -> 19486 bytes lib/win64/NvFlexDebugD3D_x64.lib | Bin 22288 -> 24486 bytes lib/win64/NvFlexDeviceDebug_x64.lib | Bin 2774 -> 2774 bytes lib/win64/NvFlexDeviceRelease_x64.lib | Bin 2804 -> 2804 bytes lib/win64/NvFlexExtDebugCUDA_x64.lib | Bin 11086 -> 11662 bytes lib/win64/NvFlexExtDebugD3D_x64.lib | Bin 11040 -> 11614 bytes lib/win64/NvFlexExtReleaseCUDA_x64.lib | Bin 11180 -> 11760 bytes lib/win64/NvFlexExtReleaseD3D_x64.lib | Bin 11134 -> 11712 bytes lib/win64/NvFlexReleaseCUDA_x64.lib | Bin 17624 -> 19660 bytes lib/win64/NvFlexReleaseD3D_x64.lib | Bin 22472 -> 24688 bytes release_notes.txt | 25 + src/dx/context/Context.h | 37 +- src/dx/context/Device.h | 12 +- src/dx/context/NvFlexTypes.h | 1 + 403 files changed, 57465 insertions(+), 20405 deletions(-) create mode 100644 bin/win32/nvToolsExt32_1.dll create mode 100644 bin/win64/nvToolsExt64_1.dll create mode 100644 demo/d3d/appGraphCtx.h create mode 100644 demo/d3d/appGraphCtxLoader.cpp create mode 100644 demo/d3d/demoContext.h create mode 100644 demo/d3d/imguiGraph.cpp create mode 100644 demo/d3d/imguiGraph.h create mode 100644 demo/d3d/imguiGraphLoader.cpp create mode 100644 demo/d3d/loader.cpp create mode 100644 demo/d3d/loader.h create mode 100644 demo/d3d/loaderMacros.h create mode 100644 demo/d3d/renderParamsD3D.cpp create mode 100644 demo/d3d/renderParamsD3D.h create mode 100644 demo/d3d/shaderCommonD3D.h create mode 100644 demo/d3d/shaders/blurDepthPS.hlsl create mode 100644 demo/d3d/shaders/blurDepthPS.hlsl.h create mode 100644 demo/d3d/shaders/compositePS.hlsl create mode 100644 demo/d3d/shaders/compositePS.hlsl.h create mode 100644 demo/d3d/shaders/debugLinePS.hlsl create mode 100644 demo/d3d/shaders/debugLinePS.hlsl.h create mode 100644 demo/d3d/shaders/debugLineVS.hlsl create mode 100644 demo/d3d/shaders/debugLineVS.hlsl.h create mode 100644 demo/d3d/shaders/diffuseGS.hlsl create mode 100644 demo/d3d/shaders/diffuseGS.hlsl.h create mode 100644 demo/d3d/shaders/diffusePS.hlsl create mode 100644 demo/d3d/shaders/diffusePS.hlsl.h create mode 100644 demo/d3d/shaders/diffuseVS.hlsl create mode 100644 demo/d3d/shaders/diffuseVS.hlsl.h create mode 100644 demo/d3d/shaders/ellipsoidDepthGS.hlsl create mode 100644 demo/d3d/shaders/ellipsoidDepthGS.hlsl.h create mode 100644 demo/d3d/shaders/ellipsoidDepthPS.hlsl create mode 100644 demo/d3d/shaders/ellipsoidDepthPS.hlsl.h create mode 100644 demo/d3d/shaders/ellipsoidDepthVS.hlsl create mode 100644 demo/d3d/shaders/ellipsoidDepthVS.hlsl.h create mode 100644 demo/d3d/shaders/imguiPS.hlsl create mode 100644 demo/d3d/shaders/imguiPS.hlsl.h create mode 100644 demo/d3d/shaders/imguiVS.hlsl create mode 100644 demo/d3d/shaders/imguiVS.hlsl.h create mode 100644 demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl create mode 100644 demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl.h create mode 100644 demo/d3d/shaders/meshPS.hlsl create mode 100644 demo/d3d/shaders/meshPS.hlsl.h create mode 100644 demo/d3d/shaders/meshShadowPS.hlsl create mode 100644 demo/d3d/shaders/meshShadowPS.hlsl.h create mode 100644 demo/d3d/shaders/meshVS.hlsl create mode 100644 demo/d3d/shaders/meshVS.hlsl.h create mode 100644 demo/d3d/shaders/passThroughVS.hlsl create mode 100644 demo/d3d/shaders/passThroughVS.hlsl.h create mode 100644 demo/d3d/shaders/pointGS.hlsl create mode 100644 demo/d3d/shaders/pointGS.hlsl.h create mode 100644 demo/d3d/shaders/pointPS.hlsl create mode 100644 demo/d3d/shaders/pointPS.hlsl.h create mode 100644 demo/d3d/shaders/pointShadowPS.hlsl create mode 100644 demo/d3d/shaders/pointShadowPS.hlsl.h create mode 100644 demo/d3d/shaders/pointVS.hlsl create mode 100644 demo/d3d/shaders/pointVS.hlsl.h create mode 100644 demo/d3d/shaders/shaderCommon.h create mode 100644 demo/d3d/shadersDemoContext.cpp create mode 100644 demo/d3d/shadersDemoContext.h delete mode 100644 demo/d3d11/debugLineRender.h create mode 100644 demo/d3d11/debugLineRenderD3D11.cpp create mode 100644 demo/d3d11/debugLineRenderD3D11.h create mode 100644 demo/d3d11/demoContextD3D11.cpp create mode 100644 demo/d3d11/demoContextD3D11.h delete mode 100644 demo/d3d11/diffuseRender.cpp delete mode 100644 demo/d3d11/diffuseRender.h create mode 100644 demo/d3d11/diffuseRenderD3D11.cpp create mode 100644 demo/d3d11/diffuseRenderD3D11.h delete mode 100644 demo/d3d11/fluidRender.cpp delete mode 100644 demo/d3d11/fluidRender.h create mode 100644 demo/d3d11/fluidRenderD3D11.cpp create mode 100644 demo/d3d11/fluidRenderD3D11.h delete mode 100644 demo/d3d11/imguiGraph.cpp delete mode 100644 demo/d3d11/imguiGraph.h create mode 100644 demo/d3d11/imguiInteropD3D11.cpp delete mode 100644 demo/d3d11/meshRender.cpp delete mode 100644 demo/d3d11/meshRender.h create mode 100644 demo/d3d11/meshRenderD3D11.cpp create mode 100644 demo/d3d11/meshRenderD3D11.h delete mode 100644 demo/d3d11/pointRender.cpp delete mode 100644 demo/d3d11/pointRender.h create mode 100644 demo/d3d11/pointRenderD3D11.cpp create mode 100644 demo/d3d11/pointRenderD3D11.h delete mode 100644 demo/d3d11/renderTarget.cpp delete mode 100644 demo/d3d11/renderTarget.h create mode 100644 demo/d3d11/renderTargetD3D11.cpp create mode 100644 demo/d3d11/renderTargetD3D11.h delete mode 100644 demo/d3d11/shaders/blurDepthPS.hlsl delete mode 100644 demo/d3d11/shaders/blurDepthPS.hlsl.h delete mode 100644 demo/d3d11/shaders/compositePS.hlsl delete mode 100644 demo/d3d11/shaders/compositePS.hlsl.h delete mode 100644 demo/d3d11/shaders/debugLinePS.hlsl delete mode 100644 demo/d3d11/shaders/debugLinePS.hlsl.h delete mode 100644 demo/d3d11/shaders/debugLineVS.hlsl delete mode 100644 demo/d3d11/shaders/debugLineVS.hlsl.h delete mode 100644 demo/d3d11/shaders/diffuseGS.hlsl delete mode 100644 demo/d3d11/shaders/diffuseGS.hlsl.h delete mode 100644 demo/d3d11/shaders/diffusePS.hlsl delete mode 100644 demo/d3d11/shaders/diffusePS.hlsl.h delete mode 100644 demo/d3d11/shaders/diffuseVS.hlsl delete mode 100644 demo/d3d11/shaders/diffuseVS.hlsl.h delete mode 100644 demo/d3d11/shaders/ellipsoidDepthGS.hlsl delete mode 100644 demo/d3d11/shaders/ellipsoidDepthGS.hlsl.h delete mode 100644 demo/d3d11/shaders/ellipsoidDepthPS.hlsl delete mode 100644 demo/d3d11/shaders/ellipsoidDepthPS.hlsl.h delete mode 100644 demo/d3d11/shaders/ellipsoidDepthVS.hlsl delete mode 100644 demo/d3d11/shaders/ellipsoidDepthVS.hlsl.h delete mode 100644 demo/d3d11/shaders/imguiPS.hlsl delete mode 100644 demo/d3d11/shaders/imguiPS.hlsl.h delete mode 100644 demo/d3d11/shaders/imguiVS.hlsl delete mode 100644 demo/d3d11/shaders/imguiVS.hlsl.h delete mode 100644 demo/d3d11/shaders/meshPS.hlsl delete mode 100644 demo/d3d11/shaders/meshPS.hlsl.h delete mode 100644 demo/d3d11/shaders/meshShadowPS.hlsl delete mode 100644 demo/d3d11/shaders/meshShadowPS.hlsl.h delete mode 100644 demo/d3d11/shaders/meshVS.hlsl delete mode 100644 demo/d3d11/shaders/meshVS.hlsl.h delete mode 100644 demo/d3d11/shaders/passThroughVS.hlsl delete mode 100644 demo/d3d11/shaders/passThroughVS.hlsl.h delete mode 100644 demo/d3d11/shaders/pointGS.hlsl delete mode 100644 demo/d3d11/shaders/pointGS.hlsl.h delete mode 100644 demo/d3d11/shaders/pointPS.hlsl delete mode 100644 demo/d3d11/shaders/pointPS.hlsl.h delete mode 100644 demo/d3d11/shaders/pointVS.hlsl delete mode 100644 demo/d3d11/shaders/pointVS.hlsl.h delete mode 100644 demo/d3d11/shaders/shaderCommon.h delete mode 100644 demo/d3d11/shadersD3D11.cpp delete mode 100644 demo/d3d11/shadowMap.cpp delete mode 100644 demo/d3d11/shadowMap.h create mode 100644 demo/d3d11/shadowMapD3D11.cpp create mode 100644 demo/d3d11/shadowMapD3D11.h create mode 100644 demo/d3d12/NvCoDx12CircularResourceHeap.cpp create mode 100644 demo/d3d12/NvCoDx12CircularResourceHeap.h create mode 100644 demo/d3d12/NvCoDx12CounterFence.cpp create mode 100644 demo/d3d12/NvCoDx12CounterFence.h create mode 100644 demo/d3d12/NvCoDx12DescriptorHeap.cpp create mode 100644 demo/d3d12/NvCoDx12DescriptorHeap.h create mode 100644 demo/d3d12/NvCoDx12Handle.h create mode 100644 demo/d3d12/NvCoDx12HelperUtil.cpp create mode 100644 demo/d3d12/NvCoDx12HelperUtil.h create mode 100644 demo/d3d12/NvCoDx12RenderTarget.cpp create mode 100644 demo/d3d12/NvCoDx12RenderTarget.h create mode 100644 demo/d3d12/NvCoDx12Resource.cpp create mode 100644 demo/d3d12/NvCoDx12Resource.h create mode 100644 demo/d3d12/NvCoDx12ResourceScopeManager.cpp create mode 100644 demo/d3d12/NvCoDx12ResourceScopeManager.h create mode 100644 demo/d3d12/NvCoDxDebugUtil.cpp create mode 100644 demo/d3d12/NvCoDxDebugUtil.h create mode 100644 demo/d3d12/NvCoDxFormatUtil.cpp create mode 100644 demo/d3d12/NvCoDxFormatUtil.h create mode 100644 demo/d3d12/NvCoFreeList.cpp create mode 100644 demo/d3d12/NvCoFreeList.h create mode 100644 demo/d3d12/NvResult.h create mode 100644 demo/d3d12/appD3D12Ctx.cpp create mode 100644 demo/d3d12/appD3D12Ctx.h create mode 100644 demo/d3d12/bufferD3D12.cpp create mode 100644 demo/d3d12/bufferD3D12.h create mode 100644 demo/d3d12/demoContextD3D12.cpp create mode 100644 demo/d3d12/demoContextD3D12.h create mode 100644 demo/d3d12/diffusePointRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/diffusePointRenderPipelineD3D12.h create mode 100644 demo/d3d12/fluidCompositeRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/fluidCompositeRenderPipelineD3D12.h create mode 100644 demo/d3d12/fluidEllipsoidRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/fluidEllipsoidRenderPipelineD3D12.h create mode 100644 demo/d3d12/fluidSmoothRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/fluidSmoothRenderPipelineD3D12.h create mode 100644 demo/d3d12/imguiGraphD3D12.cpp create mode 100644 demo/d3d12/imguiGraphD3D12.h create mode 100644 demo/d3d12/imguiInteropD3D12.cpp create mode 100644 demo/d3d12/lineRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/lineRenderPipelineD3D12.h create mode 100644 demo/d3d12/meshRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/meshRenderPipelineD3D12.h create mode 100644 demo/d3d12/meshRenderer.cpp create mode 100644 demo/d3d12/meshRenderer.h create mode 100644 demo/d3d12/meshRendererD3D12.cpp create mode 100644 demo/d3d12/meshRendererD3D12.h create mode 100644 demo/d3d12/meshUtil.cpp create mode 100644 demo/d3d12/meshUtil.h create mode 100644 demo/d3d12/pipelineUtilD3D12.cpp create mode 100644 demo/d3d12/pipelineUtilD3D12.h create mode 100644 demo/d3d12/pointRenderPipelineD3D12.cpp create mode 100644 demo/d3d12/pointRenderPipelineD3D12.h create mode 100644 demo/d3d12/renderStateD3D12.cpp create mode 100644 demo/d3d12/renderStateD3D12.h delete mode 100644 demo/scenes/plasticstack.h create mode 100644 demo/scenes/shapechannels.h create mode 100644 extensions/compiler/makeandroid_aarch64/Makefile create mode 100644 extensions/compiler/makeandroid_aarch64/Makefile.flexCUDA.mk create mode 100644 extensions/compiler/makeandroid_aarch64/Makefile.flexExtCUDA.mk create mode 100644 extensions/compiler/vc14win32/vc140.pdb create mode 100644 extensions/compiler/xpj/flexExtD3D12.xpj create mode 100644 external/D3D12/include/PIXEventsCommon.h create mode 100644 external/D3D12/include/PIXEventsGenerated.h create mode 100644 external/D3D12/include/dxgi.h create mode 100644 external/D3D12/include/dxgi1_2.h create mode 100644 external/D3D12/include/dxgi1_3.h create mode 100644 external/D3D12/include/dxgi1_4.h create mode 100644 external/D3D12/include/dxgitype.h create mode 100644 external/D3D12/include/pix3.h create mode 100644 external/D3D12/include/pix3_win.h diff --git a/.gitignore b/.gitignore index 4c58b9b..7f06484 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ +# we do not store binary outputs in Flex + +# windows +*.exp +*.ilk + # android *.apk \ No newline at end of file diff --git a/README.md b/README.md index 179054c..3dab564 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -NVIDIA Flex - 1.1.0 +NVIDIA Flex - 1.2.0 =================== Flex is a particle-based simulation library designed for real-time applications. @@ -92,7 +92,7 @@ Known Issues ============ * Crash with inflatable scenes on Intel HD Graphics 530 - +* MSAA is broken on D3D12 and currently disabled Acknowledgements ================ diff --git a/bin/linux64/NvFlexDemoDebugCUDA_x64 b/bin/linux64/NvFlexDemoDebugCUDA_x64 index e2a12a7..5804292 100644 Binary files a/bin/linux64/NvFlexDemoDebugCUDA_x64 and b/bin/linux64/NvFlexDemoDebugCUDA_x64 differ diff --git a/bin/linux64/NvFlexDemoReleaseCUDA_x64 b/bin/linux64/NvFlexDemoReleaseCUDA_x64 index 6964559..d5c6b22 100644 Binary files a/bin/linux64/NvFlexDemoReleaseCUDA_x64 and b/bin/linux64/NvFlexDemoReleaseCUDA_x64 differ diff --git a/bin/win32/NvFlexDebugCUDA_x86.dll b/bin/win32/NvFlexDebugCUDA_x86.dll index a5db95e..6cf58ef 100644 Binary files a/bin/win32/NvFlexDebugCUDA_x86.dll and b/bin/win32/NvFlexDebugCUDA_x86.dll differ diff --git a/bin/win32/NvFlexDebugCUDA_x86.dll.pdb b/bin/win32/NvFlexDebugCUDA_x86.dll.pdb index f089e3d..64b575d 100644 Binary files a/bin/win32/NvFlexDebugCUDA_x86.dll.pdb and b/bin/win32/NvFlexDebugCUDA_x86.dll.pdb differ diff --git a/bin/win32/NvFlexDebugD3D_x86.dll b/bin/win32/NvFlexDebugD3D_x86.dll index 5a47117..e9bd619 100644 Binary files a/bin/win32/NvFlexDebugD3D_x86.dll and b/bin/win32/NvFlexDebugD3D_x86.dll differ diff --git a/bin/win32/NvFlexDebugD3D_x86.dll.pdb b/bin/win32/NvFlexDebugD3D_x86.dll.pdb index 6e0d513..6de77b3 100644 Binary files a/bin/win32/NvFlexDebugD3D_x86.dll.pdb and b/bin/win32/NvFlexDebugD3D_x86.dll.pdb differ diff --git a/bin/win32/NvFlexDemoDebugCUDA_x86.exe b/bin/win32/NvFlexDemoDebugCUDA_x86.exe index c2de79a..163b8b1 100644 Binary files a/bin/win32/NvFlexDemoDebugCUDA_x86.exe and b/bin/win32/NvFlexDemoDebugCUDA_x86.exe differ diff --git a/bin/win32/NvFlexDemoDebugCUDA_x86.exe.pdb b/bin/win32/NvFlexDemoDebugCUDA_x86.exe.pdb index 86df5af..db5d77c 100644 Binary files a/bin/win32/NvFlexDemoDebugCUDA_x86.exe.pdb and b/bin/win32/NvFlexDemoDebugCUDA_x86.exe.pdb differ diff --git a/bin/win32/NvFlexDemoDebugD3D_x86.exe b/bin/win32/NvFlexDemoDebugD3D_x86.exe index 9c2b4c7..5e96714 100644 Binary files a/bin/win32/NvFlexDemoDebugD3D_x86.exe and b/bin/win32/NvFlexDemoDebugD3D_x86.exe differ diff --git a/bin/win32/NvFlexDemoDebugD3D_x86.exe.pdb b/bin/win32/NvFlexDemoDebugD3D_x86.exe.pdb index 762ef24..479454d 100644 Binary files a/bin/win32/NvFlexDemoDebugD3D_x86.exe.pdb and b/bin/win32/NvFlexDemoDebugD3D_x86.exe.pdb differ diff --git a/bin/win32/NvFlexDemoReleaseCUDA_x86.exe b/bin/win32/NvFlexDemoReleaseCUDA_x86.exe index bf27faa..5a4dffc 100644 Binary files a/bin/win32/NvFlexDemoReleaseCUDA_x86.exe and b/bin/win32/NvFlexDemoReleaseCUDA_x86.exe differ diff --git a/bin/win32/NvFlexDemoReleaseCUDA_x86.exe.pdb b/bin/win32/NvFlexDemoReleaseCUDA_x86.exe.pdb index c2a7a3d..18533e8 100644 Binary files a/bin/win32/NvFlexDemoReleaseCUDA_x86.exe.pdb and b/bin/win32/NvFlexDemoReleaseCUDA_x86.exe.pdb differ diff --git a/bin/win32/NvFlexDemoReleaseD3D_x86.exe b/bin/win32/NvFlexDemoReleaseD3D_x86.exe index 73691dc..2e7a852 100644 Binary files a/bin/win32/NvFlexDemoReleaseD3D_x86.exe and b/bin/win32/NvFlexDemoReleaseD3D_x86.exe differ diff --git a/bin/win32/NvFlexDemoReleaseD3D_x86.exe.pdb b/bin/win32/NvFlexDemoReleaseD3D_x86.exe.pdb index 5c3f7fb..5d9f2e6 100644 Binary files a/bin/win32/NvFlexDemoReleaseD3D_x86.exe.pdb and b/bin/win32/NvFlexDemoReleaseD3D_x86.exe.pdb differ diff --git a/bin/win32/NvFlexDeviceDebug_x86.dll b/bin/win32/NvFlexDeviceDebug_x86.dll index 3cebdf2..1a516d9 100644 Binary files a/bin/win32/NvFlexDeviceDebug_x86.dll and b/bin/win32/NvFlexDeviceDebug_x86.dll differ diff --git a/bin/win32/NvFlexDeviceDebug_x86.dll.pdb b/bin/win32/NvFlexDeviceDebug_x86.dll.pdb index 7cfdc33..1c22469 100644 Binary files a/bin/win32/NvFlexDeviceDebug_x86.dll.pdb and b/bin/win32/NvFlexDeviceDebug_x86.dll.pdb differ diff --git a/bin/win32/NvFlexDeviceRelease_x86.dll b/bin/win32/NvFlexDeviceRelease_x86.dll index 9cd3bdb..304c17a 100644 Binary files a/bin/win32/NvFlexDeviceRelease_x86.dll and b/bin/win32/NvFlexDeviceRelease_x86.dll differ diff --git a/bin/win32/NvFlexDeviceRelease_x86.dll.pdb b/bin/win32/NvFlexDeviceRelease_x86.dll.pdb index d12ec64..fd3e6be 100644 Binary files a/bin/win32/NvFlexDeviceRelease_x86.dll.pdb and b/bin/win32/NvFlexDeviceRelease_x86.dll.pdb differ diff --git a/bin/win32/NvFlexExtDebugCUDA_x86.dll b/bin/win32/NvFlexExtDebugCUDA_x86.dll index a545cab..43c77cd 100644 Binary files a/bin/win32/NvFlexExtDebugCUDA_x86.dll and b/bin/win32/NvFlexExtDebugCUDA_x86.dll differ diff --git a/bin/win32/NvFlexExtDebugCUDA_x86.dll.pdb b/bin/win32/NvFlexExtDebugCUDA_x86.dll.pdb index 82c1754..b201c82 100644 Binary files a/bin/win32/NvFlexExtDebugCUDA_x86.dll.pdb and b/bin/win32/NvFlexExtDebugCUDA_x86.dll.pdb differ diff --git a/bin/win32/NvFlexExtDebugD3D_x86.dll b/bin/win32/NvFlexExtDebugD3D_x86.dll index 2d2842f..c32ee68 100644 Binary files a/bin/win32/NvFlexExtDebugD3D_x86.dll and b/bin/win32/NvFlexExtDebugD3D_x86.dll differ diff --git a/bin/win32/NvFlexExtDebugD3D_x86.dll.pdb b/bin/win32/NvFlexExtDebugD3D_x86.dll.pdb index 049cf6b..e269107 100644 Binary files a/bin/win32/NvFlexExtDebugD3D_x86.dll.pdb and b/bin/win32/NvFlexExtDebugD3D_x86.dll.pdb differ diff --git a/bin/win32/NvFlexExtReleaseCUDA_x86.dll b/bin/win32/NvFlexExtReleaseCUDA_x86.dll index 2aad0be..ec0ef32 100644 Binary files a/bin/win32/NvFlexExtReleaseCUDA_x86.dll and b/bin/win32/NvFlexExtReleaseCUDA_x86.dll differ diff --git a/bin/win32/NvFlexExtReleaseCUDA_x86.dll.pdb b/bin/win32/NvFlexExtReleaseCUDA_x86.dll.pdb index d091f2d..e4bc9fc 100644 Binary files a/bin/win32/NvFlexExtReleaseCUDA_x86.dll.pdb and b/bin/win32/NvFlexExtReleaseCUDA_x86.dll.pdb differ diff --git a/bin/win32/NvFlexExtReleaseD3D_x86.dll b/bin/win32/NvFlexExtReleaseD3D_x86.dll index ceb283f..9885ddc 100644 Binary files a/bin/win32/NvFlexExtReleaseD3D_x86.dll and b/bin/win32/NvFlexExtReleaseD3D_x86.dll differ diff --git a/bin/win32/NvFlexExtReleaseD3D_x86.dll.pdb b/bin/win32/NvFlexExtReleaseD3D_x86.dll.pdb index c5c29d8..86d816e 100644 Binary files a/bin/win32/NvFlexExtReleaseD3D_x86.dll.pdb and b/bin/win32/NvFlexExtReleaseD3D_x86.dll.pdb differ diff --git a/bin/win32/NvFlexReleaseCUDA_x86.dll b/bin/win32/NvFlexReleaseCUDA_x86.dll index 994c078..7ef55d7 100644 Binary files a/bin/win32/NvFlexReleaseCUDA_x86.dll and b/bin/win32/NvFlexReleaseCUDA_x86.dll differ diff --git a/bin/win32/NvFlexReleaseCUDA_x86.dll.pdb b/bin/win32/NvFlexReleaseCUDA_x86.dll.pdb index 645def3..64513ec 100644 Binary files a/bin/win32/NvFlexReleaseCUDA_x86.dll.pdb and b/bin/win32/NvFlexReleaseCUDA_x86.dll.pdb differ diff --git a/bin/win32/NvFlexReleaseD3D_x86.dll b/bin/win32/NvFlexReleaseD3D_x86.dll index 40e4000..430f0a2 100644 Binary files a/bin/win32/NvFlexReleaseD3D_x86.dll and b/bin/win32/NvFlexReleaseD3D_x86.dll differ diff --git a/bin/win32/NvFlexReleaseD3D_x86.dll.pdb b/bin/win32/NvFlexReleaseD3D_x86.dll.pdb index 66b51b1..b15bcc9 100644 Binary files a/bin/win32/NvFlexReleaseD3D_x86.dll.pdb and b/bin/win32/NvFlexReleaseD3D_x86.dll.pdb differ diff --git a/bin/win32/nvToolsExt32_1.dll b/bin/win32/nvToolsExt32_1.dll new file mode 100644 index 0000000..ccba99b Binary files /dev/null and b/bin/win32/nvToolsExt32_1.dll differ diff --git a/bin/win64/NvFlexDebugCUDA_x64.dll b/bin/win64/NvFlexDebugCUDA_x64.dll index f6766b8..2881f01 100644 Binary files a/bin/win64/NvFlexDebugCUDA_x64.dll and b/bin/win64/NvFlexDebugCUDA_x64.dll differ diff --git a/bin/win64/NvFlexDebugCUDA_x64.dll.pdb b/bin/win64/NvFlexDebugCUDA_x64.dll.pdb index f5a7bb7..3ed3ac8 100644 Binary files a/bin/win64/NvFlexDebugCUDA_x64.dll.pdb and b/bin/win64/NvFlexDebugCUDA_x64.dll.pdb differ diff --git a/bin/win64/NvFlexDebugD3D_x64.dll b/bin/win64/NvFlexDebugD3D_x64.dll index 3987e11..de835e4 100644 Binary files a/bin/win64/NvFlexDebugD3D_x64.dll and b/bin/win64/NvFlexDebugD3D_x64.dll differ diff --git a/bin/win64/NvFlexDebugD3D_x64.dll.pdb b/bin/win64/NvFlexDebugD3D_x64.dll.pdb index eebd8af..d06f951 100644 Binary files a/bin/win64/NvFlexDebugD3D_x64.dll.pdb and b/bin/win64/NvFlexDebugD3D_x64.dll.pdb differ diff --git a/bin/win64/NvFlexDemoDebugCUDA_x64.exe b/bin/win64/NvFlexDemoDebugCUDA_x64.exe index 161b37e..3a4e649 100644 Binary files a/bin/win64/NvFlexDemoDebugCUDA_x64.exe and b/bin/win64/NvFlexDemoDebugCUDA_x64.exe differ diff --git a/bin/win64/NvFlexDemoDebugCUDA_x64.exe.pdb b/bin/win64/NvFlexDemoDebugCUDA_x64.exe.pdb index a066993..b439215 100644 Binary files a/bin/win64/NvFlexDemoDebugCUDA_x64.exe.pdb and b/bin/win64/NvFlexDemoDebugCUDA_x64.exe.pdb differ diff --git a/bin/win64/NvFlexDemoDebugD3D_x64.exe b/bin/win64/NvFlexDemoDebugD3D_x64.exe index 75773b4..dd4c12f 100644 Binary files a/bin/win64/NvFlexDemoDebugD3D_x64.exe and b/bin/win64/NvFlexDemoDebugD3D_x64.exe differ diff --git a/bin/win64/NvFlexDemoDebugD3D_x64.exe.pdb b/bin/win64/NvFlexDemoDebugD3D_x64.exe.pdb index a976c83..377c4d3 100644 Binary files a/bin/win64/NvFlexDemoDebugD3D_x64.exe.pdb and b/bin/win64/NvFlexDemoDebugD3D_x64.exe.pdb differ diff --git a/bin/win64/NvFlexDemoReleaseCUDA_x64.exe b/bin/win64/NvFlexDemoReleaseCUDA_x64.exe index a5e1d87..0bc8026 100644 Binary files a/bin/win64/NvFlexDemoReleaseCUDA_x64.exe and b/bin/win64/NvFlexDemoReleaseCUDA_x64.exe differ diff --git a/bin/win64/NvFlexDemoReleaseCUDA_x64.exe.pdb b/bin/win64/NvFlexDemoReleaseCUDA_x64.exe.pdb index 2fac616..61e3b97 100644 Binary files a/bin/win64/NvFlexDemoReleaseCUDA_x64.exe.pdb and b/bin/win64/NvFlexDemoReleaseCUDA_x64.exe.pdb differ diff --git a/bin/win64/NvFlexDemoReleaseD3D_x64.exe b/bin/win64/NvFlexDemoReleaseD3D_x64.exe index 6d22653..32bf4dc 100644 Binary files a/bin/win64/NvFlexDemoReleaseD3D_x64.exe and b/bin/win64/NvFlexDemoReleaseD3D_x64.exe differ diff --git a/bin/win64/NvFlexDemoReleaseD3D_x64.exe.pdb b/bin/win64/NvFlexDemoReleaseD3D_x64.exe.pdb index 32c586d..85e2cb7 100644 Binary files a/bin/win64/NvFlexDemoReleaseD3D_x64.exe.pdb and b/bin/win64/NvFlexDemoReleaseD3D_x64.exe.pdb differ diff --git a/bin/win64/NvFlexDeviceDebug_x64.dll b/bin/win64/NvFlexDeviceDebug_x64.dll index c456adf..25a929a 100644 Binary files a/bin/win64/NvFlexDeviceDebug_x64.dll and b/bin/win64/NvFlexDeviceDebug_x64.dll differ diff --git a/bin/win64/NvFlexDeviceDebug_x64.dll.pdb b/bin/win64/NvFlexDeviceDebug_x64.dll.pdb index 0ca8c85..56d28fd 100644 Binary files a/bin/win64/NvFlexDeviceDebug_x64.dll.pdb and b/bin/win64/NvFlexDeviceDebug_x64.dll.pdb differ diff --git a/bin/win64/NvFlexDeviceRelease_x64.dll b/bin/win64/NvFlexDeviceRelease_x64.dll index 11d6e7f..2f07259 100644 Binary files a/bin/win64/NvFlexDeviceRelease_x64.dll and b/bin/win64/NvFlexDeviceRelease_x64.dll differ diff --git a/bin/win64/NvFlexDeviceRelease_x64.dll.pdb b/bin/win64/NvFlexDeviceRelease_x64.dll.pdb index 53fbe4c..4223b08 100644 Binary files a/bin/win64/NvFlexDeviceRelease_x64.dll.pdb and b/bin/win64/NvFlexDeviceRelease_x64.dll.pdb differ diff --git a/bin/win64/NvFlexExtDebugCUDA_x64.dll b/bin/win64/NvFlexExtDebugCUDA_x64.dll index 1c2d5b9..b45d858 100644 Binary files a/bin/win64/NvFlexExtDebugCUDA_x64.dll and b/bin/win64/NvFlexExtDebugCUDA_x64.dll differ diff --git a/bin/win64/NvFlexExtDebugCUDA_x64.dll.pdb b/bin/win64/NvFlexExtDebugCUDA_x64.dll.pdb index 7d5c6c0..741c4ae 100644 Binary files a/bin/win64/NvFlexExtDebugCUDA_x64.dll.pdb and b/bin/win64/NvFlexExtDebugCUDA_x64.dll.pdb differ diff --git a/bin/win64/NvFlexExtDebugD3D_x64.dll b/bin/win64/NvFlexExtDebugD3D_x64.dll index 4c95ce1..1953ec7 100644 Binary files a/bin/win64/NvFlexExtDebugD3D_x64.dll and b/bin/win64/NvFlexExtDebugD3D_x64.dll differ diff --git a/bin/win64/NvFlexExtDebugD3D_x64.dll.pdb b/bin/win64/NvFlexExtDebugD3D_x64.dll.pdb index 1e1d2b4..2e4e542 100644 Binary files a/bin/win64/NvFlexExtDebugD3D_x64.dll.pdb and b/bin/win64/NvFlexExtDebugD3D_x64.dll.pdb differ diff --git a/bin/win64/NvFlexExtReleaseCUDA_x64.dll b/bin/win64/NvFlexExtReleaseCUDA_x64.dll index b887851..b45e0a5 100644 Binary files a/bin/win64/NvFlexExtReleaseCUDA_x64.dll and b/bin/win64/NvFlexExtReleaseCUDA_x64.dll differ diff --git a/bin/win64/NvFlexExtReleaseCUDA_x64.dll.pdb b/bin/win64/NvFlexExtReleaseCUDA_x64.dll.pdb index 74034fd..070ec30 100644 Binary files a/bin/win64/NvFlexExtReleaseCUDA_x64.dll.pdb and b/bin/win64/NvFlexExtReleaseCUDA_x64.dll.pdb differ diff --git a/bin/win64/NvFlexExtReleaseD3D_x64.dll b/bin/win64/NvFlexExtReleaseD3D_x64.dll index 46e0973..fdac877 100644 Binary files a/bin/win64/NvFlexExtReleaseD3D_x64.dll and b/bin/win64/NvFlexExtReleaseD3D_x64.dll differ diff --git a/bin/win64/NvFlexExtReleaseD3D_x64.dll.pdb b/bin/win64/NvFlexExtReleaseD3D_x64.dll.pdb index 70067d4..5fa99fa 100644 Binary files a/bin/win64/NvFlexExtReleaseD3D_x64.dll.pdb and b/bin/win64/NvFlexExtReleaseD3D_x64.dll.pdb differ diff --git a/bin/win64/NvFlexReleaseCUDA_x64.dll b/bin/win64/NvFlexReleaseCUDA_x64.dll index f443ff6..1809418 100644 Binary files a/bin/win64/NvFlexReleaseCUDA_x64.dll and b/bin/win64/NvFlexReleaseCUDA_x64.dll differ diff --git a/bin/win64/NvFlexReleaseCUDA_x64.dll.pdb b/bin/win64/NvFlexReleaseCUDA_x64.dll.pdb index 26751ae..97d7051 100644 Binary files a/bin/win64/NvFlexReleaseCUDA_x64.dll.pdb and b/bin/win64/NvFlexReleaseCUDA_x64.dll.pdb differ diff --git a/bin/win64/NvFlexReleaseD3D_x64.dll b/bin/win64/NvFlexReleaseD3D_x64.dll index 8eb99a6..94ab368 100644 Binary files a/bin/win64/NvFlexReleaseD3D_x64.dll and b/bin/win64/NvFlexReleaseD3D_x64.dll differ diff --git a/bin/win64/NvFlexReleaseD3D_x64.dll.pdb b/bin/win64/NvFlexReleaseD3D_x64.dll.pdb index e7dfcc3..6c140fc 100644 Binary files a/bin/win64/NvFlexReleaseD3D_x64.dll.pdb and b/bin/win64/NvFlexReleaseD3D_x64.dll.pdb differ diff --git a/bin/win64/nvToolsExt64_1.dll b/bin/win64/nvToolsExt64_1.dll new file mode 100644 index 0000000..b5c05d9 Binary files /dev/null and b/bin/win64/nvToolsExt64_1.dll differ diff --git a/core/core.h b/core/core.h index 7c7d940..48a2918 100644 --- a/core/core.h +++ b/core/core.h @@ -37,7 +37,7 @@ #define VERBOSE(a) #endif -#define Super __super +//#define Super __super // basically just a collection of macros and types #ifndef UNUSED diff --git a/core/platform.cpp b/core/platform.cpp index 8846e9b..8c451ab 100644 --- a/core/platform.cpp +++ b/core/platform.cpp @@ -39,7 +39,7 @@ using namespace std; -#ifdef WIN32 +#if defined(WIN32) || defined(WIN64) #include #include diff --git a/core/platform.h b/core/platform.h index 9b7a473..b58d03f 100644 --- a/core/platform.h +++ b/core/platform.h @@ -44,7 +44,7 @@ std::string GetWorkingDirectory(); #include -#ifndef +#ifndef LOGE #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , "Flex", __VA_ARGS__) #endif diff --git a/core/voxelize.cpp b/core/voxelize.cpp index 8172aea..647ceb4 100644 --- a/core/voxelize.cpp +++ b/core/voxelize.cpp @@ -28,12 +28,12 @@ #include "aabbtree.h" #include "mesh.h" -void Voxelize(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, uint32_t width, uint32_t height, uint32_t depth, uint32_t* volume, Vec3 minExtents, Vec3 maxExtents) +void Voxelize(const Vec3* vertices, int numVertices, const int* indices, int numTriangleIndices, uint32_t width, uint32_t height, uint32_t depth, uint32_t* volume, Vec3 minExtents, Vec3 maxExtents) { memset(volume, 0, sizeof(uint32_t)*width*height*depth); // build an aabb tree of the mesh - AABBTree tree((const Vec3*)vertices, numVertices, (const uint32_t*)indices, numTriangleIndices/3); + AABBTree tree(vertices, numVertices, (const uint32_t*)indices, numTriangleIndices/3); // parity count method, single pass const Vec3 extents(maxExtents-minExtents); diff --git a/core/voxelize.h b/core/voxelize.h index deb99b5..958dbf5 100644 --- a/core/voxelize.h +++ b/core/voxelize.h @@ -30,4 +30,4 @@ struct Mesh; // voxelizes a mesh using a single pass parity algorithm -void Voxelize(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, uint32_t width, uint32_t height, uint32_t depth, uint32_t* volume, Vec3 minExtents, Vec3 maxExtents); \ No newline at end of file +void Voxelize(const Vec3* vertices, int numVertices, const int* indices, int numTriangleIndices, uint32_t width, uint32_t height, uint32_t depth, uint32_t* volume, Vec3 minExtents, Vec3 maxExtents); \ No newline at end of file diff --git a/demo/benchmark.h b/demo/benchmark.h index c0ab7c2..d04e780 100644 --- a/demo/benchmark.h +++ b/demo/benchmark.h @@ -27,166 +27,402 @@ #pragma once + + #include +#include +#include const char* g_benchmarkFilename = "../../benchmark.txt"; -std::ofstream g_benchmarkFile; +std::wofstream g_benchmarkFile; -// returns the new scene if one is requested -int BenchmarkUpdate() +const int benchmarkPhaseFrameCount = 400; +const int benchmarkEndWarmup = 200; + +const int benchmarkAsyncOffDummyOnBeginFrame = benchmarkPhaseFrameCount; +const int benchmarkAsyncOnDummyOnBeginFrame = benchmarkPhaseFrameCount*2; +const int benchmarkEndFrame = benchmarkPhaseFrameCount*3; +const char* benchmarkList[] = { "Env Cloth Small", "Viscosity Med", "Inflatables", "Game Mesh Particles", "Rigid4" }; +const char* benchmarkChartPrefix[] = { "EnvClothSmall", "ViscosityMed", "Inflatables", "GameMeshParticles", "Rigid4" }; //no spaces +int numBenchmarks = sizeof(benchmarkList)/sizeof(benchmarkList[0]); + +struct GpuTimers +{ + unsigned long long renderBegin; + unsigned long long renderEnd; + unsigned long long renderFreq; + unsigned long long computeBegin; + unsigned long long computeEnd; + unsigned long long computeFreq; + + static const int maxTimerCount = 4; + double timers[benchmarkEndFrame][maxTimerCount]; + int timerCount[benchmarkEndFrame]; +}; + + +struct TimerTotals { - // Enable console benchmark profiling - static NvFlexTimers sTimersSum; - static std::vector sDTimersSum; - static float sTotalFrameTime = 0.0f; - static int sSamples = 0; + std::vector detailTimers; + + float frameTime; + int samples; - static int benchmarkIter = 0; - const int numBenchmarks = 5; - const char* benchmarkList[numBenchmarks] = { "Env Cloth Small", "Viscosity Med", "Inflatables", "Game Mesh Particles", "Rigid4" }; - const char* benchmarkChartPrefix[numBenchmarks] = { "EnvClothSmall", "ViscosityMed", "Inflatables", "GameMeshParticles", "Rigid4" }; //no spaces - //float benchmarkEnergyCheck[numBenchmarks] = { 6000, 1000, 1000, 150426, 63710 }; + float frameTimeAsync; + int samplesAsync; - int newScene = -1; + float computeTimeAsyncOff; + float computeTimeAsyncOn; + int computeSamples; + + TimerTotals() : frameTime(0), samples(0), frameTimeAsync(0), samplesAsync(0), computeTimeAsyncOff(0), computeTimeAsyncOn(0), computeSamples(0) {} +}; + +GpuTimers g_GpuTimers; + +int g_benchmarkFrame = 0; +int g_benchmarkScene = 0; +int g_benchmarkSceneNumber; + +#if defined(__linux__) +int sprintf_s(char* const buffer, size_t const bufferCount, + const char* format,...) +{ + va_list args; + va_start(args, format); + int retval = vsprintf(buffer, format, args); + va_end(args); + + return retval; +} +#endif + +//----------------------------------------------------------------------------- +char* removeSpaces(const char* in) +{ + int len = strlen(in); + char* out = new char[len+1]; - if (g_benchmark && benchmarkIter == 0 && g_frame == 1) + int i = 0; + int j = 0; + while (in[i] != 0) { - // check and see if the first scene is the same as the first benchmark - // switch to benchmark if it is not the same - if (strcmp(benchmarkList[0], g_scenes[g_scene]->GetName()) == 0) - benchmarkIter++; - else - g_frame = -1; + if (in[i] != ' ') + { + out[j] = in[i]; + j++; + } + i++; } + out[j] = 0; + + return out; +} +//----------------------------------------------------------------------------- +void ProcessGpuTimes() +{ + static bool timerfirstTime = true; + + double renderTime; + double compTime; + double unionTime; + double overlapBeginTime; + + int numParticles = NvFlexGetActiveCount(g_solver); - if (g_frame == 200) + renderTime = double(g_GpuTimers.renderEnd - g_GpuTimers.renderBegin) / double(g_GpuTimers.renderFreq); + compTime = double(g_GpuTimers.computeEnd - g_GpuTimers.computeBegin) / double(g_GpuTimers.computeFreq); + + uint64_t minTime = min(g_GpuTimers.renderBegin, g_GpuTimers.computeBegin); + uint64_t maxTime = max(g_GpuTimers.renderEnd, g_GpuTimers.computeEnd); + unionTime = double(maxTime - minTime) / double(g_GpuTimers.computeFreq); + + overlapBeginTime = abs((long long)g_GpuTimers.renderBegin - (long long)g_GpuTimers.computeBegin) / double(g_GpuTimers.computeFreq); + + if (!timerfirstTime && g_benchmarkFrame < benchmarkEndFrame) { - memset(&sTimersSum, 0, sizeof(NvFlexTimers)); - sTotalFrameTime = 0.0f; - sSamples = 0; - g_emit = true; - sDTimersSum.resize(g_numDetailTimers); + if (g_useAsyncCompute) + { + g_GpuTimers.timers[g_benchmarkFrame][0] = numParticles; + g_GpuTimers.timers[g_benchmarkFrame][1] = unionTime * 1000; + g_GpuTimers.timers[g_benchmarkFrame][2] = overlapBeginTime * 1000; + g_GpuTimers.timers[g_benchmarkFrame][3] = g_realdt * 1000; + g_GpuTimers.timerCount[g_benchmarkFrame] = 4; + } + else + { + g_GpuTimers.timers[g_benchmarkFrame][0] = numParticles; + g_GpuTimers.timers[g_benchmarkFrame][1] = renderTime * 1000; + g_GpuTimers.timers[g_benchmarkFrame][2] = compTime * 1000; + g_GpuTimers.timers[g_benchmarkFrame][3] = g_realdt * 1000; + g_GpuTimers.timerCount[g_benchmarkFrame] = 4; + } } - if (g_frame >= 200 && g_frame < 400) + timerfirstTime = false; +} +//----------------------------------------------------------------------------- +void UpdateTotals(TimerTotals& totals) +{ + // Phase 0B, async off, dummy work off + if (benchmarkEndWarmup <= g_benchmarkFrame && g_benchmarkFrame < benchmarkAsyncOffDummyOnBeginFrame) { - sTotalFrameTime += g_realdt * 1000.0f; //convert to milliseconds + totals.frameTime += g_realdt * 1000.0f; //convert to milliseconds for (int i = 0; i < g_numDetailTimers; i++) { - sDTimersSum[i].name = g_detailTimers[i].name; - sDTimersSum[i].time += g_detailTimers[i].time; + strcpy(totals.detailTimers[i].name,g_detailTimers[i].name); + totals.detailTimers[i].time += g_detailTimers[i].time; } - sTimersSum.total += g_timers.total; + totals.samples++; + } - sSamples++; + // Phase 2B, async on, dummy work on + if (benchmarkAsyncOnDummyOnBeginFrame + benchmarkEndWarmup <= g_benchmarkFrame) + { + float offGraphics = (float)g_GpuTimers.timers[g_benchmarkFrame - benchmarkPhaseFrameCount][1]; + float offCompute = (float)g_GpuTimers.timers[g_benchmarkFrame - benchmarkPhaseFrameCount][2]; + float onBoth = (float)g_GpuTimers.timers[g_benchmarkFrame][1]; + + float onCompute = onBoth - offGraphics; + + totals.computeTimeAsyncOff += offCompute; + totals.computeTimeAsyncOn += onCompute; + totals.computeSamples++; + + totals.frameTimeAsync += g_realdt * 1000.0f; //convert to milliseconds + totals.samplesAsync++; } - if (g_frame == 400) +} +//----------------------------------------------------------------------------- +void BeginNewPhaseIfNecessary(int& sceneToSwitchTo,TimerTotals& totals) +{ + // Are we beginning phase 0B? + if (g_benchmarkFrame == benchmarkEndWarmup) { + totals.frameTime = 0.0f; + totals.samples = 0; + g_emit = true; + totals.detailTimers.resize(g_numDetailTimers); - for (int i = 0; i < g_numDetailTimers; i++) { - sDTimersSum[i].time /= sSamples; + for (int i = 0; i != g_numDetailTimers; i++) + { + totals.detailTimers[i].name = new char[256]; } + } - if (g_teamCity) - { - const char* prefix = benchmarkChartPrefix[benchmarkIter - 1]; + // Are we beginning phase 1? + if (g_benchmarkFrame == benchmarkAsyncOffDummyOnBeginFrame) + { + sceneToSwitchTo = g_benchmarkSceneNumber; + g_useAsyncCompute = false; + g_increaseGfxLoadForAsyncComputeTesting = true; + } - float exclusive = 0.0f; + // Are we beginning phase 2? + if (g_benchmarkFrame == benchmarkAsyncOnDummyOnBeginFrame) + { + sceneToSwitchTo = g_benchmarkSceneNumber; + g_useAsyncCompute = true; + g_increaseGfxLoadForAsyncComputeTesting = true; + } - for (int i = 0; i < g_numDetailTimers - 1; i++) { - exclusive += sDTimersSum[i].time; - } + // Are we beginning phase 2B? + if (g_benchmarkFrame == benchmarkAsyncOnDummyOnBeginFrame + benchmarkEndWarmup) + { + totals.frameTimeAsync = 0.0f; + totals.samplesAsync = 0; + totals.computeTimeAsyncOff = 0.0f; + totals.computeTimeAsyncOn = 0.0f; + totals.computeSamples = 0; + g_emit = true; + } +} +//----------------------------------------------------------------------------- +void WriteSceneResults(TimerTotals& totals) +{ + // Write results for scene + for (int i = 0; i < g_numDetailTimers; i++) { + totals.detailTimers[i].time /= totals.samples; + } - printf("##teamcity[buildStatisticValue key='%s_FrameTime' value='%f']\n", prefix, sTotalFrameTime / sSamples); - printf("##teamcity[buildStatisticValue key='%s_SumKernel' value='%f']\n", prefix, exclusive); + if (g_profile && g_teamCity) + { + const char* prefix = benchmarkChartPrefix[g_benchmarkScene - 1]; - for (int i = 0; i < g_numDetailTimers - 1; i++) { - printf("##teamcity[buildStatisticValue key='%s_%s' value='%f']\n", prefix, sDTimersSum[i].name, sDTimersSum[i].time); - } - printf("\n"); + float exclusive = 0.0f; + + for (int i = 0; i < g_numDetailTimers - 1; i++) { + exclusive += totals.detailTimers[i].time; } - else - { - printf("Scene: %s\n", g_scenes[g_scene]->GetName()); - printf("FrameTime %f\n", sTotalFrameTime / sSamples); - printf("________________________________\n"); - float exclusive = 0.0f; - - for (int i = 0; i < g_numDetailTimers-1; i++) { - exclusive += sDTimersSum[i].time; - printf("%s %f\n", sDTimersSum[i].name, sDTimersSum[i].time); - } - printf("Sum(exclusive) %f\n", exclusive); - printf("Sum(inclusive) %f\n", sDTimersSum[g_numDetailTimers - 1].time); - printf("________________________________\n"); + + printf("##teamcity[buildStatisticValue key='%s_FrameTime' value='%f']\n", prefix, totals.frameTime / totals.samples); + printf("##teamcity[buildStatisticValue key='%s_SumKernel' value='%f']\n", prefix, exclusive); + + for (int i = 0; i < g_numDetailTimers - 1; i++) { + printf("##teamcity[buildStatisticValue key='%s_%s' value='%f']\n", prefix, totals.detailTimers[i].name, totals.detailTimers[i].time); } + printf("\n"); + } - // Dumping benchmark data to txt files + printf("Scene: %s\n", g_scenes[g_scene]->GetName()); + printf("FrameTime %f\n", totals.frameTime / totals.samples); + printf("________________________________\n"); + float exclusive = 0.0f; - g_benchmarkFile.open(g_benchmarkFilename, std::ofstream::out | std::ofstream::app); - g_benchmarkFile << std::fixed << std::setprecision(6); - g_benchmarkFile << "Scene: " << g_scenes[g_scene]->GetName() << std::endl; - g_benchmarkFile << "FrameTime " << sTotalFrameTime / sSamples << std::endl; - g_benchmarkFile << "________________________________" << std::endl; + for (int i = 0; i < g_numDetailTimers - 1; i++) { + exclusive += totals.detailTimers[i].time; + printf("%s %f\n", totals.detailTimers[i].name, totals.detailTimers[i].time); + } + printf("Sum(exclusive) %f\n", exclusive); + printf("Sum(inclusive) %f\n", totals.detailTimers[g_numDetailTimers - 1].time); + printf("________________________________\n"); + + // Dumping benchmark data to txt files + + g_benchmarkFile.open(g_benchmarkFilename, std::ofstream::out | std::ofstream::app); + g_benchmarkFile << std::fixed << std::setprecision(6); + g_benchmarkFile << "Scene: " << g_scenes[g_scene]->GetName() << std::endl; + g_benchmarkFile << "FrameTime " << totals.frameTime / totals.samples << std::endl; + g_benchmarkFile << "________________________________" << std::endl; + + if (g_profile) + { float exclusive = 0.0f; + g_benchmarkFile << std::fixed << std::setprecision(6); + for (int i = 0; i < g_numDetailTimers - 1; i++) { - exclusive += sDTimersSum[i].time; - g_benchmarkFile << sDTimersSum[i].name<<" "<< sDTimersSum[i].time << std::endl; + exclusive += totals.detailTimers[i].time; + g_benchmarkFile << totals.detailTimers[i].name << " " << totals.detailTimers[i].time << std::endl; + + delete totals.detailTimers[i].name; } - g_benchmarkFile << "Sum(exclusive) "<< exclusive << std::endl; - g_benchmarkFile << "Sum(inclusive) "<< sDTimersSum[g_numDetailTimers - 1].time<< std::endl; + g_benchmarkFile << "Sum(exclusive) " << exclusive << std::endl; + g_benchmarkFile << "Sum(inclusive) " << totals.detailTimers[g_numDetailTimers - 1].time << std::endl; g_benchmarkFile << "________________________________" << std::endl << std::endl; - g_benchmarkFile.close(); + } - if (g_benchmark) + if (g_outputAllFrameTimes) + { + for (int i = 0; i != benchmarkEndFrame; i++) { + g_benchmarkFile << g_GpuTimers.timers[i][3] << std::endl; + } -#if 0 - // Do basic kinetic energy verification check to ensure that the benchmark runs correctly - NvFlexGetVelocities(g_flex, g_buffers->velocities.buffer, g_buffers->velocities.size()); + // Per frame timers + for (int i = benchmarkAsyncOffDummyOnBeginFrame; i != benchmarkAsyncOnDummyOnBeginFrame; i++) + { + for (int j = 0; j != g_GpuTimers.timerCount[i]; j++) + { + g_benchmarkFile << g_GpuTimers.timers[i][j] << " "; + } - float sumVelocities = 0.0f; - for (int i = 0; i < g_buffers->velocities.size(); ++i) + for (int j = 0; j != g_GpuTimers.timerCount[i + benchmarkPhaseFrameCount]; j++) { - sumVelocities += g_buffers->velocities[i].x * g_buffers->velocities[i].x + g_buffers->velocities[i].y * g_buffers->velocities[i].y + g_buffers->velocities[i].z * g_buffers->velocities[i].z; + g_benchmarkFile << g_GpuTimers.timers[i + benchmarkPhaseFrameCount][j] << " "; } - // Tolerance 50% - int benchmark_id = benchmarkIter - 1; - if (sumVelocities > (benchmarkEnergyCheck[benchmark_id] * 1.50) || - sumVelocities < (benchmarkEnergyCheck[benchmark_id] * 0.50)) - printf("Benchmark kinetic energy verification failed! Expected: [%f], Actual: [%f]\n\n", benchmarkEnergyCheck[benchmark_id], sumVelocities); -#endif - g_frame = -1; + g_benchmarkFile << std::endl; } + } - if (g_benchmark && g_frame == -1) + g_benchmarkFile.close(); + + if (g_benchmark) { - if (benchmarkIter == numBenchmarks) - exit(0); - for (int i = 0; i < int(g_scenes.size()); ++i) +#if 0 + // Do basic kinetic energy verification check to ensure that the benchmark runs correctly + NvFlexGetVelocities(g_flex, g_buffers->velocities.buffer, g_buffers->velocities.size()); + + float sumVelocities = 0.0f; + for (int i = 0; i < g_buffers->velocities.size(); ++i) { - if (strcmp(benchmarkList[benchmarkIter], g_scenes[i]->GetName()) == 0) - newScene = i; + sumVelocities += g_buffers->velocities[i].x * g_buffers->velocities[i].x + g_buffers->velocities[i].y * g_buffers->velocities[i].y + g_buffers->velocities[i].z * g_buffers->velocities[i].z; } - assert(newScene != -1); + // Tolerance 50% + int benchmark_id = g_benchmarkScene - 1; + if (sumVelocities >(benchmarkEnergyCheck[benchmark_id] * 1.50) || + sumVelocities < (benchmarkEnergyCheck[benchmark_id] * 0.50)) + printf("Benchmark kinetic energy verification failed! Expected: [%f], Actual: [%f]\n\n", benchmarkEnergyCheck[benchmark_id], sumVelocities); +#endif - benchmarkIter++; } - - return newScene; } - -void BenchmarkInit() +//----------------------------------------------------------------------------- +int GoToNextScene() { - g_benchmarkFile.open(g_benchmarkFilename, std::ofstream::out | std::ofstream::app); - g_benchmarkFile << "Compute Device: " << g_deviceName << std::endl; - g_benchmarkFile << "HLSL Extensions: " << (g_extensions ? "ON" : "OFF") << std::endl << std::endl; - g_benchmarkFile.close(); + int sceneToSwitchTo = -1; + + // Advance to next benchmark scene + for (int i = 0; i < int(g_scenes.size()); ++i) + { + if (strcmp(benchmarkList[g_benchmarkScene], g_scenes[i]->GetName()) == 0) + { + sceneToSwitchTo = i; + g_benchmarkSceneNumber = i; + } + } + assert(sceneToSwitchTo != -1); + + g_useAsyncCompute = false; + g_increaseGfxLoadForAsyncComputeTesting = false; + + return sceneToSwitchTo; } +//----------------------------------------------------------------------------- +// Returns scene number if benchmark wants to switch scene, -1 otherwise +//----------------------------------------------------------------------------- +int BenchmarkUpdate() +{ + static TimerTotals s_totals; + int sceneToSwitchTo = -1; + + if (!g_benchmark) return sceneToSwitchTo; + + ProcessGpuTimes(); + UpdateTotals(s_totals); + + // Next frame + g_benchmarkFrame++; + + BeginNewPhaseIfNecessary(sceneToSwitchTo, s_totals); + + // Check whether at end of scene + if (g_benchmarkFrame == benchmarkEndFrame) + { + WriteSceneResults(s_totals); + // Next scene + g_benchmarkScene++; + // Go to next scene, or exit if all scenes done + if (g_benchmarkScene != numBenchmarks) + { + sceneToSwitchTo = GoToNextScene(); + + g_benchmarkFrame = 0; + g_frame = -1; + } + else + { + exit(0); + } + } + + return sceneToSwitchTo; +} +//----------------------------------------------------------------------------- +int BenchmarkInit() +{ + int sceneToSwitchTo = GoToNextScene(); + + return sceneToSwitchTo; +} +//----------------------------------------------------------------------------- +void BenchmarkUpdateGraph() +{ +} +//----------------------------------------------------------------------------- diff --git a/demo/compiler/makeandroid/Makefile b/demo/compiler/makeandroid/Makefile index 0b462ff..02650e4 100644 --- a/demo/compiler/makeandroid/Makefile +++ b/demo/compiler/makeandroid/Makefile @@ -2,11 +2,11 @@ # Makefile generated by XPJ for android DEPSDIR = .deps -NDKROOT = "$(NDK_ROOT)"/"$(NDK_VERSION)" -NDK_BIN_DIR = "$(NDK_ROOT)"/"$(NDK_VERSION)"/toolchains/"$(NDK_TOOLCHAIN)"/prebuilt/"linux-x86_64"/bin +NDKROOT = ./../../../../../../external/android-ndk/android-ndk-r10e-linux +NDK_BIN_DIR = ./../../../../../../external/android-ndk/android-ndk-r10e-linux/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin NDK_PREFIX = arm-linux-androideabi- -JAVA_HOME = ./../xpj/"$(JAVA_HOME)" -ANT_TOOL = ./../xpj/"$(ANT_HOME}"/bin/ant +JAVA_HOME = ./../../../../../../external/java/jdk1.8.0_20 +ANT_TOOL = ./../../../../../../external/ant/apache-ant-1.8.2/bin/ant #default defines OBJS_DIR = build RMDIR = rm -fr @@ -23,22 +23,20 @@ OBJCOPY = $(NDK_BIN_DIR)/$(NDK_PREFIX)objcopy all: debug release -debug: build_flexExtCUDA_debug +debug: build_flexCUDA_debug build_flexExtCUDA_debug -release: build_flexExtCUDA_release build_flexDemoCUDA_release +release: build_flexDevice_release build_flexCUDA_release build_flexExtCUDA_release build_flexDemoCUDA_release -clean: clean_flexExtCUDA_release clean_flexExtCUDA_debug clean_flexDemoCUDA_release +clean: clean_flexDevice_release clean_flexCUDA_release clean_flexCUDA_debug clean_flexExtCUDA_release clean_flexExtCUDA_debug clean_flexDemoCUDA_release rm -rf $(DEPSDIR) -clean_release: clean_flexExtCUDA_release clean_flexDemoCUDA_release - rm -rf $(DEPSDIR) - - -clean_debug: clean_flexExtCUDA_debug clean_flexDemoCUDA_debug +clean_release: clean_flexDevice_release clean_flexCUDA_release clean_flexExtCUDA_release clean_flexDemoCUDA_release rm -rf $(DEPSDIR) +include Makefile.flexDevice.mk +include Makefile.flexCUDA.mk include Makefile.flexExtCUDA.mk include Makefile.flexDemoCUDA.mk diff --git a/demo/compiler/makeandroid/Makefile.flexDemoCUDA.mk b/demo/compiler/makeandroid/Makefile.flexDemoCUDA.mk index dbfbaab..74e8454 100644 --- a/demo/compiler/makeandroid/Makefile.flexDemoCUDA.mk +++ b/demo/compiler/makeandroid/Makefile.flexDemoCUDA.mk @@ -18,6 +18,9 @@ flexDemoCUDA_cppfiles += ./../../../core/sdf.cpp flexDemoCUDA_cppfiles += ./../../../core/tga.cpp flexDemoCUDA_cppfiles += ./../../../core/voxelize.cpp flexDemoCUDA_cppfiles += ./../../../external/egl_setup/egl_setup.cpp +flexDemoCUDA_cppfiles += ./../../android/android_main.cpp +flexDemoCUDA_cppfiles += ./../../android/android_mainRender.cpp +flexDemoCUDA_cfiles += ./../../android/android_native_app_glue.c flexDemoCUDA_cpp_release_dep = $(addprefix $(DEPSDIR)/flexDemoCUDA/release/, $(subst ./, , $(subst ../, , $(patsubst %.cpp, %.cpp.P, $(flexDemoCUDA_cppfiles))))) flexDemoCUDA_cc_release_dep = $(addprefix $(DEPSDIR)/, $(subst ./, , $(subst ../, , $(patsubst %.cc, %.cc.release.P, $(flexDemoCUDA_ccfiles))))) @@ -26,15 +29,15 @@ flexDemoCUDA_release_dep = $(flexDemoCUDA_cpp_release_dep) $(flexDemoCUDA_c -include $(flexDemoCUDA_release_dep) flexDemoCUDA_release_hpaths := flexDemoCUDA_release_hpaths += ./../../.. -flexDemoCUDA_release_hpaths += $(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include -flexDemoCUDA_release_hpaths += $(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport -flexDemoCUDA_release_hpaths += $(CUDA_PATH)/targets/armv7-linux-androideabi/include +flexDemoCUDA_release_hpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include +flexDemoCUDA_release_hpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport +flexDemoCUDA_release_hpaths += ./../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include flexDemoCUDA_release_hpaths += ./../../../external/egl_setup flexDemoCUDA_release_hpaths += ./../../../external/regal_static/include flexDemoCUDA_release_lpaths := -flexDemoCUDA_release_lpaths += $(CUDA_PATH)/targets/armv7-linux-androideabi/lib +flexDemoCUDA_release_lpaths += ./../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/lib flexDemoCUDA_release_lpaths += ./../../../lib/android -flexDemoCUDA_release_lpaths += $(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/libs/armeabi-v7a +flexDemoCUDA_release_lpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/libs/armeabi-v7a flexDemoCUDA_release_lpaths += ./../../../external/regal_static/lib/armeabi-v7a flexDemoCUDA_release_lpaths += ./../../../lib/android flexDemoCUDA_release_defines := $(flexDemoCUDA_custom_defines) @@ -44,6 +47,8 @@ flexDemoCUDA_release_defines += ANDROID_PLAT=1 flexDemoCUDA_release_defines += DISABLE_IMPORTGL flexDemoCUDA_release_defines += NDEBUG flexDemoCUDA_release_libraries := +flexDemoCUDA_release_libraries += NvFlexReleaseCUDA_armv7l +flexDemoCUDA_release_libraries += flexDevice_x64 flexDemoCUDA_release_libraries += flexExt_cuda_release_armv7l flexDemoCUDA_release_libraries += android flexDemoCUDA_release_libraries += stdc++ @@ -62,14 +67,16 @@ flexDemoCUDA_release_common_cflags := $(flexDemoCUDA_custom_cflags) flexDemoCUDA_release_common_cflags += -MMD flexDemoCUDA_release_common_cflags += $(addprefix -D, $(flexDemoCUDA_release_defines)) flexDemoCUDA_release_common_cflags += $(addprefix -I, $(flexDemoCUDA_release_hpaths)) -flexDemoCUDA_release_common_cflags += -std=c++11 -fno-exceptions -fno-rtti -flexDemoCUDA_release_common_cflags += -fpic -fPIC -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -O2 -g -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 flexDemoCUDA_release_cflags := $(flexDemoCUDA_release_common_cflags) +flexDemoCUDA_release_cflags += -std=c++11 -fno-exceptions -fno-rtti +flexDemoCUDA_release_cflags += -fpic -fPIC -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -O2 -g -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 flexDemoCUDA_release_cppflags := $(flexDemoCUDA_release_common_cflags) +flexDemoCUDA_release_cppflags += -std=c++11 -fno-exceptions -fno-rtti +flexDemoCUDA_release_cppflags += -fpic -fPIC -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -O2 -g -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 flexDemoCUDA_release_lflags := $(flexDemoCUDA_custom_lflags) flexDemoCUDA_release_lflags += $(addprefix -L, $(flexDemoCUDA_release_lpaths)) flexDemoCUDA_release_lflags += -Wl,--start-group $(addprefix -l, $(flexDemoCUDA_release_libraries)) -Wl,--end-group -flexDemoCUDA_release_lflags += --sysroot="$(NDK_ROOT)"/"$(NDK_VERSION)"/platforms/android-15/arch-arm -shared -Wl,--no-undefined +flexDemoCUDA_release_lflags += --sysroot=/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm -shared -Wl,--no-undefined flexDemoCUDA_release_objsdir = $(OBJS_DIR)/flexDemoCUDA_release flexDemoCUDA_release_cpp_o = $(addprefix $(flexDemoCUDA_release_objsdir)/, $(subst ./, , $(subst ../, , $(patsubst %.cpp, %.cpp.o, $(flexDemoCUDA_cppfiles))))) flexDemoCUDA_release_cc_o = $(addprefix $(flexDemoCUDA_release_objsdir)/, $(subst ./, , $(subst ../, , $(patsubst %.cc, %.cc.o, $(flexDemoCUDA_ccfiles))))) @@ -91,7 +98,7 @@ antbuild_flexDemoCUDA_release: preantbuild_flexDemoCUDA_release mainbuild_flexDemoCUDA_release: prebuild_flexDemoCUDA_release $(flexDemoCUDA_release_bin) prebuild_flexDemoCUDA_release: -$(flexDemoCUDA_release_bin): $(flexDemoCUDA_release_obj) build_flexExtCUDA_release +$(flexDemoCUDA_release_bin): $(flexDemoCUDA_release_obj) build_flexCUDA_release build_flexDevice_release build_flexExtCUDA_release mkdir -p `dirname ./../android/flex_project/libs/armeabi-v7a/libflexDemo.so` $(CXX) -shared $(flexDemoCUDA_release_obj) $(flexDemoCUDA_release_lflags) -lc -o $@ $(ECHO) building $@ complete! diff --git a/demo/compiler/makeandroid/Makefile.flexExtCUDA.mk b/demo/compiler/makeandroid/Makefile.flexExtCUDA.mk index 8a33251..9e4826c 100644 --- a/demo/compiler/makeandroid/Makefile.flexExtCUDA.mk +++ b/demo/compiler/makeandroid/Makefile.flexExtCUDA.mk @@ -24,28 +24,32 @@ flexExtCUDA_debug_dep = $(flexExtCUDA_cpp_debug_dep) $(flexExtCUDA_cc_debug -include $(flexExtCUDA_debug_dep) flexExtCUDA_release_hpaths := flexExtCUDA_release_hpaths += ./../../.. -flexExtCUDA_release_hpaths += $(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include -flexExtCUDA_release_hpaths += $(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport -flexExtCUDA_release_hpaths += $(CUDA_PATH)/targets/armv7-linux-androideabi/include +flexExtCUDA_release_hpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include +flexExtCUDA_release_hpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport +flexExtCUDA_release_hpaths += ./../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include flexExtCUDA_release_lpaths := -flexExtCUDA_release_lpaths += $(CUDA_PATH)/targets/armv7-linux-androideabi/lib +flexExtCUDA_release_lpaths += ./../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/lib +flexExtCUDA_release_lpaths += ./../../../lib/android +flexExtCUDA_release_lpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/libs/armeabi-v7a flexExtCUDA_release_lpaths += ./../../../lib/android -flexExtCUDA_release_lpaths += $(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/libs/armeabi-v7a flexExtCUDA_release_defines := $(flexExtCUDA_custom_defines) flexExtCUDA_release_defines += android flexExtCUDA_release_defines += ANDROID=1 flexExtCUDA_release_defines += ANDROID_PLAT=1 flexExtCUDA_release_defines += DISABLE_IMPORTGL flexExtCUDA_release_libraries := +flexExtCUDA_release_libraries += NvFlexReleaseCUDA_armv7l flexExtCUDA_release_libraries += ./../../../lib/android/libNvFlexRelease_armv7l.a flexExtCUDA_release_common_cflags := $(flexExtCUDA_custom_cflags) flexExtCUDA_release_common_cflags += -MMD flexExtCUDA_release_common_cflags += $(addprefix -D, $(flexExtCUDA_release_defines)) flexExtCUDA_release_common_cflags += $(addprefix -I, $(flexExtCUDA_release_hpaths)) -flexExtCUDA_release_common_cflags += -Wall -std=c++11 -fpermissive -fno-strict-aliasing -fno-rtti -fno-exceptions -flexExtCUDA_release_common_cflags += -O3 -ffast-math flexExtCUDA_release_cflags := $(flexExtCUDA_release_common_cflags) +flexExtCUDA_release_cflags += -Wall -std=c++11 -fpermissive -fno-strict-aliasing -fno-rtti -fno-exceptions +flexExtCUDA_release_cflags += -O3 -ffast-math flexExtCUDA_release_cppflags := $(flexExtCUDA_release_common_cflags) +flexExtCUDA_release_cppflags += -Wall -std=c++11 -fpermissive -fno-strict-aliasing -fno-rtti -fno-exceptions +flexExtCUDA_release_cppflags += -O3 -ffast-math flexExtCUDA_release_lflags := $(flexExtCUDA_custom_lflags) flexExtCUDA_release_lflags += $(addprefix -L, $(flexExtCUDA_release_lpaths)) flexExtCUDA_release_lflags += -Wl,--start-group $(addprefix -l, $(flexExtCUDA_release_libraries)) -Wl,--end-group @@ -68,15 +72,15 @@ postbuild_flexExtCUDA_release: mainbuild_flexExtCUDA_release mainbuild_flexExtCUDA_release: prebuild_flexExtCUDA_release $(flexExtCUDA_release_bin) prebuild_flexExtCUDA_release: -$(flexExtCUDA_release_bin): $(flexExtCUDA_release_obj) +$(flexExtCUDA_release_bin): $(flexExtCUDA_release_obj) build_flexCUDA_release mkdir -p `dirname ./../../../lib/android/libflexExt_cuda_release_armv7l.a` @$(AR) rcs $(flexExtCUDA_release_bin) $(flexExtCUDA_release_obj) $(ECHO) building $@ complete! $(flexExtCUDA_release_cuda_extensions_cuda_flexExt_cu_o): $(flexExtCUDA_cuda_extensions_cuda_flexExt_cu) @mkdir -p `dirname $(OBJS_DIR)/flexExtCUDA_release/cuda/extensions/cudaflexExt.o` - $(ECHO) "$(CUDA_PATH)/bin/nvcc" -ccbin $(NDK_ROOT)/$(NDK_VERSION)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"$(CUDA_PATH)/targets/armv7-linux-androideabi/include" -I"../../.." -I"$(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport" -I"$(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include" --compile "./../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_release/cuda/extensions/cudaflexExt.o" - "$(CUDA_PATH)/bin/nvcc" -ccbin $(NDK_ROOT)/$(NDK_VERSION)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"$(CUDA_PATH)/targets/armv7-linux-androideabi/include" -I"../../.." -I"$(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport" -I"$(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include" --compile "./../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_release/cuda/extensions/cudaflexExt.o" + $(ECHO) "../../../../../../external/CUDA/cuda-6.0-linux/bin/nvcc" -ccbin /home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include" -I"../../.." -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport" -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include" --compile "../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_release/cuda/extensions/cudaflexExt.o" + "../../../../../../external/CUDA/cuda-6.0-linux/bin/nvcc" -ccbin /home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include" -I"../../.." -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport" -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include" --compile "../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_release/cuda/extensions/cudaflexExt.o" flexExtCUDA_release_DEPDIR = $(dir $(@))/$(*F) $(flexExtCUDA_release_cpp_o): $(flexExtCUDA_release_objsdir)/%.o: @@ -111,28 +115,32 @@ $(flexExtCUDA_release_c_o): $(flexExtCUDA_release_objsdir)/%.o: flexExtCUDA_debug_hpaths := flexExtCUDA_debug_hpaths += ./../../.. -flexExtCUDA_debug_hpaths += $(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include -flexExtCUDA_debug_hpaths += $(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport -flexExtCUDA_debug_hpaths += $(CUDA_PATH)/targets/armv7-linux-androideabi/include +flexExtCUDA_debug_hpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include +flexExtCUDA_debug_hpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport +flexExtCUDA_debug_hpaths += ./../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include flexExtCUDA_debug_lpaths := -flexExtCUDA_debug_lpaths += $(CUDA_PATH)/targets/armv7-linux-androideabi/lib +flexExtCUDA_debug_lpaths += ./../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/lib +flexExtCUDA_debug_lpaths += ./../../../lib/android +flexExtCUDA_debug_lpaths += ./../../../../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/libs/armeabi-v7a flexExtCUDA_debug_lpaths += ./../../../lib/android -flexExtCUDA_debug_lpaths += $(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/libs/armeabi-v7a flexExtCUDA_debug_defines := $(flexExtCUDA_custom_defines) flexExtCUDA_debug_defines += android flexExtCUDA_debug_defines += ANDROID=1 flexExtCUDA_debug_defines += ANDROID_PLAT=1 flexExtCUDA_debug_defines += DISABLE_IMPORTGL flexExtCUDA_debug_libraries := +flexExtCUDA_debug_libraries += NvFlexDebugCUDA_armv7l flexExtCUDA_debug_libraries += ./../../../lib/android/libNvFlexDebug_armv7l.a flexExtCUDA_debug_common_cflags := $(flexExtCUDA_custom_cflags) flexExtCUDA_debug_common_cflags += -MMD flexExtCUDA_debug_common_cflags += $(addprefix -D, $(flexExtCUDA_debug_defines)) flexExtCUDA_debug_common_cflags += $(addprefix -I, $(flexExtCUDA_debug_hpaths)) -flexExtCUDA_debug_common_cflags += -Wall -std=c++11 -fpermissive -fno-strict-aliasing -fno-rtti -fno-exceptions -flexExtCUDA_debug_common_cflags += -g -O0 flexExtCUDA_debug_cflags := $(flexExtCUDA_debug_common_cflags) +flexExtCUDA_debug_cflags += -Wall -std=c++11 -fpermissive -fno-strict-aliasing -fno-rtti -fno-exceptions +flexExtCUDA_debug_cflags += -g -O0 flexExtCUDA_debug_cppflags := $(flexExtCUDA_debug_common_cflags) +flexExtCUDA_debug_cppflags += -Wall -std=c++11 -fpermissive -fno-strict-aliasing -fno-rtti -fno-exceptions +flexExtCUDA_debug_cppflags += -g -O0 flexExtCUDA_debug_lflags := $(flexExtCUDA_custom_lflags) flexExtCUDA_debug_lflags += $(addprefix -L, $(flexExtCUDA_debug_lpaths)) flexExtCUDA_debug_lflags += -Wl,--start-group $(addprefix -l, $(flexExtCUDA_debug_libraries)) -Wl,--end-group @@ -155,15 +163,15 @@ postbuild_flexExtCUDA_debug: mainbuild_flexExtCUDA_debug mainbuild_flexExtCUDA_debug: prebuild_flexExtCUDA_debug $(flexExtCUDA_debug_bin) prebuild_flexExtCUDA_debug: -$(flexExtCUDA_debug_bin): $(flexExtCUDA_debug_obj) +$(flexExtCUDA_debug_bin): $(flexExtCUDA_debug_obj) build_flexCUDA_debug mkdir -p `dirname ./../../../lib/android/libflexExt_cuda_debug_armv7l.a` @$(AR) rcs $(flexExtCUDA_debug_bin) $(flexExtCUDA_debug_obj) $(ECHO) building $@ complete! $(flexExtCUDA_debug_cuda_extensions_cuda_flexExt_cu_o): $(flexExtCUDA_cuda_extensions_cuda_flexExt_cu) @mkdir -p `dirname $(OBJS_DIR)/flexExtCUDA_debug/cuda/extensions/cudaflexExt.o` - $(ECHO) "$(CUDA_PATH)/bin/nvcc" -ccbin $(NDK_ROOT)/$(NDK_VERSION)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"$(CUDA_PATH)/targets/armv7-linux-androideabi/include" -I"../../.." -I"$(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport" -I"$(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include" --compile "./../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_debug/cuda/extensions/cudaflexExt.o" - "$(CUDA_PATH)/bin/nvcc" -ccbin $(NDK_ROOT)/$(NDK_VERSION)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"$(CUDA_PATH)/targets/armv7-linux-androideabi/include" -I"../../.." -I"$(NDK_ROOT)/$(NDK_VERSION)/sources/cxx-stl/stlport/stlport" -I"$(NDK_ROOT)/$(NDK_VERSION)/platforms/android-15/arch-arm/usr/include" --compile "./../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_debug/cuda/extensions/cudaflexExt.o" + $(ECHO) "../../../../../../external/CUDA/cuda-6.0-linux/bin/nvcc" -ccbin /home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include" -I"../../.." -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport" -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include" --compile "../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_debug/cuda/extensions/cudaflexExt.o" + "../../../../../../external/CUDA/cuda-6.0-linux/bin/nvcc" -ccbin /home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -target-cpu-arch=ARM -m32 -arch=sm_32 -O3 -Xptxas -dlcm=ca -target-os-variant=Android -I"../../../../../../external/CUDA/cuda-6.0-linux/targets/armv7-linux-androideabi/include" -I"../../.." -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/sources/cxx-stl/stlport/stlport" -I"/home/mmacklin/swhost/devrel/libdev/flex/dev/main/../../../external/android-ndk/android-ndk-r10e-linux/platforms/android-15/arch-arm/usr/include" --compile "../../../extensions/cuda/flexExt.cu" -o "$(OBJS_DIR)/flexExtCUDA_debug/cuda/extensions/cudaflexExt.o" flexExtCUDA_debug_DEPDIR = $(dir $(@))/$(*F) $(flexExtCUDA_debug_cpp_o): $(flexExtCUDA_debug_objsdir)/%.o: diff --git a/demo/compiler/makelinux64/Makefile.flexDemoCUDA.mk b/demo/compiler/makelinux64/Makefile.flexDemoCUDA.mk index 152205d..f37fc83 100644 --- a/demo/compiler/makelinux64/Makefile.flexDemoCUDA.mk +++ b/demo/compiler/makelinux64/Makefile.flexDemoCUDA.mk @@ -54,7 +54,7 @@ flexDemoCUDA_release_cppflags := $(flexDemoCUDA_release_common_cflags) flexDemoCUDA_release_lflags := $(flexDemoCUDA_custom_lflags) flexDemoCUDA_release_lflags += $(addprefix -L, $(flexDemoCUDA_release_lpaths)) flexDemoCUDA_release_lflags += -Wl,--start-group $(addprefix -l, $(flexDemoCUDA_release_libraries)) -Wl,--end-group -flexDemoCUDA_release_lflags += -g -L../../../external/glew/lib/linux -L/usr/lib -L"../../../lib/linux64" -L../../../external/SDL2-2.0.4/lib/x64/ -L$(CUDA_PATH)/lib64 -lGL -lglut -lGLU -lGLEW -lcudart_static -ldl +flexDemoCUDA_release_lflags += -g -L../../../external/glew/lib/linux -L/usr/lib -L"../../../lib/linux64" -L../../../external/SDL2-2.0.4/lib/x64/ -L$(CUDA_PATH)/lib64 -lGL -lglut -lGLU -lGLEW -lcudart_static -ldl -lrt -pthread flexDemoCUDA_release_lflags += -m64 flexDemoCUDA_release_objsdir = $(OBJS_DIR)/flexDemoCUDA_release flexDemoCUDA_release_cpp_o = $(addprefix $(flexDemoCUDA_release_objsdir)/, $(subst ./, , $(subst ../, , $(patsubst %.cpp, %.cpp.o, $(flexDemoCUDA_cppfiles))))) @@ -136,7 +136,7 @@ flexDemoCUDA_debug_cppflags := $(flexDemoCUDA_debug_common_cflags) flexDemoCUDA_debug_lflags := $(flexDemoCUDA_custom_lflags) flexDemoCUDA_debug_lflags += $(addprefix -L, $(flexDemoCUDA_debug_lpaths)) flexDemoCUDA_debug_lflags += -Wl,--start-group $(addprefix -l, $(flexDemoCUDA_debug_libraries)) -Wl,--end-group -flexDemoCUDA_debug_lflags += -g -L../../../external/glew/lib/linux -L/usr/lib -L"../../../lib/linux64" -L../../../external/SDL2-2.0.4/lib/x64/ -L$(CUDA_PATH)/lib64 -lGL -lglut -lGLU -lGLEW -lcudart_static -ldl +flexDemoCUDA_debug_lflags += -g -L../../../external/glew/lib/linux -L/usr/lib -L"../../../lib/linux64" -L../../../external/SDL2-2.0.4/lib/x64/ -L$(CUDA_PATH)/lib64 -lGL -lglut -lGLU -lGLEW -lcudart_static -ldl -lrt -pthread flexDemoCUDA_debug_lflags += -m64 flexDemoCUDA_debug_objsdir = $(OBJS_DIR)/flexDemoCUDA_debug flexDemoCUDA_debug_cpp_o = $(addprefix $(flexDemoCUDA_debug_objsdir)/, $(subst ./, , $(subst ../, , $(patsubst %.cpp, %.cpp.o, $(flexDemoCUDA_cppfiles))))) diff --git a/demo/compiler/vc12win32/flexDemoCUDA.vcxproj b/demo/compiler/vc12win32/flexDemoCUDA.vcxproj index 5073547..aa6f0ae 100644 --- a/demo/compiler/vc12win32/flexDemoCUDA.vcxproj +++ b/demo/compiler/vc12win32/flexDemoCUDA.vcxproj @@ -55,7 +55,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexDebugCUDA_x86.lib;./../../../lib/win32/NvFlexExtDebugCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceDebug_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexDebugCUDA_x86.lib;./../../../lib/win32/NvFlexExtDebugCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceDebug_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugCUDA_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugCUDA_x86.exe.pdb @@ -95,7 +95,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexExtReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceRelease_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexExtReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceRelease_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseCUDA_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseCUDA_x86.exe.pdb @@ -184,8 +184,6 @@ - - @@ -206,6 +204,8 @@ + + diff --git a/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.filters b/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.filters index 45f6d6c..e5989dc 100644 --- a/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.filters +++ b/demo/compiler/vc12win32/flexDemoCUDA.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes diff --git a/demo/compiler/vc12win32/flexDemoD3D.vcxproj b/demo/compiler/vc12win32/flexDemoD3D.vcxproj index 4708dba..264f9d9 100644 --- a/demo/compiler/vc12win32/flexDemoD3D.vcxproj +++ b/demo/compiler/vc12win32/flexDemoD3D.vcxproj @@ -47,15 +47,15 @@ Precise /d2Zi+ Disabled - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;FLEX_DIRECT_COMPUTE;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;FLEX_DIRECT_COMPUTE;%(PreprocessorDefinitions) Level3 MultiThreadedDebug NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../lib/win32/NvFlexDebugD3D_x86.lib;./../../../lib/win32/NvFlexExtDebugD3D_x86.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/D3D12/libs/x86/d3d12.lib;./../../../lib/win32/NvFlexDebugD3D_x86.lib;./../../../lib/win32/NvFlexExtDebugD3D_x86.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugD3D_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugD3D_x86.exe.pdb @@ -86,15 +86,15 @@ Fast /d2Zi+ Full - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;NDEBUG;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;NDEBUG;%(PreprocessorDefinitions) Level3 MultiThreaded NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../lib/win32/NvFlexReleaseD3D_x86.lib;./../../../lib/win32/NvFlexExtReleaseD3D_x86.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/D3D12/libs/x86/d3d12.lib;./../../../lib/win32/NvFlexReleaseD3D_x86.lib;./../../../lib/win32/NvFlexExtReleaseD3D_x86.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseD3D_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseD3D_x86.exe.pdb @@ -183,8 +183,6 @@ - - @@ -205,6 +203,8 @@ + + @@ -324,57 +324,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + - + Vertex 5.0 false false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -382,17 +526,17 @@ false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -400,17 +544,17 @@ false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -418,17 +562,17 @@ false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -436,17 +580,35 @@ false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -454,17 +616,17 @@ false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -472,17 +634,17 @@ false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -490,17 +652,17 @@ false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -508,17 +670,17 @@ false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -526,17 +688,17 @@ false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -544,17 +706,35 @@ false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -562,17 +742,17 @@ false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -580,17 +760,17 @@ false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -598,17 +778,17 @@ false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -616,17 +796,17 @@ false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -634,17 +814,17 @@ false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -652,17 +832,17 @@ false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -670,17 +850,17 @@ false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -688,17 +868,17 @@ false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -706,7 +886,7 @@ false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h diff --git a/demo/compiler/vc12win32/flexDemoD3D.vcxproj.filters b/demo/compiler/vc12win32/flexDemoD3D.vcxproj.filters index 15615f5..b7f0548 100644 --- a/demo/compiler/vc12win32/flexDemoD3D.vcxproj.filters +++ b/demo/compiler/vc12win32/flexDemoD3D.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes @@ -327,6 +327,177 @@ core + + + + + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + @@ -335,121 +506,178 @@ d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + + d3d11 + + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 + + + + + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + - + + Shader Files + + + Shader Files + + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files diff --git a/demo/compiler/vc12win64/flexDemoCUDA.vcxproj b/demo/compiler/vc12win64/flexDemoCUDA.vcxproj index d00d61c..e37c7e7 100644 --- a/demo/compiler/vc12win64/flexDemoCUDA.vcxproj +++ b/demo/compiler/vc12win64/flexDemoCUDA.vcxproj @@ -55,7 +55,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexDebugCUDA_x64.lib;./../../../lib/win64/NvFlexExtDebugCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceDebug_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexDebugCUDA_x64.lib;./../../../lib/win64/NvFlexExtDebugCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceDebug_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugCUDA_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugCUDA_x64.exe.pdb @@ -95,7 +95,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexExtReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceRelease_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexExtReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceRelease_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseCUDA_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseCUDA_x64.exe.pdb @@ -184,8 +184,6 @@ - - @@ -206,6 +204,8 @@ + + diff --git a/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.filters b/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.filters index 45f6d6c..e5989dc 100644 --- a/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.filters +++ b/demo/compiler/vc12win64/flexDemoCUDA.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes diff --git a/demo/compiler/vc12win64/flexDemoD3D.vcxproj b/demo/compiler/vc12win64/flexDemoD3D.vcxproj index 50513db..d30d642 100644 --- a/demo/compiler/vc12win64/flexDemoD3D.vcxproj +++ b/demo/compiler/vc12win64/flexDemoD3D.vcxproj @@ -47,15 +47,15 @@ Precise /d2Zi+ Disabled - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Level3 MultiThreadedDebug NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../lib/win64/NvFlexDebugD3D_x64.lib;./../../../lib/win64/NvFlexExtDebugD3D_x64.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/D3D12/libs/x64/d3d12.lib;./../../../lib/win64/NvFlexDebugD3D_x64.lib;./../../../lib/win64/NvFlexExtDebugD3D_x64.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugD3D_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugD3D_x64.exe.pdb @@ -86,15 +86,15 @@ Fast /d2Zi+ Full - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;NDEBUG;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;NDEBUG;%(PreprocessorDefinitions) Level3 MultiThreaded NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../lib/win64/NvFlexReleaseD3D_x64.lib;./../../../lib/win64/NvFlexExtReleaseD3D_x64.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/D3D12/libs/x64/d3d12.lib;./../../../lib/win64/NvFlexReleaseD3D_x64.lib;./../../../lib/win64/NvFlexExtReleaseD3D_x64.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseD3D_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseD3D_x64.exe.pdb @@ -183,8 +183,6 @@ - - @@ -205,6 +203,8 @@ + + @@ -324,57 +324,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + - + Vertex 5.0 false false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -382,17 +526,17 @@ false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -400,17 +544,17 @@ false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -418,17 +562,17 @@ false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -436,17 +580,35 @@ false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -454,17 +616,17 @@ false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -472,17 +634,17 @@ false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -490,17 +652,17 @@ false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -508,17 +670,17 @@ false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -526,17 +688,17 @@ false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -544,17 +706,35 @@ false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -562,17 +742,17 @@ false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -580,17 +760,17 @@ false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -598,17 +778,17 @@ false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -616,17 +796,17 @@ false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -634,17 +814,17 @@ false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -652,17 +832,17 @@ false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -670,17 +850,17 @@ false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -688,17 +868,17 @@ false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -706,7 +886,7 @@ false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h diff --git a/demo/compiler/vc12win64/flexDemoD3D.vcxproj.filters b/demo/compiler/vc12win64/flexDemoD3D.vcxproj.filters index 15615f5..b7f0548 100644 --- a/demo/compiler/vc12win64/flexDemoD3D.vcxproj.filters +++ b/demo/compiler/vc12win64/flexDemoD3D.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes @@ -327,6 +327,177 @@ core + + + + + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + @@ -335,121 +506,178 @@ d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + + d3d11 + + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 + + + + + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + - + + Shader Files + + + Shader Files + + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files diff --git a/demo/compiler/vc14win32/flexDemoCUDA.vcxproj b/demo/compiler/vc14win32/flexDemoCUDA.vcxproj index d9aca99..984c2e4 100644 --- a/demo/compiler/vc14win32/flexDemoCUDA.vcxproj +++ b/demo/compiler/vc14win32/flexDemoCUDA.vcxproj @@ -55,7 +55,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexDebugCUDA_x86.lib;./../../../lib/win32/NvFlexExtDebugCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceDebug_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexDebugCUDA_x86.lib;./../../../lib/win32/NvFlexExtDebugCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceDebug_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugCUDA_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugCUDA_x86.exe.pdb @@ -95,7 +95,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexExtReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceRelease_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win32/NvFlexReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexExtReleaseCUDA_x86.lib;./../../../lib/win32/NvFlexDeviceRelease_x86.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseCUDA_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseCUDA_x86.exe.pdb @@ -184,8 +184,6 @@ - - @@ -206,6 +204,8 @@ + + diff --git a/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.filters b/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.filters index 45f6d6c..e5989dc 100644 --- a/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.filters +++ b/demo/compiler/vc14win32/flexDemoCUDA.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes diff --git a/demo/compiler/vc14win32/flexDemoD3D.vcxproj b/demo/compiler/vc14win32/flexDemoD3D.vcxproj index 6744073..a926666 100644 --- a/demo/compiler/vc14win32/flexDemoD3D.vcxproj +++ b/demo/compiler/vc14win32/flexDemoD3D.vcxproj @@ -13,6 +13,7 @@ {EF4EDDD8-2620-47AA-E75D-4C682C276C02} flexDemoD3D + 10.0.10586.0 @@ -47,15 +48,15 @@ Precise /d2Zi+ Disabled - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;FLEX_DIRECT_COMPUTE;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;FLEX_DIRECT_COMPUTE;%(PreprocessorDefinitions) Level3 MultiThreadedDebug NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../lib/win32/NvFlexDebugD3D_x86.lib;./../../../lib/win32/NvFlexExtDebugD3D_x86.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/D3D12/libs/x86/d3d12.lib;./../../../lib/win32/NvFlexDebugD3D_x86.lib;./../../../lib/win32/NvFlexExtDebugD3D_x86.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugD3D_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugD3D_x86.exe.pdb @@ -86,15 +87,15 @@ Fast /d2Zi+ Full - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;NDEBUG;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;NDEBUG;%(PreprocessorDefinitions) Level3 MultiThreaded NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../lib/win32/NvFlexReleaseD3D_x86.lib;./../../../lib/win32/NvFlexExtReleaseD3D_x86.lib;./../../../external/glew/lib/win32/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib;./../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib;./../../../external/D3D12/libs/x86/d3d12.lib;./../../../lib/win32/NvFlexReleaseD3D_x86.lib;./../../../lib/win32/NvFlexExtReleaseD3D_x86.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseD3D_x86.exe $(CUDA_PATH)/lib/win32;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseD3D_x86.exe.pdb @@ -183,8 +184,6 @@ - - @@ -205,6 +204,8 @@ + + @@ -324,57 +325,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + - + Vertex 5.0 false false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -382,17 +527,17 @@ false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -400,17 +545,17 @@ false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -418,17 +563,17 @@ false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -436,17 +581,35 @@ false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -454,17 +617,17 @@ false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -472,17 +635,17 @@ false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -490,17 +653,17 @@ false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -508,17 +671,17 @@ false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -526,17 +689,17 @@ false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -544,17 +707,35 @@ false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -562,17 +743,17 @@ false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -580,17 +761,17 @@ false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -598,17 +779,17 @@ false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -616,17 +797,17 @@ false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -634,17 +815,17 @@ false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -652,17 +833,17 @@ false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -670,17 +851,17 @@ false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -688,17 +869,17 @@ false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -706,7 +887,7 @@ false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h diff --git a/demo/compiler/vc14win32/flexDemoD3D.vcxproj.filters b/demo/compiler/vc14win32/flexDemoD3D.vcxproj.filters index 15615f5..b7f0548 100644 --- a/demo/compiler/vc14win32/flexDemoD3D.vcxproj.filters +++ b/demo/compiler/vc14win32/flexDemoD3D.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes @@ -327,6 +327,177 @@ core + + + + + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + @@ -335,121 +506,178 @@ d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + + d3d11 + + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 + + + + + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + - + + Shader Files + + + Shader Files + + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files diff --git a/demo/compiler/vc14win64/flexDemoCUDA.vcxproj b/demo/compiler/vc14win64/flexDemoCUDA.vcxproj index 056fb6d..8b4c665 100644 --- a/demo/compiler/vc14win64/flexDemoCUDA.vcxproj +++ b/demo/compiler/vc14win64/flexDemoCUDA.vcxproj @@ -55,7 +55,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexDebugCUDA_x64.lib;./../../../lib/win64/NvFlexExtDebugCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceDebug_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexDebugCUDA_x64.lib;./../../../lib/win64/NvFlexExtDebugCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceDebug_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugCUDA_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugCUDA_x64.exe.pdb @@ -95,7 +95,7 @@ - cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexExtReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceRelease_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../lib/win64/NvFlexReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexExtReleaseCUDA_x64.lib;./../../../lib/win64/NvFlexDeviceRelease_x64.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseCUDA_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseCUDA_x64.exe.pdb @@ -184,8 +184,6 @@ - - @@ -206,6 +204,8 @@ + + diff --git a/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.filters b/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.filters index 45f6d6c..e5989dc 100644 --- a/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.filters +++ b/demo/compiler/vc14win64/flexDemoCUDA.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes diff --git a/demo/compiler/vc14win64/flexDemoD3D.vcxproj b/demo/compiler/vc14win64/flexDemoD3D.vcxproj index 9b3dfae..3fbd922 100644 --- a/demo/compiler/vc14win64/flexDemoD3D.vcxproj +++ b/demo/compiler/vc14win64/flexDemoD3D.vcxproj @@ -13,6 +13,7 @@ {EF4EDDD8-2620-47AA-E75D-4C682C276C02} flexDemoD3D + 10.0.10586.0 @@ -47,15 +48,15 @@ Precise /d2Zi+ Disabled - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Level3 MultiThreadedDebug NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../lib/win64/NvFlexDebugD3D_x64.lib;./../../../lib/win64/NvFlexExtDebugD3D_x64.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/D3D12/libs/x64/d3d12.lib;./../../../lib/win64/NvFlexDebugD3D_x64.lib;./../../../lib/win64/NvFlexExtDebugD3D_x64.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoDebugD3D_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoDebugD3D_x64.exe.pdb @@ -86,15 +87,15 @@ Fast /d2Zi+ Full - $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../../external/SDL2-2.0.4/include;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;NDEBUG;%(PreprocessorDefinitions) + $(CUDA_PATH)/include;$(CUDA_PATH)/extras/cupti/include;./../../..;./../..;./../../d3d11;./../../d3d12;./../../../external/SDL2-2.0.4/include;./../../../external/D3D12/include;%(AdditionalIncludeDirectories) + _CONSOLE;WIN32;_CRT_SECURE_NO_WARNINGS;FLEX_DX;FLEX_DX12;NDEBUG;%(PreprocessorDefinitions) Level3 MultiThreaded NotUsing - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../lib/win64/NvFlexReleaseD3D_x64.lib;./../../../lib/win64/NvFlexExtReleaseD3D_x64.lib;./../../../external/glew/lib/x64/glew32.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;d3dcompiler.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2.lib;./../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib;./../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib;./../../../external/D3D12/libs/x64/d3d12.lib;./../../../lib/win64/NvFlexReleaseD3D_x64.lib;./../../../lib/win64/NvFlexExtReleaseD3D_x64.lib;%(AdditionalDependencies) $(OutDir)NvFlexDemoReleaseD3D_x64.exe $(CUDA_PATH)/lib/x64;%(AdditionalLibraryDirectories) $(OutDir)/NvFlexDemoReleaseD3D_x64.exe.pdb @@ -183,8 +184,6 @@ - - @@ -205,6 +204,8 @@ + + @@ -324,57 +325,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + - + Vertex 5.0 false false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -382,17 +527,17 @@ false debugLineVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -400,17 +545,17 @@ false debugLinePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -418,17 +563,17 @@ false imguiPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -436,17 +581,35 @@ false imguiVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + meshPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -454,17 +617,17 @@ false meshPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -472,17 +635,17 @@ false meshPS_Shadow false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -490,17 +653,17 @@ false meshVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -508,17 +671,17 @@ false pointVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -526,17 +689,17 @@ false pointGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -544,17 +707,35 @@ false pointPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h + + Pixel + 5.0 + false + false + pointShadowPS + false + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -562,17 +743,17 @@ false diffuseVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -580,17 +761,17 @@ false diffuseGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -598,17 +779,17 @@ false diffusePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -616,17 +797,17 @@ false ellipsoidDepthVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Geometry 5.0 false false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Geometry 5.0 @@ -634,17 +815,17 @@ false ellipsoidDepthGS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -652,17 +833,17 @@ false ellipsoidDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Vertex 5.0 false false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Vertex 5.0 @@ -670,17 +851,17 @@ false passThroughVS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -688,17 +869,17 @@ false blurDepthPS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h - + Pixel 5.0 false false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h Pixel 5.0 @@ -706,7 +887,7 @@ false compositePS false - ../../../demo/d3d11/shaders/%(Filename).hlsl.h + ../../../demo/d3d/shaders/%(Filename).hlsl.h diff --git a/demo/compiler/vc14win64/flexDemoD3D.vcxproj.filters b/demo/compiler/vc14win64/flexDemoD3D.vcxproj.filters index 15615f5..b7f0548 100644 --- a/demo/compiler/vc14win64/flexDemoD3D.vcxproj.filters +++ b/demo/compiler/vc14win64/flexDemoD3D.vcxproj.filters @@ -111,9 +111,6 @@ demo\scenes - - demo\scenes - demo\scenes @@ -144,6 +141,9 @@ demo\scenes + + demo\scenes + demo\scenes @@ -327,6 +327,177 @@ core + + + + + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + + d3d12 + + @@ -335,121 +506,178 @@ d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 d3d11 - + d3d11 - + d3d11 - + + d3d11 + + d3d11 d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 - + d3d11 + + + + + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + + d3d + + - + + Shader Files + + + Shader Files + + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files - + Shader Files diff --git a/demo/compiler/xpj/flexDemoCUDA.xpj b/demo/compiler/xpj/flexDemoCUDA.xpj index 1257e14..c4b7ab5 100644 --- a/demo/compiler/xpj/flexDemoCUDA.xpj +++ b/demo/compiler/xpj/flexDemoCUDA.xpj @@ -74,6 +74,7 @@ ../../../lib/win32/NvFlexDeviceDebug_x86.lib ../../../external/SDL2-2.0.4/lib/x86/SDL2.lib ../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib + ../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib ../../../external/glew/lib/win32/glew32.lib @@ -82,6 +83,7 @@ ../../../lib/win64/NvFlexDeviceDebug_x64.lib ../../../external/SDL2-2.0.4/lib/x64/SDL2.lib ../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib + ../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib ../../../external/glew/lib/x64/glew32.lib @@ -111,6 +113,7 @@ ../../../lib/win32/NvFlexDeviceRelease_x86.lib ../../../external/SDL2-2.0.4/lib/x86/SDL2.lib ../../../external/SDL2-2.0.4/lib/x86/SDL2main.lib + ../../../external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib ../../../external/glew/lib/win32/glew32.lib @@ -119,87 +122,12 @@ ../../../lib/win64/NvFlexDeviceRelease_x64.lib ../../../external/SDL2-2.0.4/lib/x64/SDL2.lib ../../../external/SDL2-2.0.4/lib/x64/SDL2main.lib + ../../../external/NvToolsExt/lib/x64/nvToolsExt64_1.lib ../../../external/glew/lib/x64/glew32.lib - - - - - - - - ${user:ProjectRoot}/demo/compiler/android/flex_project/libs/armeabi-v7a - - - android - ANDROID=1 - ANDROID_PLAT=1 - DISABLE_IMPORTGL - - - - "${user:ProjectRoot}" - "${user:ProjectRoot}/external/egl_setup" - "${user:ProjectRoot}/external/regal_static/include" - - - - "${user:ProjectRoot}/external/regal_static/lib/armeabi-v7a" - "${user:ProjectRoot}/lib/android" - - - - android stdc++ c m log dl EGL gomp cudart_static Regal_static - - - - stlport_static - - - True - True - - - -std=c++11 -fno-exceptions -fno-rtti - - - - -fpic -fPIC -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -O2 -g -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 - - - - --sysroot=${NDK_ROOT}/${NDK_VERSION}/platforms/android-15/arch-arm -shared -Wl,--no-undefined - - - 15 - - ${user:ProjectRoot}/demo/compiler/android/flex_project - - - ${user:ProjectRoot}/demo/compiler/android/src - - - - - - libflexDemo.so - - - NDEBUG - - - debug - - - NvFlexRelease_armv7l - NvFlexExtRelease_armv7l - - - - @@ -220,7 +148,7 @@ - -g -L${user:External}/glew/lib/linux -L/usr/lib -L"../../../lib/linux64" -L${user:External}/SDL2-2.0.4/lib/x64/ -L${user:CUDA_PATH}/lib64 -lGL -lglut -lGLU -lGLEW -lcudart_static -ldl + -g -L${user:External}/glew/lib/linux -L/usr/lib -L"../../../lib/linux64" -L${user:External}/SDL2-2.0.4/lib/x64/ -L${user:CUDA_PATH}/lib64 -lGL -lglut -lGLU -lGLEW -lcudart_static -ldl -lrt -pthread diff --git a/demo/compiler/xpj/flexDemoD3D.xpj b/demo/compiler/xpj/flexDemoD3D.xpj index 0c95377..e957c5b 100644 --- a/demo/compiler/xpj/flexDemoD3D.xpj +++ b/demo/compiler/xpj/flexDemoD3D.xpj @@ -19,6 +19,9 @@ + + 10.0.10586.0 + @@ -34,6 +37,7 @@ WIN32 _CRT_SECURE_NO_WARNINGS FLEX_DX + FLEX_DX12 3 @@ -42,23 +46,29 @@ MultiByte - ${user:ProjectRoot} - ${user:ProjectRoot}\demo - ${user:ProjectRoot}\demo\d3d11 - ${user:ProjectRoot}\external\SDL2-2.0.4\include + ${user:ProjectRoot} + ${user:ProjectRoot}\demo + ${user:ProjectRoot}\demo\d3d11 + ${user:ProjectRoot}\demo\d3d12 + ${user:ProjectRoot}\external\SDL2-2.0.4\include + ${user:ProjectRoot}\external\D3D12\include - kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib + kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib d3dcompiler.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x86/SDL2.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x86/SDL2main.lib + ${user:ProjectRoot}/external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib + ${user:ProjectRoot}/external/D3D12/libs/x86/d3d12.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x64/SDL2.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x64/SDL2main.lib + ${user:ProjectRoot}/external/NvToolsExt/lib/x64/nvToolsExt64_1.lib + ${user:ProjectRoot}/external/D3D12/libs/x64/d3d12.lib @@ -87,14 +97,14 @@ ${user:ProjectRoot}/lib/win32/NvFlexExtDebugD3D_x86.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x86/SDL2.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x86/SDL2main.lib - ${user:ProjectRoot}/external/glew/lib/win32/glew32.lib + ${user:ProjectRoot}/external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib ${user:ProjectRoot}/lib/win64/NvFlexDebugD3D_x64.lib ${user:ProjectRoot}/lib/win64/NvFlexExtDebugD3D_x64.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x64/SDL2.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x64/SDL2main.lib - ${user:ProjectRoot}/external/glew/lib/x64/glew32.lib + ${user:ProjectRoot}/external/NvToolsExt/lib/x64/nvToolsExt64_1.lib @@ -124,20 +134,67 @@ ${user:ProjectRoot}/lib/win32/NvFlexExtReleaseD3D_x86.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x86/SDL2.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x86/SDL2main.lib - ${user:ProjectRoot}/external/glew/lib/win32/glew32.lib + ${user:ProjectRoot}/external/NvToolsExt/lib/Win32/nvToolsExt32_1.lib ${user:ProjectRoot}/lib/win64/NvFlexReleaseD3D_x64.lib ${user:ProjectRoot}/lib/win64/NvFlexExtReleaseD3D_x64.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x64/SDL2.lib ${user:ProjectRoot}/external/SDL2-2.0.4/lib/x64/SDL2main.lib - ${user:ProjectRoot}/external/glew/lib/x64/glew32.lib + ${user:ProjectRoot}/external/NvToolsExt/lib/x64/nvToolsExt64_1.lib - + + + Nv/Common/*.cpp + Nv/Common/*.h + -Nv/Common/NvCoPathFinder.* + -Nv/Common/NvCoMemoryMappedFile.* + -Nv/Common/NvCoMemoryReadStream.* + -Nv/Common/NvCoMemoryWriteStream.* + -Nv/Common/NvCoCircularHeap.* + -Nv/Common/NvCoFreeListHeap.* + + Nv/Common/Platform/Win/*.cpp + Nv/Common/Platform/Win/*.h + -Nv/Common/Platform/Win/NvCoWinMemoryMappedFile.* + -Nv/Common/Platform/Win/NvCoWinPathUtil.* + -Nv/Common/Platform/Win/NvCoWinMinimalInclude.* + -Nv/Common/Platform/Win/NvCoWinCriticalSection.* + + Nv/Common/Util/*.cpp + Nv/Common/Util/*.h + -Nv/Common/Util/NvCoParseUtil.* + -Nv/Common/Util/NvCoStringEscapeUtil.* + -Nv/Common/Util/NvCoPathUtil.* + -Nv/Common/Util/NvCoArgParseUtil.* + -Nv/Common/Util/NvCoBitUtil.* + + -Nv/Common/Random/*.cpp + -Nv/Common/Random/*.h + + Nv/Common/Container/*.cpp + Nv/Common/Container/*.h + -Nv/Common/Container/NvCoHandleMap.* + + Nv/Common/Render/Dx/*.cpp + Nv/Common/Render/Dx/*.h + Nv/Common/Render/Dx12/*.cpp + Nv/Common/Render/Dx12/*.h + -Nv/Common/Render/Dx/NvCoDxIncludeHandler.* + -Nv/Common/Render/Dx/NvCoDxShaderUtil.* + -Nv/Common/Render/Dx12/NvCoDx12AsyncManager.* + -Nv/Common/Render/Dx12/NvCoDx12DescriptorCache.* + + Nv/Common/Render/Context/*.cpp + Nv/Common/Render/Context/*.h + Nv/Common/Render/Context/Dx12/*.cpp + Nv/Common/Render/Context/Dx12/*.h + + *.cpp *.h scenes/*.h @@ -154,41 +211,52 @@ flexD3D flexExtD3D - + + + + *.h + *.cpp + *.h *.cpp + + *.h + *.cpp + - + - "${user:ProjectRoot}/demo/d3d11/shaders/debugLineVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/debugLinePS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/debugLineVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/debugLinePS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/imguiPS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/imguiVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/imguiPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/imguiVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/meshPS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/meshShadowPS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/meshVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/meshPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/meshShadowPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/meshVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/pointVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/pointGS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/pointPS.hlsl" - - "${user:ProjectRoot}/demo/d3d11/shaders/diffuseVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/diffuseGS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/diffusePS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/pointVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/pointGS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/pointPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/pointShadowPS.hlsl" + + "${user:ProjectRoot}/demo/d3d/shaders/diffuseVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/diffuseGS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/diffusePS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/ellipsoidDepthVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/ellipsoidDepthGS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/ellipsoidDepthPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/ellipsoidDepthVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/ellipsoidDepthGS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/ellipsoidDepthPS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/passThroughVS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/blurDepthPS.hlsl" - "${user:ProjectRoot}/demo/d3d11/shaders/compositePS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/passThroughVS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/blurDepthPS.hlsl" + "${user:ProjectRoot}/demo/d3d/shaders/compositePS.hlsl" diff --git a/demo/d3d/appGraphCtx.h b/demo/d3d/appGraphCtx.h new file mode 100644 index 0000000..2c6300d --- /dev/null +++ b/demo/d3d/appGraphCtx.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#define APP_GRAPH_CTX_API extern "C" __declspec(dllexport) + +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, int numMSAASamples); + +APP_GRAPH_CTX_API void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context); + +APP_GRAPH_CTX_API void AppGraphCtxRelease(AppGraphCtx* context); + +APP_GRAPH_CTX_API void AppGraphCtxFrameStart(AppGraphCtx* context, AppGraphColor clearColor); + +APP_GRAPH_CTX_API void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync); + +APP_GRAPH_CTX_API void AppGraphCtxWaitForFrames(AppGraphCtx* context, unsigned int maxFramesInFlight); + +APP_GRAPH_CTX_API void AppGraphCtxProfileEnable(AppGraphCtx* context, bool enabled); + +APP_GRAPH_CTX_API void AppGraphCtxProfileBegin(AppGraphCtx* context, const char* label); + +APP_GRAPH_CTX_API void AppGraphCtxProfileEnd(AppGraphCtx* context, const char* label); + +APP_GRAPH_CTX_API bool AppGraphCtxProfileGet(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index); + +APP_GRAPH_CTX_API size_t AppGraphCtxDedicatedVideoMemory(AppGraphCtx* context); + diff --git a/demo/d3d/appGraphCtxLoader.cpp b/demo/d3d/appGraphCtxLoader.cpp new file mode 100644 index 0000000..07375b8 --- /dev/null +++ b/demo/d3d/appGraphCtxLoader.cpp @@ -0,0 +1,72 @@ +/* + * 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 + +#include "loader.h" +#include "loaderMacros.h" + +#include "appGraphCtx.h" + +#include + +#define LOADER_APPC_CTX_FUNCTIONS(op, inst, inst_func) \ + op(inst, inst_func, AppGraphCtx*, AppGraphCtxCreate, 1, ((int, deviceID)) ) \ + op(inst, inst_func, bool, AppGraphCtxUpdateSize, 4, ((AppGraphCtx*, context), (SDL_Window*, window), (bool, fullscreen), (int, numMSAASamples)) ) \ + op(inst, inst_func, void, AppGraphCtxReleaseRenderTarget, 1, ((AppGraphCtx*, context)) ) \ + op(inst, inst_func, void, AppGraphCtxRelease, 1, ((AppGraphCtx*, context)) ) \ + op(inst, inst_func, void, AppGraphCtxFrameStart, 2, ((AppGraphCtx*, context), (AppGraphColor, clearColor)) ) \ + op(inst, inst_func, void, AppGraphCtxFramePresent, 2, ((AppGraphCtx*, context), (bool, fullsync)) ) \ + op(inst, inst_func, void, AppGraphCtxWaitForFrames, 2, ((AppGraphCtx*, context), (unsigned int, maxFramesInFlight)) ) \ + op(inst, inst_func, void, AppGraphCtxProfileEnable, 2, ((AppGraphCtx*, context), (bool, enabled)) ) \ + op(inst, inst_func, void, AppGraphCtxProfileBegin, 2, ((AppGraphCtx*, context), (const char*, label)) ) \ + op(inst, inst_func, void, AppGraphCtxProfileEnd, 2, ((AppGraphCtx*, context), (const char*, label)) ) \ + op(inst, inst_func, bool, AppGraphCtxProfileGet, 5, ((AppGraphCtx*, context), (const char**, plabel), (float*, cpuTime), (float*, gpuTime), (int, index)) ) \ + op(inst, inst_func, size_t, AppGraphCtxDedicatedVideoMemory, 1, ((AppGraphCtx*, context)) ) + +LOADER_APPC_CTX_FUNCTIONS(LOADER_DECLARE_FUNCTION_PTR, (), ()) + +struct AppCtxFunctionSet +{ + LOADER_APPC_CTX_FUNCTIONS(LOADER_DECLARE_FUNCTION_VAR, (), ()) +}; + +// Declare D3D11/D3D12 versions +#define APP_CTX_D3D11_FUNCTION_NAME(x) x##D3D11 +#define APP_CTX_D3D12_FUNCTION_NAME(x) x##D3D12 + +extern "C" { + +LOADER_APPC_CTX_FUNCTIONS(LOADER_DECLARE_FUNCTION_NAME, (), APP_CTX_D3D11_FUNCTION_NAME) +LOADER_APPC_CTX_FUNCTIONS(LOADER_DECLARE_FUNCTION_NAME, (), APP_CTX_D3D12_FUNCTION_NAME) + +} // extern "C" + +static AppCtxFunctionSet g_functionSet; + +void loadAppGraphCtx(AppGraphCtxType type) +{ + if (type == APP_CONTEXT_D3D11) + { + LOADER_APPC_CTX_FUNCTIONS(LOADER_SET_FUNCTION, g_functionSet, APP_CTX_D3D11_FUNCTION_NAME) + } + if (type == APP_CONTEXT_D3D12) + { + LOADER_APPC_CTX_FUNCTIONS(LOADER_SET_FUNCTION, g_functionSet, APP_CTX_D3D12_FUNCTION_NAME) + } +} + +void unloadAppGraphCtx() +{ + g_functionSet = AppCtxFunctionSet{}; +} + +// Generate the patches +LOADER_APPC_CTX_FUNCTIONS(LOADER_FUNCTION_PTR_CALL, g_functionSet, ()) diff --git a/demo/d3d/demoContext.h b/demo/d3d/demoContext.h new file mode 100644 index 0000000..bca41f0 --- /dev/null +++ b/demo/d3d/demoContext.h @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef DEMO_CONTEXT_H +#define DEMO_CONTEXT_H + +#include "shaders.h" + +//#include "../d3d/imguiGraph.h" + +class DemoContext +{ + public: + /// Returns false if couldn't start up + virtual bool initialize(const RenderInitOptions& options) = 0; + + virtual void startFrame(Vec4 colorIn) = 0; + virtual void endFrame() = 0; + virtual void presentFrame(bool fullsync) = 0; + + virtual void getViewRay(int x, int y, Vec3& origin, Vec3& dir) = 0; + virtual void setView(Matrix44 view, Matrix44 projection) = 0; + virtual void renderEllipsoids(FluidRenderer* renderer, FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) = 0; + + virtual void drawMesh(const Mesh* m, Vec3 color) = 0; + virtual void drawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth) = 0; + virtual void drawRope(Vec4* positions, int* indices, int numIndices, float radius, int color) = 0; + virtual void drawPlane(const Vec4& p, bool color) = 0; + virtual void drawPlanes(Vec4* planes, int n, float bias) = 0; + + virtual void graphicsTimerBegin() = 0; + virtual void graphicsTimerEnd() = 0; + + virtual float rendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) = 0; + + virtual void bindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float bias, Vec4 fogColor) = 0; + virtual void unbindSolidShader() = 0; + + virtual ShadowMap* shadowCreate() = 0; + virtual void shadowDestroy(ShadowMap* map) = 0; + virtual void shadowBegin(ShadowMap* map) = 0; + virtual void shadowEnd() = 0; + + virtual FluidRenderer* createFluidRenderer(uint32_t width, uint32_t height) = 0; + virtual void destroyFluidRenderer(FluidRenderer* renderer) = 0; + + virtual FluidRenderBuffers* createFluidRenderBuffers(int numParticles, bool enableInterop) = 0; + virtual void drawPoints(FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowTex, bool showDensity) = 0; + virtual void updateFluidRenderBuffers(FluidRenderBuffers* buffers, NvFlexSolver* flex, bool anisotropy, bool density) = 0; + virtual void updateFluidRenderBuffers(FluidRenderBuffers* buffers, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) = 0; + virtual void destroyFluidRenderBuffers(FluidRenderBuffers* buffers) = 0; + + virtual GpuMesh* createGpuMesh(const Mesh* m) = 0; + virtual void destroyGpuMesh(GpuMesh* mesh) = 0; + virtual void drawGpuMesh(GpuMesh* m, const Matrix44& xform, const Vec3& color) = 0; + virtual void drawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const Vec3& color) = 0; + + virtual DiffuseRenderBuffers* createDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop) = 0; + virtual void destroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers) = 0; + virtual void updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles) = 0; + virtual void updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, NvFlexSolver* solver) = 0; + virtual int getNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers) = 0; + + virtual void drawDiffuse(FluidRenderer* render, const DiffuseRenderBuffers* buffers, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front) = 0; + + virtual void beginLines() = 0; + virtual void drawLine(const Vec3& p, const Vec3& q, const Vec4& color) = 0; + virtual void endLines() = 0; + + virtual void onSizeChanged(int width, int height, bool minimized) = 0; + + virtual void startGpuWork() = 0; + virtual void endGpuWork() = 0; + virtual void flushGraphicsAndWait() = 0; + + virtual void setFillMode(bool wire) = 0; + virtual void setCullMode(bool enabled) = 0; + + virtual void drawImguiGraph() = 0; + virtual void* getGraphicsCommandQueue() { return nullptr; } + virtual void getRenderDevice(void** device, void** context) = 0; + + virtual ~DemoContext() {} +}; + +#endif // DEMO_CONTEXT_H \ No newline at end of file diff --git a/demo/d3d/imguiGraph.cpp b/demo/d3d/imguiGraph.cpp new file mode 100644 index 0000000..7babb96 --- /dev/null +++ b/demo/d3d/imguiGraph.cpp @@ -0,0 +1,471 @@ +/* + * 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. + */ + +#define _USE_MATH_DEFINES +#include +#include "imgui.h" + +#include +#include + +#include "imguiGraph.h" + +// Some math headers don't have PI defined. +static const float PI = 3.14159265f; + +void imguifree(void* ptr, void* userptr); +void* imguimalloc(size_t size, void* userptr); + +#define STBTT_malloc(x,y) imguimalloc(x,y) +#define STBTT_free(x,y) imguifree(x,y) +#define STB_TRUETYPE_IMPLEMENTATION +#include "stb_truetype.h" + +void imguifree(void* ptr, void* /*userptr*/) +{ + free(ptr); +} + +void* imguimalloc(size_t size, void* /*userptr*/) +{ + return malloc(size); +} + +static const unsigned TEMP_COORD_COUNT = 100; +static float g_tempCoords[TEMP_COORD_COUNT * 2]; +static float g_tempNormals[TEMP_COORD_COUNT * 2]; + +static const int CIRCLE_VERTS = 8 * 4; +static float g_circleVerts[CIRCLE_VERTS * 2]; + +static stbtt_bakedchar g_cdata[96]; // ASCII 32..126 is 95 glyphs + +inline unsigned int RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) +{ + return (r) | (g << 8) | (b << 16) | (a << 24); +} + +static void drawPolygon(const float* coords, unsigned numCoords, float r, unsigned int col) +{ + if (numCoords > TEMP_COORD_COUNT) numCoords = TEMP_COORD_COUNT; + + for (unsigned i = 0, j = numCoords - 1; i < numCoords; j = i++) + { + const float* v0 = &coords[j * 2]; + const float* v1 = &coords[i * 2]; + float dx = v1[0] - v0[0]; + float dy = v1[1] - v0[1]; + float d = sqrtf(dx*dx + dy*dy); + if (d > 0) + { + d = 1.0f / d; + dx *= d; + dy *= d; + } + g_tempNormals[j * 2 + 0] = dy; + g_tempNormals[j * 2 + 1] = -dx; + } + + for (unsigned i = 0, j = numCoords - 1; i < numCoords; j = i++) + { + float dlx0 = g_tempNormals[j * 2 + 0]; + float dly0 = g_tempNormals[j * 2 + 1]; + float dlx1 = g_tempNormals[i * 2 + 0]; + float dly1 = g_tempNormals[i * 2 + 1]; + float dmx = (dlx0 + dlx1) * 0.5f; + float dmy = (dly0 + dly1) * 0.5f; + float dmr2 = dmx*dmx + dmy*dmy; + if (dmr2 > 0.000001f) + { + float scale = 1.0f / dmr2; + if (scale > 10.0f) scale = 10.0f; + dmx *= scale; + dmy *= scale; + } + g_tempCoords[i * 2 + 0] = coords[i * 2 + 0] + dmx*r; + g_tempCoords[i * 2 + 1] = coords[i * 2 + 1] + dmy*r; + } + + unsigned int colTrans = RGBA(col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff, 0); + + imguiGraphColor4ubv((uint8_t*)&col); + + for (unsigned i = 0, j = numCoords - 1; i < numCoords; j = i++) + { + imguiGraphVertex2fv(&coords[i * 2]); + imguiGraphVertex2fv(&coords[j * 2]); + imguiGraphColor4ubv((uint8_t*)&colTrans); + imguiGraphVertex2fv(&g_tempCoords[j * 2]); + + imguiGraphVertex2fv(&g_tempCoords[j * 2]); + imguiGraphVertex2fv(&g_tempCoords[i * 2]); + + imguiGraphColor4ubv((uint8_t*)&col); + imguiGraphVertex2fv(&coords[i * 2]); + } + + imguiGraphColor4ubv((uint8_t*)&col); + for (unsigned i = 2; i < numCoords; ++i) + { + imguiGraphVertex2fv(&coords[0]); + imguiGraphVertex2fv(&coords[(i - 1) * 2]); + imguiGraphVertex2fv(&coords[i * 2]); + } +} + +static void drawRect(float x, float y, float w, float h, float fth, unsigned int col) +{ + float verts[4 * 2] = + { + x + 0.5f, y + 0.5f, + x + w - 0.5f, y + 0.5f, + x + w - 0.5f, y + h - 0.5f, + x + 0.5f, y + h - 0.5f, + }; + drawPolygon(verts, 4, fth, col); +} + +/* +static void drawEllipse(float x, float y, float w, float h, float fth, unsigned int col) +{ +float verts[CIRCLE_VERTS*2]; +const float* cverts = g_circleVerts; +float* v = verts; + +for (int i = 0; i < CIRCLE_VERTS; ++i) +{ +*v++ = x + cverts[i*2]*w; +*v++ = y + cverts[i*2+1]*h; +} + +drawPolygon(verts, CIRCLE_VERTS, fth, col); +} +*/ + +static void drawRoundedRect(float x, float y, float w, float h, float r, float fth, unsigned int col) +{ + const unsigned n = CIRCLE_VERTS / 4; + float verts[(n + 1) * 4 * 2]; + const float* cverts = g_circleVerts; + float* v = verts; + + for (unsigned i = 0; i <= n; ++i) + { + *v++ = x + w - r + cverts[i * 2] * r; + *v++ = y + h - r + cverts[i * 2 + 1] * r; + } + + for (unsigned i = n; i <= n * 2; ++i) + { + *v++ = x + r + cverts[i * 2] * r; + *v++ = y + h - r + cverts[i * 2 + 1] * r; + } + + for (unsigned i = n * 2; i <= n * 3; ++i) + { + *v++ = x + r + cverts[i * 2] * r; + *v++ = y + r + cverts[i * 2 + 1] * r; + } + + for (unsigned i = n * 3; i < n * 4; ++i) + { + *v++ = x + w - r + cverts[i * 2] * r; + *v++ = y + r + cverts[i * 2 + 1] * r; + } + *v++ = x + w - r + cverts[0] * r; + *v++ = y + r + cverts[1] * r; + + drawPolygon(verts, (n + 1) * 4, fth, col); +} + + +static void drawLine(float x0, float y0, float x1, float y1, float r, float fth, unsigned int col) +{ + float dx = x1 - x0; + float dy = y1 - y0; + float d = sqrtf(dx*dx + dy*dy); + if (d > 0.0001f) + { + d = 1.0f / d; + dx *= d; + dy *= d; + } + float nx = dy; + float ny = -dx; + float verts[4 * 2]; + r -= fth; + r *= 0.5f; + if (r < 0.01f) r = 0.01f; + dx *= r; + dy *= r; + nx *= r; + ny *= r; + + verts[0] = x0 - dx - nx; + verts[1] = y0 - dy - ny; + + verts[2] = x0 - dx + nx; + verts[3] = y0 - dy + ny; + + verts[4] = x1 + dx + nx; + verts[5] = y1 + dy + ny; + + verts[6] = x1 + dx - nx; + verts[7] = y1 + dy - ny; + + drawPolygon(verts, 4, fth, col); +} + +bool imguiGraphInit(const char* fontpath, float defaultFontHeight, const ImguiGraphDesc* desc) +{ + imguiGraphContextInit(desc); + + for (int i = 0; i < CIRCLE_VERTS; ++i) + { + float a = (float)i / (float)CIRCLE_VERTS * PI * 2; + g_circleVerts[i * 2 + 0] = cosf(a); + g_circleVerts[i * 2 + 1] = sinf(a); + } + + // Load font. + FILE* fp = fopen(fontpath, "rb"); + if (!fp) return false; + fseek(fp, 0, SEEK_END); + int size = ftell(fp); + fseek(fp, 0, SEEK_SET); + + unsigned char* ttfBuffer = (unsigned char*)malloc(size); + if (!ttfBuffer) + { + fclose(fp); + return false; + } + + size_t len = fread(ttfBuffer, 1, size, fp); + (void)len; + + fclose(fp); + fp = 0; + + unsigned char* bmap = (unsigned char*)malloc(512 * 512); + if (!bmap) + { + free(ttfBuffer); + return false; + } + + defaultFontHeight = (defaultFontHeight <= 0.0f) ? 15.0f : defaultFontHeight; + + stbtt_BakeFontBitmap(ttfBuffer, 0, defaultFontHeight, bmap, 512, 512, 32, 96, g_cdata); + + // can free ttf_buffer at this point + imguiGraphFontTextureInit(bmap); + + free(ttfBuffer); + free(bmap); + + return true; +} + +void imguiGraphUpdate(const ImguiGraphDesc* desc) +{ + imguiGraphContextUpdate(desc); +} + +void imguiGraphDestroy() +{ + imguiGraphFontTextureRelease(); + + imguiGraphContextDestroy(); +} + +static void getBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, + float *xpos, float *ypos, stbtt_aligned_quad *q) +{ + stbtt_bakedchar *b = chardata + char_index; + int round_x = STBTT_ifloor(*xpos + b->xoff); + int round_y = STBTT_ifloor(*ypos - b->yoff); + + q->x0 = (float)round_x; + q->y0 = (float)round_y; + q->x1 = (float)round_x + b->x1 - b->x0; + q->y1 = (float)round_y - b->y1 + b->y0; + + q->s0 = b->x0 / (float)pw; + q->t0 = b->y0 / (float)pw; + q->s1 = b->x1 / (float)ph; + q->t1 = b->y1 / (float)ph; + + *xpos += b->xadvance; +} + +static const float g_tabStops[4] = { 150, 210, 270, 330 }; + +static float getTextLength(stbtt_bakedchar *chardata, const char* text) +{ + float xpos = 0; + float len = 0; + while (*text) + { + int c = (unsigned char)*text; + if (c == '\t') + { + for (int i = 0; i < 4; ++i) + { + if (xpos < g_tabStops[i]) + { + xpos = g_tabStops[i]; + break; + } + } + } + else if (c >= 32 && c < 128) + { + stbtt_bakedchar *b = chardata + c - 32; + int round_x = STBTT_ifloor((xpos + b->xoff) + 0.5); + len = round_x + b->x1 - b->x0 + 0.5f; + xpos += b->xadvance; + } + ++text; + } + return len; +} + +static void drawText(float x, float y, const char *text, int align, unsigned int col) +{ + if (!text) return; + + if (align == IMGUI_ALIGN_CENTER) + x -= getTextLength(g_cdata, text) / 2; + else if (align == IMGUI_ALIGN_RIGHT) + x -= getTextLength(g_cdata, text); + + imguiGraphColor4ub(col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff, (col >> 24) & 0xff); + + imguiGraphFontTextureEnable(); + + // assume orthographic projection with units = screen pixels, origin at top left + const float ox = x; + + while (*text) + { + int c = (unsigned char)*text; + if (c == '\t') + { + for (int i = 0; i < 4; ++i) + { + if (x < g_tabStops[i] + ox) + { + x = g_tabStops[i] + ox; + break; + } + } + } + else if (c >= 32 && c < 128) + { + stbtt_aligned_quad q; + getBakedQuad(g_cdata, 512, 512, c - 32, &x, &y, &q); + + imguiGraphTexCoord2f(q.s0, q.t0); + imguiGraphVertex2f(q.x0, q.y0); + imguiGraphTexCoord2f(q.s1, q.t1); + imguiGraphVertex2f(q.x1, q.y1); + imguiGraphTexCoord2f(q.s1, q.t0); + imguiGraphVertex2f(q.x1, q.y0); + + imguiGraphTexCoord2f(q.s0, q.t0); + imguiGraphVertex2f(q.x0, q.y0); + imguiGraphTexCoord2f(q.s0, q.t1); + imguiGraphVertex2f(q.x0, q.y1); + imguiGraphTexCoord2f(q.s1, q.t1); + imguiGraphVertex2f(q.x1, q.y1); + } + ++text; + } + + imguiGraphFontTextureDisable(); +} + + +void imguiGraphDraw() +{ + const imguiGfxCmd* q = imguiGetRenderQueue(); + int nq = imguiGetRenderQueueSize(); + + const float s = 1.0f / 8.0f; + + imguiGraphRecordBegin(); + + imguiGraphDisableScissor(); + for (int i = 0; i < nq; ++i) + { + const imguiGfxCmd& cmd = q[i]; + if (cmd.type == IMGUI_GFXCMD_RECT) + { + if (cmd.rect.r == 0) + { + drawRect((float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, + (float)cmd.rect.w*s - 1, (float)cmd.rect.h*s - 1, + 1.0f, cmd.col); + } + else + { + drawRoundedRect((float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, + (float)cmd.rect.w*s - 1, (float)cmd.rect.h*s - 1, + (float)cmd.rect.r*s, 1.0f, cmd.col); + } + } + else if (cmd.type == IMGUI_GFXCMD_LINE) + { + drawLine(cmd.line.x0*s, cmd.line.y0*s, cmd.line.x1*s, cmd.line.y1*s, cmd.line.r*s, 1.0f, cmd.col); + } + else if (cmd.type == IMGUI_GFXCMD_TRIANGLE) + { + if (cmd.flags == 1) + { + const float verts[3 * 2] = + { + (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, + (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s - 1, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s / 2 - 0.5f, + (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, + }; + drawPolygon(verts, 3, 1.0f, cmd.col); + } + if (cmd.flags == 2) + { + const float verts[3 * 2] = + { + (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, + (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s / 2 - 0.5f, (float)cmd.rect.y*s + 0.5f, + (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s - 1, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, + }; + drawPolygon(verts, 3, 1.0f, cmd.col); + } + } + else if (cmd.type == IMGUI_GFXCMD_TEXT) + { + drawText(cmd.text.x, cmd.text.y, cmd.text.text, cmd.text.align, cmd.col); + } + else if (cmd.type == IMGUI_GFXCMD_SCISSOR) + { + if (cmd.flags) + { + imguiGraphEnableScissor(cmd.rect.x, cmd.rect.y, cmd.rect.w, cmd.rect.h); + } + else + { + imguiGraphDisableScissor(); + } + } + } + imguiGraphDisableScissor(); + + imguiGraphRecordEnd(); +} diff --git a/demo/d3d/imguiGraph.h b/demo/d3d/imguiGraph.h new file mode 100644 index 0000000..361fa7b --- /dev/null +++ b/demo/d3d/imguiGraph.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include + +#define IMGUI_GRAPH_API extern "C" __declspec(dllexport) + +struct ImguiGraphDesc; + +typedef bool (*imguiGraphInit_t)(const char* fontpath, const ImguiGraphDesc* desc); + +typedef void (*imguiGraphUpdate_t)(const ImguiGraphDesc* desc); + +bool imguiGraphInit(const char* fontpath, float defaultFontHeight, const ImguiGraphDesc* desc); + +void imguiGraphUpdate(const ImguiGraphDesc* desc); + +void imguiGraphDestroy(); + +void imguiGraphDraw(); + +// Below are the functions that must be implemented per graphics API + +IMGUI_GRAPH_API void imguiGraphContextInit(const ImguiGraphDesc* desc); + +IMGUI_GRAPH_API void imguiGraphContextUpdate(const ImguiGraphDesc* desc); + +IMGUI_GRAPH_API void imguiGraphContextDestroy(); + +IMGUI_GRAPH_API void imguiGraphRecordBegin(); + +IMGUI_GRAPH_API void imguiGraphRecordEnd(); + +IMGUI_GRAPH_API void imguiGraphVertex2f(float x, float y); + +IMGUI_GRAPH_API void imguiGraphVertex2fv(const float* v); + +IMGUI_GRAPH_API void imguiGraphTexCoord2f(float u, float v); + +IMGUI_GRAPH_API void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha); + +IMGUI_GRAPH_API void imguiGraphColor4ubv(const uint8_t* v); + +IMGUI_GRAPH_API void imguiGraphFontTextureEnable(); + +IMGUI_GRAPH_API void imguiGraphFontTextureDisable(); + +IMGUI_GRAPH_API void imguiGraphEnableScissor(int x, int y, int width, int height); + +IMGUI_GRAPH_API void imguiGraphDisableScissor(); + +IMGUI_GRAPH_API void imguiGraphFontTextureInit(unsigned char* data); + +IMGUI_GRAPH_API void imguiGraphFontTextureRelease(); \ No newline at end of file diff --git a/demo/d3d/imguiGraphLoader.cpp b/demo/d3d/imguiGraphLoader.cpp new file mode 100644 index 0000000..6c5dbce --- /dev/null +++ b/demo/d3d/imguiGraphLoader.cpp @@ -0,0 +1,84 @@ +/* + * 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 + +#include "loader.h" + +#include "imguiGraph.h" +#include "loaderMacros.h" + +#include + +#include "imguiGraph.h" + +struct AppGraphCtx; + +#define LOADER_IMGUI_GRAPH_FUNCTIONS(op, inst, inst_func) \ + op(inst, inst_func, void, imguiGraphContextInit, 1, ((const ImguiGraphDesc*, desc)) ) \ + op(inst, inst_func, void, imguiGraphContextUpdate, 1, ((const ImguiGraphDesc*, desc)) ) \ + op(inst, inst_func, void, imguiGraphContextDestroy, 0, (()) ) \ + op(inst, inst_func, void, imguiGraphRecordBegin, 0, (()) ) \ + op(inst, inst_func, void, imguiGraphRecordEnd, 0, (()) ) \ + op(inst, inst_func, void, imguiGraphVertex2f, 2, ((float, x), (float, y)) ) \ + op(inst, inst_func, void, imguiGraphVertex2fv, 1, ((const float*, v)) ) \ + op(inst, inst_func, void, imguiGraphTexCoord2f, 2, ((float, u), (float, v)) ) \ + op(inst, inst_func, void, imguiGraphColor4ub, 4, ((uint8_t, red), (uint8_t, green), (uint8_t, blue), (uint8_t, alpha)) ) \ + op(inst, inst_func, void, imguiGraphColor4ubv, 1, ((const uint8_t*, v)) ) \ + op(inst, inst_func, void, imguiGraphFontTextureEnable, 0, (()) ) \ + op(inst, inst_func, void, imguiGraphFontTextureDisable, 0, (()) ) \ + op(inst, inst_func, void, imguiGraphEnableScissor, 4, ((int, x), (int, y), (int, width), (int, height)) ) \ + op(inst, inst_func, void, imguiGraphDisableScissor, 0, (()) ) \ + op(inst, inst_func, void, imguiGraphFontTextureInit, 1, ((unsigned char*, data)) ) \ + op(inst, inst_func, void, imguiGraphFontTextureRelease, 0, (()) ) \ + op(inst, inst_func, bool, imguiInteropGraphInit, 3, ((imguiGraphInit_t, func), (const char*, fontpath), (AppGraphCtx*, appctx)) ) \ + op(inst, inst_func, void, imguiInteropGraphUpdate, 2, ((imguiGraphUpdate_t, func), (AppGraphCtx*, appctx)) ) + +LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_DECLARE_FUNCTION_PTR, (), ()) + +struct ImguiFunctionSet +{ +LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_DECLARE_FUNCTION_VAR, (), ()) +}; + +// Declare D3D11/D3D12 versions +#define IMGUI_D3D11_FUNCTION_NAME(x) x##D3D11 +#define IMGUI_D3D12_FUNCTION_NAME(x) x##D3D12 + +extern "C" { + +LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_DECLARE_FUNCTION_NAME, (), IMGUI_D3D11_FUNCTION_NAME) +LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_DECLARE_FUNCTION_NAME, (), IMGUI_D3D12_FUNCTION_NAME) + +} // extern "C" + +static ImguiFunctionSet g_functionSet; + +void loadImgui(AppGraphCtxType type) +{ + if (type == APP_CONTEXT_D3D11) + { + LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_SET_FUNCTION, g_functionSet, IMGUI_D3D11_FUNCTION_NAME) + } + if (type == APP_CONTEXT_D3D12) + { + LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_SET_FUNCTION, g_functionSet, IMGUI_D3D12_FUNCTION_NAME) + } +} + +void unloadImgui() +{ + g_functionSet = ImguiFunctionSet{}; +} + +// Generate the patches +LOADER_IMGUI_GRAPH_FUNCTIONS(LOADER_FUNCTION_PTR_CALL, g_functionSet, ()) + + diff --git a/demo/d3d/loader.cpp b/demo/d3d/loader.cpp new file mode 100644 index 0000000..2ade2be --- /dev/null +++ b/demo/d3d/loader.cpp @@ -0,0 +1,27 @@ +/* + * 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 "loader.h" + +//#include + +#include "imgui.h" + +void loadModules(AppGraphCtxType type) +{ + loadAppGraphCtx(type); + loadImgui(type); +} + +void unloadModules() +{ + unloadImgui(); + unloadAppGraphCtx(); +} \ No newline at end of file diff --git a/demo/d3d/loader.h b/demo/d3d/loader.h new file mode 100644 index 0000000..1696001 --- /dev/null +++ b/demo/d3d/loader.h @@ -0,0 +1,24 @@ +/* + * 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. + */ + +enum AppGraphCtxType +{ + APP_CONTEXT_D3D11 = 1, + APP_CONTEXT_D3D12 = 2 +}; + +void loadModules(AppGraphCtxType type); +void unloadModules(); + +extern void loadImgui(AppGraphCtxType type); +extern void unloadImgui(); + +extern void loadAppGraphCtx(AppGraphCtxType type); +extern void unloadAppGraphCtx(); diff --git a/demo/d3d/loaderMacros.h b/demo/d3d/loaderMacros.h new file mode 100644 index 0000000..24b4999 --- /dev/null +++ b/demo/d3d/loaderMacros.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + #pragma once + +/// ----------------------------- Module Loader ----------------------------- + +#define LOADER_ESC_N(...) __VA_ARGS__ + +#define LOADER_PARAM_DECLARE(a, b) a b +#define LOADER_PARAM_NAME(a, b) b + +#define LOADER_ESC_PARAM0(PARAM, p0) +#define LOADER_ESC_PARAM1(PARAM, p0) PARAM p0 +#define LOADER_ESC_PARAM2(PARAM, p0, p1) PARAM p0, LOADER_ESC_PARAM1(PARAM, p1) +#define LOADER_ESC_PARAM3(PARAM, p0, p1, p2) PARAM p0, LOADER_ESC_PARAM2(PARAM, p1, p2) +#define LOADER_ESC_PARAM4(PARAM, p0, p1, p2, p3) PARAM p0, LOADER_ESC_PARAM3(PARAM, p1, p2, p3) +#define LOADER_ESC_PARAM5(PARAM, p0, p1, p2, p3, p4) PARAM p0, LOADER_ESC_PARAM4(PARAM, p1, p2, p3, p4) +#define LOADER_ESC_PARAM6(PARAM, p0, p1, p2, p3, p4, p5) PARAM p0, LOADER_ESC_PARAM5(PARAM, p1, p2, p3, p4, p5) +#define LOADER_ESC_PARAM7(PARAM, p0, p1, p2, p3, p4, p5, p6) PARAM p0, LOADER_ESC_PARAM6(PARAM, p1, p2, p3, p4, p5, p6) + +#define LOADER_ESC_MERGE(a, b) (a, b) + +#define LOADER_ESC(mode, numParams, params) \ + LOADER_ESC_PARAM##numParams LOADER_ESC_MERGE(mode, LOADER_ESC_N params) + +#define LOADER_DECLARE_FUNCTION_PTR(inst, inst_func, retType, method, numParams, params) \ + typedef retType (*method##_ptr_t)( LOADER_ESC (LOADER_PARAM_DECLARE, numParams, params) ); + +#define LOADER_DECLARE_FUNCTION_VAR(inst, inst_func, retType, method, numParams, params) \ + method##_ptr_t method##_ptr; + +#define LOADER_DECLARE_FUNCTION_NAME(inst, inst_func, retType, method, numParams, params) \ + extern retType inst_func(method) (LOADER_ESC (LOADER_PARAM_DECLARE, numParams, params) ); + +#define LOADER_SET_FUNCTION(inst, inst_func, retType, method, numParams, params) \ + inst.method##_ptr = inst_func(method); + + +#define LOADER_FUNCTION_PTR_CALL(inst, inst_func, retType, method, numParams, params) \ + retType method( LOADER_ESC (LOADER_PARAM_DECLARE, numParams, params) ) { \ + return inst.method##_ptr( LOADER_ESC (LOADER_PARAM_NAME, numParams, params) ); \ + } + +#define LOADER_LOAD_FUNCTION_PTR(inst, inst_func, retType, method, numParams, params) \ + inst->method##_ptr = (retType (*)( LOADER_ESC (LOADER_PARAM_DECLARE, numParams, params) ))(inst_func(inst, #method)); + +#define LOADER_CLEAR_FUNCTION_PTR(inst, inst_func, retType, method, numParams, params) \ + inst->method##_ptr = nullptr; + +#define LOADER_DECLARE_FUNCTION(inst, inst_func, retType, method, numParams, params) \ + retType method( LOADER_ESC (LOADER_PARAM_DECLARE, numParams, params) ); + +#define LOADER_FUNCTION_IMPL(inst, inst_func, retType, method, numParams, params) \ + retType method( LOADER_ESC (LOADER_PARAM_DECLARE, numParams, params) ) { \ + return method##Impl( LOADER_ESC (LOADER_PARAM_NAME, numParams, params) ); \ + } + diff --git a/demo/d3d/renderParamsD3D.cpp b/demo/d3d/renderParamsD3D.cpp new file mode 100644 index 0000000..22962ba --- /dev/null +++ b/demo/d3d/renderParamsD3D.cpp @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2008-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 "renderParamsD3D.h" + +/* static */void RenderParamsUtilD3D::calcShadowParams(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, float shadowBias, ShadowParamsD3D* paramsOut) +{ + paramsOut->lightTransform = (DirectX::XMMATRIX&)(convertGLToD3DProjection(lightTransform)); + paramsOut->lightPos = (float3&)lightPos; + paramsOut->lightDir = (float3&)Normalize(lightTarget - lightPos); + paramsOut->bias = shadowBias; + + const Vec4 taps[] = + { + Vec2(-0.326212f,-0.40581f), Vec2(-0.840144f,-0.07358f), + Vec2(-0.695914f,0.457137f), Vec2(-0.203345f,0.620716f), + Vec2(0.96234f,-0.194983f), Vec2(0.473434f,-0.480026f), + Vec2(0.519456f,0.767022f), Vec2(0.185461f,-0.893124f), + Vec2(0.507431f,0.064425f), Vec2(0.89642f,0.412458f), + Vec2(-0.32194f,-0.932615f), Vec2(-0.791559f,-0.59771f) + }; + memcpy(paramsOut->shadowTaps, taps, sizeof(taps)); +} + +Matrix44 RenderParamsUtilD3D::convertGLToD3DProjection(const Matrix44& proj) +{ + Matrix44 scale = Matrix44::kIdentity; + scale.columns[2][2] = 0.5f; + + Matrix44 bias = Matrix44::kIdentity; + bias.columns[3][2] = 1.0f; + + return scale*bias*proj; +} + +/* static */void RenderParamsUtilD3D::calcMeshConstantBuffer(const MeshDrawParamsD3D& params, Hlsl::MeshShaderConst& constBuf) +{ + constBuf.modelViewProjection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params.model, params.view), params.projection)); + + constBuf.modelView = (float4x4&)XMMatrixMultiply(params.model, params.view); + + constBuf.objectTransform = (float4x4&)params.objectTransform; + constBuf.lightTransform = (float4x4&)params.lightTransform; + + constBuf.clipPlane = params.clipPlane; + constBuf.fogColor = params.fogColor; + constBuf.color = params.color; + constBuf.secondaryColor = params.secondaryColor; + + constBuf.lightPos = params.lightPos; + constBuf.lightDir = params.lightDir; + + constBuf.bias = params.bias; + constBuf.expand = params.expand; + constBuf.spotMin = params.spotMin; + constBuf.spotMax = params.spotMax; + + constBuf.grid = params.grid; + constBuf.tex = params.tex; + constBuf.colorArray = params.colorArray; + + memcpy(constBuf.shadowTaps, params.shadowTaps, sizeof(constBuf.shadowTaps)); +} + +/* static */void RenderParamsUtilD3D::calcFluidConstantBuffer(const FluidDrawParamsD3D& params, Hlsl::FluidShaderConst& constBuf) +{ + constBuf.modelViewProjection = (Hlsl::float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params.model, params.view), params.projection)); + constBuf.projection = (Hlsl::float4x4&)params.projection; + constBuf.inverseModelView = (Hlsl::float4x4&)XMMatrixInverse(nullptr, XMMatrixMultiply(params.model, params.view)); + constBuf.inverseProjection = (Hlsl::float4x4&)XMMatrixInverse(nullptr, params.projection); + + //constBuf.invTexScale = invTexScale; + //constBuf.invProjection = invProjection; + constBuf.invViewport = params.invViewport; + + constBuf.blurRadiusWorld = params.blurRadiusWorld; + constBuf.blurScale = params.blurScale; + constBuf.blurFalloff = params.blurFalloff; + constBuf.debug = params.debug; +} + +/* static */void RenderParamsUtilD3D::calcDiffuseConstantBuffer(const DiffuseDrawParamsD3D& params, Hlsl::DiffuseShaderConst& constBuf) +{ + using namespace DirectX; + + XMMATRIX modelViewProj = XMMatrixMultiply(XMMatrixMultiply(params.model, params.view), params.projection); + constBuf.modelViewProjection = (Hlsl::float4x4&)modelViewProj; + XMMATRIX modelView = XMMatrixMultiply(params.model, params.view); + constBuf.modelView = (Hlsl::float4x4&)modelView; + constBuf.projection = (Hlsl::float4x4&)params.projection; + + constBuf.motionBlurScale = params.motionScale; + constBuf.diffuseRadius = params.diffuseRadius; + constBuf.diffuseScale = params.diffuseScale; + constBuf.spotMin = params.spotMin; + constBuf.spotMax = params.spotMax; + + constBuf.lightTransform = (Hlsl::float4x4&)params.lightTransform; + constBuf.lightPos = params.lightPos; + constBuf.lightDir = params.lightDir; + constBuf.color = params.color; + + memcpy(constBuf.shadowTaps, params.shadowTaps, sizeof(constBuf.shadowTaps)); +} + +/* static */void RenderParamsUtilD3D::calcFluidCompositeConstantBuffer(const FluidDrawParamsD3D& params, Hlsl::FluidShaderConst& constBuf) +{ + constBuf.modelViewProjection = (Hlsl::float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params.model, params.view), params.projection)); + constBuf.modelView = (Hlsl::float4x4&)XMMatrixMultiply(params.model, params.view); + constBuf.projection = (Hlsl::float4x4&)params.projection; + constBuf.inverseModelView = (Hlsl::float4x4&)XMMatrixInverse(nullptr, XMMatrixMultiply(params.model, params.view)); + constBuf.inverseProjection = (Hlsl::float4x4&)XMMatrixInverse(nullptr, params.projection); + + constBuf.lightTransform = (Hlsl::float4x4&)params.lightTransform; + + constBuf.invTexScale = params.invTexScale; + + //constBuf.invViewport = params.invViewport; + //constBuf.invProjection = params.invProjection; + + constBuf.blurRadiusWorld = params.blurRadiusWorld; + constBuf.blurScale = params.blurScale; + constBuf.blurFalloff = params.blurFalloff; + constBuf.debug = params.debug; + + constBuf.clipPosToEye = params.clipPosToEye; + constBuf.color = params.color; + constBuf.ior = params.ior; + constBuf.spotMin = params.spotMin; + constBuf.spotMax = params.spotMax; + + constBuf.lightPos = params.lightPos; + constBuf.lightDir = params.lightDir; + + typedef DirectX::XMFLOAT2 float2; + const float2 taps[] = + { + float2(-0.326212f,-0.40581f), float2(-0.840144f,-0.07358f), + float2(-0.695914f,0.457137f), float2(-0.203345f,0.620716f), + float2(0.96234f,-0.194983f), float2(0.473434f,-0.480026f), + float2(0.519456f,0.767022f), float2(0.185461f,-0.893124f), + float2(0.507431f,0.064425f), float2(0.89642f,0.412458f), + float2(-0.32194f,-0.932615f), float2(-0.791559f,-0.59771f) + }; + memcpy(constBuf.shadowTaps, taps, sizeof(taps)); +} + +/* static */void RenderParamsUtilD3D::calcPointConstantBuffer(const PointDrawParamsD3D& params, Hlsl::PointShaderConst& constBuf) +{ + using namespace DirectX; + + constBuf.modelView = (float4x4&)XMMatrixMultiply(params.model, params.view); + constBuf.projection = (float4x4&)params.projection; + + constBuf.pointRadius = params.pointRadius; + constBuf.pointScale = params.pointScale; + constBuf.spotMin = params.spotMin; + constBuf.spotMax = params.spotMax; + + constBuf.lightTransform = (float4x4&)params.lightTransform; + constBuf.lightPos = params.lightPos; + constBuf.lightDir = params.lightDir; + + for (int i = 0; i < 8; i++) + constBuf.colors[i] = params.colors[i]; + + memcpy(constBuf.shadowTaps, params.shadowTaps, sizeof(constBuf.shadowTaps)); + + constBuf.mode = params.mode; +} \ No newline at end of file diff --git a/demo/d3d/renderParamsD3D.h b/demo/d3d/renderParamsD3D.h new file mode 100644 index 0000000..0c730bc --- /dev/null +++ b/demo/d3d/renderParamsD3D.h @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#define NOMINMAX + +#include "core/maths.h" +#include + +#include "shaderCommonD3D.h" + +struct ShadowMapD3D; + +typedef DirectX::XMFLOAT3 float3; +typedef DirectX::XMFLOAT4 float4; +typedef DirectX::XMFLOAT4X4 float4x4; + +struct DiffuseDrawParamsD3D +{ + DirectX::XMMATRIX projection; + DirectX::XMMATRIX view; + DirectX::XMMATRIX model; + + float diffuseRadius; // point size in world space + float diffuseScale; // scale to calculate size in pixels + float spotMin; + float spotMax; + float motionScale; + + DirectX::XMMATRIX lightTransform; + float3 lightPos; + float3 lightDir; + + float4 color; + + float4 shadowTaps[12]; + ShadowMapD3D* shadowMap; + + int mode; +}; + +enum FluidRenderMode +{ + FLUID_RENDER_WIREFRAME, + FLUID_RENDER_SOLID, + NUM_FLUID_RENDER_MODES +}; + +enum FluidCullMode +{ + FLUID_CULL_NONE, + FLUID_CULL_FRONT, + FLUID_CULL_BACK, + NUM_FLUID_CULL_MODES +}; + +enum FluidDrawStage +{ + FLUID_DRAW_NULL, + FLUID_DRAW_SHADOW, + FLUID_DRAW_REFLECTION, + FLUID_DRAW_LIGHT +}; + +struct FluidDrawParamsD3D +{ + FluidRenderMode renderMode; + FluidCullMode cullMode; + FluidDrawStage renderStage; + + int offset; + int n; + + DirectX::XMMATRIX projection; + DirectX::XMMATRIX view; + DirectX::XMMATRIX model; + + float4 invTexScale; + + float3 invViewport; + float3 invProjection; + + float blurRadiusWorld; + float blurScale; + float blurFalloff; + int debug; + + float3 lightPos; + float3 lightDir; + DirectX::XMMATRIX lightTransform; + + float4 color; + float4 clipPosToEye; + + float spotMin; + float spotMax; + float ior; + + ShadowMapD3D* shadowMap; + + // Used on D3D12 + int m_srvDescriptorBase; + int m_sampleDescriptorBase; +}; + +enum MeshRenderMode +{ + MESH_RENDER_WIREFRAME, + MESH_RENDER_SOLID, + NUM_MESH_RENDER_MODES +}; + +enum MeshCullMode +{ + MESH_CULL_NONE, + MESH_CULL_FRONT, + MESH_CULL_BACK, + NUM_MESH_CULL_MODES +}; + +enum MeshDrawStage +{ + MESH_DRAW_NULL, + MESH_DRAW_SHADOW, + MESH_DRAW_REFLECTION, + MESH_DRAW_LIGHT +}; + +struct MeshDrawParamsD3D +{ + MeshRenderMode renderMode; + MeshCullMode cullMode; + MeshDrawStage renderStage; + + DirectX::XMMATRIX projection; + DirectX::XMMATRIX view; + DirectX::XMMATRIX model; + + float4x4 objectTransform; + + DirectX::XMMATRIX lightTransform; + float3 lightPos; + float3 lightDir; + + float4 clipPlane; + float4 fogColor; + float4 color; + float4 secondaryColor; + + float bias; + float expand; + float spotMin; + float spotMax; + + int grid; + int tex; + int colorArray; + + float4 shadowTaps[12]; + ShadowMapD3D* shadowMap; +}; + +enum PointRenderMode +{ + POINT_RENDER_WIREFRAME, + POINT_RENDER_SOLID, + NUM_POINT_RENDER_MODES +}; + +enum PointCullMode +{ + POINT_CULL_NONE, + POINT_CULL_FRONT, + POINT_CULL_BACK, + NUM_POINT_CULL_MODES +}; + +enum PointDrawStage +{ + POINT_DRAW_NULL, + POINT_DRAW_SHADOW, + POINT_DRAW_REFLECTION, + POINT_DRAW_LIGHT +}; + +struct PointDrawParamsD3D +{ + PointRenderMode renderMode; + PointCullMode cullMode; + PointDrawStage renderStage; + + DirectX::XMMATRIX projection; + DirectX::XMMATRIX view; + DirectX::XMMATRIX model; + + float pointRadius; // point size in world space + float pointScale; // scale to calculate size in pixels + float spotMin; + float spotMax; + + DirectX::XMMATRIX lightTransform; + float3 lightPos; + float3 lightDir; + + float4 colors[8]; + + float4 shadowTaps[12]; + ShadowMapD3D* shadowMap; + + int mode; +}; + +struct ShadowParamsD3D +{ + DirectX::XMMATRIX lightTransform; + float3 lightPos; + float3 lightDir; + float bias; + float4 shadowTaps[12]; +}; + +struct RenderParamsUtilD3D +{ + /// Assumes the lightTransform is in OpenGl projection format + static void calcShadowParams(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, float shadowBias, ShadowParamsD3D* paramsOut); + + /// Convert a projection from GL into the same projection as can be used by Direct3D + /// D3D has clip z range [0, 1], GL -1 to 1 (as is unit cube) + static Matrix44 convertGLToD3DProjection(const Matrix44& proj); + + static void calcMeshConstantBuffer(const MeshDrawParamsD3D& params, Hlsl::MeshShaderConst& constBufOut); + + static void calcFluidConstantBuffer(const FluidDrawParamsD3D& params, Hlsl::FluidShaderConst& constBuf); + + static void calcFluidCompositeConstantBuffer(const FluidDrawParamsD3D& params, Hlsl::FluidShaderConst& constBuf); + + static void calcDiffuseConstantBuffer(const DiffuseDrawParamsD3D& params, Hlsl::DiffuseShaderConst& constBuf); + + static void calcPointConstantBuffer(const PointDrawParamsD3D& params, Hlsl::PointShaderConst& constBuf); +}; diff --git a/demo/d3d/shaderCommonD3D.h b/demo/d3d/shaderCommonD3D.h new file mode 100644 index 0000000..e143d18 --- /dev/null +++ b/demo/d3d/shaderCommonD3D.h @@ -0,0 +1,19 @@ +#ifndef SHADER_COMMON_D3D_H +#define SHADER_COMMON_D3D_H + +#include + +struct ShadowMap; + +namespace Hlsl { + +typedef DirectX::XMFLOAT3 float3; +typedef DirectX::XMFLOAT4 float4; +typedef DirectX::XMFLOAT4X4 float4x4; + +#define EXCLUDE_SHADER_STRUCTS 1 +#include "../d3d/shaders/shaderCommon.h" + +} // namespace Shader + +#endif // SHADER_COMMON_D3D_H diff --git a/demo/d3d/shaders/blurDepthPS.hlsl b/demo/d3d/shaders/blurDepthPS.hlsl new file mode 100644 index 0000000..c08d7f5 --- /dev/null +++ b/demo/d3d/shaders/blurDepthPS.hlsl @@ -0,0 +1,84 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + FluidShaderConst gParams; +}; + +Texture2D depthTex : register(t0); + +float sqr(float x) { return x*x; } + +float blurDepthPS(PassthroughVertexOut input) : SV_TARGET +{ + float4 inPosition = input.position; + + // debug: return the center depth sample + //return depthTex.Load(int3(inPosition.xy, 0)).x; + + const float blurRadiusWorld = gParams.blurRadiusWorld; + const float blurScale = gParams.blurScale; + const float blurFalloff = gParams.blurFalloff; + + // eye-space depth of center sample + float depth = depthTex.Load(int3(inPosition.xy, 0)).x; + float thickness = 0.0f; //texture2D(thicknessTex, gl_TexCoord[0].xy).x; + + /* + // threshold on thickness to create nice smooth silhouettes + if (depth == 0.0) + { + return 0.0f; + } + */ + + float blurDepthFalloff = 5.5; + float maxBlurRadius = 5.0; + + //discontinuities between different tap counts are visible. to avoid this we + //use fractional contributions between #taps = ceil(radius) and floor(radius) + float radius = min(maxBlurRadius, blurScale * (blurRadiusWorld / -depth)); + float radiusInv = 1.0 / radius; + float taps = ceil(radius); + float frac = taps - radius; + + float sum = 0.0; + float wsum = 0.0; + float count = 0.0; + + for (float y = -taps; y <= taps; y += 1.0) + { + for (float x = -taps; x <= taps; x += 1.0) + { + float2 offset = float2(x, y); + float sample = depthTex.Load(int3(inPosition.xy + offset, 0)).x; + + //if (sample < -10000.0 * 0.5) + //continue; + + // spatial domain + float r1 = length(float2(x, y))*radiusInv; + float w = exp(-(r1*r1)); + + // range domain (based on depth difference) + float r2 = (sample - depth) * blurDepthFalloff; + float g = exp(-(r2*r2)); + + //fractional radius contributions + float wBoundary = step(radius, max(abs(x), abs(y))); + float wFrac = 1.0 - wBoundary*frac; + + sum += sample * w * g * wFrac; + wsum += w * g * wFrac; + count += g * wFrac; + } + } + + if (wsum > 0.0) + { + sum /= wsum; + } + + float blend = count / sqr(2.0 * radius + 1.0); + return lerp(depth, sum, blend); +} diff --git a/demo/d3d/shaders/blurDepthPS.hlsl.h b/demo/d3d/shaders/blurDepthPS.hlsl.h new file mode 100644 index 0000000..ce5eec9 --- /dev/null +++ b/demo/d3d/shaders/blurDepthPS.hlsl.h @@ -0,0 +1,657 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct FluidShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 projection; // Offset: 128 +// float4x4 inverseModelView; // Offset: 192 +// float4x4 inverseProjection; // Offset: 256 +// float4 invTexScale; // Offset: 320 +// float3 invViewport; // Offset: 336 +// float _pad0; // Offset: 348 +// float blurRadiusWorld; // Offset: 352 +// float blurScale; // Offset: 356 +// float blurFalloff; // Offset: 360 +// int debug; // Offset: 364 +// float3 lightPos; // Offset: 368 +// float _pad1; // Offset: 380 +// float3 lightDir; // Offset: 384 +// float _pad2; // Offset: 396 +// float4x4 lightTransform; // Offset: 400 +// float4 color; // Offset: 464 +// float4 clipPosToEye; // Offset: 480 +// float spotMin; // Offset: 496 +// float spotMax; // Offset: 500 +// float ior; // Offset: 504 +// float _pad3; // Offset: 508 +// float4 shadowTaps[12]; // Offset: 512 +// +// } gParams; // Offset: 0 Size: 704 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// depthTex texture float 2d 0 1 +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xy +// TEXCOORD 0 xy 1 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 x 0 TARGET float x +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[23], immediateIndexed +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps_siv linear noperspective v0.xy, position +dcl_output o0.x +dcl_temps 5 +ftoi r0.xy, v0.xyxx +mov r0.zw, l(0,0,0,0) +ld_indexable(texture2d)(float,float,float,float) r0.x, r0.xyzw, t0.xyzw +div r0.y, cb0[22].x, -r0.x +mul r0.y, r0.y, cb0[22].y +min r0.y, r0.y, l(5.000000) +div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y +round_pi r0.w, r0.y +add r1.x, -r0.y, r0.w +mov r2.zw, l(0,0,0,0) +mov r1.yzw, l(0,0,0,0) +mov r3.y, -r0.w +loop + lt r3.z, r0.w, r3.y + breakc_nz r3.z + mov r4.xyz, r1.yzwy + mov r4.w, -r0.w + loop + lt r3.z, r0.w, r4.w + breakc_nz r3.z + mov r3.x, r4.w + add r3.zw, r3.xxxy, v0.xxxy + ftoi r2.xy, r3.zwzz + ld_indexable(texture2d)(float,float,float,float) r2.x, r2.xyzw, t0.xyzw + dp2 r2.y, r3.xyxx, r3.xyxx + sqrt r2.y, r2.y + mul r2.y, r0.z, r2.y + mul r2.y, r2.y, r2.y + mul r2.y, r2.y, l(-1.442695) + exp r2.y, r2.y + add r3.x, -r0.x, r2.x + mul r3.x, r3.x, l(5.500000) + mul r3.x, r3.x, r3.x + mul r3.x, r3.x, l(-1.442695) + exp r3.x, r3.x + max r3.z, |r3.y|, |r4.w| + ge r3.z, r3.z, r0.y + and r3.z, r3.z, l(0x3f800000) + mad r3.z, -r3.z, r1.x, l(1.000000) + mul r2.x, r2.y, r2.x + mul r2.x, r3.x, r2.x + mad r4.x, r2.x, r3.z, r4.x + mul r2.x, r2.y, r3.x + mad r4.y, r2.x, r3.z, r4.y + mad r4.z, r3.x, r3.z, r4.z + add r4.w, r4.w, l(1.000000) + endloop + mov r1.yzw, r4.xxyz + add r3.y, r3.y, l(1.000000) +endloop +lt r0.z, l(0.000000), r1.z +div r0.w, r1.y, r1.z +movc r0.z, r0.z, r0.w, r1.y +mad r0.y, r0.y, l(2.000000), l(1.000000) +mul r0.y, r0.y, r0.y +div r0.y, r1.w, r0.y +add r0.z, -r0.x, r0.z +mad o0.x, r0.y, r0.z, r0.x +ret +// Approximately 59 instruction slots used +#endif + +const BYTE g_blurDepthPS[] = +{ + 68, 88, 66, 67, 25, 16, + 90, 102, 178, 215, 22, 204, + 41, 91, 183, 73, 123, 5, + 153, 37, 1, 0, 0, 0, + 40, 12, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 152, 4, 0, 0, 240, 4, + 0, 0, 36, 5, 0, 0, + 140, 11, 0, 0, 82, 68, + 69, 70, 92, 4, 0, 0, + 1, 0, 0, 0, 144, 0, + 0, 0, 2, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 40, 4, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 124, 0, 0, 0, 2, 0, + 0, 0, 5, 0, 0, 0, + 4, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 133, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 100, 101, + 112, 116, 104, 84, 101, 120, + 0, 99, 111, 110, 115, 116, + 66, 117, 102, 0, 171, 171, + 133, 0, 0, 0, 1, 0, + 0, 0, 168, 0, 0, 0, + 192, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 208, 0, 0, 0, 0, 0, + 0, 0, 192, 2, 0, 0, + 2, 0, 0, 0, 4, 4, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 103, 80, + 97, 114, 97, 109, 115, 0, + 70, 108, 117, 105, 100, 83, + 104, 97, 100, 101, 114, 67, + 111, 110, 115, 116, 0, 109, + 111, 100, 101, 108, 86, 105, + 101, 119, 80, 114, 111, 106, + 101, 99, 116, 105, 111, 110, + 0, 102, 108, 111, 97, 116, + 52, 120, 52, 0, 171, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 253, 0, 0, 0, + 109, 111, 100, 101, 108, 86, + 105, 101, 119, 0, 112, 114, + 111, 106, 101, 99, 116, 105, + 111, 110, 0, 105, 110, 118, + 101, 114, 115, 101, 77, 111, + 100, 101, 108, 86, 105, 101, + 119, 0, 105, 110, 118, 101, + 114, 115, 101, 80, 114, 111, + 106, 101, 99, 116, 105, 111, + 110, 0, 105, 110, 118, 84, + 101, 120, 83, 99, 97, 108, + 101, 0, 102, 108, 111, 97, + 116, 52, 0, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 112, 1, 0, 0, 105, 110, + 118, 86, 105, 101, 119, 112, + 111, 114, 116, 0, 102, 108, + 111, 97, 116, 51, 0, 171, + 1, 0, 3, 0, 1, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 1, 0, 0, + 95, 112, 97, 100, 48, 0, + 102, 108, 111, 97, 116, 0, + 0, 0, 3, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 218, 1, 0, 0, + 98, 108, 117, 114, 82, 97, + 100, 105, 117, 115, 87, 111, + 114, 108, 100, 0, 98, 108, + 117, 114, 83, 99, 97, 108, + 101, 0, 98, 108, 117, 114, + 70, 97, 108, 108, 111, 102, + 102, 0, 100, 101, 98, 117, + 103, 0, 105, 110, 116, 0, + 0, 0, 2, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 48, 2, 0, 0, + 108, 105, 103, 104, 116, 80, + 111, 115, 0, 95, 112, 97, + 100, 49, 0, 108, 105, 103, + 104, 116, 68, 105, 114, 0, + 95, 112, 97, 100, 50, 0, + 108, 105, 103, 104, 116, 84, + 114, 97, 110, 115, 102, 111, + 114, 109, 0, 99, 111, 108, + 111, 114, 0, 99, 108, 105, + 112, 80, 111, 115, 84, 111, + 69, 121, 101, 0, 115, 112, + 111, 116, 77, 105, 110, 0, + 115, 112, 111, 116, 77, 97, + 120, 0, 105, 111, 114, 0, + 95, 112, 97, 100, 51, 0, + 115, 104, 97, 100, 111, 119, + 84, 97, 112, 115, 0, 171, + 171, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 112, 1, + 0, 0, 233, 0, 0, 0, + 8, 1, 0, 0, 0, 0, + 0, 0, 44, 1, 0, 0, + 8, 1, 0, 0, 64, 0, + 0, 0, 54, 1, 0, 0, + 8, 1, 0, 0, 128, 0, + 0, 0, 65, 1, 0, 0, + 8, 1, 0, 0, 192, 0, + 0, 0, 82, 1, 0, 0, + 8, 1, 0, 0, 0, 1, + 0, 0, 100, 1, 0, 0, + 120, 1, 0, 0, 64, 1, + 0, 0, 156, 1, 0, 0, + 176, 1, 0, 0, 80, 1, + 0, 0, 212, 1, 0, 0, + 224, 1, 0, 0, 92, 1, + 0, 0, 4, 2, 0, 0, + 224, 1, 0, 0, 96, 1, + 0, 0, 20, 2, 0, 0, + 224, 1, 0, 0, 100, 1, + 0, 0, 30, 2, 0, 0, + 224, 1, 0, 0, 104, 1, + 0, 0, 42, 2, 0, 0, + 52, 2, 0, 0, 108, 1, + 0, 0, 88, 2, 0, 0, + 176, 1, 0, 0, 112, 1, + 0, 0, 97, 2, 0, 0, + 224, 1, 0, 0, 124, 1, + 0, 0, 103, 2, 0, 0, + 176, 1, 0, 0, 128, 1, + 0, 0, 112, 2, 0, 0, + 224, 1, 0, 0, 140, 1, + 0, 0, 118, 2, 0, 0, + 8, 1, 0, 0, 144, 1, + 0, 0, 133, 2, 0, 0, + 120, 1, 0, 0, 208, 1, + 0, 0, 139, 2, 0, 0, + 120, 1, 0, 0, 224, 1, + 0, 0, 152, 2, 0, 0, + 224, 1, 0, 0, 240, 1, + 0, 0, 160, 2, 0, 0, + 224, 1, 0, 0, 244, 1, + 0, 0, 168, 2, 0, 0, + 224, 1, 0, 0, 248, 1, + 0, 0, 172, 2, 0, 0, + 224, 1, 0, 0, 252, 1, + 0, 0, 178, 2, 0, 0, + 192, 2, 0, 0, 0, 2, + 0, 0, 5, 0, 0, 0, + 1, 0, 176, 0, 0, 0, + 24, 0, 228, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 0, 77, 105, 99, 114, + 111, 115, 111, 102, 116, 32, + 40, 82, 41, 32, 72, 76, + 83, 76, 32, 83, 104, 97, + 100, 101, 114, 32, 67, 111, + 109, 112, 105, 108, 101, 114, + 32, 54, 46, 51, 46, 57, + 54, 48, 48, 46, 49, 54, + 51, 56, 52, 0, 171, 171, + 73, 83, 71, 78, 80, 0, + 0, 0, 2, 0, 0, 0, + 8, 0, 0, 0, 56, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 3, 0, 0, 68, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 171, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 1, 14, + 0, 0, 83, 86, 95, 84, + 65, 82, 71, 69, 84, 0, + 171, 171, 83, 72, 69, 88, + 96, 6, 0, 0, 80, 0, + 0, 0, 152, 1, 0, 0, + 106, 8, 0, 1, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 100, 32, 0, 4, 50, 16, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 18, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 5, 0, 0, 0, + 27, 0, 0, 5, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 8, + 194, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 45, 0, + 0, 137, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 14, 0, + 0, 9, 34, 0, 16, 0, + 0, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 10, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 51, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 160, 64, 14, 0, + 0, 10, 66, 0, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 26, 0, 16, 0, 0, 0, + 0, 0, 66, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 8, 18, 0, 16, 0, + 1, 0, 0, 0, 26, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 8, 194, 0, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 8, + 226, 0, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 54, 0, + 0, 6, 34, 0, 16, 0, + 3, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 48, 0, + 0, 1, 49, 0, 0, 7, + 66, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 3, 0, 4, 3, 42, 0, + 16, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 114, 0, + 16, 0, 4, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 130, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 48, 0, 0, 1, + 49, 0, 0, 7, 66, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 4, 0, 0, 0, 3, 0, + 4, 3, 42, 0, 16, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 18, 0, 16, 0, + 3, 0, 0, 0, 58, 0, + 16, 0, 4, 0, 0, 0, + 0, 0, 0, 7, 194, 0, + 16, 0, 3, 0, 0, 0, + 6, 4, 16, 0, 3, 0, + 0, 0, 6, 20, 16, 0, + 0, 0, 0, 0, 27, 0, + 0, 5, 50, 0, 16, 0, + 2, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 45, 0, 0, 137, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 15, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 75, 0, + 0, 5, 34, 0, 16, 0, + 2, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 56, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 59, 170, 184, 191, + 25, 0, 0, 5, 34, 0, + 16, 0, 2, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 0, 0, 0, 8, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 0, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 176, 64, 56, 0, 0, 7, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 59, 170, 184, 191, 25, 0, + 0, 5, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 52, 0, 0, 9, 66, 0, + 16, 0, 3, 0, 0, 0, + 26, 0, 16, 128, 129, 0, + 0, 0, 3, 0, 0, 0, + 58, 0, 16, 128, 129, 0, + 0, 0, 4, 0, 0, 0, + 29, 0, 0, 7, 66, 0, + 16, 0, 3, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 7, 66, 0, 16, 0, + 3, 0, 0, 0, 42, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 50, 0, 0, 10, + 66, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 128, + 65, 0, 0, 0, 3, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 18, 0, + 16, 0, 2, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 9, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 42, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 4, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 9, 34, 0, + 16, 0, 4, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 9, 66, 0, + 16, 0, 4, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 42, 0, + 16, 0, 4, 0, 0, 0, + 0, 0, 0, 7, 130, 0, + 16, 0, 4, 0, 0, 0, + 58, 0, 16, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 22, 0, + 0, 1, 54, 0, 0, 5, + 226, 0, 16, 0, 1, 0, + 0, 0, 6, 9, 16, 0, + 4, 0, 0, 0, 0, 0, + 0, 7, 34, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 22, 0, 0, 1, + 49, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 14, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 1, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 55, 0, 0, 9, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 9, + 34, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 64, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 7, + 34, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 14, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 18, 32, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 59, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 38, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/compositePS.hlsl b/demo/d3d/shaders/compositePS.hlsl new file mode 100644 index 0000000..6e8bb6a --- /dev/null +++ b/demo/d3d/shaders/compositePS.hlsl @@ -0,0 +1,182 @@ +#include "shaderCommon.h" + +#define ENABLE_SIMPLE_FLUID 1 + +cbuffer constBuf : register(b0) +{ + FluidShaderConst gParams; +}; + +Texture2D depthTex : register(t0); +Texture2D sceneTex : register(t1); +Texture2D shadowTex : register(t2); // shadow map + +SamplerState texSampler : register(s0); +SamplerComparisonState shadowSampler : register(s1); // texture sample used to sample depth from shadow texture in this sample + +// sample shadow map +float shadowSample(float3 worldPos, out float attenuation) +{ +#if 0 + attenuation = 0.0f; + return 0.5; +#else + + float4 pos = mul(gParams.lightTransform, float4(worldPos + gParams.lightDir*0.15, 1.0)); + pos /= pos.w; + float3 uvw = (pos.xyz * float3(0.5, 0.5, 1.0)) + float3(0.5, 0.5, 0.0); + + attenuation = 1.0;//max(smoothstep(spotMax, spotMin, dot(pos.xy, pos.xy)), 0.05); + + // user clip + if (uvw.x < 0.0 || uvw.x > 1.0) + return 1.0; + if (uvw.y < 0.0 || uvw.y > 1.0) + return 1.0; + + float s = 0.0; + float radius = 0.002; + + uvw.y = 1.0f - uvw.y; + + [unroll] + for (int i = 0; i < 8; i++) + { + float2 shadowTaps = gParams.shadowTaps[i].xy; + shadowTaps.y = 1.0f - shadowTaps.y; + s += shadowTex.SampleCmp(shadowSampler, uvw.xy + shadowTaps * radius, uvw.z); + } + + s /= 8.0; + return s; +#endif +} + +float3 viewportToEyeSpace(float2 coord, float eyeZ) +{ + float2 clipPosToEye = gParams.clipPosToEye.xy; + + // find position at z=1 plane + //float2 uv = (coord * 2.0 - float2(1.0, 1.0)) * clipPosToEye; + float2 uv = float2(coord.x*2.0f-1.0f, (1.0f-coord.y)*2.0f - 1.0f)*clipPosToEye; + + return float3(-uv * eyeZ, eyeZ); +} + +float3 srgbToLinear(float3 c) { const float v = 2.2; return pow(c, float3(v, v, v)); } +float3 linearToSrgb(float3 c) { const float v = 1.0 / 2.2; return pow(c, float3(v, v, v)); } + +float sqr(float x) { return x*x; } +float cube(float x) { return x*x*x; } + +float4 compositePS(PassthroughVertexOut input, out float depthOut : SV_DEPTH) : SV_TARGET +{ + const float4x4 projectionMatrix = gParams.projection; + const float4x4 modelViewMatrix = gParams.modelView; + const float4x4 modelViewMatrixInverse = gParams.inverseModelView; + + const float2 invTexScale = gParams.invTexScale.xy; + + const float3 lightDir = gParams.lightDir; + const float3 lightPos = gParams.lightPos; + const float spotMin = gParams.spotMin; + const float spotMax = gParams.spotMax; + const float ior = gParams.ior; + const float4 color = gParams.color; + + // flip uv y-coordinate + float2 uvCoord = float2(input.texCoord.x, 1.0f-input.texCoord.y); + + float eyeZ = depthTex.Sample(texSampler, uvCoord).x; + + if (eyeZ == 0.0) + discard; + + // reconstruct eye space pos from depth + float3 eyePos = viewportToEyeSpace(uvCoord, eyeZ); + + // finite difference approx for normals, can't take dFdx because + // the one-sided difference is incorrect at shape boundaries + float3 zl = eyePos - viewportToEyeSpace(uvCoord - float2(invTexScale.x, 0.0), depthTex.Sample(texSampler, uvCoord - float2(invTexScale.x, 0.0)).x); + float3 zr = viewportToEyeSpace(uvCoord + float2(invTexScale.x, 0.0), depthTex.Sample(texSampler, uvCoord + float2(invTexScale.x, 0.0)).x) - eyePos; + float3 zt = viewportToEyeSpace(uvCoord + float2(0.0, invTexScale.y), depthTex.Sample(texSampler, uvCoord + float2(0.0, invTexScale.y)).x) - eyePos; + float3 zb = eyePos - viewportToEyeSpace(uvCoord - float2(0.0, invTexScale.y), depthTex.Sample(texSampler, uvCoord - float2(0.0, invTexScale.y)).x); + + float3 dx = zl; + float3 dy = zt; + + if (abs(zr.z) < abs(zl.z)) + dx = zr; + + if (abs(zb.z) < abs(zt.z)) + dy = zb; + + //float3 dx = ddx(eyePos.xyz); + //float3 dy = -ddy(eyePos.xyz); + + float4 worldPos = mul(modelViewMatrixInverse, float4(eyePos, 1.0)); + + float attenuation; + float shadow = shadowSample(worldPos.xyz, attenuation); + + float3 l = mul(modelViewMatrix, float4(lightDir, 0.0)).xyz; + float3 v = -normalize(eyePos); + + float3 n = -normalize(cross(dx, dy)); // sign difference from texcoord coordinate difference between OpenGL + float3 h = normalize(v + l); + + float3 skyColor = float3(0.1, 0.2, 0.4)*1.2; + float3 groundColor = float3(0.1, 0.1, 0.2); + + float fresnel = 0.1 + (1.0 - 0.1)*cube(1.0 - max(dot(n, v), 0.0)); + + float3 lVec = normalize(worldPos.xyz - lightPos); + + float ln = dot(l, n)*attenuation; + + float3 rEye = reflect(-v, n).xyz; + float3 rWorld = mul(modelViewMatrixInverse, float4(rEye, 0.0)).xyz; + + float2 texScale = float2(0.75, 1.0); // to account for backbuffer aspect ratio (todo: pass in) + + float refractScale = ior*0.025; + float reflectScale = ior*0.1; + + // attenuate refraction near ground (hack) + refractScale *= smoothstep(0.1, 0.4, worldPos.y); + + float2 refractCoord = uvCoord + n.xy*refractScale*texScale; + + // read thickness from refracted coordinate otherwise we get halos around objectsw + float thickness = 0.8f;//max(texture2D(thicknessTex, refractCoord).x, 0.3); + + //vec3 transmission = exp(-(vec3(1.0)-color.xyz)*thickness); + float3 transmission = (1.0 - (1.0 - color.xyz)*thickness*0.8)*color.w; + float3 refract = sceneTex.Sample(texSampler, refractCoord).xyz*transmission; + + float2 sceneReflectCoord = uvCoord - rEye.xy*texScale*reflectScale / eyePos.z; + float3 sceneReflect = sceneTex.Sample(texSampler, sceneReflectCoord).xyz*shadow; + //vec3 planarReflect = texture2D(reflectTex, gl_TexCoord[0].xy).xyz; + float3 planarReflect = float3(0.0, 0.0, 0.0); + + // fade out planar reflections above the ground + //float3 reflect = lerp(planarReflect, sceneReflect, smoothstep(0.05, 0.3, worldPos.y)) + lerp(groundColor, skyColor, smoothstep(0.15, 0.25, rWorld.y)*shadow); + float3 reflect = sceneReflect + lerp(groundColor, skyColor, smoothstep(0.15, 0.25, rWorld.y)*shadow); + + // lighting + float3 diffuse = color.xyz * lerp(float3(0.29, 0.379, 0.59), float3(1.0, 1.0, 1.0), (ln*0.5 + 0.5)*max(shadow, 0.4))*(1.0 - color.w); + float specular = 1.2*pow(max(dot(h, n), 0.0), 400.0); + + // write valid z + float4 clipPos = mul(projectionMatrix, float4(0.0, 0.0, eyeZ, 1.0)); + clipPos.z /= clipPos.w; + depthOut = clipPos.z; + + // visualize normals + //return float4(n*0.5 + 0.5, 1.0); + //return float4(fresnel, fresnel, fresnel, 0); + //return float4(n, 1); + + // Color + return float4(diffuse + (lerp(refract, reflect, fresnel) + specular)*color.w, 1.0); +} diff --git a/demo/d3d/shaders/compositePS.hlsl.h b/demo/d3d/shaders/compositePS.hlsl.h new file mode 100644 index 0000000..76f4c49 --- /dev/null +++ b/demo/d3d/shaders/compositePS.hlsl.h @@ -0,0 +1,1642 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct FluidShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 projection; // Offset: 128 +// float4x4 inverseModelView; // Offset: 192 +// float4x4 inverseProjection; // Offset: 256 +// float4 invTexScale; // Offset: 320 +// float3 invViewport; // Offset: 336 +// float _pad0; // Offset: 348 +// float blurRadiusWorld; // Offset: 352 +// float blurScale; // Offset: 356 +// float blurFalloff; // Offset: 360 +// int debug; // Offset: 364 +// float3 lightPos; // Offset: 368 +// float _pad1; // Offset: 380 +// float3 lightDir; // Offset: 384 +// float _pad2; // Offset: 396 +// float4x4 lightTransform; // Offset: 400 +// float4 color; // Offset: 464 +// float4 clipPosToEye; // Offset: 480 +// float spotMin; // Offset: 496 +// float spotMax; // Offset: 500 +// float ior; // Offset: 504 +// float _pad3; // Offset: 508 +// float4 shadowTaps[12]; // Offset: 512 +// +// } gParams; // Offset: 0 Size: 704 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// texSampler sampler NA NA 0 1 +// shadowSampler sampler_c NA NA 1 1 +// depthTex texture float 2d 0 1 +// sceneTex texture float3 2d 1 1 +// shadowTex texture float 2d 2 1 +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// SV_DEPTH 0 N/A oDepth DEPTH float YES +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[40], immediateIndexed +dcl_sampler s0, mode_default +dcl_sampler s1, mode_comparison +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texture2d (float,float,float,float) t1 +dcl_resource_texture2d (float,float,float,float) t2 +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_output oDepth +dcl_temps 8 +mad r0.xy, v1.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(0.000000, 1.000000, 0.000000, 0.000000) +sample_indexable(texture2d)(float,float,float,float) r1.z, r0.xyxx, t0.yzxw, s0 +eq r0.z, r1.z, l(0.000000) +discard_nz r0.z +mad r0.zw, v1.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000) +mul r0.zw, r0.zzzw, cb0[30].xxxy +mul r1.xy, r1.zzzz, -r0.zwzz +mov r2.y, cb0[20].x +mov r2.z, l(0) +add r0.zw, r0.xxxy, -r2.yyyz +sample_indexable(texture2d)(float,float,float,float) r2.x, r0.zwzz, t0.xyzw, s0 +mad r0.zw, r0.zzzw, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000) +mul r0.zw, r0.zzzw, cb0[30].xxxy +mul r2.yz, r2.xxxx, -r0.zzwz +add r2.xyz, r1.zxyz, -r2.xyzx +mov r3.y, cb0[20].x +mov r3.z, l(1.000000) +mad r0.zw, v1.xxxy, l(0.000000, 0.000000, 1.000000, -1.000000), r3.yyyz +sample_indexable(texture2d)(float,float,float,float) r3.x, r0.zwzz, t0.xyzw, s0 +mad r0.zw, r0.zzzw, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000) +mul r0.zw, r0.zzzw, cb0[30].xxxy +mul r3.yz, r3.xxxx, -r0.zzwz +add r3.xyz, -r1.zxyz, r3.xyzx +mov r4.z, l(0) +mov r4.x, cb0[20].y +add r0.zw, r0.yyyx, r4.xxxz +sample_indexable(texture2d)(float,float,float,float) r5.y, r0.wzww, t0.yxzw, s0 +mad r0.zw, r0.zzzw, l(0.000000, 0.000000, -2.000000, 2.000000), l(0.000000, 0.000000, 1.000000, -1.000000) +mul r0.zw, r0.zzzw, cb0[30].yyyx +mul r5.xz, r5.yyyy, -r0.zzwz +add r5.xyz, -r1.yzxy, r5.xyzx +add r0.zw, r0.yyyx, -r4.xxxz +sample_indexable(texture2d)(float,float,float,float) r4.y, r0.wzww, t0.yxzw, s0 +mad r0.zw, r0.zzzw, l(0.000000, 0.000000, -2.000000, 2.000000), l(0.000000, 0.000000, 1.000000, -1.000000) +mul r0.zw, r0.zzzw, cb0[30].yyyx +mul r4.xz, r4.yyyy, -r0.zzwz +add r4.xyz, r1.yzxy, -r4.xyzx +lt r0.z, |r3.x|, |r2.x| +movc r2.xyz, r0.zzzz, r3.xyzx, r2.xyzx +lt r0.z, |r4.y|, |r5.y| +movc r3.xyz, r0.zzzz, r4.xyzx, r5.xyzx +mul r4.xyz, r1.yyyy, cb0[13].xyzx +mad r4.xyz, cb0[12].xyzx, r1.xxxx, r4.xyzx +mad r4.xyz, cb0[14].xyzx, r1.zzzz, r4.xyzx +add r4.xyz, r4.xyzx, cb0[15].xyzx +mad r4.xzw, cb0[24].xxyz, l(0.150000, 0.000000, 0.150000, 0.150000), r4.xxyz +mul r5.xyzw, r4.zzzz, cb0[26].xyzw +mad r5.xyzw, cb0[25].xyzw, r4.xxxx, r5.xyzw +mad r5.xyzw, cb0[27].xyzw, r4.wwww, r5.xyzw +add r5.xyzw, r5.xyzw, cb0[28].xyzw +div r4.xzw, r5.xxyz, r5.wwww +mad r5.xyz, r4.xzwx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) +lt r0.z, r5.x, l(0.000000) +lt r0.w, l(1.000000), r5.x +or r0.z, r0.w, r0.z +add r0.w, -cb0[32].y, l(1.000000) +mul r6.x, cb0[32].x, l(0.002000) +mul r6.y, r0.w, l(0.002000) +add r5.w, -r5.y, l(1.000000) +add r4.xz, r5.xxwx, r6.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z +add r1.w, -cb0[33].y, l(1.000000) +mul r6.x, cb0[33].x, l(0.002000) +mul r6.y, r1.w, l(0.002000) +add r4.xz, r5.xxwx, r6.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r1.w, r4.xzxx, t2.xxxx, s1, r5.z +add r2.w, -cb0[34].y, l(1.000000) +mul r6.x, cb0[34].x, l(0.002000) +mul r6.y, r2.w, l(0.002000) +add r4.xz, r5.xxwx, r6.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r2.w, r4.xzxx, t2.xxxx, s1, r5.z +add r3.w, -cb0[35].y, l(1.000000) +mul r6.x, cb0[35].x, l(0.002000) +mul r6.y, r3.w, l(0.002000) +add r4.xz, r5.xxwx, r6.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r3.w, r4.xzxx, t2.xxxx, s1, r5.z +add r4.x, -cb0[36].y, l(1.000000) +mul r6.x, cb0[36].x, l(0.002000) +mul r6.y, r4.x, l(0.002000) +add r4.xz, r5.xxwx, r6.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r4.x, r4.xzxx, t2.xxxx, s1, r5.z +add r4.z, -cb0[37].y, l(1.000000) +mul r6.x, cb0[37].x, l(0.002000) +mul r6.y, r4.z, l(0.002000) +add r4.zw, r5.xxxw, r6.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r4.z, r4.zwzz, t2.xxxx, s1, r5.z +add r4.w, -cb0[38].y, l(1.000000) +mul r6.x, cb0[38].x, l(0.002000) +mul r6.y, r4.w, l(0.002000) +add r6.xy, r5.xwxx, r6.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r4.w, r6.xyxx, t2.xxxx, s1, r5.z +add r6.x, -cb0[39].y, l(1.000000) +mul r7.x, cb0[39].x, l(0.002000) +mul r7.y, r6.x, l(0.002000) +add r5.xw, r5.xxxw, r7.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r5.x, r5.xwxx, t2.xxxx, s1, r5.z +if_z r0.z + lt r0.z, r5.y, l(0.000000) + lt r5.y, l(1.000000), r5.y + or r0.z, r0.z, r5.y + if_z r0.z + add r0.z, r0.w, r1.w + add r0.z, r2.w, r0.z + add r0.z, r3.w, r0.z + add r0.z, r4.x, r0.z + add r0.z, r4.z, r0.z + add r0.z, r4.w, r0.z + add r0.z, r5.x, r0.z + mul r0.z, r0.z, l(0.125000) + else + mov r0.z, l(1.000000) + endif +else + mov r0.z, l(1.000000) +endif +mul r4.xzw, cb0[5].xxyz, cb0[24].yyyy +mad r4.xzw, cb0[4].xxyz, cb0[24].xxxx, r4.xxzw +mad r4.xzw, cb0[6].xxyz, cb0[24].zzzz, r4.xxzw +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r5.xyz, r0.wwww, r1.xyzx +mul r6.xyz, r2.xyzx, r3.xyzx +mad r2.xyz, r2.zxyz, r3.yzxy, -r6.xyzx +dp3 r1.w, r2.xyzx, r2.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, r2.xyzx +mad r1.xyw, -r1.xyxz, r0.wwww, r4.xzxw +dp3 r0.w, r1.xywx, r1.xywx +rsq r0.w, r0.w +mul r1.xyw, r0.wwww, r1.xyxw +dp3 r0.w, -r2.xyzx, -r5.xyzx +max r0.w, r0.w, l(0.000000) +add r0.w, -r0.w, l(1.000000) +mul r2.w, r0.w, r0.w +mul r0.w, r0.w, r2.w +mad r0.w, r0.w, l(0.900000), l(0.100000) +dp3 r2.w, r4.xzwx, -r2.xyzx +dp3 r3.x, r5.xyzx, -r2.xyzx +add r3.x, r3.x, r3.x +mad r3.xyz, r2.xyzx, r3.xxxx, r5.xyzx +mul r3.w, r3.y, cb0[13].y +mad r3.w, cb0[12].y, r3.x, r3.w +mad r3.z, cb0[14].y, r3.z, r3.w +mul r5.xy, cb0[31].zzzz, l(0.025000, 0.100000, 0.000000, 0.000000) +add r3.w, r4.y, l(-0.100000) +mul_sat r3.w, r3.w, l(3.333333) +mad r4.x, r3.w, l(-2.000000), l(3.000000) +mul r3.w, r3.w, r3.w +mul r3.w, r3.w, r4.x +mul r3.w, r3.w, r5.x +mul r4.xy, -r2.xyxx, r3.wwww +mad r4.xy, r4.xyxx, l(0.750000, 1.000000, 0.000000, 0.000000), r0.xyxx +add r6.xyzw, -cb0[29].xyzw, l(1.000000, 1.000000, 1.000000, 1.000000) +mad r6.xyz, -r6.xyzx, l(0.640000, 0.640000, 0.640000, 0.000000), l(1.000000, 1.000000, 1.000000, 0.000000) +mul r6.xyz, r6.xyzx, cb0[29].wwww +sample_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyxx, t1.xyzw, s0 +mul r7.xyz, r6.xyzx, r4.xyzx +mov r5.xz, l(0.750000,0,1.000000,0) +mul r3.xy, r3.xyxx, r5.yzyy +mul r5.y, cb0[31].z, l(0.100000) +mul r3.xy, r3.xyxx, r5.xyxx +div r3.xy, r3.xyxx, r1.zzzz +add r0.xy, r0.xyxx, -r3.xyxx +sample_indexable(texture2d)(float,float,float,float) r3.xyw, r0.xyxx, t1.xywz, s0 +add r0.x, r3.z, l(-0.150000) +mul_sat r0.x, r0.x, l(10.000001) +mad r0.y, r0.x, l(-2.000000), l(3.000000) +mul r0.x, r0.x, r0.x +mul r0.x, r0.x, r0.y +mul r0.x, r0.z, r0.x +mul r5.xyz, r0.xxxx, l(0.020000, 0.140000, 0.280000, 0.000000) +mad r3.xyz, r3.xywx, r0.zzzz, r5.xyzx +add r3.xyz, r3.xyzx, l(0.100000, 0.100000, 0.200000, 0.000000) +mad r0.x, r2.w, l(0.500000), l(0.500000) +max r0.y, r0.z, l(0.400000) +mul r0.x, r0.y, r0.x +mad r0.xyz, r0.xxxx, l(0.710000, 0.621000, 0.410000, 0.000000), l(0.290000, 0.379000, 0.590000, 0.000000) +mul r0.xyz, r0.xyzx, cb0[29].xyzx +dp3 r1.x, r1.xywx, -r2.xyzx +max r1.x, r1.x, l(0.000000) +log r1.x, r1.x +mul r1.x, r1.x, l(400.000000) +exp r1.x, r1.x +mad r1.yz, cb0[10].zzwz, r1.zzzz, cb0[11].zzwz +div oDepth, r1.y, r1.z +mad r1.yzw, -r4.xxyz, r6.xxyz, r3.xxyz +mad r1.yzw, r0.wwww, r1.yyzw, r7.xxyz +mad r1.xyz, r1.xxxx, l(1.200000, 1.200000, 1.200000, 0.000000), r1.yzwy +mul r1.xyz, r1.xyzx, cb0[29].wwww +mad o0.xyz, r0.xyzx, r6.wwww, r1.xyzx +mov o0.w, l(1.000000) +ret +// Approximately 192 instruction slots used +#endif + +const BYTE g_compositePS[] = +{ + 68, 88, 66, 67, 88, 43, + 70, 135, 189, 112, 158, 157, + 120, 182, 250, 215, 210, 92, + 57, 163, 1, 0, 0, 0, + 228, 31, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 68, 5, 0, 0, 156, 5, + 0, 0, 240, 5, 0, 0, + 72, 31, 0, 0, 82, 68, + 69, 70, 8, 5, 0, 0, + 1, 0, 0, 0, 60, 1, + 0, 0, 6, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 212, 4, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 252, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 7, 1, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 21, 1, + 0, 0, 2, 0, 0, 0, + 5, 0, 0, 0, 4, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 30, 1, 0, 0, 2, 0, + 0, 0, 5, 0, 0, 0, + 4, 0, 0, 0, 255, 255, + 255, 255, 1, 0, 0, 0, + 1, 0, 0, 0, 9, 0, + 0, 0, 39, 1, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 2, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 49, 1, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 116, 101, 120, 83, 97, 109, + 112, 108, 101, 114, 0, 115, + 104, 97, 100, 111, 119, 83, + 97, 109, 112, 108, 101, 114, + 0, 100, 101, 112, 116, 104, + 84, 101, 120, 0, 115, 99, + 101, 110, 101, 84, 101, 120, + 0, 115, 104, 97, 100, 111, + 119, 84, 101, 120, 0, 99, + 111, 110, 115, 116, 66, 117, + 102, 0, 171, 171, 49, 1, + 0, 0, 1, 0, 0, 0, + 84, 1, 0, 0, 192, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 124, 1, + 0, 0, 0, 0, 0, 0, + 192, 2, 0, 0, 2, 0, + 0, 0, 176, 4, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 103, 80, 97, 114, + 97, 109, 115, 0, 70, 108, + 117, 105, 100, 83, 104, 97, + 100, 101, 114, 67, 111, 110, + 115, 116, 0, 109, 111, 100, + 101, 108, 86, 105, 101, 119, + 80, 114, 111, 106, 101, 99, + 116, 105, 111, 110, 0, 102, + 108, 111, 97, 116, 52, 120, + 52, 0, 171, 171, 3, 0, + 3, 0, 4, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 169, 1, 0, 0, 109, 111, + 100, 101, 108, 86, 105, 101, + 119, 0, 112, 114, 111, 106, + 101, 99, 116, 105, 111, 110, + 0, 105, 110, 118, 101, 114, + 115, 101, 77, 111, 100, 101, + 108, 86, 105, 101, 119, 0, + 105, 110, 118, 101, 114, 115, + 101, 80, 114, 111, 106, 101, + 99, 116, 105, 111, 110, 0, + 105, 110, 118, 84, 101, 120, + 83, 99, 97, 108, 101, 0, + 102, 108, 111, 97, 116, 52, + 0, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 28, 2, + 0, 0, 105, 110, 118, 86, + 105, 101, 119, 112, 111, 114, + 116, 0, 102, 108, 111, 97, + 116, 51, 0, 171, 1, 0, + 3, 0, 1, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 84, 2, 0, 0, 95, 112, + 97, 100, 48, 0, 102, 108, + 111, 97, 116, 0, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 134, 2, 0, 0, 98, 108, + 117, 114, 82, 97, 100, 105, + 117, 115, 87, 111, 114, 108, + 100, 0, 98, 108, 117, 114, + 83, 99, 97, 108, 101, 0, + 98, 108, 117, 114, 70, 97, + 108, 108, 111, 102, 102, 0, + 100, 101, 98, 117, 103, 0, + 105, 110, 116, 0, 0, 0, + 2, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 220, 2, 0, 0, 108, 105, + 103, 104, 116, 80, 111, 115, + 0, 95, 112, 97, 100, 49, + 0, 108, 105, 103, 104, 116, + 68, 105, 114, 0, 95, 112, + 97, 100, 50, 0, 108, 105, + 103, 104, 116, 84, 114, 97, + 110, 115, 102, 111, 114, 109, + 0, 99, 111, 108, 111, 114, + 0, 99, 108, 105, 112, 80, + 111, 115, 84, 111, 69, 121, + 101, 0, 115, 112, 111, 116, + 77, 105, 110, 0, 115, 112, + 111, 116, 77, 97, 120, 0, + 105, 111, 114, 0, 95, 112, + 97, 100, 51, 0, 115, 104, + 97, 100, 111, 119, 84, 97, + 112, 115, 0, 171, 171, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 28, 2, 0, 0, + 149, 1, 0, 0, 180, 1, + 0, 0, 0, 0, 0, 0, + 216, 1, 0, 0, 180, 1, + 0, 0, 64, 0, 0, 0, + 226, 1, 0, 0, 180, 1, + 0, 0, 128, 0, 0, 0, + 237, 1, 0, 0, 180, 1, + 0, 0, 192, 0, 0, 0, + 254, 1, 0, 0, 180, 1, + 0, 0, 0, 1, 0, 0, + 16, 2, 0, 0, 36, 2, + 0, 0, 64, 1, 0, 0, + 72, 2, 0, 0, 92, 2, + 0, 0, 80, 1, 0, 0, + 128, 2, 0, 0, 140, 2, + 0, 0, 92, 1, 0, 0, + 176, 2, 0, 0, 140, 2, + 0, 0, 96, 1, 0, 0, + 192, 2, 0, 0, 140, 2, + 0, 0, 100, 1, 0, 0, + 202, 2, 0, 0, 140, 2, + 0, 0, 104, 1, 0, 0, + 214, 2, 0, 0, 224, 2, + 0, 0, 108, 1, 0, 0, + 4, 3, 0, 0, 92, 2, + 0, 0, 112, 1, 0, 0, + 13, 3, 0, 0, 140, 2, + 0, 0, 124, 1, 0, 0, + 19, 3, 0, 0, 92, 2, + 0, 0, 128, 1, 0, 0, + 28, 3, 0, 0, 140, 2, + 0, 0, 140, 1, 0, 0, + 34, 3, 0, 0, 180, 1, + 0, 0, 144, 1, 0, 0, + 49, 3, 0, 0, 36, 2, + 0, 0, 208, 1, 0, 0, + 55, 3, 0, 0, 36, 2, + 0, 0, 224, 1, 0, 0, + 68, 3, 0, 0, 140, 2, + 0, 0, 240, 1, 0, 0, + 76, 3, 0, 0, 140, 2, + 0, 0, 244, 1, 0, 0, + 84, 3, 0, 0, 140, 2, + 0, 0, 248, 1, 0, 0, + 88, 3, 0, 0, 140, 2, + 0, 0, 252, 1, 0, 0, + 94, 3, 0, 0, 108, 3, + 0, 0, 0, 2, 0, 0, + 5, 0, 0, 0, 1, 0, + 176, 0, 0, 0, 24, 0, + 144, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 132, 1, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 80, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 66, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 255, 255, + 255, 255, 1, 14, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 83, 86, + 95, 68, 69, 80, 84, 72, + 0, 171, 83, 72, 69, 88, + 80, 25, 0, 0, 80, 0, + 0, 0, 84, 6, 0, 0, + 106, 8, 0, 1, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 40, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 90, 8, 0, 3, + 0, 96, 16, 0, 1, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 1, 0, 0, 0, + 85, 85, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 2, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 2, + 1, 192, 0, 0, 104, 0, + 0, 2, 8, 0, 0, 0, + 50, 0, 0, 15, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 191, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 150, 124, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 24, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 13, 0, 4, 3, 42, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 15, 194, 0, + 16, 0, 0, 0, 0, 0, + 6, 20, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 64, + 0, 0, 0, 64, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 128, 191, 0, 0, 128, 191, + 56, 0, 0, 8, 194, 0, + 16, 0, 0, 0, 0, 0, + 166, 14, 16, 0, 0, 0, + 0, 0, 6, 132, 32, 0, + 0, 0, 0, 0, 30, 0, + 0, 0, 56, 0, 0, 8, + 50, 0, 16, 0, 1, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 230, 10, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 54, 0, + 0, 6, 34, 0, 16, 0, + 2, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 54, 0, + 0, 5, 66, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 194, 0, + 16, 0, 0, 0, 0, 0, + 6, 4, 16, 0, 0, 0, + 0, 0, 86, 9, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 230, 10, + 16, 0, 0, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 15, 194, 0, 16, 0, + 0, 0, 0, 0, 166, 14, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 192, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 191, + 0, 0, 128, 63, 56, 0, + 0, 8, 194, 0, 16, 0, + 0, 0, 0, 0, 166, 14, + 16, 0, 0, 0, 0, 0, + 6, 132, 32, 0, 0, 0, + 0, 0, 30, 0, 0, 0, + 56, 0, 0, 8, 98, 0, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 166, 11, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 38, 9, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 6, 34, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 54, 0, + 0, 5, 66, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 50, 0, 0, 12, 194, 0, + 16, 0, 0, 0, 0, 0, + 6, 20, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 191, 86, 9, + 16, 0, 3, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 3, 0, + 0, 0, 230, 10, 16, 0, + 0, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 15, + 194, 0, 16, 0, 0, 0, + 0, 0, 166, 14, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 64, 0, 0, 0, 192, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 191, 0, 0, + 128, 63, 56, 0, 0, 8, + 194, 0, 16, 0, 0, 0, + 0, 0, 166, 14, 16, 0, + 0, 0, 0, 0, 6, 132, + 32, 0, 0, 0, 0, 0, + 30, 0, 0, 0, 56, 0, + 0, 8, 98, 0, 16, 0, + 3, 0, 0, 0, 6, 0, + 16, 0, 3, 0, 0, 0, + 166, 11, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 114, 0, + 16, 0, 3, 0, 0, 0, + 38, 9, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 54, 0, 0, 5, + 66, 0, 16, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 54, 0, + 0, 6, 18, 0, 16, 0, + 4, 0, 0, 0, 26, 128, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 0, 0, + 0, 7, 194, 0, 16, 0, + 0, 0, 0, 0, 86, 1, + 16, 0, 0, 0, 0, 0, + 6, 8, 16, 0, 4, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 34, 0, 16, 0, + 5, 0, 0, 0, 182, 15, + 16, 0, 0, 0, 0, 0, + 22, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 15, 194, 0, 16, 0, + 0, 0, 0, 0, 166, 14, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 192, 0, 0, + 0, 64, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 191, 56, 0, + 0, 8, 194, 0, 16, 0, + 0, 0, 0, 0, 166, 14, + 16, 0, 0, 0, 0, 0, + 86, 129, 32, 0, 0, 0, + 0, 0, 30, 0, 0, 0, + 56, 0, 0, 8, 82, 0, + 16, 0, 5, 0, 0, 0, + 86, 5, 16, 0, 5, 0, + 0, 0, 166, 11, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 114, 0, 16, 0, 5, 0, + 0, 0, 150, 4, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 8, 194, 0, 16, 0, + 0, 0, 0, 0, 86, 1, + 16, 0, 0, 0, 0, 0, + 6, 8, 16, 128, 65, 0, + 0, 0, 4, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 34, 0, 16, 0, 4, 0, + 0, 0, 182, 15, 16, 0, + 0, 0, 0, 0, 22, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 15, + 194, 0, 16, 0, 0, 0, + 0, 0, 166, 14, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 192, 0, 0, 0, 64, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 191, 56, 0, 0, 8, + 194, 0, 16, 0, 0, 0, + 0, 0, 166, 14, 16, 0, + 0, 0, 0, 0, 86, 129, + 32, 0, 0, 0, 0, 0, + 30, 0, 0, 0, 56, 0, + 0, 8, 82, 0, 16, 0, + 4, 0, 0, 0, 86, 5, + 16, 0, 4, 0, 0, 0, + 166, 11, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 114, 0, + 16, 0, 4, 0, 0, 0, + 150, 4, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 4, 0, + 0, 0, 49, 0, 0, 9, + 66, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 128, + 129, 0, 0, 0, 3, 0, + 0, 0, 10, 0, 16, 128, + 129, 0, 0, 0, 2, 0, + 0, 0, 55, 0, 0, 9, + 114, 0, 16, 0, 2, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 49, 0, 0, 9, + 66, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 128, + 129, 0, 0, 0, 4, 0, + 0, 0, 26, 0, 16, 128, + 129, 0, 0, 0, 5, 0, + 0, 0, 55, 0, 0, 9, + 114, 0, 16, 0, 3, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 4, 0, + 0, 0, 86, 5, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 0, 0, 0, 8, 114, 0, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 50, 0, 0, 13, + 210, 0, 16, 0, 4, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 2, 64, 0, 0, + 154, 153, 25, 62, 0, 0, + 0, 0, 154, 153, 25, 62, + 154, 153, 25, 62, 6, 9, + 16, 0, 4, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 5, 0, 0, 0, + 166, 10, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 5, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 6, 0, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 5, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 5, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 27, 0, 0, 0, + 246, 15, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 8, 242, 0, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 5, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 28, 0, 0, 0, + 14, 0, 0, 7, 210, 0, + 16, 0, 4, 0, 0, 0, + 6, 9, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 5, 0, 0, 0, 50, 0, + 0, 15, 114, 0, 16, 0, + 5, 0, 0, 0, 134, 3, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 5, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 10, 0, + 16, 0, 5, 0, 0, 0, + 60, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 32, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 6, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 32, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 6, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 8, 130, 0, 16, 0, + 5, 0, 0, 0, 26, 0, + 16, 128, 65, 0, 0, 0, + 5, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 7, 82, 0, + 16, 0, 4, 0, 0, 0, + 6, 3, 16, 0, 5, 0, + 0, 0, 6, 1, 16, 0, + 6, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 130, 0, + 16, 0, 0, 0, 0, 0, + 134, 0, 16, 0, 4, 0, + 0, 0, 6, 112, 16, 0, + 2, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 42, 0, 16, 0, 5, 0, + 0, 0, 0, 0, 0, 9, + 130, 0, 16, 0, 1, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 6, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 33, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 6, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 82, 0, 16, 0, 4, 0, + 0, 0, 6, 3, 16, 0, + 5, 0, 0, 0, 6, 1, + 16, 0, 6, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 130, 0, 16, 0, 1, 0, + 0, 0, 134, 0, 16, 0, + 4, 0, 0, 0, 6, 112, + 16, 0, 2, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 9, 130, 0, 16, 0, + 2, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 34, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 6, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 34, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 6, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 82, 0, 16, 0, + 4, 0, 0, 0, 6, 3, + 16, 0, 5, 0, 0, 0, + 6, 1, 16, 0, 6, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 130, 0, 16, 0, + 2, 0, 0, 0, 134, 0, + 16, 0, 4, 0, 0, 0, + 6, 112, 16, 0, 2, 0, + 0, 0, 0, 96, 16, 0, + 1, 0, 0, 0, 42, 0, + 16, 0, 5, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 35, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 6, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 35, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 6, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 82, 0, + 16, 0, 4, 0, 0, 0, + 6, 3, 16, 0, 5, 0, + 0, 0, 6, 1, 16, 0, + 6, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 130, 0, + 16, 0, 3, 0, 0, 0, + 134, 0, 16, 0, 4, 0, + 0, 0, 6, 112, 16, 0, + 2, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 42, 0, 16, 0, 5, 0, + 0, 0, 0, 0, 0, 9, + 18, 0, 16, 0, 4, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 36, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 6, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 36, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 6, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 82, 0, 16, 0, 4, 0, + 0, 0, 6, 3, 16, 0, + 5, 0, 0, 0, 6, 1, + 16, 0, 6, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 4, 0, + 0, 0, 134, 0, 16, 0, + 4, 0, 0, 0, 6, 112, + 16, 0, 2, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 9, 66, 0, 16, 0, + 4, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 37, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 6, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 37, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 6, 0, 0, 0, + 42, 0, 16, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 194, 0, 16, 0, + 4, 0, 0, 0, 6, 12, + 16, 0, 5, 0, 0, 0, + 6, 4, 16, 0, 6, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 66, 0, 16, 0, + 4, 0, 0, 0, 230, 10, + 16, 0, 4, 0, 0, 0, + 6, 112, 16, 0, 2, 0, + 0, 0, 0, 96, 16, 0, + 1, 0, 0, 0, 42, 0, + 16, 0, 5, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 4, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 38, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 6, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 38, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 6, 0, + 0, 0, 58, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 6, 0, 0, 0, + 198, 0, 16, 0, 5, 0, + 0, 0, 70, 0, 16, 0, + 6, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 130, 0, + 16, 0, 4, 0, 0, 0, + 70, 0, 16, 0, 6, 0, + 0, 0, 6, 112, 16, 0, + 2, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 42, 0, 16, 0, 5, 0, + 0, 0, 0, 0, 0, 9, + 18, 0, 16, 0, 6, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 39, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 7, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 39, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 7, 0, 0, 0, 10, 0, + 16, 0, 6, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 146, 0, 16, 0, 5, 0, + 0, 0, 6, 12, 16, 0, + 5, 0, 0, 0, 6, 4, + 16, 0, 7, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 5, 0, + 0, 0, 198, 0, 16, 0, + 5, 0, 0, 0, 6, 112, + 16, 0, 2, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 5, 0, 0, 0, 31, 0, + 0, 3, 42, 0, 16, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 5, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 7, + 34, 0, 16, 0, 5, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 26, 0, + 16, 0, 5, 0, 0, 0, + 60, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 5, 0, 0, 0, 31, 0, + 0, 3, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 4, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 5, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 62, + 18, 0, 0, 1, 54, 0, + 0, 5, 66, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 21, 0, 0, 1, 18, 0, + 0, 1, 54, 0, 0, 5, + 66, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 21, 0, + 0, 1, 56, 0, 0, 9, + 210, 0, 16, 0, 4, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 86, 133, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 50, 0, 0, 11, + 210, 0, 16, 0, 4, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 6, 128, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 6, 14, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 11, 210, 0, 16, 0, + 4, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 166, 138, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 6, 14, + 16, 0, 4, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 5, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 6, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 38, 9, 16, 0, + 2, 0, 0, 0, 150, 4, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 6, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 1, 0, 0, 0, 70, 8, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 134, 12, 16, 0, 4, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 3, 16, 0, + 1, 0, 0, 0, 70, 3, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 178, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 12, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 9, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 5, 0, 0, 0, + 52, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 9, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 102, 102, 102, 63, + 1, 64, 0, 0, 205, 204, + 204, 61, 16, 0, 0, 8, + 130, 0, 16, 0, 2, 0, + 0, 0, 134, 3, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 2, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 7, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 5, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 13, 0, 0, 0, + 50, 0, 0, 10, 130, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 10, 66, 0, 16, 0, + 3, 0, 0, 0, 26, 128, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 42, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 11, + 50, 0, 16, 0, 5, 0, + 0, 0, 166, 138, 32, 0, + 0, 0, 0, 0, 31, 0, + 0, 0, 2, 64, 0, 0, + 205, 204, 204, 60, 205, 204, + 204, 61, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 130, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 205, 204, + 204, 189, 56, 32, 0, 7, + 130, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 85, 85, 85, 64, + 50, 0, 0, 9, 18, 0, + 16, 0, 4, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 192, 1, 64, + 0, 0, 0, 0, 64, 64, + 56, 0, 0, 7, 130, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 3, 0, 0, 0, 58, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 4, 0, + 0, 0, 56, 0, 0, 7, + 130, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 5, 0, 0, 0, + 56, 0, 0, 8, 50, 0, + 16, 0, 4, 0, 0, 0, + 70, 0, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 64, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 12, + 242, 0, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 29, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 50, 0, 0, 16, + 114, 0, 16, 0, 6, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 6, 0, + 0, 0, 2, 64, 0, 0, + 11, 215, 35, 63, 11, 215, + 35, 63, 11, 215, 35, 63, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 6, 0, 0, 0, + 70, 2, 16, 0, 6, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 29, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 114, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 70, 126, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 7, 0, 0, 0, 70, 2, + 16, 0, 6, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 54, 0, 0, 8, + 82, 0, 16, 0, 5, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 64, 63, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 56, 0, + 0, 7, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 150, 5, 16, 0, 5, 0, + 0, 0, 56, 0, 0, 8, + 34, 0, 16, 0, 5, 0, + 0, 0, 42, 128, 32, 0, + 0, 0, 0, 0, 31, 0, + 0, 0, 1, 64, 0, 0, + 205, 204, 204, 61, 56, 0, + 0, 7, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 5, 0, + 0, 0, 14, 0, 0, 7, + 50, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 166, 10, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 8, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 3, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 178, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 0, 0, 0, 0, + 70, 123, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 154, 153, + 25, 190, 56, 32, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 1, 0, 32, 65, + 50, 0, 0, 9, 34, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 192, 1, 64, + 0, 0, 0, 0, 64, 64, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 114, 0, + 16, 0, 5, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 8, 215, 163, 60, 40, 92, + 15, 62, 40, 92, 143, 62, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 3, + 16, 0, 3, 0, 0, 0, + 166, 10, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 10, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 205, 204, + 204, 61, 205, 204, 204, 61, + 205, 204, 76, 62, 0, 0, + 0, 0, 50, 0, 0, 9, + 18, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 63, + 1, 64, 0, 0, 0, 0, + 0, 63, 52, 0, 0, 7, + 34, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 205, 204, 204, 62, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 15, 114, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 144, 194, + 53, 63, 219, 249, 30, 63, + 134, 235, 209, 62, 0, 0, + 0, 0, 2, 64, 0, 0, + 225, 122, 148, 62, 74, 12, + 194, 62, 61, 10, 23, 63, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 29, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 3, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 52, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 200, 67, + 25, 0, 0, 5, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 98, 0, 16, 0, 1, 0, + 0, 0, 166, 139, 32, 0, + 0, 0, 0, 0, 10, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 166, 139, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 14, 0, + 0, 6, 1, 192, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 226, 0, 16, 0, + 1, 0, 0, 0, 6, 9, + 16, 128, 65, 0, 0, 0, + 4, 0, 0, 0, 6, 9, + 16, 0, 6, 0, 0, 0, + 6, 9, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 9, + 226, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 86, 14, + 16, 0, 1, 0, 0, 0, + 6, 9, 16, 0, 7, 0, + 0, 0, 50, 0, 0, 12, + 114, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 154, 153, 153, 63, + 154, 153, 153, 63, 154, 153, + 153, 63, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 246, 143, + 32, 0, 0, 0, 0, 0, + 29, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 6, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 192, 0, 0, 0, 8, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 155, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/debugLinePS.hlsl b/demo/d3d/shaders/debugLinePS.hlsl new file mode 100644 index 0000000..d01847b --- /dev/null +++ b/demo/d3d/shaders/debugLinePS.hlsl @@ -0,0 +1,10 @@ +struct Input +{ + float4 position : SV_POSITION; + float4 color : COLOR; +}; + +float4 debugLinePS(Input input) : SV_TARGET +{ + return input.color; +} diff --git a/demo/d3d/shaders/debugLinePS.hlsl.h b/demo/d3d/shaders/debugLinePS.hlsl.h new file mode 100644 index 0000000..6243104 --- /dev/null +++ b/demo/d3d/shaders/debugLinePS.hlsl.h @@ -0,0 +1,121 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_input_ps linear v1.xyzw +dcl_output o0.xyzw +mov o0.xyzw, v1.xyzw +ret +// Approximately 2 instruction slots used +#endif + +const BYTE g_debugLinePS[] = +{ + 68, 88, 66, 67, 51, 80, + 148, 24, 206, 189, 182, 148, + 220, 111, 88, 236, 138, 6, + 146, 179, 1, 0, 0, 0, + 20, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 0, 1, + 0, 0, 52, 1, 0, 0, + 120, 1, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 76, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 65, 82, 71, 69, 84, 0, + 171, 171, 83, 72, 69, 88, + 60, 0, 0, 0, 80, 0, + 0, 0, 15, 0, 0, 0, + 106, 8, 0, 1, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/debugLineVS.hlsl b/demo/d3d/shaders/debugLineVS.hlsl new file mode 100644 index 0000000..1033b35 --- /dev/null +++ b/demo/d3d/shaders/debugLineVS.hlsl @@ -0,0 +1,26 @@ + +cbuffer params : register(b0) +{ + float4x4 projectionViewWorld; +}; + +struct Input +{ + float3 position : POSITION; + float4 color : COLOR; +}; + +struct Output +{ + float4 position : SV_POSITION; + float4 color : COLOR; +}; + +Output debugLineVS(Input input) +{ + Output output; + output.position = mul(projectionViewWorld, float4(input.position, 1.0f)); + output.color = input.color; + + return output; +} diff --git a/demo/d3d/shaders/debugLineVS.hlsl.h b/demo/d3d/shaders/debugLineVS.hlsl.h new file mode 100644 index 0000000..cdf7e4b --- /dev/null +++ b/demo/d3d/shaders/debugLineVS.hlsl.h @@ -0,0 +1,213 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer params +// { +// +// float4x4 projectionViewWorld; // Offset: 0 Size: 64 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// params cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyz 0 NONE float xyz +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[4], immediateIndexed +dcl_input v0.xyz +dcl_input v1.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_temps 1 +mul r0.xyzw, v0.yyyy, cb0[1].xyzw +mad r0.xyzw, cb0[0].xyzw, v0.xxxx, r0.xyzw +mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw +add o0.xyzw, r0.xyzw, cb0[3].xyzw +mov o1.xyzw, v1.xyzw +ret +// Approximately 6 instruction slots used +#endif + +const BYTE g_debugLineVS[] = +{ + 68, 88, 66, 67, 240, 24, + 40, 204, 192, 159, 63, 125, + 158, 223, 41, 237, 85, 39, + 230, 54, 1, 0, 0, 0, + 160, 3, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 88, 1, 0, 0, 168, 1, + 0, 0, 252, 1, 0, 0, + 4, 3, 0, 0, 82, 68, + 69, 70, 28, 1, 0, 0, + 1, 0, 0, 0, 100, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 232, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 112, 97, 114, 97, + 109, 115, 0, 171, 92, 0, + 0, 0, 1, 0, 0, 0, + 124, 0, 0, 0, 64, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 0, + 0, 0, 0, 0, 0, 0, + 64, 0, 0, 0, 2, 0, + 0, 0, 196, 0, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 112, 114, 111, 106, + 101, 99, 116, 105, 111, 110, + 86, 105, 101, 119, 87, 111, + 114, 108, 100, 0, 102, 108, + 111, 97, 116, 52, 120, 52, + 0, 171, 171, 171, 3, 0, + 3, 0, 4, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 184, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 72, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 7, 7, 0, 0, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 67, 79, 76, + 79, 82, 0, 171, 79, 83, + 71, 78, 76, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 83, 72, + 69, 88, 0, 1, 0, 0, + 80, 0, 1, 0, 64, 0, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 0, 0, 0, 0, 86, 21, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 166, 26, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 6, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/diffuseGS.hlsl b/demo/d3d/shaders/diffuseGS.hlsl new file mode 100644 index 0000000..e7a50d8 --- /dev/null +++ b/demo/d3d/shaders/diffuseGS.hlsl @@ -0,0 +1,83 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + DiffuseShaderConst gParams; +}; + +static const float2 corners[4] = +{ + float2(0.0, 1.0), + float2(0.0, 0.0), + float2(1.0, 1.0), + float2(1.0, 0.0) +}; + +[maxvertexcount(4)] +void diffuseGS(point DiffuseVertexOut input[1], inout TriangleStream triStream) +{ + float4 ndcPos = input[0].ndcPos; + + // frustrum culling + const float ndcBound = 1.0; + if (ndcPos.x < -ndcBound) return; + if (ndcPos.x > ndcBound) return; + if (ndcPos.y < -ndcBound) return; + if (ndcPos.y > ndcBound) return; + + float pointScale = gParams.diffuseScale; + float velocityScale = 1.0; + + float3 v = input[0].viewVel.xyz; + float3 p = input[0].viewPos.xyz; + + // billboard in eye space + float3 u = float3(0.0, pointScale, 0.0); + float3 l = float3(pointScale, 0.0, 0.0); + + // increase size based on life + float lifeTime = input[0].worldPos.w; + + float lifeFade = lerp(1.0f + gParams.diffusion, 1.0, min(1.0, lifeTime*0.25f)); + u *= lifeFade; + l *= lifeFade; + + float fade = 1.0/(lifeFade*lifeFade); + float vlen = length(v)*gParams.motionBlurScale; + + if (vlen > 0.5) + { + float len = max(pointScale, vlen*0.016); + fade = min(1.0, 2.0/(len/pointScale)); + + u = normalize(v)*max(pointScale, vlen*0.016); // assume 60hz + l = normalize(cross(u, float3(0.0, 0.0, -1.0)))*pointScale; + } + + { + DiffuseGeometryOut output; + + output.worldPos = input[0].worldPos; // vertex world pos (life in w) + output.viewPos = input[0].viewPos; // vertex eye pos + output.viewVel.xyz = input[0].viewVel.xyz; // vertex velocity in view space + output.viewVel.w = fade; + output.lightDir = mul(gParams.modelView, float4(gParams.lightDir, 0.0)); + output.color = input[0].color; + + output.uv = float2(0.0, 1.0); + output.clipPos = mul(gParams.projection, float4(p + u - l, 1.0)); + triStream.Append(output); + + output.uv = float2(0.0, 0.0); + output.clipPos = mul(gParams.projection, float4(p - u - l, 1.0)); + triStream.Append(output); + + output.uv = float2(1.0, 1.0); + output.clipPos = mul(gParams.projection, float4(p + u + l, 1.0)); + triStream.Append(output); + + output.uv = float2(1.0, 0.0); + output.clipPos = mul(gParams.projection, float4(p - u + l, 1.0)); + triStream.Append(output); + } +} diff --git a/demo/d3d/shaders/diffuseGS.hlsl.h b/demo/d3d/shaders/diffuseGS.hlsl.h new file mode 100644 index 0000000..6e3efd8 --- /dev/null +++ b/demo/d3d/shaders/diffuseGS.hlsl.h @@ -0,0 +1,973 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct DiffuseShaderConst +// { +// +// float3 lightPos; // Offset: 0 +// float pad0; // Offset: 12 +// float3 lightDir; // Offset: 16 +// float pad1; // Offset: 28 +// float4x4 lightTransform; // Offset: 32 +// float4 color; // Offset: 96 +// float4x4 modelView; // Offset: 112 +// float4x4 modelViewProjection; // Offset: 176 +// float4x4 projection; // Offset: 240 +// float4 shadowTaps[12]; // Offset: 304 +// float diffusion; // Offset: 496 +// float diffuseRadius; // Offset: 500 +// float diffuseScale; // Offset: 504 +// float spotMin; // Offset: 508 +// float spotMax; // Offset: 512 +// float motionBlurScale; // Offset: 516 +// float pad3; // Offset: 520 +// float pad4; // Offset: 524 +// +// } gParams; // Offset: 0 Size: 528 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// NCDPOS 0 xyzw 1 NONE float xy +// VIEWPOS 0 xyzw 2 NONE float xyzw +// VIEWVEL 0 xyzw 3 NONE float xyz +// COLOR 0 xyzw 4 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// POSITION 0 xyzw 1 NONE float xyzw +// VIEWPOS 0 xyzw 2 NONE float xyzw +// VIEWVEL 0 xyzw 3 NONE float xyzw +// LIGHTDIR 0 xyzw 4 NONE float xyzw +// COLOR 0 xyzw 5 NONE float xyzw +// UV 0 xy 6 NONE float xy +// +gs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[33], immediateIndexed +dcl_input v[1][0].xyzw +dcl_input v[1][1].xyzw +dcl_input v[1][2].xyzw +dcl_input v[1][3].xyzw +dcl_input v[1][4].xyzw +dcl_temps 6 +dcl_inputprimitive point +dcl_stream m0 +dcl_outputtopology trianglestrip +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xyzw +dcl_output o3.xyzw +dcl_output o4.xyzw +dcl_output o5.xyzw +dcl_output o6.xy +dcl_maxout 4 +lt r0.x, v[0][1].x, l(-1.000000) +if_nz r0.x + ret +endif +lt r0.x, l(1.000000), v[0][1].x +if_nz r0.x + ret +endif +lt r0.x, v[0][1].y, l(-1.000000) +if_nz r0.x + ret +endif +lt r0.x, l(1.000000), v[0][1].y +if_nz r0.x + ret +endif +add r0.x, cb0[31].x, l(1.000000) +mul r0.y, l(0.250000), v[0][0].w +min r0.y, r0.y, l(1.000000) +add r0.z, -r0.x, l(1.000000) +mad r0.x, r0.y, r0.z, r0.x +mov r1.yz, l(0,0,0,0) +mov r1.x, cb0[31].z +mul r1.xyz, r0.xxxx, r1.xyzx +mul r0.x, r0.x, r0.x +div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x +dp3 r0.x, v[0][3].xyzx, v[0][3].xyzx +sqrt r0.y, r0.x +mul r0.y, r0.y, cb0[32].y +lt r0.z, l(0.500000), r0.y +mul r0.y, r0.y, l(0.016000) +max r0.y, r0.y, cb0[31].z +div r0.w, r0.y, cb0[31].z +div r0.w, l(2.000000), r0.w +min r2.w, r0.w, l(1.000000) +rsq r0.x, r0.x +mul r3.xyz, r0.xxxx, v[0][3].xyzx +mul r0.xyw, r0.yyyy, r3.xyxz +mul r3.xyz, r0.wxyw, l(0.000000, -1.000000, 0.000000, 0.000000) +mad r3.xyz, r0.ywxy, l(-1.000000, 0.000000, 0.000000, 0.000000), -r3.xyzx +dp2 r3.w, r3.xyxx, r3.xyxx +rsq r3.w, r3.w +mul r3.xyz, r3.wwww, r3.xyzx +mul r2.xyz, r3.xyzx, cb0[31].zzzz +movc r0.xyw, r0.zzzz, r0.xyxw, r1.zxzz +movc r1.xyzw, r0.zzzz, r2.xyzw, r1.xyzw +mul r2.xyzw, cb0[1].yyyy, cb0[8].xyzw +mad r2.xyzw, cb0[7].xyzw, cb0[1].xxxx, r2.xyzw +mad r2.xyzw, cb0[9].xyzw, cb0[1].zzzz, r2.xyzw +add r3.xyz, r0.xywx, v[0][2].xyzx +add r4.xyz, -r1.xyzx, r3.xyzx +mul r5.xyzw, r4.yyyy, cb0[16].xyzw +mad r5.xyzw, cb0[15].xyzw, r4.xxxx, r5.xyzw +mad r4.xyzw, cb0[17].xyzw, r4.zzzz, r5.xyzw +add r4.xyzw, r4.xyzw, cb0[18].xyzw +mov o0.xyzw, r4.xyzw +mov o1.xyzw, v[0][0].xyzw +mov o2.xyzw, v[0][2].xyzw +mov o3.xyz, v[0][3].xyzx +mov o3.w, r1.w +mov o4.xyzw, r2.xyzw +mov o5.xyzw, v[0][4].xyzw +mov o6.xy, l(0,1.000000,0,0) +emit_stream m0 +add r0.xyz, -r0.xywx, v[0][2].xyzx +add r4.xyz, -r1.xyzx, r0.xyzx +mul r5.xyzw, r4.yyyy, cb0[16].xyzw +mad r5.xyzw, cb0[15].xyzw, r4.xxxx, r5.xyzw +mad r4.xyzw, cb0[17].xyzw, r4.zzzz, r5.xyzw +add r4.xyzw, r4.xyzw, cb0[18].xyzw +mov o0.xyzw, r4.xyzw +mov o1.xyzw, v[0][0].xyzw +mov o2.xyzw, v[0][2].xyzw +mov o3.xyz, v[0][3].xyzx +mov o3.w, r1.w +mov o4.xyzw, r2.xyzw +mov o5.xyzw, v[0][4].xyzw +mov o6.xy, l(0,0,0,0) +emit_stream m0 +add r3.xyz, r1.xyzx, r3.xyzx +mul r4.xyzw, r3.yyyy, cb0[16].xyzw +mad r4.xyzw, cb0[15].xyzw, r3.xxxx, r4.xyzw +mad r3.xyzw, cb0[17].xyzw, r3.zzzz, r4.xyzw +add r3.xyzw, r3.xyzw, cb0[18].xyzw +mov o0.xyzw, r3.xyzw +mov o1.xyzw, v[0][0].xyzw +mov o2.xyzw, v[0][2].xyzw +mov o3.xyz, v[0][3].xyzx +mov o3.w, r1.w +mov o4.xyzw, r2.xyzw +mov o5.xyzw, v[0][4].xyzw +mov o6.xy, l(1.000000,1.000000,0,0) +emit_stream m0 +add r0.xyz, r1.xyzx, r0.xyzx +mul r3.xyzw, r0.yyyy, cb0[16].xyzw +mad r3.xyzw, cb0[15].xyzw, r0.xxxx, r3.xyzw +mad r0.xyzw, cb0[17].xyzw, r0.zzzz, r3.xyzw +add r0.xyzw, r0.xyzw, cb0[18].xyzw +mov o0.xyzw, r0.xyzw +mov o1.xyzw, v[0][0].xyzw +mov o2.xyzw, v[0][2].xyzw +mov o3.xyz, v[0][3].xyzx +mov o3.w, r1.w +mov o4.xyzw, r2.xyzw +mov o5.xyzw, v[0][4].xyzw +mov o6.xy, l(1.000000,0,0,0) +emit_stream m0 +ret +// Approximately 108 instruction slots used +#endif + +const BYTE g_diffuseGS[] = +{ + 68, 88, 66, 67, 210, 25, + 219, 88, 83, 177, 178, 56, + 31, 41, 77, 1, 224, 175, + 13, 250, 1, 0, 0, 0, + 16, 18, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 188, 3, 0, 0, 108, 4, + 0, 0, 120, 5, 0, 0, + 116, 17, 0, 0, 82, 68, + 69, 70, 128, 3, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 83, 71, 0, 1, 0, 0, + 76, 3, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 16, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 16, 2, + 0, 0, 2, 0, 0, 0, + 40, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 68, 105, 102, 102, + 117, 115, 101, 83, 104, 97, + 100, 101, 114, 67, 111, 110, + 115, 116, 0, 108, 105, 103, + 104, 116, 80, 111, 115, 0, + 102, 108, 111, 97, 116, 51, + 0, 171, 1, 0, 3, 0, + 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 204, 0, + 0, 0, 112, 97, 100, 48, + 0, 102, 108, 111, 97, 116, + 0, 171, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 253, 0, + 0, 0, 108, 105, 103, 104, + 116, 68, 105, 114, 0, 112, + 97, 100, 49, 0, 108, 105, + 103, 104, 116, 84, 114, 97, + 110, 115, 102, 111, 114, 109, + 0, 102, 108, 111, 97, 116, + 52, 120, 52, 0, 171, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 69, 1, 0, 0, + 99, 111, 108, 111, 114, 0, + 102, 108, 111, 97, 116, 52, + 0, 171, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 122, 1, 0, 0, 109, 111, + 100, 101, 108, 86, 105, 101, + 119, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 80, + 114, 111, 106, 101, 99, 116, + 105, 111, 110, 0, 112, 114, + 111, 106, 101, 99, 116, 105, + 111, 110, 0, 115, 104, 97, + 100, 111, 119, 84, 97, 112, + 115, 0, 1, 0, 3, 0, + 1, 0, 4, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 122, 1, + 0, 0, 100, 105, 102, 102, + 117, 115, 105, 111, 110, 0, + 100, 105, 102, 102, 117, 115, + 101, 82, 97, 100, 105, 117, + 115, 0, 100, 105, 102, 102, + 117, 115, 101, 83, 99, 97, + 108, 101, 0, 115, 112, 111, + 116, 77, 105, 110, 0, 115, + 112, 111, 116, 77, 97, 120, + 0, 109, 111, 116, 105, 111, + 110, 66, 108, 117, 114, 83, + 99, 97, 108, 101, 0, 112, + 97, 100, 51, 0, 112, 97, + 100, 52, 0, 171, 195, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 248, 0, + 0, 0, 4, 1, 0, 0, + 12, 0, 0, 0, 40, 1, + 0, 0, 212, 0, 0, 0, + 16, 0, 0, 0, 49, 1, + 0, 0, 4, 1, 0, 0, + 28, 0, 0, 0, 54, 1, + 0, 0, 80, 1, 0, 0, + 32, 0, 0, 0, 116, 1, + 0, 0, 132, 1, 0, 0, + 96, 0, 0, 0, 168, 1, + 0, 0, 80, 1, 0, 0, + 112, 0, 0, 0, 178, 1, + 0, 0, 80, 1, 0, 0, + 176, 0, 0, 0, 198, 1, + 0, 0, 80, 1, 0, 0, + 240, 0, 0, 0, 209, 1, + 0, 0, 220, 1, 0, 0, + 48, 1, 0, 0, 0, 2, + 0, 0, 4, 1, 0, 0, + 240, 1, 0, 0, 10, 2, + 0, 0, 4, 1, 0, 0, + 244, 1, 0, 0, 24, 2, + 0, 0, 4, 1, 0, 0, + 248, 1, 0, 0, 37, 2, + 0, 0, 4, 1, 0, 0, + 252, 1, 0, 0, 45, 2, + 0, 0, 4, 1, 0, 0, + 0, 2, 0, 0, 53, 2, + 0, 0, 4, 1, 0, 0, + 4, 2, 0, 0, 69, 2, + 0, 0, 4, 1, 0, 0, + 8, 2, 0, 0, 74, 2, + 0, 0, 4, 1, 0, 0, + 12, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 132, 0, + 0, 0, 18, 0, 80, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 176, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 168, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 3, 0, 0, + 144, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 152, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 7, 0, 0, + 160, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 15, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 78, 67, 68, + 80, 79, 83, 0, 86, 73, + 69, 87, 80, 79, 83, 0, + 86, 73, 69, 87, 86, 69, + 76, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 79, 83, + 71, 53, 4, 1, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 0, 0, 0, 0, + 204, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 0, 0, + 0, 0, 225, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 0, 0, 0, 0, + 233, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 241, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 0, 0, 0, 0, 0, + 0, 0, 250, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 15, 0, + 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 3, 12, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 86, 73, 69, + 87, 80, 79, 83, 0, 86, + 73, 69, 87, 86, 69, 76, + 0, 76, 73, 71, 72, 84, + 68, 73, 82, 0, 67, 79, + 76, 79, 82, 0, 85, 86, + 0, 171, 83, 72, 69, 88, + 244, 11, 0, 0, 80, 0, + 2, 0, 253, 2, 0, 0, + 106, 8, 0, 1, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 33, 0, + 0, 0, 95, 0, 0, 4, + 242, 16, 32, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 95, 0, 0, 4, 242, 16, + 32, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 95, 0, + 0, 4, 242, 16, 32, 0, + 1, 0, 0, 0, 2, 0, + 0, 0, 95, 0, 0, 4, + 242, 16, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 95, 0, 0, 4, 242, 16, + 32, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 104, 0, + 0, 2, 6, 0, 0, 0, + 93, 8, 0, 1, 143, 0, + 0, 3, 0, 0, 17, 0, + 0, 0, 0, 0, 92, 40, + 0, 1, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 5, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 6, 0, 0, 0, + 94, 0, 0, 2, 4, 0, + 0, 0, 49, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 16, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 191, 31, 0, + 4, 3, 10, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 21, 0, 0, 1, + 49, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 10, 16, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 31, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 21, 0, 0, 1, 49, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 26, 16, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 191, + 31, 0, 4, 3, 10, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 21, 0, + 0, 1, 49, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 26, 16, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 31, 0, + 4, 3, 10, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 21, 0, 0, 1, + 0, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 31, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 62, 58, 16, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 51, 0, + 0, 7, 34, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 8, + 66, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 50, 0, + 0, 9, 18, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 8, 98, 0, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 18, 0, + 16, 0, 1, 0, 0, 0, + 42, 128, 32, 0, 0, 0, + 0, 0, 31, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 14, 0, 0, 10, + 130, 0, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 10, 0, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 75, 0, 0, 5, 34, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 26, 128, + 32, 0, 0, 0, 0, 0, + 32, 0, 0, 0, 49, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 63, + 26, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 34, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 131, 60, + 52, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 42, 128, 32, 0, + 0, 0, 0, 0, 31, 0, + 0, 0, 14, 0, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 42, 128, + 32, 0, 0, 0, 0, 0, + 31, 0, 0, 0, 14, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 64, + 58, 0, 16, 0, 0, 0, + 0, 0, 51, 0, 0, 7, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 68, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 3, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 56, 0, + 0, 7, 178, 0, 16, 0, + 0, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 8, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 114, 0, 16, 0, 3, 0, + 0, 0, 54, 13, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 50, 0, 0, 13, 114, 0, + 16, 0, 3, 0, 0, 0, + 214, 4, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 7, 130, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 166, 138, + 32, 0, 0, 0, 0, 0, + 31, 0, 0, 0, 55, 0, + 0, 9, 178, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 12, 16, 0, 0, 0, + 0, 0, 38, 10, 16, 0, + 1, 0, 0, 0, 55, 0, + 0, 9, 242, 0, 16, 0, + 1, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 9, 242, 0, 16, 0, + 2, 0, 0, 0, 86, 133, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 50, 0, + 0, 11, 242, 0, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 6, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 11, 242, 0, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 166, 138, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 0, 0, 0, 8, + 114, 0, 16, 0, 3, 0, + 0, 0, 70, 3, 16, 0, + 0, 0, 0, 0, 70, 18, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 8, 114, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 5, 0, 0, 0, + 86, 5, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 5, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 6, 0, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 5, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 166, 10, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 8, 242, 0, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 18, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 54, 0, 0, 6, + 114, 32, 16, 0, 3, 0, + 0, 0, 70, 18, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 5, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 54, 0, 0, 8, 50, 32, + 16, 0, 6, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 117, 0, 0, 3, + 0, 0, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 3, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 18, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 8, + 114, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 5, 0, 0, 0, 86, 5, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 5, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 6, 0, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 5, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 166, 10, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 5, 0, + 0, 0, 0, 0, 0, 8, + 242, 0, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 6, 114, 32, + 16, 0, 3, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 5, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 54, 0, + 0, 8, 50, 32, 16, 0, + 6, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 117, 0, 0, 3, 0, 0, + 17, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 4, 0, 0, 0, 86, 5, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 6, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 166, 10, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 0, 0, 0, 8, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 6, 114, 32, + 16, 0, 3, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 5, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 54, 0, + 0, 8, 50, 32, 16, 0, + 6, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 117, 0, 0, 3, 0, 0, + 17, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 0, 0, 0, 8, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 6, 114, 32, + 16, 0, 3, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 5, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 54, 0, + 0, 8, 50, 32, 16, 0, + 6, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 117, 0, 0, 3, 0, 0, + 17, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 108, 0, 0, 0, 6, 0, + 0, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 55, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 5, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/diffusePS.hlsl b/demo/d3d/shaders/diffusePS.hlsl new file mode 100644 index 0000000..b548b49 --- /dev/null +++ b/demo/d3d/shaders/diffusePS.hlsl @@ -0,0 +1,29 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + DiffuseShaderConst gParams; +}; + +float sqr(float x) { return x * x; } + +float4 diffusePS(DiffuseGeometryOut input) : SV_TARGET +{ + float attenuation = 1.0f; + float lifeTime = input.worldPos.w; + float lifeFade = min(1.0, lifeTime*0.125); + float velocityFade = input.viewVel.w; + + // calculate normal from texture coordinates + float3 normal = float3(input.uv * 2.0 + float2(-1.0, -1.0), 0.0); + float mag = dot(normal.xy, normal.xy); + + // kill pixels outside circle + if (mag > 1.0) + discard; + + normal.z = 1.0-mag; + + float alpha = lifeFade*velocityFade*sqr(normal.z); + return float4(alpha, alpha, alpha, alpha); +} diff --git a/demo/d3d/shaders/diffusePS.hlsl.h b/demo/d3d/shaders/diffusePS.hlsl.h new file mode 100644 index 0000000..44a31b1 --- /dev/null +++ b/demo/d3d/shaders/diffusePS.hlsl.h @@ -0,0 +1,216 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// POSITION 0 xyzw 1 NONE float w +// VIEWPOS 0 xyzw 2 NONE float +// VIEWVEL 0 xyzw 3 NONE float w +// LIGHTDIR 0 xyzw 4 NONE float +// COLOR 0 xyzw 5 NONE float +// UV 0 xy 6 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_input_ps linear v1.w +dcl_input_ps linear v3.w +dcl_input_ps linear v6.xy +dcl_output o0.xyzw +dcl_temps 1 +mad r0.xy, v6.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000) +dp2 r0.x, r0.xyxx, r0.xyxx +lt r0.y, l(1.000000), r0.x +discard_nz r0.y +mul r0.y, v1.w, l(0.125000) +min r0.y, r0.y, l(1.000000) +add r0.x, -r0.x, l(1.000000) +mul r0.y, r0.y, v3.w +mul r0.x, r0.x, r0.x +mul o0.xyzw, r0.xxxx, r0.yyyy +ret +// Approximately 11 instruction slots used +#endif + +const BYTE g_diffusePS[] = +{ + 68, 88, 66, 67, 226, 109, + 117, 161, 154, 99, 48, 92, + 15, 92, 142, 117, 138, 39, + 5, 123, 1, 0, 0, 0, + 232, 3, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 156, 1, + 0, 0, 208, 1, 0, 0, + 76, 3, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 232, 0, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 176, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 188, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 8, + 0, 0, 197, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 205, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 8, + 0, 0, 213, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 222, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 15, 0, + 0, 0, 228, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 86, + 73, 69, 87, 80, 79, 83, + 0, 86, 73, 69, 87, 86, + 69, 76, 0, 76, 73, 71, + 72, 84, 68, 73, 82, 0, + 67, 79, 76, 79, 82, 0, + 85, 86, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 65, 82, 71, 69, 84, 0, + 171, 171, 83, 72, 69, 88, + 116, 1, 0, 0, 80, 0, + 0, 0, 93, 0, 0, 0, + 106, 8, 0, 1, 98, 16, + 0, 3, 130, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 130, 16, 16, 0, + 3, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 6, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 50, 0, 0, 15, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 6, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 191, + 0, 0, 128, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 34, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 10, 0, 16, 0, 0, 0, + 0, 0, 13, 0, 4, 3, + 26, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 34, 0, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 62, + 51, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 32, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 11, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 9, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/diffuseVS.hlsl b/demo/d3d/shaders/diffuseVS.hlsl new file mode 100644 index 0000000..303b896 --- /dev/null +++ b/demo/d3d/shaders/diffuseVS.hlsl @@ -0,0 +1,25 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + DiffuseShaderConst gParams; +}; + +DiffuseVertexOut diffuseVS(DiffuseVertexIn input) +{ + float3 worldPos = input.position.xyz; + float4 eyePos = mul(gParams.modelView, float4(worldPos, 1.0)); + + DiffuseVertexOut output; + + output.worldPos = input.position; // lifetime in w + output.viewPos = eyePos; + output.viewVel = mul(gParams.modelView, float4(input.velocity.xyz, 0.0)); + output.color = gParams.color; + + // compute ndc pos for frustrum culling in GS + float4 ndcPos = mul(gParams.modelViewProjection, float4(worldPos.xyz, 1.0)); + output.ndcPos = ndcPos / ndcPos.w; + + return output; +} diff --git a/demo/d3d/shaders/diffuseVS.hlsl.h b/demo/d3d/shaders/diffuseVS.hlsl.h new file mode 100644 index 0000000..7db0a8c --- /dev/null +++ b/demo/d3d/shaders/diffuseVS.hlsl.h @@ -0,0 +1,425 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct DiffuseShaderConst +// { +// +// float3 lightPos; // Offset: 0 +// float pad0; // Offset: 12 +// float3 lightDir; // Offset: 16 +// float pad1; // Offset: 28 +// float4x4 lightTransform; // Offset: 32 +// float4 color; // Offset: 96 +// float4x4 modelView; // Offset: 112 +// float4x4 modelViewProjection; // Offset: 176 +// float4x4 projection; // Offset: 240 +// float4 shadowTaps[12]; // Offset: 304 +// float diffusion; // Offset: 496 +// float diffuseRadius; // Offset: 500 +// float diffuseScale; // Offset: 504 +// float spotMin; // Offset: 508 +// float spotMax; // Offset: 512 +// float motionBlurScale; // Offset: 516 +// float pad3; // Offset: 520 +// float pad4; // Offset: 524 +// +// } gParams; // Offset: 0 Size: 528 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// VELOCITY 0 xyzw 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// NCDPOS 0 xyzw 1 NONE float xyzw +// VIEWPOS 0 xyzw 2 NONE float xyzw +// VIEWVEL 0 xyzw 3 NONE float xyzw +// COLOR 0 xyzw 4 NONE float xyzw +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[15], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xyzw +dcl_output o3.xyzw +dcl_output o4.xyzw +dcl_temps 1 +mov o0.xyzw, v0.xyzw +mul r0.xyzw, v0.yyyy, cb0[12].xyzw +mad r0.xyzw, cb0[11].xyzw, v0.xxxx, r0.xyzw +mad r0.xyzw, cb0[13].xyzw, v0.zzzz, r0.xyzw +add r0.xyzw, r0.xyzw, cb0[14].xyzw +div o1.xyzw, r0.xyzw, r0.wwww +mul r0.xyzw, v0.yyyy, cb0[8].xyzw +mad r0.xyzw, cb0[7].xyzw, v0.xxxx, r0.xyzw +mad r0.xyzw, cb0[9].xyzw, v0.zzzz, r0.xyzw +add o2.xyzw, r0.xyzw, cb0[10].xyzw +mul r0.xyzw, v1.yyyy, cb0[8].xyzw +mad r0.xyzw, cb0[7].xyzw, v1.xxxx, r0.xyzw +mad o3.xyzw, cb0[9].xyzw, v1.zzzz, r0.xyzw +mov o4.xyzw, cb0[6].xyzw +ret +// Approximately 15 instruction slots used +#endif + +const BYTE g_diffuseVS[] = +{ + 68, 88, 66, 67, 169, 46, + 39, 192, 132, 15, 181, 233, + 181, 235, 144, 49, 232, 212, + 251, 135, 1, 0, 0, 0, + 184, 7, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 188, 3, 0, 0, 16, 4, + 0, 0, 192, 4, 0, 0, + 28, 7, 0, 0, 82, 68, + 69, 70, 128, 3, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 76, 3, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 16, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 16, 2, + 0, 0, 2, 0, 0, 0, + 40, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 68, 105, 102, 102, + 117, 115, 101, 83, 104, 97, + 100, 101, 114, 67, 111, 110, + 115, 116, 0, 108, 105, 103, + 104, 116, 80, 111, 115, 0, + 102, 108, 111, 97, 116, 51, + 0, 171, 1, 0, 3, 0, + 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 204, 0, + 0, 0, 112, 97, 100, 48, + 0, 102, 108, 111, 97, 116, + 0, 171, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 253, 0, + 0, 0, 108, 105, 103, 104, + 116, 68, 105, 114, 0, 112, + 97, 100, 49, 0, 108, 105, + 103, 104, 116, 84, 114, 97, + 110, 115, 102, 111, 114, 109, + 0, 102, 108, 111, 97, 116, + 52, 120, 52, 0, 171, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 69, 1, 0, 0, + 99, 111, 108, 111, 114, 0, + 102, 108, 111, 97, 116, 52, + 0, 171, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 122, 1, 0, 0, 109, 111, + 100, 101, 108, 86, 105, 101, + 119, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 80, + 114, 111, 106, 101, 99, 116, + 105, 111, 110, 0, 112, 114, + 111, 106, 101, 99, 116, 105, + 111, 110, 0, 115, 104, 97, + 100, 111, 119, 84, 97, 112, + 115, 0, 1, 0, 3, 0, + 1, 0, 4, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 122, 1, + 0, 0, 100, 105, 102, 102, + 117, 115, 105, 111, 110, 0, + 100, 105, 102, 102, 117, 115, + 101, 82, 97, 100, 105, 117, + 115, 0, 100, 105, 102, 102, + 117, 115, 101, 83, 99, 97, + 108, 101, 0, 115, 112, 111, + 116, 77, 105, 110, 0, 115, + 112, 111, 116, 77, 97, 120, + 0, 109, 111, 116, 105, 111, + 110, 66, 108, 117, 114, 83, + 99, 97, 108, 101, 0, 112, + 97, 100, 51, 0, 112, 97, + 100, 52, 0, 171, 195, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 248, 0, + 0, 0, 4, 1, 0, 0, + 12, 0, 0, 0, 40, 1, + 0, 0, 212, 0, 0, 0, + 16, 0, 0, 0, 49, 1, + 0, 0, 4, 1, 0, 0, + 28, 0, 0, 0, 54, 1, + 0, 0, 80, 1, 0, 0, + 32, 0, 0, 0, 116, 1, + 0, 0, 132, 1, 0, 0, + 96, 0, 0, 0, 168, 1, + 0, 0, 80, 1, 0, 0, + 112, 0, 0, 0, 178, 1, + 0, 0, 80, 1, 0, 0, + 176, 0, 0, 0, 198, 1, + 0, 0, 80, 1, 0, 0, + 240, 0, 0, 0, 209, 1, + 0, 0, 220, 1, 0, 0, + 48, 1, 0, 0, 0, 2, + 0, 0, 4, 1, 0, 0, + 240, 1, 0, 0, 10, 2, + 0, 0, 4, 1, 0, 0, + 244, 1, 0, 0, 24, 2, + 0, 0, 4, 1, 0, 0, + 248, 1, 0, 0, 37, 2, + 0, 0, 4, 1, 0, 0, + 252, 1, 0, 0, 45, 2, + 0, 0, 4, 1, 0, 0, + 0, 2, 0, 0, 53, 2, + 0, 0, 4, 1, 0, 0, + 4, 2, 0, 0, 69, 2, + 0, 0, 4, 1, 0, 0, + 8, 2, 0, 0, 74, 2, + 0, 0, 4, 1, 0, 0, + 12, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 132, 0, + 0, 0, 18, 0, 80, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 176, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 7, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 86, 69, 76, + 79, 67, 73, 84, 89, 0, + 171, 171, 79, 83, 71, 78, + 168, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 144, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 152, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 160, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 78, 67, 68, + 80, 79, 83, 0, 86, 73, + 69, 87, 80, 79, 83, 0, + 86, 73, 69, 87, 86, 69, + 76, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 83, 72, + 69, 88, 84, 2, 0, 0, + 80, 0, 1, 0, 149, 0, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 4, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 0, 0, + 0, 0, 86, 21, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 6, 16, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 166, 26, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 14, 0, 0, 7, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 0, 0, 0, 0, + 86, 21, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 6, 16, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 166, 26, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 8, 242, 32, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 0, 0, 0, 0, + 86, 21, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 6, 16, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 242, 32, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 166, 26, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 15, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/demo/d3d/shaders/ellipsoidDepthGS.hlsl b/demo/d3d/shaders/ellipsoidDepthGS.hlsl new file mode 100644 index 0000000..92169d3 --- /dev/null +++ b/demo/d3d/shaders/ellipsoidDepthGS.hlsl @@ -0,0 +1,65 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + FluidShaderConst gParams; +}; + +static const float2 corners[4] = +{ + float2(0.0, 1.0), float2(0.0, 0.0), float2(1.0, 1.0), float2(1.0, 0.0) +}; + +[maxvertexcount(4)] +void ellipsoidDepthGS(point FluidVertexOut input[1], inout TriangleStream triStream) +{ + const float4 ndcPos = input[0].ndcPos; + // frustrum culling + const float ndcBound = 1.0; + if (any(abs(ndcPos.xy) > ndcBound)) + { + return; + } + + float4 bounds = input[0].bounds; + + const float4 invQuad0 = input[0].invQ0; + const float4 invQuad1 = input[0].invQ1; + const float4 invQuad2 = input[0].invQ2; + const float4 invQuad3 = input[0].invQ3; + + float xmin = bounds.x; + float xmax = bounds.y; + float ymin = bounds.z; + float ymax = bounds.w; + + FluidGeoOut output; + + output.position = float4(xmin, ymax, 0.5, 1.0); + output.invQ0 = invQuad0; + output.invQ1 = invQuad1; + output.invQ2 = invQuad2; + output.invQ3 = invQuad3; + triStream.Append(output); + + output.position = float4(xmin, ymin, 0.5, 1.0); + output.invQ0 = invQuad0; + output.invQ1 = invQuad1; + output.invQ2 = invQuad2; + output.invQ3 = invQuad3; + triStream.Append(output); + + output.position = float4(xmax, ymax, 0.5, 1.0); + output.invQ0 = invQuad0; + output.invQ1 = invQuad1; + output.invQ2 = invQuad2; + output.invQ3 = invQuad3; + triStream.Append(output); + + output.position = float4(xmax, ymin, 0.5, 1.0); + output.invQ0 = invQuad0; + output.invQ1 = invQuad1; + output.invQ2 = invQuad2; + output.invQ3 = invQuad3; + triStream.Append(output); +} diff --git a/demo/d3d/shaders/ellipsoidDepthGS.hlsl.h b/demo/d3d/shaders/ellipsoidDepthGS.hlsl.h new file mode 100644 index 0000000..5966899 --- /dev/null +++ b/demo/d3d/shaders/ellipsoidDepthGS.hlsl.h @@ -0,0 +1,372 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float +// TEXCOORD 0 xyzw 1 NONE float xyzw +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyzw 3 NONE float xyzw +// TEXCOORD 3 xyzw 4 NONE float xyzw +// TEXCOORD 4 xyzw 5 NONE float xyzw +// TEXCOORD 5 xyzw 6 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xyzw 1 NONE float xyzw +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyzw 3 NONE float xyzw +// TEXCOORD 3 xyzw 4 NONE float xyzw +// +gs_5_0 +dcl_globalFlags refactoringAllowed +dcl_input v[1][0].xyzw +dcl_input v[1][1].xyzw +dcl_input v[1][2].xyzw +dcl_input v[1][3].xyzw +dcl_input v[1][4].xyzw +dcl_input v[1][5].xyzw +dcl_input v[1][6].xyzw +dcl_temps 1 +dcl_inputprimitive point +dcl_stream m0 +dcl_outputtopology trianglestrip +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xyzw +dcl_output o3.xyzw +dcl_output o4.xyzw +dcl_maxout 4 +lt r0.xy, l(1.000000, 1.000000, 0.000000, 0.000000), |v[0][6].xyxx| +or r0.x, r0.y, r0.x +if_nz r0.x + ret +endif +mov o0.xy, v[0][1].xwxx +mov o0.zw, l(0,0,0.500000,1.000000) +mov o1.xyzw, v[0][2].xyzw +mov o2.xyzw, v[0][3].xyzw +mov o3.xyzw, v[0][4].xyzw +mov o4.xyzw, v[0][5].xyzw +emit_stream m0 +mov o0.xy, v[0][1].xzxx +mov o0.zw, l(0,0,0.500000,1.000000) +mov o1.xyzw, v[0][2].xyzw +mov o2.xyzw, v[0][3].xyzw +mov o3.xyzw, v[0][4].xyzw +mov o4.xyzw, v[0][5].xyzw +emit_stream m0 +mov o0.xy, v[0][1].ywyy +mov o0.zw, l(0,0,0.500000,1.000000) +mov o1.xyzw, v[0][2].xyzw +mov o2.xyzw, v[0][3].xyzw +mov o3.xyzw, v[0][4].xyzw +mov o4.xyzw, v[0][5].xyzw +emit_stream m0 +mov o0.xy, v[0][1].yzyy +mov o0.zw, l(0,0,0.500000,1.000000) +mov o1.xyzw, v[0][2].xyzw +mov o2.xyzw, v[0][3].xyzw +mov o3.xyzw, v[0][4].xyzw +mov o4.xyzw, v[0][5].xyzw +emit_stream m0 +ret +// Approximately 34 instruction slots used +#endif + +const BYTE g_ellipsoidDepthGS[] = +{ + 68, 88, 66, 67, 152, 192, + 203, 71, 86, 80, 184, 94, + 47, 161, 87, 71, 136, 207, + 121, 6, 1, 0, 0, 0, + 164, 6, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 120, 1, + 0, 0, 44, 2, 0, 0, + 8, 6, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 83, 71, 0, 1, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 196, 0, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 176, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 185, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 185, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 15, + 0, 0, 185, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 15, + 0, 0, 185, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 15, 15, + 0, 0, 185, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 3, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 171, 171, 79, 83, + 71, 53, 172, 0, 0, 0, + 5, 0, 0, 0, 8, 0, + 0, 0, 0, 0, 0, 0, + 148, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 160, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 0, 0, + 0, 0, 160, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 0, 0, 0, 0, + 160, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 160, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 171, 171, 83, 72, + 69, 88, 212, 3, 0, 0, + 80, 0, 2, 0, 245, 0, + 0, 0, 106, 8, 0, 1, + 95, 0, 0, 4, 242, 16, + 32, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 95, 0, + 0, 4, 242, 16, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 95, 0, 0, 4, + 242, 16, 32, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 95, 0, 0, 4, 242, 16, + 32, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 95, 0, + 0, 4, 242, 16, 32, 0, + 1, 0, 0, 0, 4, 0, + 0, 0, 95, 0, 0, 4, + 242, 16, 32, 0, 1, 0, + 0, 0, 5, 0, 0, 0, + 95, 0, 0, 4, 242, 16, + 32, 0, 1, 0, 0, 0, + 6, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 93, 8, 0, 1, 143, 0, + 0, 3, 0, 0, 17, 0, + 0, 0, 0, 0, 92, 40, + 0, 1, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 4, 0, 0, 0, + 94, 0, 0, 2, 4, 0, + 0, 0, 49, 0, 0, 12, + 50, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 16, + 32, 128, 129, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 60, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 31, 0, 4, 3, 10, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 21, 0, + 0, 1, 54, 0, 0, 6, + 50, 32, 16, 0, 0, 0, + 0, 0, 198, 16, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 8, + 194, 32, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 63, + 0, 0, 128, 63, 54, 0, + 0, 6, 242, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 117, 0, + 0, 3, 0, 0, 17, 0, + 0, 0, 0, 0, 54, 0, + 0, 6, 50, 32, 16, 0, + 0, 0, 0, 0, 134, 16, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 54, 0, + 0, 8, 194, 32, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 63, 0, 0, 128, 63, + 54, 0, 0, 6, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 117, 0, 0, 3, 0, 0, + 17, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 50, 32, + 16, 0, 0, 0, 0, 0, + 214, 21, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 8, 194, 32, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 128, 63, 54, 0, 0, 6, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 117, 0, 0, 3, + 0, 0, 17, 0, 0, 0, + 0, 0, 54, 0, 0, 6, + 50, 32, 16, 0, 0, 0, + 0, 0, 150, 21, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 8, + 194, 32, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 63, + 0, 0, 128, 63, 54, 0, + 0, 6, 242, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 117, 0, + 0, 3, 0, 0, 17, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 34, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/demo/d3d/shaders/ellipsoidDepthPS.hlsl b/demo/d3d/shaders/ellipsoidDepthPS.hlsl new file mode 100644 index 0000000..ccccc69 --- /dev/null +++ b/demo/d3d/shaders/ellipsoidDepthPS.hlsl @@ -0,0 +1,88 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + FluidShaderConst gParams; +}; + +float Sign(float x) { return x < 0.0 ? -1.0 : 1.0; } + +bool solveQuadratic(float a, float b, float c, out float minT, out float maxT) +{ +#if 0 + minT = 0.0f; + maxT = 0.0f; +#endif + + if (a == 0.0 && b == 0.0) + { + minT = maxT = 0.0; + return true; + } + + float discriminant = b*b - 4.0*a*c; + + if (discriminant < 0.0) + { + return false; + } + + float t = -0.5*(b + Sign(b)*sqrt(discriminant)); + minT = t / a; + maxT = c / t; + + if (minT > maxT) + { + float tmp = minT; + minT = maxT; + maxT = tmp; + } + + return true; +} + +float sqr(float x) { return x * x; } + +float ellipsoidDepthPS(FluidGeoOut input , out float depthOut : SV_DEPTH) : SV_TARGET +{ + const float4x4 projectionMatrix = gParams.projection; + const float4x4 projectionMatrixInverse = gParams.inverseProjection; + const float3 invViewport = gParams.invViewport; + const float4 position = input.position; + + // transform from view space to parameter space + //column_major + float4x4 invQuadric; + invQuadric._m00_m10_m20_m30 = input.invQ0; + invQuadric._m01_m11_m21_m31 = input.invQ1; + invQuadric._m02_m12_m22_m32 = input.invQ2; + invQuadric._m03_m13_m23_m33 = input.invQ3; + + float4 ndcPos = float4(position.x*invViewport.x*2.0f-1.0f, (1.0f-position.y*invViewport.y)*2.0 - 1.0, 0.0f, 1.0); + float4 viewDir = mul(projectionMatrixInverse, ndcPos); + + // ray to parameter space + float4 dir = mul(invQuadric, float4(viewDir.xyz, 0.0)); + float4 origin = invQuadric._m03_m13_m23_m33; + + // set up quadratric equation + float a = sqr(dir.x) + sqr(dir.y) + sqr(dir.z); + float b = dir.x*origin.x + dir.y*origin.y + dir.z*origin.z - dir.w*origin.w; + float c = sqr(origin.x) + sqr(origin.y) + sqr(origin.z) - sqr(origin.w); + + float minT; + float maxT; + + if (!solveQuadratic(a, 2.0 * b, c, minT, maxT)) + { + discard; + } + { + float3 eyePos = viewDir.xyz*minT; + float4 ndcPos = mul(projectionMatrix, float4(eyePos, 1.0)); + ndcPos.z /= ndcPos.w; + + depthOut = ndcPos.z; + return eyePos.z; + } +} diff --git a/demo/d3d/shaders/ellipsoidDepthPS.hlsl.h b/demo/d3d/shaders/ellipsoidDepthPS.hlsl.h new file mode 100644 index 0000000..7e007a5 --- /dev/null +++ b/demo/d3d/shaders/ellipsoidDepthPS.hlsl.h @@ -0,0 +1,643 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct FluidShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 projection; // Offset: 128 +// float4x4 inverseModelView; // Offset: 192 +// float4x4 inverseProjection; // Offset: 256 +// float4 invTexScale; // Offset: 320 +// float3 invViewport; // Offset: 336 +// float _pad0; // Offset: 348 +// float blurRadiusWorld; // Offset: 352 +// float blurScale; // Offset: 356 +// float blurFalloff; // Offset: 360 +// int debug; // Offset: 364 +// float3 lightPos; // Offset: 368 +// float _pad1; // Offset: 380 +// float3 lightDir; // Offset: 384 +// float _pad2; // Offset: 396 +// float4x4 lightTransform; // Offset: 400 +// float4 color; // Offset: 464 +// float4 clipPosToEye; // Offset: 480 +// float spotMin; // Offset: 496 +// float spotMax; // Offset: 500 +// float ior; // Offset: 504 +// float _pad3; // Offset: 508 +// float4 shadowTaps[12]; // Offset: 512 +// +// } gParams; // Offset: 0 Size: 704 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xy +// TEXCOORD 0 xyzw 1 NONE float xyzw +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyzw 3 NONE float xyzw +// TEXCOORD 3 xyzw 4 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 x 0 TARGET float x +// SV_DEPTH 0 N/A oDepth DEPTH float YES +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[22], immediateIndexed +dcl_input_ps_siv linear noperspective v0.xy, position +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xyzw +dcl_input_ps linear v3.xyzw +dcl_input_ps linear v4.xyzw +dcl_output o0.x +dcl_output oDepth +dcl_temps 4 +dp2 r0.x, v0.xxxx, cb0[21].xxxx +add r0.x, r0.x, l(-1.000000) +mad r0.y, -v0.y, cb0[21].y, l(1.000000) +mad r0.y, r0.y, l(2.000000), l(-1.000000) +mul r0.yzw, r0.yyyy, cb0[17].xxyz +mad r0.xyz, cb0[16].xyzx, r0.xxxx, r0.yzwy +add r0.xyz, r0.xyzx, cb0[19].xyzx +mul r1.xyzw, r0.yyyy, v2.xyzw +mad r1.xyzw, v1.xyzw, r0.xxxx, r1.xyzw +mad r1.xyzw, v3.xyzw, r0.zzzz, r1.xyzw +dp3 r0.w, r1.xyzx, r1.xyzx +dp3 r1.x, r1.xyzx, v4.xyzx +mad r1.x, -r1.w, v4.w, r1.x +dp3 r1.y, v4.xyzx, v4.xyzx +mad r1.y, -v4.w, v4.w, r1.y +add r1.z, r1.x, r1.x +eq r1.w, r0.w, l(0.000000) +eq r2.x, r1.x, l(0.000000) +and r1.w, r1.w, r2.x +mul r2.x, r0.w, r1.y +mul r2.x, r2.x, l(4.000000) +mad r2.x, r1.z, r1.z, -r2.x +lt r2.y, r2.x, l(0.000000) +not r3.y, r2.y +lt r1.x, r1.x, l(0.000000) +movc r1.x, r1.x, l(-1.000000), l(1.000000) +sqrt r2.x, r2.x +mad r1.x, r1.x, r2.x, r1.z +mul r1.x, r1.x, l(-0.500000) +div r0.w, r1.x, r0.w +div r1.x, r1.y, r1.x +lt r1.y, r1.x, r0.w +movc r3.z, r1.y, r1.x, r0.w +mov r3.xw, l(0,0,0,-1) +movc r1.xy, r2.yyyy, r3.xyxx, r3.zwzz +movc r1.xy, r1.wwww, l(0,-1,0,0), r1.xyxx +not r0.w, r1.y +discard_nz r0.w +mul r0.xyz, r0.xyzx, r1.xxxx +mul r0.yw, r0.yyyy, cb0[9].zzzw +mad r0.xy, cb0[8].zwzz, r0.xxxx, r0.ywyy +mad r0.xy, cb0[10].zwzz, r0.zzzz, r0.xyxx +add r0.xy, r0.xyxx, cb0[11].zwzz +div oDepth, r0.x, r0.y +mov o0.x, r0.z +ret +// Approximately 46 instruction slots used +#endif + +const BYTE g_ellipsoidDepthPS[] = +{ + 68, 88, 66, 67, 108, 237, + 133, 240, 171, 175, 220, 253, + 207, 147, 106, 237, 177, 103, + 173, 51, 1, 0, 0, 0, + 248, 11, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 112, 4, 0, 0, 16, 5, + 0, 0, 100, 5, 0, 0, + 92, 11, 0, 0, 82, 68, + 69, 70, 52, 4, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 0, 4, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 192, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 192, 2, + 0, 0, 2, 0, 0, 0, + 220, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 70, 108, 117, 105, + 100, 83, 104, 97, 100, 101, + 114, 67, 111, 110, 115, 116, + 0, 109, 111, 100, 101, 108, + 86, 105, 101, 119, 80, 114, + 111, 106, 101, 99, 116, 105, + 111, 110, 0, 102, 108, 111, + 97, 116, 52, 120, 52, 0, + 171, 171, 3, 0, 3, 0, + 4, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 213, 0, + 0, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 0, + 112, 114, 111, 106, 101, 99, + 116, 105, 111, 110, 0, 105, + 110, 118, 101, 114, 115, 101, + 77, 111, 100, 101, 108, 86, + 105, 101, 119, 0, 105, 110, + 118, 101, 114, 115, 101, 80, + 114, 111, 106, 101, 99, 116, + 105, 111, 110, 0, 105, 110, + 118, 84, 101, 120, 83, 99, + 97, 108, 101, 0, 102, 108, + 111, 97, 116, 52, 0, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 72, 1, 0, 0, + 105, 110, 118, 86, 105, 101, + 119, 112, 111, 114, 116, 0, + 102, 108, 111, 97, 116, 51, + 0, 171, 1, 0, 3, 0, + 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 1, + 0, 0, 95, 112, 97, 100, + 48, 0, 102, 108, 111, 97, + 116, 0, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 178, 1, + 0, 0, 98, 108, 117, 114, + 82, 97, 100, 105, 117, 115, + 87, 111, 114, 108, 100, 0, + 98, 108, 117, 114, 83, 99, + 97, 108, 101, 0, 98, 108, + 117, 114, 70, 97, 108, 108, + 111, 102, 102, 0, 100, 101, + 98, 117, 103, 0, 105, 110, + 116, 0, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 8, 2, + 0, 0, 108, 105, 103, 104, + 116, 80, 111, 115, 0, 95, + 112, 97, 100, 49, 0, 108, + 105, 103, 104, 116, 68, 105, + 114, 0, 95, 112, 97, 100, + 50, 0, 108, 105, 103, 104, + 116, 84, 114, 97, 110, 115, + 102, 111, 114, 109, 0, 99, + 111, 108, 111, 114, 0, 99, + 108, 105, 112, 80, 111, 115, + 84, 111, 69, 121, 101, 0, + 115, 112, 111, 116, 77, 105, + 110, 0, 115, 112, 111, 116, + 77, 97, 120, 0, 105, 111, + 114, 0, 95, 112, 97, 100, + 51, 0, 115, 104, 97, 100, + 111, 119, 84, 97, 112, 115, + 0, 171, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 12, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 72, 1, 0, 0, 193, 0, + 0, 0, 224, 0, 0, 0, + 0, 0, 0, 0, 4, 1, + 0, 0, 224, 0, 0, 0, + 64, 0, 0, 0, 14, 1, + 0, 0, 224, 0, 0, 0, + 128, 0, 0, 0, 25, 1, + 0, 0, 224, 0, 0, 0, + 192, 0, 0, 0, 42, 1, + 0, 0, 224, 0, 0, 0, + 0, 1, 0, 0, 60, 1, + 0, 0, 80, 1, 0, 0, + 64, 1, 0, 0, 116, 1, + 0, 0, 136, 1, 0, 0, + 80, 1, 0, 0, 172, 1, + 0, 0, 184, 1, 0, 0, + 92, 1, 0, 0, 220, 1, + 0, 0, 184, 1, 0, 0, + 96, 1, 0, 0, 236, 1, + 0, 0, 184, 1, 0, 0, + 100, 1, 0, 0, 246, 1, + 0, 0, 184, 1, 0, 0, + 104, 1, 0, 0, 2, 2, + 0, 0, 12, 2, 0, 0, + 108, 1, 0, 0, 48, 2, + 0, 0, 136, 1, 0, 0, + 112, 1, 0, 0, 57, 2, + 0, 0, 184, 1, 0, 0, + 124, 1, 0, 0, 63, 2, + 0, 0, 136, 1, 0, 0, + 128, 1, 0, 0, 72, 2, + 0, 0, 184, 1, 0, 0, + 140, 1, 0, 0, 78, 2, + 0, 0, 224, 0, 0, 0, + 144, 1, 0, 0, 93, 2, + 0, 0, 80, 1, 0, 0, + 208, 1, 0, 0, 99, 2, + 0, 0, 80, 1, 0, 0, + 224, 1, 0, 0, 112, 2, + 0, 0, 184, 1, 0, 0, + 240, 1, 0, 0, 120, 2, + 0, 0, 184, 1, 0, 0, + 244, 1, 0, 0, 128, 2, + 0, 0, 184, 1, 0, 0, + 248, 1, 0, 0, 132, 2, + 0, 0, 184, 1, 0, 0, + 252, 1, 0, 0, 138, 2, + 0, 0, 152, 2, 0, 0, + 0, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 176, 0, + 0, 0, 24, 0, 188, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 176, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 152, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 3, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 171, 171, + 79, 83, 71, 78, 76, 0, + 0, 0, 2, 0, 0, 0, + 8, 0, 0, 0, 56, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 1, 14, 0, 0, 66, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 255, 255, 255, 255, + 1, 14, 0, 0, 83, 86, + 95, 84, 65, 82, 71, 69, + 84, 0, 83, 86, 95, 68, + 69, 80, 84, 72, 0, 171, + 83, 72, 69, 88, 240, 5, + 0, 0, 80, 0, 0, 0, + 124, 1, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 100, 32, 0, 4, 50, 16, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 18, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 2, 1, 192, 0, 0, + 104, 0, 0, 2, 4, 0, + 0, 0, 15, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 0, 0, 0, 0, 6, 128, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 0, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 191, 50, 0, 0, 11, + 34, 0, 16, 0, 0, 0, + 0, 0, 26, 16, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 26, 128, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 50, 0, + 0, 9, 34, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 64, 1, 64, 0, 0, + 0, 0, 128, 191, 56, 0, + 0, 8, 226, 0, 16, 0, + 0, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 1, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 9, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 9, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 3, 0, 0, 0, + 166, 10, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 10, 18, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 58, 16, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 4, 0, + 0, 0, 50, 0, 0, 10, + 34, 0, 16, 0, 1, 0, + 0, 0, 58, 16, 16, 128, + 65, 0, 0, 0, 4, 0, + 0, 0, 58, 16, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 24, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 24, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 64, + 50, 0, 0, 10, 18, 0, + 16, 0, 2, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 128, 65, 0, 0, 0, + 2, 0, 0, 0, 49, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 59, 0, 0, 5, + 34, 0, 16, 0, 3, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 49, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 55, 0, 0, 9, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 191, + 1, 64, 0, 0, 0, 0, + 128, 63, 75, 0, 0, 5, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 9, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 191, 14, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 14, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 49, 0, + 0, 7, 34, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 55, 0, 0, 9, + 66, 0, 16, 0, 3, 0, + 0, 0, 26, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 8, + 146, 0, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 55, 0, + 0, 9, 50, 0, 16, 0, + 1, 0, 0, 0, 86, 5, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 230, 10, 16, 0, + 3, 0, 0, 0, 55, 0, + 0, 12, 50, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 1, 0, 0, 0, 59, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 1, 0, 0, 0, + 13, 0, 4, 3, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 162, 0, 16, 0, + 0, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 166, 142, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 50, 0, 0, 10, 50, 0, + 16, 0, 0, 0, 0, 0, + 230, 138, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 214, 5, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 50, 0, 16, 0, + 0, 0, 0, 0, 230, 138, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 50, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 230, 138, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 14, 0, + 0, 6, 1, 192, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 18, 32, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 46, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 35, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/ellipsoidDepthVS.hlsl b/demo/d3d/shaders/ellipsoidDepthVS.hlsl new file mode 100644 index 0000000..f26317e --- /dev/null +++ b/demo/d3d/shaders/ellipsoidDepthVS.hlsl @@ -0,0 +1,118 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + FluidShaderConst gParams; +}; + +// returns 1.0 for x==0.0 (unlike glsl) +float Sign(float x) { return x < 0.0 ? -1.0 : 1.0; } + +bool solveQuadratic(float a, float b, float c, out float minT, out float maxT) +{ +#if 0 + // for debugging + minT = -0.5; + maxT = 0.5; + return true; +#else + //minT = 0.0f; + //maxT = 0.0f; +#endif + + if (a == 0.0 && b == 0.0) + { + minT = maxT = 0.0; + return false; + } + + float discriminant = b*b - 4.0*a*c; + + if (discriminant < 0.0) + { + return false; + } + + float t = -0.5*(b + Sign(b)*sqrt(discriminant)); + minT = t / a; + maxT = c / t; + + if (minT > maxT) + { + float tmp = minT; + minT = maxT; + maxT = tmp; + } + + return true; +} + +float DotInvW(float4 a, float4 b) { return a.x*b.x + a.y*b.y + a.z*b.z - a.w*b.w; } + +FluidVertexOut ellipsoidDepthVS(FluidVertexIn input, uint instance : SV_VertexID) +{ + const float4 q1 = input.q1; + const float4 q2 = input.q2; + const float4 q3 = input.q3; + + const float4x4 modelViewProjectionMatrix = gParams.modelViewProjection; + const float4x4 modelViewMatrixInverse = gParams.inverseModelView; + + float3 worldPos = input.position.xyz; + + // construct quadric matrix + float4x4 q; + q._m00_m10_m20_m30 = float4(q1.xyz*q1.w, 0.0); + q._m01_m11_m21_m31 = float4(q2.xyz*q2.w, 0.0); + q._m02_m12_m22_m32 = float4(q3.xyz*q3.w, 0.0); + q._m03_m13_m23_m33 = float4(worldPos, 1.0); + + // transforms a normal to parameter space (inverse transpose of (q*modelview)^-T) + float4x4 invClip = mul(modelViewProjectionMatrix, q); + + // solve for the right hand bounds in homogenous clip space + float a1 = DotInvW(invClip[3], invClip[3]); + float b1 = -2.0f*DotInvW(invClip[0], invClip[3]); + float c1 = DotInvW(invClip[0], invClip[0]); + + float xmin; + float xmax; + solveQuadratic(a1, b1, c1, xmin, xmax); + + // solve for the right hand bounds in homogenous clip space + float a2 = DotInvW(invClip[3], invClip[3]); + float b2 = -2.0f*DotInvW(invClip[1], invClip[3]); + float c2 = DotInvW(invClip[1], invClip[1]); + + float ymin; + float ymax; + solveQuadratic(a2, b2, c2, ymin, ymax); + + FluidVertexOut output; + output.position = float4(worldPos.xyz, 1.0); + output.bounds = float4(xmin, xmax, ymin, ymax); + + // construct inverse quadric matrix (used for ray-casting in parameter space) + float4x4 invq; + invq._m00_m10_m20_m30 = float4(q1.xyz / q1.w, 0.0); + invq._m01_m11_m21_m31 = float4(q2.xyz / q2.w, 0.0); + invq._m02_m12_m22_m32 = float4(q3.xyz / q3.w, 0.0); + invq._m03_m13_m23_m33 = float4(0.0, 0.0, 0.0, 1.0); + + invq = transpose(invq); + invq._m03_m13_m23_m33 = -(mul(invq, output.position)); + + // transform a point from view space to parameter space + invq = mul(invq, modelViewMatrixInverse); + + // pass down + output.invQ0 = invq._m00_m10_m20_m30; + output.invQ1 = invq._m01_m11_m21_m31; + output.invQ2 = invq._m02_m12_m22_m32; + output.invQ3 = invq._m03_m13_m23_m33; + + // compute ndc pos for frustrum culling in GS + float4 projPos = mul(modelViewProjectionMatrix, float4(worldPos.xyz, 1.0)); + output.ndcPos = projPos / projPos.w; + return output; +} diff --git a/demo/d3d/shaders/ellipsoidDepthVS.hlsl.h b/demo/d3d/shaders/ellipsoidDepthVS.hlsl.h new file mode 100644 index 0000000..719d17d --- /dev/null +++ b/demo/d3d/shaders/ellipsoidDepthVS.hlsl.h @@ -0,0 +1,935 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct FluidShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 projection; // Offset: 128 +// float4x4 inverseModelView; // Offset: 192 +// float4x4 inverseProjection; // Offset: 256 +// float4 invTexScale; // Offset: 320 +// float3 invViewport; // Offset: 336 +// float _pad0; // Offset: 348 +// float blurRadiusWorld; // Offset: 352 +// float blurScale; // Offset: 356 +// float blurFalloff; // Offset: 360 +// int debug; // Offset: 364 +// float3 lightPos; // Offset: 368 +// float _pad1; // Offset: 380 +// float3 lightDir; // Offset: 384 +// float _pad2; // Offset: 396 +// float4x4 lightTransform; // Offset: 400 +// float4 color; // Offset: 464 +// float4 clipPosToEye; // Offset: 480 +// float spotMin; // Offset: 496 +// float spotMax; // Offset: 500 +// float ior; // Offset: 504 +// float _pad3; // Offset: 508 +// float4 shadowTaps[12]; // Offset: 512 +// +// } gParams; // Offset: 0 Size: 704 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyz +// U 0 xyzw 1 NONE float xyzw +// V 0 xyzw 2 NONE float xyzw +// W 0 xyzw 3 NONE float xyzw +// SV_VertexID 0 x 4 VERTID uint +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xyzw 1 NONE float xyzw +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyzw 3 NONE float xyzw +// TEXCOORD 3 xyzw 4 NONE float xyzw +// TEXCOORD 4 xyzw 5 NONE float xyzw +// TEXCOORD 5 xyzw 6 NONE float xyzw +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[16], immediateIndexed +dcl_input v0.xyz +dcl_input v1.xyzw +dcl_input v2.xyzw +dcl_input v3.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xyzw +dcl_output o3.xyzw +dcl_output o4.xyzw +dcl_output o5.xyzw +dcl_output o6.xyzw +dcl_temps 4 +mov o0.xyz, v0.xyzx +mov o0.w, l(1.000000) +mul r0.xyz, v2.wwww, v2.xyzx +mul r1.xyzw, r0.yyyy, cb0[1].wxxy +mad r1.xyzw, cb0[0].wxxy, r0.xxxx, r1.xyzw +mad r0.xyzw, cb0[2].wxxy, r0.zzzz, r1.xyzw +mul r1.x, r0.w, r0.w +mul r0.xyzw, r0.xxzx, r0.xyzw +mul r1.yzw, v1.wwww, v1.xxyz +mul r2.xyzw, r1.zzzz, cb0[1].wxxy +mad r2.xyzw, cb0[0].wxxy, r1.yyyy, r2.xyzw +mad r2.xyzw, cb0[2].wxxy, r1.wwww, r2.xyzw +mad r1.x, r2.w, r2.w, r1.x +mad r0.xyzw, r2.xyzw, r2.xxzx, r0.xyzw +mul r1.yzw, v3.wwww, v3.xxyz +mul r2.xyzw, r1.zzzz, cb0[1].wxxy +mad r2.xyzw, cb0[0].wxxy, r1.yyyy, r2.xyzw +mad r2.xyzw, cb0[2].wxxy, r1.wwww, r2.xyzw +mad r1.x, r2.w, r2.w, r1.x +mad r0.xyzw, r2.xyzw, r2.xxzx, r0.xyzw +mul r2.xyzw, v0.yyyy, cb0[1].wxxy +mad r2.xyzw, cb0[0].wxxy, v0.xxxx, r2.xyzw +mad r2.xyzw, cb0[2].wxxy, v0.zzzz, r2.xyzw +add r2.xyzw, r2.xyzw, cb0[3].wxxy +mad r1.x, -r2.w, r2.w, r1.x +mad r0.xyzw, -r2.xyzw, r2.xxzx, r0.xyzw +mul r1.yzw, r0.yyxw, l(0.000000, -2.000000, 4.000000, -2.000000) +mul r2.xy, r1.ywyy, r1.ywyy +mad r2.y, -r1.z, r1.x, r2.y +mad r1.z, -r1.z, r0.z, r2.x +sqrt r2.x, r2.y +ge r2.y, r2.y, l(0.000000) +lt r2.zw, l(0.000000, 0.000000, -0.000000, -0.000000), r0.yyyw +movc r2.zw, r2.zzzw, l(0,0,-1.000000,-1.000000), l(0,0,1.000000,1.000000) +mad r1.w, r2.w, r2.x, r1.w +mul r1.w, r1.w, l(-0.500000) +div r3.w, r1.w, r0.x +div r3.z, r1.x, r1.w +lt r1.x, r3.z, r3.w +movc r1.xw, r1.xxxx, r3.zzzw, r3.wwwz +and r1.xw, r1.xxxw, r2.yyyy +eq r2.xyw, r0.xyxw, l(0.000000, -0.000000, 0.000000, -0.000000) +and r0.yw, r2.yyyw, r2.xxxx +movc o1.zw, r0.wwww, l(0,0,0,0), r1.xxxw +sqrt r0.w, r1.z +ge r1.x, r1.z, l(0.000000) +mad r0.w, r2.z, r0.w, r1.y +mul r0.w, r0.w, l(-0.500000) +div r2.xy, r0.zwzz, r0.wxww +lt r0.x, r2.x, r2.y +movc r0.xz, r0.xxxx, r2.xxyx, r2.yyxy +and r0.xz, r0.xxzx, r1.xxxx +movc o1.xy, r0.yyyy, l(0,0,0,0), r0.xzxx +mov o2.w, -cb0[12].w +div r0.xyz, v1.xyzx, v1.wwww +dp3 r0.w, r0.xyzx, v0.xyzx +mov r0.w, -r0.w +dp4 o2.x, r0.xyzw, cb0[12].xyzw +div r1.xyz, v2.xyzx, v2.wwww +dp3 r1.w, r1.xyzx, v0.xyzx +mov r1.w, -r1.w +dp4 o2.y, r1.xyzw, cb0[12].xyzw +div r2.xyz, v3.xyzx, v3.wwww +dp3 r2.w, r2.xyzx, v0.xyzx +mov r2.w, -r2.w +dp4 o2.z, r2.xyzw, cb0[12].xyzw +mov o3.w, -cb0[13].w +dp4 o3.x, r0.xyzw, cb0[13].xyzw +dp4 o3.y, r1.xyzw, cb0[13].xyzw +dp4 o3.z, r2.xyzw, cb0[13].xyzw +dp4 o4.x, r0.xyzw, cb0[14].xyzw +dp4 o5.x, r0.xyzw, cb0[15].xyzw +dp4 o4.y, r1.xyzw, cb0[14].xyzw +dp4 o5.y, r1.xyzw, cb0[15].xyzw +dp4 o4.z, r2.xyzw, cb0[14].xyzw +dp4 o5.z, r2.xyzw, cb0[15].xyzw +mov o4.w, -cb0[14].w +mov o5.w, -cb0[15].w +mul r0.xyzw, v0.yyyy, cb0[1].xyzw +mad r0.xyzw, cb0[0].xyzw, v0.xxxx, r0.xyzw +mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw +add r0.xyzw, r0.xyzw, cb0[3].xyzw +div o6.xyzw, r0.xyzw, r0.wwww +ret +// Approximately 84 instruction slots used +#endif + +const BYTE g_ellipsoidDepthVS[] = +{ + 68, 88, 66, 67, 251, 213, + 215, 144, 39, 19, 119, 132, + 9, 110, 41, 184, 9, 243, + 116, 11, 1, 0, 0, 0, + 184, 17, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 112, 4, 0, 0, 20, 5, + 0, 0, 224, 5, 0, 0, + 28, 17, 0, 0, 82, 68, + 69, 70, 52, 4, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 0, 4, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 192, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 192, 2, + 0, 0, 2, 0, 0, 0, + 220, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 70, 108, 117, 105, + 100, 83, 104, 97, 100, 101, + 114, 67, 111, 110, 115, 116, + 0, 109, 111, 100, 101, 108, + 86, 105, 101, 119, 80, 114, + 111, 106, 101, 99, 116, 105, + 111, 110, 0, 102, 108, 111, + 97, 116, 52, 120, 52, 0, + 171, 171, 3, 0, 3, 0, + 4, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 213, 0, + 0, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 0, + 112, 114, 111, 106, 101, 99, + 116, 105, 111, 110, 0, 105, + 110, 118, 101, 114, 115, 101, + 77, 111, 100, 101, 108, 86, + 105, 101, 119, 0, 105, 110, + 118, 101, 114, 115, 101, 80, + 114, 111, 106, 101, 99, 116, + 105, 111, 110, 0, 105, 110, + 118, 84, 101, 120, 83, 99, + 97, 108, 101, 0, 102, 108, + 111, 97, 116, 52, 0, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 72, 1, 0, 0, + 105, 110, 118, 86, 105, 101, + 119, 112, 111, 114, 116, 0, + 102, 108, 111, 97, 116, 51, + 0, 171, 1, 0, 3, 0, + 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 1, + 0, 0, 95, 112, 97, 100, + 48, 0, 102, 108, 111, 97, + 116, 0, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 178, 1, + 0, 0, 98, 108, 117, 114, + 82, 97, 100, 105, 117, 115, + 87, 111, 114, 108, 100, 0, + 98, 108, 117, 114, 83, 99, + 97, 108, 101, 0, 98, 108, + 117, 114, 70, 97, 108, 108, + 111, 102, 102, 0, 100, 101, + 98, 117, 103, 0, 105, 110, + 116, 0, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 8, 2, + 0, 0, 108, 105, 103, 104, + 116, 80, 111, 115, 0, 95, + 112, 97, 100, 49, 0, 108, + 105, 103, 104, 116, 68, 105, + 114, 0, 95, 112, 97, 100, + 50, 0, 108, 105, 103, 104, + 116, 84, 114, 97, 110, 115, + 102, 111, 114, 109, 0, 99, + 111, 108, 111, 114, 0, 99, + 108, 105, 112, 80, 111, 115, + 84, 111, 69, 121, 101, 0, + 115, 112, 111, 116, 77, 105, + 110, 0, 115, 112, 111, 116, + 77, 97, 120, 0, 105, 111, + 114, 0, 95, 112, 97, 100, + 51, 0, 115, 104, 97, 100, + 111, 119, 84, 97, 112, 115, + 0, 171, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 12, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 72, 1, 0, 0, 193, 0, + 0, 0, 224, 0, 0, 0, + 0, 0, 0, 0, 4, 1, + 0, 0, 224, 0, 0, 0, + 64, 0, 0, 0, 14, 1, + 0, 0, 224, 0, 0, 0, + 128, 0, 0, 0, 25, 1, + 0, 0, 224, 0, 0, 0, + 192, 0, 0, 0, 42, 1, + 0, 0, 224, 0, 0, 0, + 0, 1, 0, 0, 60, 1, + 0, 0, 80, 1, 0, 0, + 64, 1, 0, 0, 116, 1, + 0, 0, 136, 1, 0, 0, + 80, 1, 0, 0, 172, 1, + 0, 0, 184, 1, 0, 0, + 92, 1, 0, 0, 220, 1, + 0, 0, 184, 1, 0, 0, + 96, 1, 0, 0, 236, 1, + 0, 0, 184, 1, 0, 0, + 100, 1, 0, 0, 246, 1, + 0, 0, 184, 1, 0, 0, + 104, 1, 0, 0, 2, 2, + 0, 0, 12, 2, 0, 0, + 108, 1, 0, 0, 48, 2, + 0, 0, 136, 1, 0, 0, + 112, 1, 0, 0, 57, 2, + 0, 0, 184, 1, 0, 0, + 124, 1, 0, 0, 63, 2, + 0, 0, 136, 1, 0, 0, + 128, 1, 0, 0, 72, 2, + 0, 0, 184, 1, 0, 0, + 140, 1, 0, 0, 78, 2, + 0, 0, 224, 0, 0, 0, + 144, 1, 0, 0, 93, 2, + 0, 0, 80, 1, 0, 0, + 208, 1, 0, 0, 99, 2, + 0, 0, 80, 1, 0, 0, + 224, 1, 0, 0, 112, 2, + 0, 0, 184, 1, 0, 0, + 240, 1, 0, 0, 120, 2, + 0, 0, 184, 1, 0, 0, + 244, 1, 0, 0, 128, 2, + 0, 0, 184, 1, 0, 0, + 248, 1, 0, 0, 132, 2, + 0, 0, 184, 1, 0, 0, + 252, 1, 0, 0, 138, 2, + 0, 0, 152, 2, 0, 0, + 0, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 176, 0, + 0, 0, 24, 0, 188, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 176, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 7, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 139, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 141, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 1, 0, 0, 0, 4, 0, + 0, 0, 1, 0, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 85, 0, 86, + 0, 87, 0, 83, 86, 95, + 86, 101, 114, 116, 101, 120, + 73, 68, 0, 171, 79, 83, + 71, 78, 196, 0, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 176, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 15, 0, + 0, 0, 185, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 171, 171, 83, 72, + 69, 88, 52, 11, 0, 0, + 80, 0, 1, 0, 205, 2, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 5, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 6, 0, 0, 0, 104, 0, + 0, 2, 4, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 1, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 54, 132, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 54, 132, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 54, 132, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 6, 2, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 226, 0, 16, 0, 1, 0, + 0, 0, 246, 31, 16, 0, + 1, 0, 0, 0, 6, 25, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 2, 0, 0, 0, + 166, 10, 16, 0, 1, 0, + 0, 0, 54, 132, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 2, 0, + 0, 0, 54, 132, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 86, 5, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 2, 0, 0, 0, + 54, 132, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 9, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 6, 2, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 226, 0, 16, 0, + 1, 0, 0, 0, 246, 31, + 16, 0, 3, 0, 0, 0, + 6, 25, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 2, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 54, 132, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 2, 0, 0, 0, 54, 132, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 86, 5, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 2, 0, + 0, 0, 54, 132, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 9, 18, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 6, 2, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 2, 0, 0, 0, + 86, 21, 16, 0, 0, 0, + 0, 0, 54, 132, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 2, 0, + 0, 0, 54, 132, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 2, 0, 0, 0, + 54, 132, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 166, 26, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 0, 0, + 0, 8, 242, 0, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 54, 132, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 50, 0, 0, 10, 18, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 128, 65, 0, 0, 0, + 2, 0, 0, 0, 6, 2, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 226, 0, 16, 0, 1, 0, + 0, 0, 86, 12, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 192, 0, 0, + 128, 64, 0, 0, 0, 192, + 56, 0, 0, 7, 50, 0, + 16, 0, 2, 0, 0, 0, + 214, 5, 16, 0, 1, 0, + 0, 0, 214, 5, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 34, 0, 16, 0, + 2, 0, 0, 0, 42, 0, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 66, 0, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 75, 0, 0, 5, 18, 0, + 16, 0, 2, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 29, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 10, 194, 0, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 128, 0, 0, + 0, 128, 86, 13, 16, 0, + 0, 0, 0, 0, 55, 0, + 0, 15, 194, 0, 16, 0, + 2, 0, 0, 0, 166, 14, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 191, 0, 0, + 128, 191, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 50, 0, + 0, 9, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 2, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 191, 14, 0, 0, 7, + 130, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 14, 0, 0, 7, 66, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 49, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 42, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 55, 0, 0, 9, + 146, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 166, 14, + 16, 0, 3, 0, 0, 0, + 246, 11, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 7, + 146, 0, 16, 0, 1, 0, + 0, 0, 6, 12, 16, 0, + 1, 0, 0, 0, 86, 5, + 16, 0, 2, 0, 0, 0, + 24, 0, 0, 10, 178, 0, + 16, 0, 2, 0, 0, 0, + 70, 12, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 0, 0, + 0, 0, 0, 128, 1, 0, + 0, 7, 162, 0, 16, 0, + 0, 0, 0, 0, 86, 13, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 55, 0, 0, 12, + 194, 32, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 12, 16, 0, 1, 0, + 0, 0, 75, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 130, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 191, + 14, 0, 0, 7, 50, 0, + 16, 0, 2, 0, 0, 0, + 230, 10, 16, 0, 0, 0, + 0, 0, 54, 15, 16, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 55, 0, 0, 9, + 82, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 6, 1, + 16, 0, 2, 0, 0, 0, + 86, 4, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 7, + 82, 0, 16, 0, 0, 0, + 0, 0, 6, 2, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 55, 0, 0, 12, 50, 32, + 16, 0, 1, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 134, 0, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 7, 130, 32, + 16, 0, 2, 0, 0, 0, + 58, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 14, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 246, 31, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 14, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 246, 31, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 6, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 14, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 246, 31, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 6, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 54, 0, + 0, 7, 130, 32, 16, 0, + 3, 0, 0, 0, 58, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 13, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 5, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 54, 0, 0, 7, + 130, 32, 16, 0, 4, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 54, 0, 0, 7, 130, 32, + 16, 0, 5, 0, 0, 0, + 58, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 0, 0, 0, 0, 86, 21, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 166, 26, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 14, 0, + 0, 7, 242, 32, 16, 0, + 6, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 84, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/imguiPS.hlsl b/demo/d3d/shaders/imguiPS.hlsl new file mode 100644 index 0000000..f51a21b --- /dev/null +++ b/demo/d3d/shaders/imguiPS.hlsl @@ -0,0 +1,22 @@ + +struct Input +{ + float4 position : SV_POSITION; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +Texture2D tex : register(t0); +SamplerState texSampler : register(s0); + +float4 imguiPS(Input input) : SV_TARGET +{ + float4 color = input.color; + + if (input.texCoord.x >= 0.f) + { + color.a *= tex.SampleLevel(texSampler, input.texCoord, 0.f); + } + + return color; +} \ No newline at end of file diff --git a/demo/d3d/shaders/imguiPS.hlsl.h b/demo/d3d/shaders/imguiPS.hlsl.h new file mode 100644 index 0000000..92aa84a --- /dev/null +++ b/demo/d3d/shaders/imguiPS.hlsl.h @@ -0,0 +1,197 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// texSampler sampler NA NA 0 1 +// tex texture float 2d 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xy +dcl_input_ps linear v2.xyzw +dcl_output o0.xyzw +dcl_temps 1 +ge r0.x, v1.x, l(0.000000) +if_nz r0.x + sample_l_indexable(texture2d)(float,float,float,float) r0.x, v1.xyxx, t0.xyzw, s0, l(0.000000) + mul r0.x, r0.x, v2.w +else + mov r0.x, v2.w +endif +mov r0.yzw, v2.xxyz +mov o0.xyzw, r0.yzwx +ret +// Approximately 10 instruction slots used +#endif + +const BYTE g_imguiPS[] = +{ + 68, 88, 66, 67, 214, 230, + 179, 60, 250, 108, 227, 78, + 125, 188, 145, 68, 25, 248, + 141, 62, 1, 0, 0, 0, + 92, 3, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 252, 0, 0, 0, 112, 1, + 0, 0, 164, 1, 0, 0, + 192, 2, 0, 0, 82, 68, + 69, 70, 192, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 139, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 124, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 135, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 116, 101, + 120, 83, 97, 109, 112, 108, + 101, 114, 0, 116, 101, 120, + 0, 77, 105, 99, 114, 111, + 115, 111, 102, 116, 32, 40, + 82, 41, 32, 72, 76, 83, + 76, 32, 83, 104, 97, 100, + 101, 114, 32, 67, 111, 109, + 112, 105, 108, 101, 114, 32, + 54, 46, 51, 46, 57, 54, + 48, 48, 46, 49, 54, 51, + 56, 52, 0, 171, 171, 171, + 73, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 3, 0, 0, 101, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 67, 79, 76, 79, 82, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 171, 171, + 83, 72, 69, 88, 20, 1, + 0, 0, 80, 0, 0, 0, + 69, 0, 0, 0, 106, 8, + 0, 1, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 29, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 16, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 31, 0, 4, 3, 10, 0, + 16, 0, 0, 0, 0, 0, + 72, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 2, 0, + 0, 0, 18, 0, 0, 1, + 54, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 2, 0, + 0, 0, 21, 0, 0, 1, + 54, 0, 0, 5, 226, 0, + 16, 0, 0, 0, 0, 0, + 6, 25, 16, 0, 2, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 0, 0, + 0, 0, 150, 3, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 10, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/demo/d3d/shaders/imguiVS.hlsl b/demo/d3d/shaders/imguiVS.hlsl new file mode 100644 index 0000000..6116ee1 --- /dev/null +++ b/demo/d3d/shaders/imguiVS.hlsl @@ -0,0 +1,31 @@ + +cbuffer params : register(b0) +{ + float4x4 transform; +}; + +struct Input +{ + float2 position : POSITION; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +struct Output +{ + float4 position : SV_POSITION; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +Output imguiVS(Input input, uint instance : SV_InstanceID) +{ + Output output; + + output.position = mul(float4(input.position, 0.f, 1.f), transform); + + output.texCoord = input.texCoord.xy; // float2(input.texCoord.x, 1.f - input.texCoord.y); + output.color = input.color; + + return output; +} \ No newline at end of file diff --git a/demo/d3d/shaders/imguiVS.hlsl.h b/demo/d3d/shaders/imguiVS.hlsl.h new file mode 100644 index 0000000..7249cec --- /dev/null +++ b/demo/d3d/shaders/imguiVS.hlsl.h @@ -0,0 +1,248 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer params +// { +// +// float4x4 transform; // Offset: 0 Size: 64 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// params cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xy 0 NONE float xy +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// SV_InstanceID 0 x 3 INSTID uint +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[4], immediateIndexed +dcl_input v0.xy +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xy +dcl_output o2.xyzw +dcl_temps 1 +mov r0.xy, v0.xyxx +mov r0.z, l(1.000000) +dp3 o0.x, r0.xyzx, cb0[0].xywx +dp3 o0.y, r0.xyzx, cb0[1].xywx +dp3 o0.z, r0.xyzx, cb0[2].xywx +dp3 o0.w, r0.xyzx, cb0[3].xywx +mov o1.xy, v1.xyxx +mov o2.xyzw, v2.xyzw +ret +// Approximately 9 instruction slots used +#endif + +const BYTE g_imguiVS[] = +{ + 68, 88, 66, 67, 11, 92, + 70, 30, 32, 80, 66, 187, + 246, 56, 106, 189, 128, 201, + 215, 197, 1, 0, 0, 0, + 64, 4, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 76, 1, 0, 0, 228, 1, + 0, 0, 88, 2, 0, 0, + 164, 3, 0, 0, 82, 68, + 69, 70, 16, 1, 0, 0, + 1, 0, 0, 0, 100, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 220, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 112, 97, 114, 97, + 109, 115, 0, 171, 92, 0, + 0, 0, 1, 0, 0, 0, + 124, 0, 0, 0, 64, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 0, + 0, 0, 0, 0, 0, 0, + 64, 0, 0, 0, 2, 0, + 0, 0, 184, 0, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 116, 114, 97, 110, + 115, 102, 111, 114, 109, 0, + 102, 108, 111, 97, 116, 52, + 120, 52, 0, 171, 3, 0, + 3, 0, 4, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 174, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 144, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 3, 0, 0, + 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 122, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 67, 79, 76, 79, 82, 0, + 83, 86, 95, 73, 110, 115, + 116, 97, 110, 99, 101, 73, + 68, 0, 171, 171, 79, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 12, + 0, 0, 101, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 83, 72, 69, 88, 68, 1, + 0, 0, 80, 0, 1, 0, + 81, 0, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 2, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 2, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 54, 0, 0, 5, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 66, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 16, 0, + 0, 8, 18, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 131, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 131, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 16, 0, 0, 8, + 66, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 131, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 16, 0, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 131, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 2, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 9, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl b/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl new file mode 100644 index 0000000..1d8b9d5 --- /dev/null +++ b/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl @@ -0,0 +1,3 @@ +#define FLX_ASYNC_COMPUTE_BENCHMARK_ENABLE 1 + +#include "meshPS.hlsl" diff --git a/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl.h b/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl.h new file mode 100644 index 0000000..8223a67 --- /dev/null +++ b/demo/d3d/shaders/meshAsyncComputeBenchPS.hlsl.h @@ -0,0 +1,1558 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct MeshShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 objectTransform; // Offset: 128 +// float4x4 lightTransform; // Offset: 192 +// float4 clipPlane; // Offset: 256 +// float4 fogColor; // Offset: 272 +// float4 color; // Offset: 288 +// float4 secondaryColor; // Offset: 304 +// float4 shadowTaps[12]; // Offset: 320 +// float3 lightPos; // Offset: 512 +// float _pad0; // Offset: 524 +// float3 lightDir; // Offset: 528 +// float _pad1; // Offset: 540 +// float bias; // Offset: 544 +// float expand; // Offset: 548 +// float spotMin; // Offset: 552 +// float spotMax; // Offset: 556 +// int grid; // Offset: 560 +// int tex; // Offset: 564 +// int colorArray; // Offset: 568 +// int increaseGfxLoadForAsyncComputeTesting;// Offset: 572 +// +// } gParams; // Offset: 0 Size: 576 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// shadowSampler sampler_c NA NA 0 1 +// shadowTexture texture float 2d 0 1 +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xyz 1 NONE float xyz +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyz 3 NONE float +// TEXCOORD 3 xyz 4 NONE float xyz +// TEXCOORD 4 xyzw 5 NONE float xyz +// TEXCOORD 5 xy 6 NONE float +// TEXCOORD 6 xyzw 7 NONE float xyz +// TEXCOORD 7 xyzw 8 NONE float z +// SV_IsFrontFace 0 x 9 FFACE uint x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[36], immediateIndexed +dcl_sampler s0, mode_comparison +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xyzw +dcl_input_ps linear v4.xyz +dcl_input_ps linear v5.xyz +dcl_input_ps linear v7.xyz +dcl_input_ps linear v8.z +dcl_input_ps_sgv v9.x, is_front_face +dcl_output o0.xyzw +dcl_temps 6 +div r0.xyz, v2.xyzx, v2.wwww +mad r1.xyz, r0.xyzx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) +lt r0.z, r1.x, l(0.000000) +lt r0.w, l(1.000000), r1.x +or r0.z, r0.w, r0.z +add r0.w, -cb0[20].y, l(1.000000) +mul r2.x, cb0[20].x, l(0.002000) +mul r2.y, r0.w, l(0.002000) +add r1.w, -r1.y, l(1.000000) +add r2.xy, r1.xwxx, r2.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z +add r2.x, -cb0[21].y, l(1.000000) +mul r3.x, cb0[21].x, l(0.002000) +mul r3.y, r2.x, l(0.002000) +add r2.xy, r1.xwxx, r3.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r2.x, r2.xyxx, t0.xxxx, s0, r1.z +add r2.y, -cb0[22].y, l(1.000000) +mul r3.x, cb0[22].x, l(0.002000) +mul r3.y, r2.y, l(0.002000) +add r2.yz, r1.xxwx, r3.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r2.y, r2.yzyy, t0.xxxx, s0, r1.z +add r2.z, -cb0[23].y, l(1.000000) +mul r3.x, cb0[23].x, l(0.002000) +mul r3.y, r2.z, l(0.002000) +add r2.zw, r1.xxxw, r3.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r2.z, r2.zwzz, t0.xxxx, s0, r1.z +add r2.w, -cb0[24].y, l(1.000000) +mul r3.x, cb0[24].x, l(0.002000) +mul r3.y, r2.w, l(0.002000) +add r3.xy, r1.xwxx, r3.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r2.w, r3.xyxx, t0.xxxx, s0, r1.z +add r3.x, -cb0[25].y, l(1.000000) +mul r4.x, cb0[25].x, l(0.002000) +mul r4.y, r3.x, l(0.002000) +add r3.xy, r1.xwxx, r4.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r3.x, r3.xyxx, t0.xxxx, s0, r1.z +add r3.y, -cb0[26].y, l(1.000000) +mul r4.x, cb0[26].x, l(0.002000) +mul r4.y, r3.y, l(0.002000) +add r3.yz, r1.xxwx, r4.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r3.y, r3.yzyy, t0.xxxx, s0, r1.z +add r3.z, -cb0[27].y, l(1.000000) +mul r4.x, cb0[27].x, l(0.002000) +mul r4.y, r3.z, l(0.002000) +add r3.zw, r1.xxxw, r4.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r3.z, r3.zwzz, t0.xxxx, s0, r1.z +add r3.w, -cb0[28].y, l(1.000000) +mul r4.x, cb0[28].x, l(0.002000) +mul r4.y, r3.w, l(0.002000) +add r4.xy, r1.xwxx, r4.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r3.w, r4.xyxx, t0.xxxx, s0, r1.z +add r4.x, -cb0[29].y, l(1.000000) +mul r5.x, cb0[29].x, l(0.002000) +mul r5.y, r4.x, l(0.002000) +add r4.xy, r1.xwxx, r5.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r4.x, r4.xyxx, t0.xxxx, s0, r1.z +add r4.y, -cb0[30].y, l(1.000000) +mul r5.x, cb0[30].x, l(0.002000) +mul r5.y, r4.y, l(0.002000) +add r4.yz, r1.xxwx, r5.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r4.y, r4.yzyy, t0.xxxx, s0, r1.z +add r4.z, -cb0[31].y, l(1.000000) +mul r5.x, cb0[31].x, l(0.002000) +mul r5.y, r4.z, l(0.002000) +add r1.xw, r1.xxxw, r5.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r1.x, r1.xwxx, t0.xxxx, s0, r1.z +if_z r0.z + lt r0.z, r1.y, l(0.000000) + lt r1.y, l(1.000000), r1.y + or r0.z, r0.z, r1.y + if_z r0.z + add r0.z, r0.w, r2.x + add r0.z, r2.y, r0.z + add r0.z, r2.z, r0.z + add r0.z, r2.w, r0.z + add r0.z, r3.x, r0.z + add r0.z, r3.y, r0.z + add r0.z, r3.z, r0.z + add r0.z, r3.w, r0.z + add r0.z, r4.x, r0.z + add r0.z, r4.y, r0.z + add r0.z, r1.x, r0.z + mul r0.z, r0.z, l(0.083333) + else + mov r0.z, l(1.000000) + endif +else + mov r0.z, l(1.000000) +endif +dp2 r0.x, r0.xyxx, r0.xyxx +add r0.y, -cb0[34].w, cb0[34].z +add r0.x, r0.x, -cb0[34].w +div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y +mul_sat r0.x, r0.y, r0.x +mad r0.y, r0.x, l(-2.000000), l(3.000000) +mul r0.x, r0.x, r0.x +mul r0.x, r0.x, r0.y +max r0.xz, r0.xxzx, l(0.050000, 0.000000, 0.500000, 0.000000) +movc r1.xyz, v9.xxxx, v1.xyzx, -v1.xyzx +movc r2.xyz, v9.xxxx, v5.xyzx, v7.xyzx +ine r0.y, cb0[35].x, l(0) +lt r0.w, l(0.995000), r1.y +and r0.w, r0.w, r0.y +if_nz r0.w + deriv_rtx_coarse r3.xy, v4.xzxx + deriv_rty_coarse r3.zw, v4.xxxz + max r3.xy, |r3.zwzz|, |r3.xyxx| + max r0.w, r3.y, r3.x + mad r3.xy, -r0.wwww, l(0.500000, 0.500000, 0.000000, 0.000000), v4.xzxx + mad r3.zw, r0.wwww, l(0.000000, 0.000000, 0.500000, 0.500000), v4.xxxz + mul r4.xy, r3.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r4.xy, r4.xyxx + mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), -r4.xxxy + add r3.zw, r3.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000) + max r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), r4.xxxy + mul r4.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r4.xy, r4.xyxx + mad r3.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), -r4.xyxx + add r3.xy, r3.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) + max r3.xy, r3.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r4.xyxx + add r3.xy, -r3.xyxx, r3.zwzz + div r3.xy, r3.xyxx, r0.wwww + add r3.zw, -r3.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) + mul r0.w, r3.w, r3.z + mad r0.w, r3.x, r3.y, r0.w + mad r0.w, -r0.w, l(0.250000), l(1.000000) + mul r3.xyz, r0.wwww, r2.xyzx +else + lt r0.w, l(0.995000), |r1.z| + and r0.y, r0.w, r0.y + deriv_rtx_coarse r4.xy, v4.yxyy + deriv_rty_coarse r4.zw, v4.yyyx + max r4.xy, |r4.zwzz|, |r4.xyxx| + max r0.w, r4.y, r4.x + mad r4.xy, -r0.wwww, l(0.500000, 0.500000, 0.000000, 0.000000), v4.yxyy + mad r4.zw, r0.wwww, l(0.000000, 0.000000, 0.500000, 0.500000), v4.yyyx + mul r5.xy, r4.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r5.xy, r5.xyxx + mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), -r5.xxxy + add r4.zw, r4.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000) + max r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), r5.xxxy + mul r5.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r5.xy, r5.xyxx + mad r4.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), -r5.xyxx + add r4.xy, r4.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) + max r4.xy, r4.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r4.xy, r4.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r5.xyxx + add r4.xy, -r4.xyxx, r4.zwzz + div r4.xy, r4.xyxx, r0.wwww + add r4.zw, -r4.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) + mul r0.w, r4.w, r4.z + mad r0.w, r4.x, r4.y, r0.w + mad r0.w, -r0.w, l(0.250000), l(1.000000) + mul r4.xyz, r0.wwww, r2.xyzx + movc r3.xyz, r0.yyyy, r4.xyzx, r2.xyzx +endif +dp3 r0.y, cb0[33].xyzx, r1.xyzx +mul r0.z, r0.z, -r0.y +max r0.z, r0.z, l(0.000000) +mul r1.xyz, r0.zzzz, r3.xyzx +mul r2.xyz, r3.xyzx, l(4.000000, 4.000000, 4.000000, 0.000000) +mad r0.yzw, r0.yyyy, l(0.000000, -0.500000, -0.500000, -1.000000), l(0.000000, 0.500000, 0.500000, 0.000000) +mad r0.yzw, r0.yyzw, l(0.000000, 0.020000, 0.012500, 0.007500), l(0.000000, 0.025000, 0.025000, 0.030000) +mul r0.yzw, r0.yyzw, r2.xxyz +mul r0.yzw, r0.xxxx, r0.yyzw +mad r0.xyz, r1.xyzx, r0.xxxx, r0.yzwy +mul r0.w, v8.z, cb0[17].w +mul r0.w, r0.w, l(1.442695) +exp r0.w, r0.w +add r0.xyz, r0.xyzx, -cb0[17].xyzx +mad r0.xyz, r0.wwww, r0.xyzx, cb0[17].xyzx +log r0.xyz, |r0.xyzx| +mul r0.xyz, r0.xyzx, l(0.454545, 0.454545, 0.454545, 0.000000) +exp o0.xyz, r0.xyzx +mov o0.w, l(1.000000) +ret +// Approximately 179 instruction slots used +#endif + +const BYTE g_meshPS[] = +{ + 68, 88, 66, 67, 72, 67, + 173, 99, 108, 111, 205, 171, + 203, 27, 188, 233, 104, 15, + 95, 167, 1, 0, 0, 0, + 40, 30, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 148, 4, 0, 0, 184, 5, + 0, 0, 236, 5, 0, 0, + 140, 29, 0, 0, 82, 68, + 69, 70, 88, 4, 0, 0, + 1, 0, 0, 0, 196, 0, + 0, 0, 3, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 36, 4, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 156, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 170, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 184, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 115, 104, 97, 100, 111, 119, + 83, 97, 109, 112, 108, 101, + 114, 0, 115, 104, 97, 100, + 111, 119, 84, 101, 120, 116, + 117, 114, 101, 0, 99, 111, + 110, 115, 116, 66, 117, 102, + 0, 171, 171, 171, 184, 0, + 0, 0, 1, 0, 0, 0, + 220, 0, 0, 0, 64, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 1, + 0, 0, 0, 0, 0, 0, + 64, 2, 0, 0, 2, 0, + 0, 0, 0, 4, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 103, 80, 97, 114, + 97, 109, 115, 0, 77, 101, + 115, 104, 83, 104, 97, 100, + 101, 114, 67, 111, 110, 115, + 116, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 80, + 114, 111, 106, 101, 99, 116, + 105, 111, 110, 0, 102, 108, + 111, 97, 116, 52, 120, 52, + 0, 171, 171, 171, 3, 0, + 3, 0, 4, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 48, 1, 0, 0, 109, 111, + 100, 101, 108, 86, 105, 101, + 119, 0, 111, 98, 106, 101, + 99, 116, 84, 114, 97, 110, + 115, 102, 111, 114, 109, 0, + 108, 105, 103, 104, 116, 84, + 114, 97, 110, 115, 102, 111, + 114, 109, 0, 99, 108, 105, + 112, 80, 108, 97, 110, 101, + 0, 102, 108, 111, 97, 116, + 52, 0, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 147, 1, 0, 0, 102, 111, + 103, 67, 111, 108, 111, 114, + 0, 99, 111, 108, 111, 114, + 0, 115, 101, 99, 111, 110, + 100, 97, 114, 121, 67, 111, + 108, 111, 114, 0, 115, 104, + 97, 100, 111, 119, 84, 97, + 112, 115, 0, 171, 171, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 147, 1, 0, 0, + 108, 105, 103, 104, 116, 80, + 111, 115, 0, 102, 108, 111, + 97, 116, 51, 0, 1, 0, + 3, 0, 1, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 25, 2, 0, 0, 95, 112, + 97, 100, 48, 0, 102, 108, + 111, 97, 116, 0, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 74, 2, 0, 0, 108, 105, + 103, 104, 116, 68, 105, 114, + 0, 95, 112, 97, 100, 49, + 0, 98, 105, 97, 115, 0, + 101, 120, 112, 97, 110, 100, + 0, 115, 112, 111, 116, 77, + 105, 110, 0, 115, 112, 111, + 116, 77, 97, 120, 0, 103, + 114, 105, 100, 0, 105, 110, + 116, 0, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 2, + 0, 0, 116, 101, 120, 0, + 99, 111, 108, 111, 114, 65, + 114, 114, 97, 121, 0, 105, + 110, 99, 114, 101, 97, 115, + 101, 71, 102, 120, 76, 111, + 97, 100, 70, 111, 114, 65, + 115, 121, 110, 99, 67, 111, + 109, 112, 117, 116, 101, 84, + 101, 115, 116, 105, 110, 103, + 0, 171, 171, 171, 28, 1, + 0, 0, 60, 1, 0, 0, + 0, 0, 0, 0, 96, 1, + 0, 0, 60, 1, 0, 0, + 64, 0, 0, 0, 106, 1, + 0, 0, 60, 1, 0, 0, + 128, 0, 0, 0, 122, 1, + 0, 0, 60, 1, 0, 0, + 192, 0, 0, 0, 137, 1, + 0, 0, 156, 1, 0, 0, + 0, 1, 0, 0, 192, 1, + 0, 0, 156, 1, 0, 0, + 16, 1, 0, 0, 201, 1, + 0, 0, 156, 1, 0, 0, + 32, 1, 0, 0, 207, 1, + 0, 0, 156, 1, 0, 0, + 48, 1, 0, 0, 222, 1, + 0, 0, 236, 1, 0, 0, + 64, 1, 0, 0, 16, 2, + 0, 0, 32, 2, 0, 0, + 0, 2, 0, 0, 68, 2, + 0, 0, 80, 2, 0, 0, + 12, 2, 0, 0, 116, 2, + 0, 0, 32, 2, 0, 0, + 16, 2, 0, 0, 125, 2, + 0, 0, 80, 2, 0, 0, + 28, 2, 0, 0, 131, 2, + 0, 0, 80, 2, 0, 0, + 32, 2, 0, 0, 136, 2, + 0, 0, 80, 2, 0, 0, + 36, 2, 0, 0, 143, 2, + 0, 0, 80, 2, 0, 0, + 40, 2, 0, 0, 151, 2, + 0, 0, 80, 2, 0, 0, + 44, 2, 0, 0, 159, 2, + 0, 0, 168, 2, 0, 0, + 48, 2, 0, 0, 204, 2, + 0, 0, 168, 2, 0, 0, + 52, 2, 0, 0, 208, 2, + 0, 0, 168, 2, 0, 0, + 56, 2, 0, 0, 219, 2, + 0, 0, 168, 2, 0, 0, + 60, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 144, 0, + 0, 0, 21, 0, 4, 3, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 12, 1, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 28, 1, 0, 0, 10, 0, + 0, 0, 8, 0, 0, 0, + 248, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 4, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 4, 1, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 4, 1, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 4, 1, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 7, 0, 0, + 4, 1, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 15, 7, 0, 0, + 4, 1, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 3, 0, 0, 0, + 4, 1, 0, 0, 6, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 15, 7, 0, 0, + 4, 1, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 15, 4, 0, 0, + 13, 1, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 1, 0, 0, 0, 9, 0, + 0, 0, 1, 1, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 73, 115, 70, 114, 111, 110, + 116, 70, 97, 99, 101, 0, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 65, 82, 71, 69, + 84, 0, 171, 171, 83, 72, + 69, 88, 152, 23, 0, 0, + 80, 0, 0, 0, 230, 5, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 36, 0, 0, 0, 90, 8, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 4, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 5, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 7, 0, + 0, 0, 98, 16, 0, 3, + 66, 16, 16, 0, 8, 0, + 0, 0, 99, 8, 0, 4, + 18, 16, 16, 0, 9, 0, + 0, 0, 9, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 6, 0, + 0, 0, 14, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 246, 31, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 15, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 10, 0, 16, 0, 1, 0, + 0, 0, 60, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 8, 130, 0, + 16, 0, 1, 0, 0, 0, + 26, 0, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 7, + 50, 0, 16, 0, 2, 0, + 0, 0, 198, 0, 16, 0, + 1, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 2, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 18, 0, 16, 0, + 2, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 50, 0, 16, 0, + 2, 0, 0, 0, 198, 0, + 16, 0, 1, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 34, 0, + 16, 0, 2, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 3, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 98, 0, + 16, 0, 2, 0, 0, 0, + 6, 3, 16, 0, 1, 0, + 0, 0, 6, 1, 16, 0, + 3, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 34, 0, + 16, 0, 2, 0, 0, 0, + 150, 5, 16, 0, 2, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 9, + 66, 0, 16, 0, 2, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 3, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 194, 0, 16, 0, 2, 0, + 0, 0, 6, 12, 16, 0, + 1, 0, 0, 0, 6, 4, + 16, 0, 3, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 66, 0, 16, 0, 2, 0, + 0, 0, 230, 10, 16, 0, + 2, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 130, 0, 16, 0, + 2, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 50, 0, 16, 0, + 3, 0, 0, 0, 198, 0, + 16, 0, 1, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 3, 0, 0, 0, + 198, 0, 16, 0, 1, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 9, + 34, 0, 16, 0, 3, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 26, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 98, 0, 16, 0, 3, 0, + 0, 0, 6, 3, 16, 0, + 1, 0, 0, 0, 6, 1, + 16, 0, 4, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 34, 0, 16, 0, 3, 0, + 0, 0, 150, 5, 16, 0, + 3, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 66, 0, 16, 0, + 3, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 27, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 4, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 27, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 194, 0, 16, 0, + 3, 0, 0, 0, 6, 12, + 16, 0, 1, 0, 0, 0, + 6, 4, 16, 0, 4, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 66, 0, 16, 0, + 3, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 28, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 4, 0, 0, 0, + 198, 0, 16, 0, 1, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 130, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 9, + 18, 0, 16, 0, 4, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 29, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 5, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 29, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 5, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 50, 0, 16, 0, 4, 0, + 0, 0, 198, 0, 16, 0, + 1, 0, 0, 0, 70, 0, + 16, 0, 5, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 30, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 5, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 30, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 5, 0, 0, 0, + 26, 0, 16, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 98, 0, 16, 0, + 4, 0, 0, 0, 6, 3, + 16, 0, 1, 0, 0, 0, + 6, 1, 16, 0, 5, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 34, 0, 16, 0, + 4, 0, 0, 0, 150, 5, + 16, 0, 4, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 66, 0, + 16, 0, 4, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 5, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 31, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 5, 0, + 0, 0, 42, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 146, 0, + 16, 0, 1, 0, 0, 0, + 6, 12, 16, 0, 1, 0, + 0, 0, 6, 4, 16, 0, + 5, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 1, 0, 0, 0, + 198, 0, 16, 0, 1, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 31, 0, 0, 3, + 42, 0, 16, 0, 0, 0, + 0, 0, 49, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 26, 0, 16, 0, + 1, 0, 0, 0, 60, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 31, 0, 0, 3, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 171, 170, + 170, 61, 18, 0, 0, 1, + 54, 0, 0, 5, 66, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 21, 0, 0, 1, + 18, 0, 0, 1, 54, 0, + 0, 5, 66, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 21, 0, 0, 1, 15, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 10, + 34, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 42, 128, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 14, 0, 0, 10, 34, 0, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 26, 0, 16, 0, + 0, 0, 0, 0, 56, 32, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 34, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 192, + 1, 64, 0, 0, 0, 0, + 64, 64, 56, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 52, 0, + 0, 10, 82, 0, 16, 0, + 0, 0, 0, 0, 6, 2, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 205, 204, + 76, 61, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 0, 55, 0, 0, 10, + 114, 0, 16, 0, 1, 0, + 0, 0, 6, 16, 16, 0, + 9, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 55, 0, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 6, 16, 16, 0, 9, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 70, 18, + 16, 0, 7, 0, 0, 0, + 39, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 35, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 82, 184, 126, 63, 26, 0, + 16, 0, 1, 0, 0, 0, + 1, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 31, 0, + 4, 3, 58, 0, 16, 0, + 0, 0, 0, 0, 122, 0, + 0, 5, 50, 0, 16, 0, + 3, 0, 0, 0, 134, 16, + 16, 0, 4, 0, 0, 0, + 124, 0, 0, 5, 194, 0, + 16, 0, 3, 0, 0, 0, + 6, 24, 16, 0, 4, 0, + 0, 0, 52, 0, 0, 9, + 50, 0, 16, 0, 3, 0, + 0, 0, 230, 10, 16, 128, + 129, 0, 0, 0, 3, 0, + 0, 0, 70, 0, 16, 128, + 129, 0, 0, 0, 3, 0, + 0, 0, 52, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 13, 50, 0, + 16, 0, 3, 0, 0, 0, + 246, 15, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 134, 16, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 6, 24, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 4, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 13, 194, 0, 16, 0, + 3, 0, 0, 0, 166, 14, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 6, 4, 16, 128, + 65, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 10, + 194, 0, 16, 0, 3, 0, + 0, 0, 166, 14, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 52, 0, 0, 10, 194, 0, + 16, 0, 3, 0, 0, 0, + 166, 14, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 3, 0, 0, 0, 166, 14, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 64, 6, 4, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 13, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 10, + 50, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 191, + 0, 0, 0, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 52, 0, 0, 10, 50, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 0, 0, + 0, 8, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 14, 0, 0, 7, 50, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 11, 194, 0, 16, 0, + 3, 0, 0, 0, 6, 4, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 26, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 62, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 18, 0, 0, 1, 49, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 82, 184, 126, 63, + 42, 0, 16, 128, 129, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 122, 0, + 0, 5, 50, 0, 16, 0, + 4, 0, 0, 0, 22, 21, + 16, 0, 4, 0, 0, 0, + 124, 0, 0, 5, 194, 0, + 16, 0, 4, 0, 0, 0, + 86, 17, 16, 0, 4, 0, + 0, 0, 52, 0, 0, 9, + 50, 0, 16, 0, 4, 0, + 0, 0, 230, 10, 16, 128, + 129, 0, 0, 0, 4, 0, + 0, 0, 70, 0, 16, 128, + 129, 0, 0, 0, 4, 0, + 0, 0, 52, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 4, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 13, 50, 0, + 16, 0, 4, 0, 0, 0, + 246, 15, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 22, 21, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 86, 17, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 5, 0, 0, 0, 230, 10, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 5, 0, + 0, 0, 70, 0, 16, 0, + 5, 0, 0, 0, 50, 0, + 0, 13, 194, 0, 16, 0, + 4, 0, 0, 0, 166, 14, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 6, 4, 16, 128, + 65, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 10, + 194, 0, 16, 0, 4, 0, + 0, 0, 166, 14, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 52, 0, 0, 10, 194, 0, + 16, 0, 4, 0, 0, 0, + 166, 14, 16, 0, 4, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 4, 0, 0, 0, 166, 14, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 64, 6, 4, 16, 0, + 5, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 5, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 5, 0, + 0, 0, 70, 0, 16, 0, + 5, 0, 0, 0, 50, 0, + 0, 13, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 10, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 191, + 0, 0, 0, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 52, 0, 0, 10, 50, 0, + 16, 0, 4, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 8, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 128, 65, 0, 0, 0, + 4, 0, 0, 0, 230, 10, + 16, 0, 4, 0, 0, 0, + 14, 0, 0, 7, 50, 0, + 16, 0, 4, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 11, 194, 0, 16, 0, + 4, 0, 0, 0, 6, 4, + 16, 128, 65, 0, 0, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 4, 0, + 0, 0, 42, 0, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 26, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 62, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 7, + 114, 0, 16, 0, 4, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 55, 0, 0, 9, 114, 0, + 16, 0, 3, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 21, 0, 0, 1, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 52, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 166, 10, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 64, 0, 0, 128, 64, + 0, 0, 128, 64, 0, 0, + 0, 0, 50, 0, 0, 15, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 191, 0, 0, + 0, 191, 0, 0, 128, 191, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 0, 50, 0, 0, 15, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 11, 215, 163, 60, 206, 204, + 76, 60, 148, 194, 245, 59, + 2, 64, 0, 0, 0, 0, + 0, 0, 205, 204, 204, 60, + 205, 204, 204, 60, 143, 194, + 245, 60, 56, 0, 0, 7, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 6, 9, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 42, 16, + 16, 0, 8, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 59, 170, 184, 63, 25, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 47, 0, + 0, 6, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 129, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 47, 186, + 232, 62, 47, 186, 232, 62, + 47, 186, 232, 62, 0, 0, + 0, 0, 25, 0, 0, 5, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 179, 0, 0, 0, 6, 0, + 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 146, 0, + 0, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 4, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/meshPS.hlsl b/demo/d3d/shaders/meshPS.hlsl new file mode 100644 index 0000000..a78d249 --- /dev/null +++ b/demo/d3d/shaders/meshPS.hlsl @@ -0,0 +1,123 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + MeshShaderConst gParams; +}; + +Texture2D shadowTexture : register(t0); // shadow map +SamplerComparisonState shadowSampler : register(s0); // texture sample used to sample depth from shadow texture in this sample + +// sample shadow map +float shadowSample(float4 lightOffsetPosition) +{ + float3 pos = float3(lightOffsetPosition.xyz / lightOffsetPosition.w); + float3 uvw = (pos.xyz * float3(0.5, 0.5, 1.0)) + float3(0.5, 0.5, 0.0); + + // user clip + if (uvw.x < 0.0 || uvw.x > 1.0) + return 1.0; + if (uvw.y < 0.0 || uvw.y > 1.0) + return 1.0; + + float s = 0.0; + float radius = 0.002; + + const int numTaps = 12; + + // flip uv y-coordinate + uvw.y = 1.0f - uvw.y; + + [unroll] + for (int i = 0; i < numTaps; i++) + { + float2 shadowTaps = gParams.shadowTaps[i].xy; + shadowTaps.y = 1.0f - shadowTaps.y; + s += shadowTexture.SampleCmp(shadowSampler, uvw.xy + shadowTaps * radius, uvw.z); + } + s /= numTaps; + + return s; +} + +float filterwidth(float2 v) +{ + float2 fw = max(abs(ddx(v)), abs(ddy(v))); + return max(fw.x, fw.y); +} + +float2 bump(float2 x) +{ + return (floor((x) / 2) + 2.f * max(((x) / 2) - floor((x) / 2) - .5f, 0.f)); +} + +float checker(float2 uv) +{ + float width = filterwidth(uv); + float2 p0 = uv - 0.5 * width; + float2 p1 = uv + 0.5 * width; + + float2 i = (bump(p1) - bump(p0)) / width; + return i.x * i.y + (1 - i.x) * (1 - i.y); +} + +float4 meshPS(MeshVertexOut input, bool isFrontFace : SV_IsFrontFace) : SV_TARGET +{ + const float4 fogColor = gParams.fogColor; + const float3 lightDir = gParams.lightDir; + const float3 lightPos = gParams.lightPos; + const float spotMin = gParams.spotMin; + const float spotMax = gParams.spotMax; + const int grid = gParams.grid; + const int tex = gParams.tex; + + // calculate lighting + float shadow = max(shadowSample(input.lightOffsetPosition), 0.5); + //float shadow = 0.5f; + + float3 lVec = normalize(input.worldPosition - lightPos); + float3 lPos = float3(input.lightOffsetPosition.xyz / input.lightOffsetPosition.w); + float attenuation = max(smoothstep(spotMax, spotMin, dot(lPos.xy, lPos.xy)), 0.05); + + float3 n = input.worldNormal; + float3 color = input.color.xyz; + + if (!isFrontFace) + { + color = input.secondaryColor.xyz; + n *= -1.0f; + } + + if (grid && (n.y > 0.995)) + { + color *= 1.0 - 0.25 * checker(float2(input.worldPosition.x, input.worldPosition.z)); + } + else if (grid && abs(n.z) > 0.995) + { + color *= 1.0 - 0.25 * checker(float2(input.worldPosition.y, input.worldPosition.x)); + } + + if (tex) + { + //color = texture2D(tex, gl_TexCoord[5].xy).xyz; + } + + // direct light term + float wrap = 0.0; + float3 diffuse = color * float3(1.0, 1.0, 1.0) * max(0.0, (-dot(lightDir, n) + wrap) / (1.0 + wrap) * shadow) * attenuation; + + // wrap ambient term aligned with light dir + float3 light = float3(0.03, 0.025, 0.025) * 1.5; + float3 dark = float3(0.025, 0.025, 0.03); + //float3 ambient = 4.0 * color * lerp(dark, light, -dot(lightDir, n) * 0.5 + 0.5) * attenuation; + float3 ambient = 4.0 * color * lerp(dark, light, -dot(lightDir, n) * float3(0.5, 0.5, 1.0) + float3(0.5, 0.5, 0.0)) * attenuation; + + float3 fog = lerp(fogColor.xyz, diffuse + ambient, exp(input.viewPosition.z * fogColor.w)); + + //outColor = float4(pow(fog, float3(1.0 / 2.2)), 1.0); + const float tmp = 1.0 / 2.2; + + float4 outColor = float4(pow(abs(fog), float3(tmp, tmp, tmp)), 1.0); + + return outColor; +} diff --git a/demo/d3d/shaders/meshPS.hlsl.h b/demo/d3d/shaders/meshPS.hlsl.h new file mode 100644 index 0000000..8223a67 --- /dev/null +++ b/demo/d3d/shaders/meshPS.hlsl.h @@ -0,0 +1,1558 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct MeshShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 objectTransform; // Offset: 128 +// float4x4 lightTransform; // Offset: 192 +// float4 clipPlane; // Offset: 256 +// float4 fogColor; // Offset: 272 +// float4 color; // Offset: 288 +// float4 secondaryColor; // Offset: 304 +// float4 shadowTaps[12]; // Offset: 320 +// float3 lightPos; // Offset: 512 +// float _pad0; // Offset: 524 +// float3 lightDir; // Offset: 528 +// float _pad1; // Offset: 540 +// float bias; // Offset: 544 +// float expand; // Offset: 548 +// float spotMin; // Offset: 552 +// float spotMax; // Offset: 556 +// int grid; // Offset: 560 +// int tex; // Offset: 564 +// int colorArray; // Offset: 568 +// int increaseGfxLoadForAsyncComputeTesting;// Offset: 572 +// +// } gParams; // Offset: 0 Size: 576 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// shadowSampler sampler_c NA NA 0 1 +// shadowTexture texture float 2d 0 1 +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xyz 1 NONE float xyz +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyz 3 NONE float +// TEXCOORD 3 xyz 4 NONE float xyz +// TEXCOORD 4 xyzw 5 NONE float xyz +// TEXCOORD 5 xy 6 NONE float +// TEXCOORD 6 xyzw 7 NONE float xyz +// TEXCOORD 7 xyzw 8 NONE float z +// SV_IsFrontFace 0 x 9 FFACE uint x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[36], immediateIndexed +dcl_sampler s0, mode_comparison +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xyzw +dcl_input_ps linear v4.xyz +dcl_input_ps linear v5.xyz +dcl_input_ps linear v7.xyz +dcl_input_ps linear v8.z +dcl_input_ps_sgv v9.x, is_front_face +dcl_output o0.xyzw +dcl_temps 6 +div r0.xyz, v2.xyzx, v2.wwww +mad r1.xyz, r0.xyzx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) +lt r0.z, r1.x, l(0.000000) +lt r0.w, l(1.000000), r1.x +or r0.z, r0.w, r0.z +add r0.w, -cb0[20].y, l(1.000000) +mul r2.x, cb0[20].x, l(0.002000) +mul r2.y, r0.w, l(0.002000) +add r1.w, -r1.y, l(1.000000) +add r2.xy, r1.xwxx, r2.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z +add r2.x, -cb0[21].y, l(1.000000) +mul r3.x, cb0[21].x, l(0.002000) +mul r3.y, r2.x, l(0.002000) +add r2.xy, r1.xwxx, r3.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r2.x, r2.xyxx, t0.xxxx, s0, r1.z +add r2.y, -cb0[22].y, l(1.000000) +mul r3.x, cb0[22].x, l(0.002000) +mul r3.y, r2.y, l(0.002000) +add r2.yz, r1.xxwx, r3.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r2.y, r2.yzyy, t0.xxxx, s0, r1.z +add r2.z, -cb0[23].y, l(1.000000) +mul r3.x, cb0[23].x, l(0.002000) +mul r3.y, r2.z, l(0.002000) +add r2.zw, r1.xxxw, r3.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r2.z, r2.zwzz, t0.xxxx, s0, r1.z +add r2.w, -cb0[24].y, l(1.000000) +mul r3.x, cb0[24].x, l(0.002000) +mul r3.y, r2.w, l(0.002000) +add r3.xy, r1.xwxx, r3.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r2.w, r3.xyxx, t0.xxxx, s0, r1.z +add r3.x, -cb0[25].y, l(1.000000) +mul r4.x, cb0[25].x, l(0.002000) +mul r4.y, r3.x, l(0.002000) +add r3.xy, r1.xwxx, r4.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r3.x, r3.xyxx, t0.xxxx, s0, r1.z +add r3.y, -cb0[26].y, l(1.000000) +mul r4.x, cb0[26].x, l(0.002000) +mul r4.y, r3.y, l(0.002000) +add r3.yz, r1.xxwx, r4.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r3.y, r3.yzyy, t0.xxxx, s0, r1.z +add r3.z, -cb0[27].y, l(1.000000) +mul r4.x, cb0[27].x, l(0.002000) +mul r4.y, r3.z, l(0.002000) +add r3.zw, r1.xxxw, r4.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r3.z, r3.zwzz, t0.xxxx, s0, r1.z +add r3.w, -cb0[28].y, l(1.000000) +mul r4.x, cb0[28].x, l(0.002000) +mul r4.y, r3.w, l(0.002000) +add r4.xy, r1.xwxx, r4.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r3.w, r4.xyxx, t0.xxxx, s0, r1.z +add r4.x, -cb0[29].y, l(1.000000) +mul r5.x, cb0[29].x, l(0.002000) +mul r5.y, r4.x, l(0.002000) +add r4.xy, r1.xwxx, r5.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r4.x, r4.xyxx, t0.xxxx, s0, r1.z +add r4.y, -cb0[30].y, l(1.000000) +mul r5.x, cb0[30].x, l(0.002000) +mul r5.y, r4.y, l(0.002000) +add r4.yz, r1.xxwx, r5.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r4.y, r4.yzyy, t0.xxxx, s0, r1.z +add r4.z, -cb0[31].y, l(1.000000) +mul r5.x, cb0[31].x, l(0.002000) +mul r5.y, r4.z, l(0.002000) +add r1.xw, r1.xxxw, r5.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r1.x, r1.xwxx, t0.xxxx, s0, r1.z +if_z r0.z + lt r0.z, r1.y, l(0.000000) + lt r1.y, l(1.000000), r1.y + or r0.z, r0.z, r1.y + if_z r0.z + add r0.z, r0.w, r2.x + add r0.z, r2.y, r0.z + add r0.z, r2.z, r0.z + add r0.z, r2.w, r0.z + add r0.z, r3.x, r0.z + add r0.z, r3.y, r0.z + add r0.z, r3.z, r0.z + add r0.z, r3.w, r0.z + add r0.z, r4.x, r0.z + add r0.z, r4.y, r0.z + add r0.z, r1.x, r0.z + mul r0.z, r0.z, l(0.083333) + else + mov r0.z, l(1.000000) + endif +else + mov r0.z, l(1.000000) +endif +dp2 r0.x, r0.xyxx, r0.xyxx +add r0.y, -cb0[34].w, cb0[34].z +add r0.x, r0.x, -cb0[34].w +div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y +mul_sat r0.x, r0.y, r0.x +mad r0.y, r0.x, l(-2.000000), l(3.000000) +mul r0.x, r0.x, r0.x +mul r0.x, r0.x, r0.y +max r0.xz, r0.xxzx, l(0.050000, 0.000000, 0.500000, 0.000000) +movc r1.xyz, v9.xxxx, v1.xyzx, -v1.xyzx +movc r2.xyz, v9.xxxx, v5.xyzx, v7.xyzx +ine r0.y, cb0[35].x, l(0) +lt r0.w, l(0.995000), r1.y +and r0.w, r0.w, r0.y +if_nz r0.w + deriv_rtx_coarse r3.xy, v4.xzxx + deriv_rty_coarse r3.zw, v4.xxxz + max r3.xy, |r3.zwzz|, |r3.xyxx| + max r0.w, r3.y, r3.x + mad r3.xy, -r0.wwww, l(0.500000, 0.500000, 0.000000, 0.000000), v4.xzxx + mad r3.zw, r0.wwww, l(0.000000, 0.000000, 0.500000, 0.500000), v4.xxxz + mul r4.xy, r3.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r4.xy, r4.xyxx + mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), -r4.xxxy + add r3.zw, r3.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000) + max r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), r4.xxxy + mul r4.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r4.xy, r4.xyxx + mad r3.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), -r4.xyxx + add r3.xy, r3.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) + max r3.xy, r3.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r4.xyxx + add r3.xy, -r3.xyxx, r3.zwzz + div r3.xy, r3.xyxx, r0.wwww + add r3.zw, -r3.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) + mul r0.w, r3.w, r3.z + mad r0.w, r3.x, r3.y, r0.w + mad r0.w, -r0.w, l(0.250000), l(1.000000) + mul r3.xyz, r0.wwww, r2.xyzx +else + lt r0.w, l(0.995000), |r1.z| + and r0.y, r0.w, r0.y + deriv_rtx_coarse r4.xy, v4.yxyy + deriv_rty_coarse r4.zw, v4.yyyx + max r4.xy, |r4.zwzz|, |r4.xyxx| + max r0.w, r4.y, r4.x + mad r4.xy, -r0.wwww, l(0.500000, 0.500000, 0.000000, 0.000000), v4.yxyy + mad r4.zw, r0.wwww, l(0.000000, 0.000000, 0.500000, 0.500000), v4.yyyx + mul r5.xy, r4.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r5.xy, r5.xyxx + mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), -r5.xxxy + add r4.zw, r4.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000) + max r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), r5.xxxy + mul r5.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r5.xy, r5.xyxx + mad r4.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), -r5.xyxx + add r4.xy, r4.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) + max r4.xy, r4.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) + mad r4.xy, r4.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r5.xyxx + add r4.xy, -r4.xyxx, r4.zwzz + div r4.xy, r4.xyxx, r0.wwww + add r4.zw, -r4.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) + mul r0.w, r4.w, r4.z + mad r0.w, r4.x, r4.y, r0.w + mad r0.w, -r0.w, l(0.250000), l(1.000000) + mul r4.xyz, r0.wwww, r2.xyzx + movc r3.xyz, r0.yyyy, r4.xyzx, r2.xyzx +endif +dp3 r0.y, cb0[33].xyzx, r1.xyzx +mul r0.z, r0.z, -r0.y +max r0.z, r0.z, l(0.000000) +mul r1.xyz, r0.zzzz, r3.xyzx +mul r2.xyz, r3.xyzx, l(4.000000, 4.000000, 4.000000, 0.000000) +mad r0.yzw, r0.yyyy, l(0.000000, -0.500000, -0.500000, -1.000000), l(0.000000, 0.500000, 0.500000, 0.000000) +mad r0.yzw, r0.yyzw, l(0.000000, 0.020000, 0.012500, 0.007500), l(0.000000, 0.025000, 0.025000, 0.030000) +mul r0.yzw, r0.yyzw, r2.xxyz +mul r0.yzw, r0.xxxx, r0.yyzw +mad r0.xyz, r1.xyzx, r0.xxxx, r0.yzwy +mul r0.w, v8.z, cb0[17].w +mul r0.w, r0.w, l(1.442695) +exp r0.w, r0.w +add r0.xyz, r0.xyzx, -cb0[17].xyzx +mad r0.xyz, r0.wwww, r0.xyzx, cb0[17].xyzx +log r0.xyz, |r0.xyzx| +mul r0.xyz, r0.xyzx, l(0.454545, 0.454545, 0.454545, 0.000000) +exp o0.xyz, r0.xyzx +mov o0.w, l(1.000000) +ret +// Approximately 179 instruction slots used +#endif + +const BYTE g_meshPS[] = +{ + 68, 88, 66, 67, 72, 67, + 173, 99, 108, 111, 205, 171, + 203, 27, 188, 233, 104, 15, + 95, 167, 1, 0, 0, 0, + 40, 30, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 148, 4, 0, 0, 184, 5, + 0, 0, 236, 5, 0, 0, + 140, 29, 0, 0, 82, 68, + 69, 70, 88, 4, 0, 0, + 1, 0, 0, 0, 196, 0, + 0, 0, 3, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 36, 4, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 156, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 170, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 184, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 115, 104, 97, 100, 111, 119, + 83, 97, 109, 112, 108, 101, + 114, 0, 115, 104, 97, 100, + 111, 119, 84, 101, 120, 116, + 117, 114, 101, 0, 99, 111, + 110, 115, 116, 66, 117, 102, + 0, 171, 171, 171, 184, 0, + 0, 0, 1, 0, 0, 0, + 220, 0, 0, 0, 64, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 1, + 0, 0, 0, 0, 0, 0, + 64, 2, 0, 0, 2, 0, + 0, 0, 0, 4, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 103, 80, 97, 114, + 97, 109, 115, 0, 77, 101, + 115, 104, 83, 104, 97, 100, + 101, 114, 67, 111, 110, 115, + 116, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 80, + 114, 111, 106, 101, 99, 116, + 105, 111, 110, 0, 102, 108, + 111, 97, 116, 52, 120, 52, + 0, 171, 171, 171, 3, 0, + 3, 0, 4, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 48, 1, 0, 0, 109, 111, + 100, 101, 108, 86, 105, 101, + 119, 0, 111, 98, 106, 101, + 99, 116, 84, 114, 97, 110, + 115, 102, 111, 114, 109, 0, + 108, 105, 103, 104, 116, 84, + 114, 97, 110, 115, 102, 111, + 114, 109, 0, 99, 108, 105, + 112, 80, 108, 97, 110, 101, + 0, 102, 108, 111, 97, 116, + 52, 0, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 147, 1, 0, 0, 102, 111, + 103, 67, 111, 108, 111, 114, + 0, 99, 111, 108, 111, 114, + 0, 115, 101, 99, 111, 110, + 100, 97, 114, 121, 67, 111, + 108, 111, 114, 0, 115, 104, + 97, 100, 111, 119, 84, 97, + 112, 115, 0, 171, 171, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 147, 1, 0, 0, + 108, 105, 103, 104, 116, 80, + 111, 115, 0, 102, 108, 111, + 97, 116, 51, 0, 1, 0, + 3, 0, 1, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 25, 2, 0, 0, 95, 112, + 97, 100, 48, 0, 102, 108, + 111, 97, 116, 0, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 74, 2, 0, 0, 108, 105, + 103, 104, 116, 68, 105, 114, + 0, 95, 112, 97, 100, 49, + 0, 98, 105, 97, 115, 0, + 101, 120, 112, 97, 110, 100, + 0, 115, 112, 111, 116, 77, + 105, 110, 0, 115, 112, 111, + 116, 77, 97, 120, 0, 103, + 114, 105, 100, 0, 105, 110, + 116, 0, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 2, + 0, 0, 116, 101, 120, 0, + 99, 111, 108, 111, 114, 65, + 114, 114, 97, 121, 0, 105, + 110, 99, 114, 101, 97, 115, + 101, 71, 102, 120, 76, 111, + 97, 100, 70, 111, 114, 65, + 115, 121, 110, 99, 67, 111, + 109, 112, 117, 116, 101, 84, + 101, 115, 116, 105, 110, 103, + 0, 171, 171, 171, 28, 1, + 0, 0, 60, 1, 0, 0, + 0, 0, 0, 0, 96, 1, + 0, 0, 60, 1, 0, 0, + 64, 0, 0, 0, 106, 1, + 0, 0, 60, 1, 0, 0, + 128, 0, 0, 0, 122, 1, + 0, 0, 60, 1, 0, 0, + 192, 0, 0, 0, 137, 1, + 0, 0, 156, 1, 0, 0, + 0, 1, 0, 0, 192, 1, + 0, 0, 156, 1, 0, 0, + 16, 1, 0, 0, 201, 1, + 0, 0, 156, 1, 0, 0, + 32, 1, 0, 0, 207, 1, + 0, 0, 156, 1, 0, 0, + 48, 1, 0, 0, 222, 1, + 0, 0, 236, 1, 0, 0, + 64, 1, 0, 0, 16, 2, + 0, 0, 32, 2, 0, 0, + 0, 2, 0, 0, 68, 2, + 0, 0, 80, 2, 0, 0, + 12, 2, 0, 0, 116, 2, + 0, 0, 32, 2, 0, 0, + 16, 2, 0, 0, 125, 2, + 0, 0, 80, 2, 0, 0, + 28, 2, 0, 0, 131, 2, + 0, 0, 80, 2, 0, 0, + 32, 2, 0, 0, 136, 2, + 0, 0, 80, 2, 0, 0, + 36, 2, 0, 0, 143, 2, + 0, 0, 80, 2, 0, 0, + 40, 2, 0, 0, 151, 2, + 0, 0, 80, 2, 0, 0, + 44, 2, 0, 0, 159, 2, + 0, 0, 168, 2, 0, 0, + 48, 2, 0, 0, 204, 2, + 0, 0, 168, 2, 0, 0, + 52, 2, 0, 0, 208, 2, + 0, 0, 168, 2, 0, 0, + 56, 2, 0, 0, 219, 2, + 0, 0, 168, 2, 0, 0, + 60, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 144, 0, + 0, 0, 21, 0, 4, 3, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 12, 1, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 28, 1, 0, 0, 10, 0, + 0, 0, 8, 0, 0, 0, + 248, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 4, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 4, 1, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 4, 1, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 4, 1, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 7, 0, 0, + 4, 1, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 15, 7, 0, 0, + 4, 1, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 3, 0, 0, 0, + 4, 1, 0, 0, 6, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 15, 7, 0, 0, + 4, 1, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 15, 4, 0, 0, + 13, 1, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 1, 0, 0, 0, 9, 0, + 0, 0, 1, 1, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 73, 115, 70, 114, 111, 110, + 116, 70, 97, 99, 101, 0, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 65, 82, 71, 69, + 84, 0, 171, 171, 83, 72, + 69, 88, 152, 23, 0, 0, + 80, 0, 0, 0, 230, 5, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 36, 0, 0, 0, 90, 8, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 4, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 5, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 7, 0, + 0, 0, 98, 16, 0, 3, + 66, 16, 16, 0, 8, 0, + 0, 0, 99, 8, 0, 4, + 18, 16, 16, 0, 9, 0, + 0, 0, 9, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 6, 0, + 0, 0, 14, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 246, 31, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 15, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 10, 0, 16, 0, 1, 0, + 0, 0, 60, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 8, 130, 0, + 16, 0, 1, 0, 0, 0, + 26, 0, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 7, + 50, 0, 16, 0, 2, 0, + 0, 0, 198, 0, 16, 0, + 1, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 2, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 18, 0, 16, 0, + 2, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 50, 0, 16, 0, + 2, 0, 0, 0, 198, 0, + 16, 0, 1, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 34, 0, + 16, 0, 2, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 3, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 98, 0, + 16, 0, 2, 0, 0, 0, + 6, 3, 16, 0, 1, 0, + 0, 0, 6, 1, 16, 0, + 3, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 34, 0, + 16, 0, 2, 0, 0, 0, + 150, 5, 16, 0, 2, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 9, + 66, 0, 16, 0, 2, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 3, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 194, 0, 16, 0, 2, 0, + 0, 0, 6, 12, 16, 0, + 1, 0, 0, 0, 6, 4, + 16, 0, 3, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 66, 0, 16, 0, 2, 0, + 0, 0, 230, 10, 16, 0, + 2, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 130, 0, 16, 0, + 2, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 50, 0, 16, 0, + 3, 0, 0, 0, 198, 0, + 16, 0, 1, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 3, 0, 0, 0, + 198, 0, 16, 0, 1, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 9, + 34, 0, 16, 0, 3, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 26, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 98, 0, 16, 0, 3, 0, + 0, 0, 6, 3, 16, 0, + 1, 0, 0, 0, 6, 1, + 16, 0, 4, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 34, 0, 16, 0, 3, 0, + 0, 0, 150, 5, 16, 0, + 3, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 66, 0, 16, 0, + 3, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 27, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 4, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 27, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 194, 0, 16, 0, + 3, 0, 0, 0, 6, 12, + 16, 0, 1, 0, 0, 0, + 6, 4, 16, 0, 4, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 66, 0, 16, 0, + 3, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 28, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 4, 0, 0, 0, + 198, 0, 16, 0, 1, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 130, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 9, + 18, 0, 16, 0, 4, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 29, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 5, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 29, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 5, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 50, 0, 16, 0, 4, 0, + 0, 0, 198, 0, 16, 0, + 1, 0, 0, 0, 70, 0, + 16, 0, 5, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 30, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 5, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 30, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 5, 0, 0, 0, + 26, 0, 16, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 98, 0, 16, 0, + 4, 0, 0, 0, 6, 3, + 16, 0, 1, 0, 0, 0, + 6, 1, 16, 0, 5, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 34, 0, 16, 0, + 4, 0, 0, 0, 150, 5, + 16, 0, 4, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 66, 0, + 16, 0, 4, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 5, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 31, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 5, 0, + 0, 0, 42, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 146, 0, + 16, 0, 1, 0, 0, 0, + 6, 12, 16, 0, 1, 0, + 0, 0, 6, 4, 16, 0, + 5, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 1, 0, 0, 0, + 198, 0, 16, 0, 1, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 31, 0, 0, 3, + 42, 0, 16, 0, 0, 0, + 0, 0, 49, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 26, 0, 16, 0, + 1, 0, 0, 0, 60, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 31, 0, 0, 3, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 66, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 66, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 171, 170, + 170, 61, 18, 0, 0, 1, + 54, 0, 0, 5, 66, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 21, 0, 0, 1, + 18, 0, 0, 1, 54, 0, + 0, 5, 66, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 21, 0, 0, 1, 15, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 10, + 34, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 42, 128, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 14, 0, 0, 10, 34, 0, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 26, 0, 16, 0, + 0, 0, 0, 0, 56, 32, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 34, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 192, + 1, 64, 0, 0, 0, 0, + 64, 64, 56, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 52, 0, + 0, 10, 82, 0, 16, 0, + 0, 0, 0, 0, 6, 2, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 205, 204, + 76, 61, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 0, 55, 0, 0, 10, + 114, 0, 16, 0, 1, 0, + 0, 0, 6, 16, 16, 0, + 9, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 55, 0, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 6, 16, 16, 0, 9, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 70, 18, + 16, 0, 7, 0, 0, 0, + 39, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 35, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 82, 184, 126, 63, 26, 0, + 16, 0, 1, 0, 0, 0, + 1, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 31, 0, + 4, 3, 58, 0, 16, 0, + 0, 0, 0, 0, 122, 0, + 0, 5, 50, 0, 16, 0, + 3, 0, 0, 0, 134, 16, + 16, 0, 4, 0, 0, 0, + 124, 0, 0, 5, 194, 0, + 16, 0, 3, 0, 0, 0, + 6, 24, 16, 0, 4, 0, + 0, 0, 52, 0, 0, 9, + 50, 0, 16, 0, 3, 0, + 0, 0, 230, 10, 16, 128, + 129, 0, 0, 0, 3, 0, + 0, 0, 70, 0, 16, 128, + 129, 0, 0, 0, 3, 0, + 0, 0, 52, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 13, 50, 0, + 16, 0, 3, 0, 0, 0, + 246, 15, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 134, 16, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 6, 24, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 4, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 13, 194, 0, 16, 0, + 3, 0, 0, 0, 166, 14, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 6, 4, 16, 128, + 65, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 10, + 194, 0, 16, 0, 3, 0, + 0, 0, 166, 14, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 52, 0, 0, 10, 194, 0, + 16, 0, 3, 0, 0, 0, + 166, 14, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 3, 0, 0, 0, 166, 14, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 64, 6, 4, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 13, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 10, + 50, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 191, + 0, 0, 0, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 52, 0, 0, 10, 50, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 0, 0, + 0, 8, 50, 0, 16, 0, + 3, 0, 0, 0, 70, 0, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 14, 0, 0, 7, 50, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 11, 194, 0, 16, 0, + 3, 0, 0, 0, 6, 4, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 26, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 62, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 18, 0, 0, 1, 49, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 82, 184, 126, 63, + 42, 0, 16, 128, 129, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 122, 0, + 0, 5, 50, 0, 16, 0, + 4, 0, 0, 0, 22, 21, + 16, 0, 4, 0, 0, 0, + 124, 0, 0, 5, 194, 0, + 16, 0, 4, 0, 0, 0, + 86, 17, 16, 0, 4, 0, + 0, 0, 52, 0, 0, 9, + 50, 0, 16, 0, 4, 0, + 0, 0, 230, 10, 16, 128, + 129, 0, 0, 0, 4, 0, + 0, 0, 70, 0, 16, 128, + 129, 0, 0, 0, 4, 0, + 0, 0, 52, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 4, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 13, 50, 0, + 16, 0, 4, 0, 0, 0, + 246, 15, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 22, 21, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 86, 17, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 5, 0, 0, 0, 230, 10, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 5, 0, + 0, 0, 70, 0, 16, 0, + 5, 0, 0, 0, 50, 0, + 0, 13, 194, 0, 16, 0, + 4, 0, 0, 0, 166, 14, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 6, 4, 16, 128, + 65, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 10, + 194, 0, 16, 0, 4, 0, + 0, 0, 166, 14, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 52, 0, 0, 10, 194, 0, + 16, 0, 4, 0, 0, 0, + 166, 14, 16, 0, 4, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 194, 0, 16, 0, + 4, 0, 0, 0, 166, 14, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 64, 6, 4, 16, 0, + 5, 0, 0, 0, 56, 0, + 0, 10, 50, 0, 16, 0, + 5, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 65, 0, 0, 5, + 50, 0, 16, 0, 5, 0, + 0, 0, 70, 0, 16, 0, + 5, 0, 0, 0, 50, 0, + 0, 13, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 10, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 191, + 0, 0, 0, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 52, 0, 0, 10, 50, 0, + 16, 0, 4, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 8, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 16, 128, 65, 0, 0, 0, + 4, 0, 0, 0, 230, 10, + 16, 0, 4, 0, 0, 0, + 14, 0, 0, 7, 50, 0, + 16, 0, 4, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 11, 194, 0, 16, 0, + 4, 0, 0, 0, 6, 4, + 16, 128, 65, 0, 0, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 4, 0, + 0, 0, 42, 0, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 26, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 62, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 7, + 114, 0, 16, 0, 4, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 55, 0, 0, 9, 114, 0, + 16, 0, 3, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 21, 0, 0, 1, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 52, 0, 0, 7, + 66, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 166, 10, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 64, 0, 0, 128, 64, + 0, 0, 128, 64, 0, 0, + 0, 0, 50, 0, 0, 15, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 191, 0, 0, + 0, 191, 0, 0, 128, 191, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 0, 50, 0, 0, 15, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 11, 215, 163, 60, 206, 204, + 76, 60, 148, 194, 245, 59, + 2, 64, 0, 0, 0, 0, + 0, 0, 205, 204, 204, 60, + 205, 204, 204, 60, 143, 194, + 245, 60, 56, 0, 0, 7, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 6, 9, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 42, 16, + 16, 0, 8, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 59, 170, 184, 63, 25, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 47, 0, + 0, 6, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 129, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 47, 186, + 232, 62, 47, 186, 232, 62, + 47, 186, 232, 62, 0, 0, + 0, 0, 25, 0, 0, 5, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 179, 0, 0, 0, 6, 0, + 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 146, 0, + 0, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 4, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/meshShadowPS.hlsl b/demo/d3d/shaders/meshShadowPS.hlsl new file mode 100644 index 0000000..96d7371 --- /dev/null +++ b/demo/d3d/shaders/meshShadowPS.hlsl @@ -0,0 +1,12 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + MeshShaderConst gParams; +}; + + +void meshPS_Shadow(MeshVertexOut input) +{ +} + diff --git a/demo/d3d/shaders/meshShadowPS.hlsl.h b/demo/d3d/shaders/meshShadowPS.hlsl.h new file mode 100644 index 0000000..f921264 --- /dev/null +++ b/demo/d3d/shaders/meshShadowPS.hlsl.h @@ -0,0 +1,139 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xyz 1 NONE float +// TEXCOORD 1 xyzw 2 NONE float +// TEXCOORD 2 xyz 3 NONE float +// TEXCOORD 3 xyz 4 NONE float +// TEXCOORD 4 xyzw 5 NONE float +// TEXCOORD 5 xy 6 NONE float +// TEXCOORD 6 xyzw 7 NONE float +// TEXCOORD 7 xyzw 8 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// no Output +ps_5_0 +dcl_globalFlags refactoringAllowed +ret +// Approximately 1 instruction slots used +#endif + +const BYTE g_meshPS_Shadow[] = +{ + 68, 88, 66, 67, 92, 14, + 98, 50, 73, 255, 171, 211, + 114, 130, 157, 79, 70, 204, + 106, 183, 1, 0, 0, 0, + 112, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 172, 1, + 0, 0, 188, 1, 0, 0, + 212, 1, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 248, 0, 0, 0, + 9, 0, 0, 0, 8, 0, + 0, 0, 224, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 236, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 0, + 0, 0, 236, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 236, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 236, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 0, + 0, 0, 236, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 15, 0, + 0, 0, 236, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 3, 0, + 0, 0, 236, 0, 0, 0, + 6, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 15, 0, + 0, 0, 236, 0, 0, 0, + 7, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 8, 0, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 83, 72, 69, 88, 16, 0, + 0, 0, 80, 0, 0, 0, + 4, 0, 0, 0, 106, 8, + 0, 1, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/meshVS.hlsl b/demo/d3d/shaders/meshVS.hlsl new file mode 100644 index 0000000..d2fa9e5 --- /dev/null +++ b/demo/d3d/shaders/meshVS.hlsl @@ -0,0 +1,35 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + MeshShaderConst gParams; +}; + +MeshVertexOut meshVS(MeshVertexIn input) +{ + const float4x4 modelViewProjectionMatrix = gParams.modelViewProjection; + const float4x4 modelViewMatrix = gParams.modelView; + const float4x4 objectTransform = gParams.objectTransform; + const float4x4 lightTransform = gParams.lightTransform; + + float3 n = normalize(mul(objectTransform, float4(input.normal, 0.0)).xyz); + float3 p = mul(objectTransform, float4(input.position.xyz, 1.0)).xyz; + + // calculate window-space point size + MeshVertexOut output; + output.position = mul(modelViewProjectionMatrix, float4(p + gParams.expand * n, 1.0)); + + output.worldNormal = n; + output.lightOffsetPosition = mul(lightTransform, float4(p + n * gParams.bias, 1.0)); + output.viewLightDir = mul(modelViewMatrix, float4(gParams.lightDir, 0.0)); + output.worldPosition = p; + if (gParams.colorArray) + output.color = input.color; + else + output.color = gParams.color; + output.texCoord = float2(input.texCoord.x, 1.0f - input.texCoord.y); // flip the y component of uv (glsl to hlsl conversion) + output.secondaryColor = gParams.secondaryColor; + output.viewPosition = mul(modelViewMatrix, float4(input.position.xyz, 1.0)); + + return output; +} diff --git a/demo/d3d/shaders/meshVS.hlsl.h b/demo/d3d/shaders/meshVS.hlsl.h new file mode 100644 index 0000000..15198ae --- /dev/null +++ b/demo/d3d/shaders/meshVS.hlsl.h @@ -0,0 +1,625 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct MeshShaderConst +// { +// +// float4x4 modelViewProjection; // Offset: 0 +// float4x4 modelView; // Offset: 64 +// float4x4 objectTransform; // Offset: 128 +// float4x4 lightTransform; // Offset: 192 +// float4 clipPlane; // Offset: 256 +// float4 fogColor; // Offset: 272 +// float4 color; // Offset: 288 +// float4 secondaryColor; // Offset: 304 +// float4 shadowTaps[12]; // Offset: 320 +// float3 lightPos; // Offset: 512 +// float _pad0; // Offset: 524 +// float3 lightDir; // Offset: 528 +// float _pad1; // Offset: 540 +// float bias; // Offset: 544 +// float expand; // Offset: 548 +// float spotMin; // Offset: 552 +// float spotMax; // Offset: 556 +// int grid; // Offset: 560 +// int tex; // Offset: 564 +// int colorArray; // Offset: 568 +// int increaseGfxLoadForAsyncComputeTesting;// Offset: 572 +// +// } gParams; // Offset: 0 Size: 576 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyz 0 NONE float xyz +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xyz 1 NONE float xyz +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyz 3 NONE float xyz +// TEXCOORD 3 xyz 4 NONE float xyz +// TEXCOORD 4 xyzw 5 NONE float xyzw +// TEXCOORD 5 xy 6 NONE float xy +// TEXCOORD 6 xyzw 7 NONE float xyzw +// TEXCOORD 7 xyzw 8 NONE float xyzw +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[36], immediateIndexed +dcl_input v0.xyz +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyz +dcl_output o2.xyzw +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyzw +dcl_output o6.xy +dcl_output o7.xyzw +dcl_output o8.xyzw +dcl_temps 4 +mul r0.xyz, v1.yyyy, cb0[9].xyzx +mad r0.xyz, cb0[8].xyzx, v1.xxxx, r0.xyzx +mad r0.xyz, cb0[10].xyzx, v1.zzzz, r0.xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +mul r1.xyz, v0.yyyy, cb0[9].xyzx +mad r1.xyz, cb0[8].xyzx, v0.xxxx, r1.xyzx +mad r1.xyz, cb0[10].xyzx, v0.zzzz, r1.xyzx +add r1.xyz, r1.xyzx, cb0[11].xyzx +mad r2.xyz, cb0[34].yyyy, r0.xyzx, r1.xyzx +mul r3.xyzw, r2.yyyy, cb0[1].xyzw +mad r3.xyzw, cb0[0].xyzw, r2.xxxx, r3.xyzw +mad r2.xyzw, cb0[2].xyzw, r2.zzzz, r3.xyzw +add o0.xyzw, r2.xyzw, cb0[3].xyzw +mov o1.xyz, r0.xyzx +mad r0.xyz, r0.xyzx, cb0[34].xxxx, r1.xyzx +mov o4.xyz, r1.xyzx +mul r1.xyzw, r0.yyyy, cb0[13].xyzw +mad r1.xyzw, cb0[12].xyzw, r0.xxxx, r1.xyzw +mad r0.xyzw, cb0[14].xyzw, r0.zzzz, r1.xyzw +add o2.xyzw, r0.xyzw, cb0[15].xyzw +mul r0.xyz, cb0[5].xyzx, cb0[33].yyyy +mad r0.xyz, cb0[4].xyzx, cb0[33].xxxx, r0.xyzx +mad o3.xyz, cb0[6].xyzx, cb0[33].zzzz, r0.xyzx +movc o5.xyzw, cb0[35].zzzz, v3.xyzw, cb0[18].xyzw +mad o6.xy, v2.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(0.000000, 1.000000, 0.000000, 0.000000) +mov o7.xyzw, cb0[19].xyzw +mul r0.xyzw, v0.yyyy, cb0[5].xyzw +mad r0.xyzw, cb0[4].xyzw, v0.xxxx, r0.xyzw +mad r0.xyzw, cb0[6].xyzw, v0.zzzz, r0.xyzw +add o8.xyzw, r0.xyzw, cb0[7].xyzw +ret +// Approximately 33 instruction slots used +#endif + +const BYTE g_meshVS[] = +{ + 68, 88, 66, 67, 224, 200, + 225, 174, 179, 134, 152, 85, + 252, 211, 193, 254, 28, 42, + 106, 184, 1, 0, 0, 0, + 164, 11, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 56, 4, 0, 0, 200, 4, + 0, 0, 200, 5, 0, 0, + 8, 11, 0, 0, 82, 68, + 69, 70, 252, 3, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 200, 3, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 64, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 64, 2, + 0, 0, 2, 0, 0, 0, + 164, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 77, 101, 115, 104, + 83, 104, 97, 100, 101, 114, + 67, 111, 110, 115, 116, 0, + 109, 111, 100, 101, 108, 86, + 105, 101, 119, 80, 114, 111, + 106, 101, 99, 116, 105, 111, + 110, 0, 102, 108, 111, 97, + 116, 52, 120, 52, 0, 171, + 171, 171, 3, 0, 3, 0, + 4, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 212, 0, + 0, 0, 109, 111, 100, 101, + 108, 86, 105, 101, 119, 0, + 111, 98, 106, 101, 99, 116, + 84, 114, 97, 110, 115, 102, + 111, 114, 109, 0, 108, 105, + 103, 104, 116, 84, 114, 97, + 110, 115, 102, 111, 114, 109, + 0, 99, 108, 105, 112, 80, + 108, 97, 110, 101, 0, 102, + 108, 111, 97, 116, 52, 0, + 171, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 55, 1, + 0, 0, 102, 111, 103, 67, + 111, 108, 111, 114, 0, 99, + 111, 108, 111, 114, 0, 115, + 101, 99, 111, 110, 100, 97, + 114, 121, 67, 111, 108, 111, + 114, 0, 115, 104, 97, 100, + 111, 119, 84, 97, 112, 115, + 0, 171, 171, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 12, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 55, 1, 0, 0, 108, 105, + 103, 104, 116, 80, 111, 115, + 0, 102, 108, 111, 97, 116, + 51, 0, 1, 0, 3, 0, + 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 189, 1, + 0, 0, 95, 112, 97, 100, + 48, 0, 102, 108, 111, 97, + 116, 0, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 238, 1, + 0, 0, 108, 105, 103, 104, + 116, 68, 105, 114, 0, 95, + 112, 97, 100, 49, 0, 98, + 105, 97, 115, 0, 101, 120, + 112, 97, 110, 100, 0, 115, + 112, 111, 116, 77, 105, 110, + 0, 115, 112, 111, 116, 77, + 97, 120, 0, 103, 114, 105, + 100, 0, 105, 110, 116, 0, + 0, 0, 2, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 72, 2, 0, 0, + 116, 101, 120, 0, 99, 111, + 108, 111, 114, 65, 114, 114, + 97, 121, 0, 105, 110, 99, + 114, 101, 97, 115, 101, 71, + 102, 120, 76, 111, 97, 100, + 70, 111, 114, 65, 115, 121, + 110, 99, 67, 111, 109, 112, + 117, 116, 101, 84, 101, 115, + 116, 105, 110, 103, 0, 171, + 171, 171, 192, 0, 0, 0, + 224, 0, 0, 0, 0, 0, + 0, 0, 4, 1, 0, 0, + 224, 0, 0, 0, 64, 0, + 0, 0, 14, 1, 0, 0, + 224, 0, 0, 0, 128, 0, + 0, 0, 30, 1, 0, 0, + 224, 0, 0, 0, 192, 0, + 0, 0, 45, 1, 0, 0, + 64, 1, 0, 0, 0, 1, + 0, 0, 100, 1, 0, 0, + 64, 1, 0, 0, 16, 1, + 0, 0, 109, 1, 0, 0, + 64, 1, 0, 0, 32, 1, + 0, 0, 115, 1, 0, 0, + 64, 1, 0, 0, 48, 1, + 0, 0, 130, 1, 0, 0, + 144, 1, 0, 0, 64, 1, + 0, 0, 180, 1, 0, 0, + 196, 1, 0, 0, 0, 2, + 0, 0, 232, 1, 0, 0, + 244, 1, 0, 0, 12, 2, + 0, 0, 24, 2, 0, 0, + 196, 1, 0, 0, 16, 2, + 0, 0, 33, 2, 0, 0, + 244, 1, 0, 0, 28, 2, + 0, 0, 39, 2, 0, 0, + 244, 1, 0, 0, 32, 2, + 0, 0, 44, 2, 0, 0, + 244, 1, 0, 0, 36, 2, + 0, 0, 51, 2, 0, 0, + 244, 1, 0, 0, 40, 2, + 0, 0, 59, 2, 0, 0, + 244, 1, 0, 0, 44, 2, + 0, 0, 67, 2, 0, 0, + 76, 2, 0, 0, 48, 2, + 0, 0, 112, 2, 0, 0, + 76, 2, 0, 0, 52, 2, + 0, 0, 116, 2, 0, 0, + 76, 2, 0, 0, 56, 2, + 0, 0, 127, 2, 0, 0, + 76, 2, 0, 0, 60, 2, + 0, 0, 5, 0, 0, 0, + 1, 0, 144, 0, 0, 0, + 21, 0, 168, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 176, 0, + 0, 0, 77, 105, 99, 114, + 111, 115, 111, 102, 116, 32, + 40, 82, 41, 32, 72, 76, + 83, 76, 32, 83, 104, 97, + 100, 101, 114, 32, 67, 111, + 109, 112, 105, 108, 101, 114, + 32, 54, 46, 51, 46, 57, + 54, 48, 48, 46, 49, 54, + 51, 56, 52, 0, 171, 171, + 73, 83, 71, 78, 136, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 7, 7, 0, 0, 113, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 120, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 129, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 15, 0, 0, 80, 79, + 83, 73, 84, 73, 79, 78, + 0, 78, 79, 82, 77, 65, + 76, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 79, 83, 71, 78, 248, 0, + 0, 0, 9, 0, 0, 0, + 8, 0, 0, 0, 224, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 236, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 8, 0, 0, 236, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 0, 0, 0, 236, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 236, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 7, 8, 0, 0, 236, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 5, 0, 0, 0, + 15, 0, 0, 0, 236, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 6, 0, 0, 0, + 3, 12, 0, 0, 236, 0, + 0, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 15, 0, 0, 0, 236, 0, + 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 171, 171, 83, 72, + 69, 88, 56, 5, 0, 0, + 80, 0, 1, 0, 78, 1, + 0, 0, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 36, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 4, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 5, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 6, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 7, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 8, 0, + 0, 0, 104, 0, 0, 2, + 4, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 86, 21, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 6, 16, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 166, 26, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 1, 0, 0, 0, + 86, 21, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 6, 16, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 166, 26, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 86, 133, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 5, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 166, 10, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 0, 0, 0, 8, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 6, 128, 32, 0, + 0, 0, 0, 0, 34, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 1, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 166, 10, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 8, 242, 32, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 56, 0, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 86, 133, 32, 0, 0, 0, + 0, 0, 33, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 6, 128, 32, 0, 0, 0, + 0, 0, 33, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 32, 16, 0, 3, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 166, 138, 32, 0, + 0, 0, 0, 0, 33, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 55, 0, + 0, 11, 242, 32, 16, 0, + 5, 0, 0, 0, 166, 138, + 32, 0, 0, 0, 0, 0, + 35, 0, 0, 0, 70, 30, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 18, 0, 0, 0, + 50, 0, 0, 15, 50, 32, + 16, 0, 6, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 191, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 7, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 0, 0, 0, 0, + 86, 21, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 6, 16, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 166, 26, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 8, 242, 32, 16, 0, + 8, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 148, 0, 0, 0, + 33, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 28, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/passThroughVS.hlsl b/demo/d3d/shaders/passThroughVS.hlsl new file mode 100644 index 0000000..f8005d7 --- /dev/null +++ b/demo/d3d/shaders/passThroughVS.hlsl @@ -0,0 +1,14 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + FluidShaderConst gParams; +}; + +PassthroughVertexOut passThroughVS(MeshVertexIn input) +{ + PassthroughVertexOut output; + output.position = float4(input.position, 1.0f); + output.texCoord = input.texCoord; + return output; +} diff --git a/demo/d3d/shaders/passThroughVS.hlsl.h b/demo/d3d/shaders/passThroughVS.hlsl.h new file mode 100644 index 0000000..3ff9109 --- /dev/null +++ b/demo/d3d/shaders/passThroughVS.hlsl.h @@ -0,0 +1,155 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyz 0 NONE float xyz +// NORMAL 0 xyz 1 NONE float +// TEXCOORD 0 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_input v0.xyz +dcl_input v2.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xy +mov o0.xyz, v0.xyzx +mov o0.w, l(1.000000) +mov o1.xy, v2.xyxx +ret +// Approximately 4 instruction slots used +#endif + +const BYTE g_passThroughVS[] = +{ + 68, 88, 66, 67, 185, 168, + 119, 184, 113, 66, 215, 46, + 63, 211, 78, 140, 226, 35, + 139, 164, 1, 0, 0, 0, + 184, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 60, 1, + 0, 0, 148, 1, 0, 0, + 28, 2, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 136, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 7, 7, + 0, 0, 113, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 0, + 0, 0, 120, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 129, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 78, + 79, 82, 77, 65, 76, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 171, 79, 83, + 71, 78, 80, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 12, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 83, 72, 69, 88, + 128, 0, 0, 0, 80, 0, + 1, 0, 32, 0, 0, 0, + 106, 8, 0, 1, 95, 0, + 0, 3, 114, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 54, 0, 0, 5, 50, 32, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/pointGS.hlsl b/demo/d3d/shaders/pointGS.hlsl new file mode 100644 index 0000000..4d654af --- /dev/null +++ b/demo/d3d/shaders/pointGS.hlsl @@ -0,0 +1,68 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + PointShaderConst gParams; +}; + +static const float2 corners[4] = +{ + float2(0.0, 1.0), float2(0.0, 0.0), float2(1.0, 1.0), float2(1.0, 0.0) +}; + +[maxvertexcount(4)] +void pointGS(point PointVertexOut input[1], inout TriangleStream triStream) +{ + const float4x4 modelViewMatrix = gParams.modelView; + const float pointRadius = gParams.pointRadius; + const float pointScale = gParams.pointScale; + const float4x4 lightTransform = gParams.lightTransform; + const float3 lightDir = gParams.lightDir.xyz; + const int mode = gParams.mode; + + const float4 viewPosition = input[0].viewPosition; + const float density = input[0].density; + const unsigned int phase = input[0].phase; + const float4 modelPosition = input[0].modelPosition; + + //float spriteSize = (pointRadius / viewPos.z); + const float spriteSize = pointRadius * 2; + + PointGeoOut output; + for (int i = 0; i < 4; ++i) + { + const float2 corner = corners[i]; + float4 eyePos = viewPosition; // start with point position + eyePos.xy += spriteSize * (corner - float2(0.5, 0.5)); // add corner position + output.position = mul(gParams.projection, eyePos); // complete transformation + + // use corner as texCoord, flip the y component of uv (glsl to hlsl conversion) + output.texCoord = float2(corner.x, 1.0f - corner.y); + output.lightOffsetPosition = mul(lightTransform, float4(modelPosition.xyz - lightDir * pointRadius * 2.0, 1.0)); + output.viewLightDir = mul(modelViewMatrix, float4(lightDir, 0.0)).xyz; + + if (mode == 1) + { + // density visualization + if (density < 0.0f) + output.reflectance = float4(lerp(float3(0.1, 0.1, 1.0), float3(0.1, 1.0, 1.0), -density), 0); + else + output.reflectance = float4(lerp(float3(1.0, 1.0, 1.0), float3(0.1, 0.2, 1.0), density), 0); + } + else if (mode == 2) + { + //gl_PointSize *= clamp(inPosition.w * 0.25, 0.0f, 1.0); + float tmp = clamp(modelPosition.w * 0.05, 0.0f, 1.0); + output.reflectance = float4(tmp, tmp, tmp, tmp); + } + else + { + output.reflectance = float4(lerp(gParams.colors[phase % 8].xyz * 2.0, float3(1.0, 1.0, 1.0), 0.1), 0); + } + + output.modelPosition= modelPosition.xyz; + output.viewPosition = viewPosition.xyz; + + triStream.Append(output); + } +} diff --git a/demo/d3d/shaders/pointGS.hlsl.h b/demo/d3d/shaders/pointGS.hlsl.h new file mode 100644 index 0000000..46806ac --- /dev/null +++ b/demo/d3d/shaders/pointGS.hlsl.h @@ -0,0 +1,713 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct PointShaderConst +// { +// +// float4x4 modelView; // Offset: 0 +// float4x4 projection; // Offset: 64 +// float4x4 lightTransform; // Offset: 128 +// float4 colors[8]; // Offset: 192 +// float4 shadowTaps[12]; // Offset: 320 +// float3 lightPos; // Offset: 512 +// float _pad0; // Offset: 524 +// float3 lightDir; // Offset: 528 +// float _pad1; // Offset: 540 +// float pointRadius; // Offset: 544 +// float pointScale; // Offset: 548 +// float spotMin; // Offset: 552 +// float spotMax; // Offset: 556 +// int mode; // Offset: 560 +// int _pad2[3]; // Offset: 576 +// +// } gParams; // Offset: 0 Size: 612 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// DENSITY 0 x 1 NONE float x +// PHASE 0 x 2 NONE int x +// VERTEX 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyz 3 NONE float xyz +// TEXCOORD 3 xyzw 4 NONE float xyzw +// TEXCOORD 4 xyz 5 NONE float xyz +// TEXCOORD 5 xyz 6 NONE float xyz +// +gs_5_0 +dcl_globalFlags refactoringAllowed +dcl_immediateConstantBuffer { { 0, 1.000000, 0, 0}, + { 0, 0, 0, 0}, + { 1.000000, 1.000000, 0, 0}, + { 1.000000, 0, 0, 0} } +dcl_constantbuffer cb0[36], dynamicIndexed +dcl_input v[1][0].xyzw +dcl_input v[1][1].x +dcl_input v[1][2].x +dcl_input v[1][3].xyzw +dcl_temps 8 +dcl_inputprimitive point +dcl_stream m0 +dcl_outputtopology trianglestrip +dcl_output_siv o0.xyzw, position +dcl_output o1.xy +dcl_output o2.xyzw +dcl_output o3.xyz +dcl_output o4.xyzw +dcl_output o5.xyz +dcl_output o6.xyz +dcl_maxout 4 +add r0.x, cb0[34].x, cb0[34].x +mul r0.yzw, cb0[33].xxyz, cb0[34].xxxx +mad r0.yzw, -r0.yyzw, l(0.000000, 2.000000, 2.000000, 2.000000), v[0][3].xxyz +mul r1.xyzw, r0.zzzz, cb0[9].xyzw +mad r1.xyzw, cb0[8].xyzw, r0.yyyy, r1.xyzw +mad r1.xyzw, cb0[10].xyzw, r0.wwww, r1.xyzw +add r1.xyzw, r1.xyzw, cb0[11].xyzw +mul r0.yzw, cb0[1].xxyz, cb0[33].yyyy +mad r0.yzw, cb0[0].xxyz, cb0[33].xxxx, r0.yyzw +mad r0.yzw, cb0[2].xxyz, cb0[33].zzzz, r0.yyzw +lt r2.x, v[0][1].x, l(0.000000) +mad r2.yzw, v[0][1].xxxx, l(0.000000, -0.900000, -0.800000, 0.000000), l(0.000000, 1.000000, 1.000000, 1.000000) +mov r3.xz, l(0.100000,0,1.000000,0) +mad r3.y, v[0][1].x, l(-0.900000), l(0.100000) +movc r2.xyz, r2.xxxx, r3.xyzx, r2.yzwy +mov r2.w, l(0) +ieq r3.xy, l(1, 2, 0, 0), cb0[35].xxxx +mul r3.z, l(0.050000), v[0][3].w +mov_sat r4.xyzw, r3.zzzz +and r3.z, l(7), v[0][2].x +add r5.xyz, cb0[r3.z + 12].xyzx, cb0[r3.z + 12].xyzx +mad r6.xyz, -cb0[r3.z + 12].xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(1.000000, 1.000000, 1.000000, 0.000000) +mad r5.xyz, r6.xyzx, l(0.100000, 0.100000, 0.100000, 0.000000), r5.xyzx +mov r5.w, l(0) +mov r3.z, l(0) +loop + ige r3.w, r3.z, l(4) + breakc_nz r3.w + add r6.xy, l(-0.500000, -0.500000, 0.000000, 0.000000), icb[r3.z + 0].xyxx + mad r6.xy, r0.xxxx, r6.xyxx, v[0][0].xyxx + mul r7.xyzw, r6.yyyy, cb0[5].xyzw + mad r6.xyzw, cb0[4].xyzw, r6.xxxx, r7.xyzw + mad r6.xyzw, cb0[6].xyzw, v[0][0].zzzz, r6.xyzw + mad r6.xyzw, cb0[7].xyzw, v[0][0].wwww, r6.xyzw + add r3.w, l(1.000000), -icb[r3.z + 0].y + if_nz r3.x + mov r7.xyzw, r2.xyzw + else + if_nz r3.y + mov r7.xyzw, r4.xyzw + else + mov r7.xyzw, r5.xyzw + endif + endif + mov o0.xyzw, r6.xyzw + mov o1.x, icb[r3.z + 0].x + mov o1.y, r3.w + mov o2.xyzw, r1.xyzw + mov o3.xyz, r0.yzwy + mov o4.xyzw, r7.xyzw + mov o5.xyz, v[0][3].xyzx + mov o6.xyz, v[0][0].xyzx + emit_stream m0 + iadd r3.z, r3.z, l(1) +endloop +ret +// Approximately 56 instruction slots used +#endif + +const BYTE g_pointGS[] = +{ + 68, 88, 66, 67, 225, 171, + 155, 174, 109, 180, 8, 136, + 18, 164, 43, 168, 152, 216, + 179, 151, 1, 0, 0, 0, + 56, 13, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 176, 3, 0, 0, 64, 4, + 0, 0, 44, 5, 0, 0, + 156, 12, 0, 0, 82, 68, + 69, 70, 116, 3, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 83, 71, 0, 1, 0, 0, + 64, 3, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 112, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 100, 2, + 0, 0, 2, 0, 0, 0, + 28, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 80, 111, 105, 110, + 116, 83, 104, 97, 100, 101, + 114, 67, 111, 110, 115, 116, + 0, 109, 111, 100, 101, 108, + 86, 105, 101, 119, 0, 102, + 108, 111, 97, 116, 52, 120, + 52, 0, 3, 0, 3, 0, + 4, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 203, 0, + 0, 0, 112, 114, 111, 106, + 101, 99, 116, 105, 111, 110, + 0, 108, 105, 103, 104, 116, + 84, 114, 97, 110, 115, 102, + 111, 114, 109, 0, 99, 111, + 108, 111, 114, 115, 0, 102, + 108, 111, 97, 116, 52, 0, + 1, 0, 3, 0, 1, 0, + 4, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 25, 1, 0, 0, + 115, 104, 97, 100, 111, 119, + 84, 97, 112, 115, 0, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 25, 1, 0, 0, + 108, 105, 103, 104, 116, 80, + 111, 115, 0, 102, 108, 111, + 97, 116, 51, 0, 1, 0, + 3, 0, 1, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 125, 1, 0, 0, 95, 112, + 97, 100, 48, 0, 102, 108, + 111, 97, 116, 0, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 174, 1, 0, 0, 108, 105, + 103, 104, 116, 68, 105, 114, + 0, 95, 112, 97, 100, 49, + 0, 112, 111, 105, 110, 116, + 82, 97, 100, 105, 117, 115, + 0, 112, 111, 105, 110, 116, + 83, 99, 97, 108, 101, 0, + 115, 112, 111, 116, 77, 105, + 110, 0, 115, 112, 111, 116, + 77, 97, 120, 0, 109, 111, + 100, 101, 0, 105, 110, 116, + 0, 171, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 2, + 0, 0, 95, 112, 97, 100, + 50, 0, 171, 171, 0, 0, + 2, 0, 1, 0, 1, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 19, 2, 0, 0, 193, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 248, 0, + 0, 0, 212, 0, 0, 0, + 64, 0, 0, 0, 3, 1, + 0, 0, 212, 0, 0, 0, + 128, 0, 0, 0, 18, 1, + 0, 0, 32, 1, 0, 0, + 192, 0, 0, 0, 68, 1, + 0, 0, 80, 1, 0, 0, + 64, 1, 0, 0, 116, 1, + 0, 0, 132, 1, 0, 0, + 0, 2, 0, 0, 168, 1, + 0, 0, 180, 1, 0, 0, + 12, 2, 0, 0, 216, 1, + 0, 0, 132, 1, 0, 0, + 16, 2, 0, 0, 225, 1, + 0, 0, 180, 1, 0, 0, + 28, 2, 0, 0, 231, 1, + 0, 0, 180, 1, 0, 0, + 32, 2, 0, 0, 243, 1, + 0, 0, 180, 1, 0, 0, + 36, 2, 0, 0, 254, 1, + 0, 0, 180, 1, 0, 0, + 40, 2, 0, 0, 6, 2, + 0, 0, 180, 1, 0, 0, + 44, 2, 0, 0, 14, 2, + 0, 0, 24, 2, 0, 0, + 48, 2, 0, 0, 60, 2, + 0, 0, 68, 2, 0, 0, + 64, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 144, 0, + 0, 0, 15, 0, 104, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 176, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 136, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 1, 1, 0, 0, + 121, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 1, 1, 0, 0, + 127, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 68, 69, 78, + 83, 73, 84, 89, 0, 80, + 72, 65, 83, 69, 0, 86, + 69, 82, 84, 69, 88, 0, + 171, 171, 79, 83, 71, 53, + 228, 0, 0, 0, 7, 0, + 0, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 204, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 0, 0, + 0, 0, 216, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 12, + 0, 0, 0, 0, 0, 0, + 216, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 0, 0, + 0, 0, 216, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 0, 0, 0, 0, + 216, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 8, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 6, 0, 0, 0, + 7, 8, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 171, 171, 83, 72, + 69, 88, 104, 7, 0, 0, + 80, 0, 2, 0, 218, 1, + 0, 0, 106, 8, 0, 1, + 53, 24, 0, 0, 18, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 36, 0, 0, 0, 95, 0, + 0, 4, 242, 16, 32, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 95, 0, 0, 4, + 18, 16, 32, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 95, 0, 0, 4, 18, 16, + 32, 0, 1, 0, 0, 0, + 2, 0, 0, 0, 95, 0, + 0, 4, 242, 16, 32, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 104, 0, 0, 2, + 8, 0, 0, 0, 93, 8, + 0, 1, 143, 0, 0, 3, + 0, 0, 17, 0, 0, 0, + 0, 0, 92, 40, 0, 1, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 5, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 6, 0, 0, 0, 94, 0, + 0, 2, 4, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 56, 0, 0, 9, 226, 0, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 33, 0, 0, 0, + 6, 128, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 50, 0, 0, 14, 226, 0, + 16, 0, 0, 0, 0, 0, + 86, 14, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 64, + 0, 0, 0, 64, 0, 0, + 0, 64, 6, 25, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 1, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 10, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 8, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 11, 0, + 0, 0, 56, 0, 0, 9, + 226, 0, 16, 0, 0, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 86, 133, 32, 0, + 0, 0, 0, 0, 33, 0, + 0, 0, 50, 0, 0, 11, + 226, 0, 16, 0, 0, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 6, 128, 32, 0, + 0, 0, 0, 0, 33, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 226, 0, 16, 0, + 0, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 166, 138, + 32, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 86, 14, + 16, 0, 0, 0, 0, 0, + 49, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 10, 16, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 16, + 226, 0, 16, 0, 2, 0, + 0, 0, 6, 16, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 102, 102, + 102, 191, 205, 204, 76, 191, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 54, 0, 0, 8, 82, 0, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 205, 204, + 204, 61, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 0, 0, 50, 0, 0, 10, + 34, 0, 16, 0, 3, 0, + 0, 0, 10, 16, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 102, 102, 102, 191, 1, 64, + 0, 0, 205, 204, 204, 61, + 55, 0, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 32, 0, 0, 11, + 50, 0, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 1, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 128, + 32, 0, 0, 0, 0, 0, + 35, 0, 0, 0, 56, 0, + 0, 8, 66, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 205, 204, 76, 61, + 58, 16, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 32, 0, 5, 242, 0, + 16, 0, 4, 0, 0, 0, + 166, 10, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 8, + 66, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 7, 0, 0, 0, 10, 16, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 13, 114, 0, 16, 0, + 5, 0, 0, 0, 70, 130, + 32, 6, 0, 0, 0, 0, + 12, 0, 0, 0, 42, 0, + 16, 0, 3, 0, 0, 0, + 70, 130, 32, 6, 0, 0, + 0, 0, 12, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 19, + 114, 0, 16, 0, 6, 0, + 0, 0, 70, 130, 32, 134, + 65, 0, 0, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 50, 0, 0, 12, 114, 0, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 6, 0, + 0, 0, 2, 64, 0, 0, + 205, 204, 204, 61, 205, 204, + 204, 61, 205, 204, 204, 61, + 0, 0, 0, 0, 70, 2, + 16, 0, 5, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 5, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 66, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 48, 0, + 0, 1, 33, 0, 0, 7, + 130, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 4, 0, 0, 0, + 3, 0, 4, 3, 58, 0, + 16, 0, 3, 0, 0, 0, + 0, 0, 0, 11, 50, 0, + 16, 0, 6, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 144, 144, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 10, + 50, 0, 16, 0, 6, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 0, + 16, 0, 6, 0, 0, 0, + 70, 16, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 7, 0, 0, 0, + 86, 5, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 6, 0, 16, 0, + 6, 0, 0, 0, 70, 14, + 16, 0, 7, 0, 0, 0, + 50, 0, 0, 11, 242, 0, + 16, 0, 6, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 166, 26, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 6, 0, + 0, 0, 50, 0, 0, 11, + 242, 0, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 246, 31, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 6, 0, 0, 0, 0, 0, + 0, 9, 130, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 26, 144, 144, 128, 65, 0, + 0, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 31, 0, + 4, 3, 10, 0, 16, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 242, 0, 16, 0, + 7, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 18, 0, 0, 1, 31, 0, + 4, 3, 26, 0, 16, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 242, 0, 16, 0, + 7, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 18, 0, 0, 1, 54, 0, + 0, 5, 242, 0, 16, 0, + 7, 0, 0, 0, 70, 14, + 16, 0, 5, 0, 0, 0, + 21, 0, 0, 1, 21, 0, + 0, 1, 54, 0, 0, 5, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 6, 0, 0, 0, 54, 0, + 0, 6, 18, 32, 16, 0, + 1, 0, 0, 0, 10, 144, + 144, 0, 42, 0, 16, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 34, 32, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 3, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 7, 0, 0, 0, + 54, 0, 0, 6, 114, 32, + 16, 0, 5, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 6, 114, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 117, 0, 0, 3, 0, 0, + 17, 0, 0, 0, 0, 0, + 30, 0, 0, 7, 66, 0, + 16, 0, 3, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 1, 0, 0, 0, 22, 0, + 0, 1, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 56, 0, 0, 0, + 8, 0, 0, 0, 4, 0, + 0, 0, 11, 0, 0, 0, + 24, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 5, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/pointPS.hlsl b/demo/d3d/shaders/pointPS.hlsl new file mode 100644 index 0000000..62c8ab4 --- /dev/null +++ b/demo/d3d/shaders/pointPS.hlsl @@ -0,0 +1,81 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + PointShaderConst gParams; +}; + +Texture2D shadowTexture : register(t0); // shadow map + +SamplerComparisonState shadowSampler : register(s0); // texture sample used to sample depth from shadow texture in this sample + +float sqr(float x) { return x * x; } + +float shadowSample(float4 lightOffsetPosition) +{ + float3 pos = float3(lightOffsetPosition.xyz / lightOffsetPosition.w); + //float3 uvw = (pos.xyz * 0.5) + vec3(0.5); + float3 uvw = (pos.xyz * float3(0.5, 0.5, 1.0)) + float3(0.5, 0.5, 0.0); + + // user clip + if (uvw.x < 0.0 || uvw.x > 1.0) + return 1.0; + if (uvw.y < 0.0 || uvw.y > 1.0) + return 1.0; + + float s = 0.0; + float radius = 0.002; + + // flip uv y-coordinate + uvw.y = 1.0f - uvw.y; + + [unroll] + for (int i = 0; i < 8; i++) + { + float2 shadowTaps = gParams.shadowTaps[i].xy; + shadowTaps.y = 1.0f - shadowTaps.y; + + //s += shadow2D(shadowTex, vec3(uvw.xy + shadowTaps[i] * radius, uvw.z)).r; + s += shadowTexture.SampleCmp(shadowSampler, uvw.xy + shadowTaps * radius, uvw.z); + } + s /= 8.0; + + return s; +} + +float4 pointPS(PointGeoOut input) : SV_TARGET +{ + const float spotMin = gParams.spotMin; + const float spotMax = gParams.spotMax; + + // calculate normal from texture coordinates + float3 normal; + normal.xy = input.texCoord * float2(2.0, -2.0) + float2(-1.0, 1.0); + float mag = dot(normal.xy, normal.xy); + if (mag > 1.0) + { + discard; // kill pixels outside circle + } + + normal.z = sqrt(1.0 - mag); + + if (gParams.mode == 2) + { + float alpha = normal.z * input.reflectance.w; + return float4(input.reflectance.xyz * alpha, alpha); + } + + // calculate lighting + float shadow = shadowSample(input.lightOffsetPosition); + + float3 lPos = float3(input.lightOffsetPosition.xyz / input.lightOffsetPosition.w); + float attenuation = max(smoothstep(spotMax, spotMin, dot(lPos.xy, lPos.xy)), 0.05); + + float3 diffuse = float3(0.9, 0.9, 0.9); + float3 reflectance = input.reflectance.xyz; + + float3 lo = diffuse * reflectance * max(0.0, sqr(-dot(input.viewLightDir, normal) * 0.5 + 0.5)) * max(0.2, shadow) * attenuation; + + const float tmp = 1.0 / 2.2; + return float4(pow(abs(lo), float3(tmp, tmp, tmp)), 1.0); +} diff --git a/demo/d3d/shaders/pointPS.hlsl.h b/demo/d3d/shaders/pointPS.hlsl.h new file mode 100644 index 0000000..1320e1d --- /dev/null +++ b/demo/d3d/shaders/pointPS.hlsl.h @@ -0,0 +1,947 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct PointShaderConst +// { +// +// float4x4 modelView; // Offset: 0 +// float4x4 projection; // Offset: 64 +// float4x4 lightTransform; // Offset: 128 +// float4 colors[8]; // Offset: 192 +// float4 shadowTaps[12]; // Offset: 320 +// float3 lightPos; // Offset: 512 +// float _pad0; // Offset: 524 +// float3 lightDir; // Offset: 528 +// float _pad1; // Offset: 540 +// float pointRadius; // Offset: 544 +// float pointScale; // Offset: 548 +// float spotMin; // Offset: 552 +// float spotMax; // Offset: 556 +// int mode; // Offset: 560 +// int _pad2[3]; // Offset: 576 +// +// } gParams; // Offset: 0 Size: 612 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// shadowSampler sampler_c NA NA 0 1 +// shadowTexture texture float 2d 0 1 +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xyzw 2 NONE float xyzw +// TEXCOORD 2 xyz 3 NONE float xyz +// TEXCOORD 3 xyzw 4 NONE float xyzw +// TEXCOORD 4 xyz 5 NONE float +// TEXCOORD 5 xyz 6 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[36], immediateIndexed +dcl_sampler s0, mode_comparison +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xy +dcl_input_ps linear v2.xyzw +dcl_input_ps linear v3.xyz +dcl_input_ps linear v4.xyzw +dcl_output o0.xyzw +dcl_temps 6 +mad r0.xy, v1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000) +dp2 r0.x, r0.xyxx, r0.xyxx +lt r0.y, l(1.000000), r0.x +discard_nz r0.y +add r0.x, -r0.x, l(1.000000) +sqrt r0.z, r0.x +ieq r0.w, cb0[35].x, l(2) +if_nz r0.w + mul r0.w, r0.z, v4.w + mul o0.xyz, r0.wwww, v4.xyzx + mov o0.w, r0.w + ret +endif +div r1.xyz, v2.xyzx, v2.wwww +mad r2.xyz, r1.xyzx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) +lt r0.w, r2.x, l(0.000000) +lt r1.z, l(1.000000), r2.x +or r0.w, r0.w, r1.z +add r1.z, -cb0[20].y, l(1.000000) +mul r3.x, cb0[20].x, l(0.002000) +mul r3.y, r1.z, l(0.002000) +add r2.w, -r2.y, l(1.000000) +add r1.zw, r2.xxxw, r3.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z +add r1.w, -cb0[21].y, l(1.000000) +mul r3.x, cb0[21].x, l(0.002000) +mul r3.y, r1.w, l(0.002000) +add r3.xy, r2.xwxx, r3.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r1.w, r3.xyxx, t0.xxxx, s0, r2.z +add r3.x, -cb0[22].y, l(1.000000) +mul r4.x, cb0[22].x, l(0.002000) +mul r4.y, r3.x, l(0.002000) +add r3.xy, r2.xwxx, r4.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r3.x, r3.xyxx, t0.xxxx, s0, r2.z +add r3.y, -cb0[23].y, l(1.000000) +mul r4.x, cb0[23].x, l(0.002000) +mul r4.y, r3.y, l(0.002000) +add r3.yz, r2.xxwx, r4.xxyx +sample_c_indexable(texture2d)(float,float,float,float) r3.y, r3.yzyy, t0.xxxx, s0, r2.z +add r3.z, -cb0[24].y, l(1.000000) +mul r4.x, cb0[24].x, l(0.002000) +mul r4.y, r3.z, l(0.002000) +add r3.zw, r2.xxxw, r4.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r3.z, r3.zwzz, t0.xxxx, s0, r2.z +add r3.w, -cb0[25].y, l(1.000000) +mul r4.x, cb0[25].x, l(0.002000) +mul r4.y, r3.w, l(0.002000) +add r4.xy, r2.xwxx, r4.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r3.w, r4.xyxx, t0.xxxx, s0, r2.z +add r4.x, -cb0[26].y, l(1.000000) +mul r5.x, cb0[26].x, l(0.002000) +mul r5.y, r4.x, l(0.002000) +add r4.xy, r2.xwxx, r5.xyxx +sample_c_indexable(texture2d)(float,float,float,float) r4.x, r4.xyxx, t0.xxxx, s0, r2.z +add r4.y, -cb0[27].y, l(1.000000) +mul r5.x, cb0[27].x, l(0.002000) +mul r5.y, r4.y, l(0.002000) +add r2.xw, r2.xxxw, r5.xxxy +sample_c_indexable(texture2d)(float,float,float,float) r2.x, r2.xwxx, t0.xxxx, s0, r2.z +if_z r0.w + lt r0.w, r2.y, l(0.000000) + lt r2.y, l(1.000000), r2.y + or r0.w, r0.w, r2.y + if_z r0.w + add r0.w, r1.w, r1.z + add r0.w, r3.x, r0.w + add r0.w, r3.y, r0.w + add r0.w, r3.z, r0.w + add r0.w, r3.w, r0.w + add r0.w, r4.x, r0.w + add r0.w, r2.x, r0.w + mul r0.w, r0.w, l(0.125000) + else + mov r0.w, l(1.000000) + endif +else + mov r0.w, l(1.000000) +endif +dp2 r1.x, r1.xyxx, r1.xyxx +add r1.y, -cb0[34].w, cb0[34].z +add r1.x, r1.x, -cb0[34].w +div r1.y, l(1.000000, 1.000000, 1.000000, 1.000000), r1.y +mul_sat r1.x, r1.y, r1.x +mad r1.y, r1.x, l(-2.000000), l(3.000000) +mul r1.x, r1.x, r1.x +mul r1.x, r1.x, r1.y +max r1.x, r1.x, l(0.050000) +mul r1.yzw, v4.xxyz, l(0.000000, 0.900000, 0.900000, 0.900000) +mad r0.xy, v1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000) +dp3 r0.x, v3.xyzx, r0.xyzx +mad r0.x, r0.x, l(-0.500000), l(0.500000) +mul r0.x, r0.x, r0.x +mul r0.xyz, r0.xxxx, r1.yzwy +max r0.w, r0.w, l(0.200000) +mul r0.xyz, r0.wwww, r0.xyzx +mul r0.xyz, r1.xxxx, r0.xyzx +log r0.xyz, |r0.xyzx| +mul r0.xyz, r0.xyzx, l(0.454545, 0.454545, 0.454545, 0.000000) +exp o0.xyz, r0.xyzx +mov o0.w, l(1.000000) +ret +// Approximately 101 instruction slots used +#endif + +const BYTE g_pointPS[] = +{ + 68, 88, 66, 67, 132, 161, + 61, 72, 143, 190, 218, 225, + 129, 194, 219, 86, 52, 88, + 26, 5, 1, 0, 0, 0, + 244, 17, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 12, 4, 0, 0, 220, 4, + 0, 0, 16, 5, 0, 0, + 88, 17, 0, 0, 82, 68, + 69, 70, 208, 3, 0, 0, + 1, 0, 0, 0, 196, 0, + 0, 0, 3, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 156, 3, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 156, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 170, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 184, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 115, 104, 97, 100, 111, 119, + 83, 97, 109, 112, 108, 101, + 114, 0, 115, 104, 97, 100, + 111, 119, 84, 101, 120, 116, + 117, 114, 101, 0, 99, 111, + 110, 115, 116, 66, 117, 102, + 0, 171, 171, 171, 184, 0, + 0, 0, 1, 0, 0, 0, + 220, 0, 0, 0, 112, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 1, + 0, 0, 0, 0, 0, 0, + 100, 2, 0, 0, 2, 0, + 0, 0, 120, 3, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 103, 80, 97, 114, + 97, 109, 115, 0, 80, 111, + 105, 110, 116, 83, 104, 97, + 100, 101, 114, 67, 111, 110, + 115, 116, 0, 109, 111, 100, + 101, 108, 86, 105, 101, 119, + 0, 102, 108, 111, 97, 116, + 52, 120, 52, 0, 3, 0, + 3, 0, 4, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 39, 1, 0, 0, 112, 114, + 111, 106, 101, 99, 116, 105, + 111, 110, 0, 108, 105, 103, + 104, 116, 84, 114, 97, 110, + 115, 102, 111, 114, 109, 0, + 99, 111, 108, 111, 114, 115, + 0, 102, 108, 111, 97, 116, + 52, 0, 1, 0, 3, 0, + 1, 0, 4, 0, 8, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 117, 1, + 0, 0, 115, 104, 97, 100, + 111, 119, 84, 97, 112, 115, + 0, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 117, 1, + 0, 0, 108, 105, 103, 104, + 116, 80, 111, 115, 0, 102, + 108, 111, 97, 116, 51, 0, + 1, 0, 3, 0, 1, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 217, 1, 0, 0, + 95, 112, 97, 100, 48, 0, + 102, 108, 111, 97, 116, 0, + 0, 0, 3, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 10, 2, 0, 0, + 108, 105, 103, 104, 116, 68, + 105, 114, 0, 95, 112, 97, + 100, 49, 0, 112, 111, 105, + 110, 116, 82, 97, 100, 105, + 117, 115, 0, 112, 111, 105, + 110, 116, 83, 99, 97, 108, + 101, 0, 115, 112, 111, 116, + 77, 105, 110, 0, 115, 112, + 111, 116, 77, 97, 120, 0, + 109, 111, 100, 101, 0, 105, + 110, 116, 0, 171, 0, 0, + 2, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 111, 2, 0, 0, 95, 112, + 97, 100, 50, 0, 171, 171, + 0, 0, 2, 0, 1, 0, + 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 111, 2, 0, 0, + 29, 1, 0, 0, 48, 1, + 0, 0, 0, 0, 0, 0, + 84, 1, 0, 0, 48, 1, + 0, 0, 64, 0, 0, 0, + 95, 1, 0, 0, 48, 1, + 0, 0, 128, 0, 0, 0, + 110, 1, 0, 0, 124, 1, + 0, 0, 192, 0, 0, 0, + 160, 1, 0, 0, 172, 1, + 0, 0, 64, 1, 0, 0, + 208, 1, 0, 0, 224, 1, + 0, 0, 0, 2, 0, 0, + 4, 2, 0, 0, 16, 2, + 0, 0, 12, 2, 0, 0, + 52, 2, 0, 0, 224, 1, + 0, 0, 16, 2, 0, 0, + 61, 2, 0, 0, 16, 2, + 0, 0, 28, 2, 0, 0, + 67, 2, 0, 0, 16, 2, + 0, 0, 32, 2, 0, 0, + 79, 2, 0, 0, 16, 2, + 0, 0, 36, 2, 0, 0, + 90, 2, 0, 0, 16, 2, + 0, 0, 40, 2, 0, 0, + 98, 2, 0, 0, 16, 2, + 0, 0, 44, 2, 0, 0, + 106, 2, 0, 0, 116, 2, + 0, 0, 48, 2, 0, 0, + 152, 2, 0, 0, 160, 2, + 0, 0, 64, 2, 0, 0, + 5, 0, 0, 0, 1, 0, + 144, 0, 0, 0, 15, 0, + 196, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 12, 1, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 200, 0, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 176, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 188, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 188, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 188, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 7, + 0, 0, 188, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 15, + 0, 0, 188, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 0, + 0, 0, 188, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 171, 171, + 83, 72, 69, 88, 64, 12, + 0, 0, 80, 0, 0, 0, + 16, 3, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 36, 0, 0, 0, + 90, 8, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 3, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 6, 0, 0, 0, + 50, 0, 0, 15, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 192, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 191, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 34, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 10, 0, 16, 0, 0, 0, + 0, 0, 13, 0, 4, 3, + 26, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 75, 0, + 0, 5, 66, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 32, 0, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 35, 0, 0, 0, + 1, 64, 0, 0, 2, 0, + 0, 0, 31, 0, 4, 3, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 4, 0, 0, 0, + 56, 0, 0, 7, 114, 32, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 4, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 21, 0, + 0, 1, 14, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 246, 31, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 15, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 66, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 10, 0, 16, 0, 2, 0, + 0, 0, 60, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 9, 66, 0, + 16, 0, 1, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 3, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 8, 130, 0, + 16, 0, 2, 0, 0, 0, + 26, 0, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 7, + 194, 0, 16, 0, 1, 0, + 0, 0, 6, 12, 16, 0, + 2, 0, 0, 0, 6, 4, + 16, 0, 3, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 66, 0, 16, 0, 1, 0, + 0, 0, 230, 10, 16, 0, + 1, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 2, 0, 0, 0, 0, 0, + 0, 9, 130, 0, 16, 0, + 1, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 50, 0, 16, 0, + 3, 0, 0, 0, 198, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 3, 0, 0, 0, + 198, 0, 16, 0, 2, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 2, 0, + 0, 0, 0, 0, 0, 9, + 34, 0, 16, 0, 3, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 98, 0, 16, 0, 3, 0, + 0, 0, 6, 3, 16, 0, + 2, 0, 0, 0, 6, 1, + 16, 0, 4, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 34, 0, 16, 0, 3, 0, + 0, 0, 150, 5, 16, 0, + 3, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 2, 0, 0, 0, 0, 0, + 0, 9, 66, 0, 16, 0, + 3, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 4, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 194, 0, 16, 0, + 3, 0, 0, 0, 6, 12, + 16, 0, 2, 0, 0, 0, + 6, 4, 16, 0, 4, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 66, 0, 16, 0, + 3, 0, 0, 0, 230, 10, + 16, 0, 3, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 9, 130, 0, + 16, 0, 3, 0, 0, 0, + 26, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 8, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 56, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 0, 0, 0, 7, 50, 0, + 16, 0, 4, 0, 0, 0, + 198, 0, 16, 0, 2, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 70, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 130, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 6, 112, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 2, 0, + 0, 0, 0, 0, 0, 9, + 18, 0, 16, 0, 4, 0, + 0, 0, 26, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 26, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 8, + 18, 0, 16, 0, 5, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 56, 0, + 0, 7, 34, 0, 16, 0, + 5, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 111, 18, + 3, 59, 0, 0, 0, 7, + 50, 0, 16, 0, 4, 0, + 0, 0, 198, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 5, 0, 0, 0, + 70, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 4, 0, 0, 0, 6, 112, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 2, 0, 0, 0, 0, 0, + 0, 9, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 128, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 27, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 8, 18, 0, 16, 0, + 5, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 27, 0, 0, 0, 1, 64, + 0, 0, 111, 18, 3, 59, + 56, 0, 0, 7, 34, 0, + 16, 0, 5, 0, 0, 0, + 26, 0, 16, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 111, 18, 3, 59, 0, 0, + 0, 7, 146, 0, 16, 0, + 2, 0, 0, 0, 6, 12, + 16, 0, 2, 0, 0, 0, + 6, 4, 16, 0, 5, 0, + 0, 0, 70, 0, 0, 141, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 198, 0, + 16, 0, 2, 0, 0, 0, + 6, 112, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 31, 0, 0, 3, 58, 0, + 16, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 49, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 26, 0, 16, 0, 2, 0, + 0, 0, 60, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 31, 0, 0, 3, 58, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 3, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 3, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 4, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 62, 18, 0, 0, 1, + 54, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 21, 0, 0, 1, + 18, 0, 0, 1, 54, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 21, 0, 0, 1, 15, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 0, + 16, 0, 1, 0, 0, 0, + 70, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 10, + 34, 0, 16, 0, 1, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 42, 128, 32, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 0, 0, 0, 9, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 58, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, + 14, 0, 0, 10, 34, 0, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 26, 0, 16, 0, + 1, 0, 0, 0, 56, 32, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 26, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 9, + 34, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 192, + 1, 64, 0, 0, 0, 0, + 64, 64, 56, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 26, 0, 16, 0, + 1, 0, 0, 0, 52, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 205, 204, + 76, 61, 56, 0, 0, 10, + 226, 0, 16, 0, 1, 0, + 0, 0, 6, 25, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 102, 102, 102, 63, 102, 102, + 102, 63, 102, 102, 102, 63, + 50, 0, 0, 15, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 64, 0, 0, + 0, 192, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 191, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 191, 1, 64, 0, 0, + 0, 0, 0, 63, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 52, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 205, 204, 76, 62, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 47, 0, 0, 6, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 129, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 47, 186, 232, 62, 47, 186, + 232, 62, 47, 186, 232, 62, + 0, 0, 0, 0, 25, 0, + 0, 5, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 101, 0, 0, 0, + 6, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 75, 0, 0, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 4, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/pointShadowPS.hlsl b/demo/d3d/shaders/pointShadowPS.hlsl new file mode 100644 index 0000000..d8fcff8 --- /dev/null +++ b/demo/d3d/shaders/pointShadowPS.hlsl @@ -0,0 +1,17 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + PointShaderConst gParams; +}; + +void pointShadowPS(PointGeoOut input) +{ + // calculate normal from texture coordinates + float2 normal = input.texCoord.xy - float2(0.5, 0.5); + float mag = dot(normal.xy, normal.xy); + if (mag > 0.5 * 0.5) + { + discard; // kill pixels outside circle + } +} diff --git a/demo/d3d/shaders/pointShadowPS.hlsl.h b/demo/d3d/shaders/pointShadowPS.hlsl.h new file mode 100644 index 0000000..ee3c121 --- /dev/null +++ b/demo/d3d/shaders/pointShadowPS.hlsl.h @@ -0,0 +1,157 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xyzw 2 NONE float +// TEXCOORD 2 xyz 3 NONE float +// TEXCOORD 3 xyzw 4 NONE float +// TEXCOORD 4 xyz 5 NONE float +// TEXCOORD 5 xyz 6 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// no Output +ps_5_0 +dcl_globalFlags refactoringAllowed +dcl_input_ps linear v1.xy +dcl_temps 1 +add r0.xy, v1.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) +dp2 r0.x, r0.xyxx, r0.xyxx +lt r0.x, l(0.250000), r0.x +discard_nz r0.x +ret +// Approximately 5 instruction slots used +#endif + +const BYTE g_pointShadowPS[] = +{ + 68, 88, 66, 67, 124, 19, + 253, 39, 130, 123, 235, 41, + 10, 2, 21, 191, 153, 200, + 242, 4, 1, 0, 0, 0, + 192, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 172, 0, 0, 0, 124, 1, + 0, 0, 140, 1, 0, 0, + 36, 2, 0, 0, 82, 68, + 69, 70, 112, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 255, 255, 0, 1, 0, 0, + 60, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, + 71, 78, 200, 0, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 176, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 188, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 188, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 188, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 188, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 188, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 0, + 0, 0, 188, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 8, 0, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 83, 72, 69, 88, 144, 0, + 0, 0, 80, 0, 0, 0, + 36, 0, 0, 0, 106, 8, + 0, 1, 98, 16, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 0, 0, + 0, 10, 50, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 0, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 0, 0, 0, 0, 70, 0, + 16, 0, 0, 0, 0, 0, + 49, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 62, 10, 0, 16, 0, + 0, 0, 0, 0, 13, 0, + 4, 3, 10, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 5, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/demo/d3d/shaders/pointVS.hlsl b/demo/d3d/shaders/pointVS.hlsl new file mode 100644 index 0000000..ecd1e38 --- /dev/null +++ b/demo/d3d/shaders/pointVS.hlsl @@ -0,0 +1,25 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + PointShaderConst gParams; +}; + +PointVertexOut pointVS(PointVertexIn input, uint instance : SV_VertexID) +{ + const float4 modelPosition = input.position; + const float4x4 modelViewMatrix = gParams.modelView; + + float density = input.density; + int phase = input.phase; + + // calculate window-space point size + float4 viewPos = mul(modelViewMatrix, float4(modelPosition.xyz, 1.0)); + + PointVertexOut output; + output.viewPosition = viewPos; + output.density = density; + output.phase = phase; + output.modelPosition = modelPosition; + return output; +} diff --git a/demo/d3d/shaders/pointVS.hlsl.h b/demo/d3d/shaders/pointVS.hlsl.h new file mode 100644 index 0000000..5051a59 --- /dev/null +++ b/demo/d3d/shaders/pointVS.hlsl.h @@ -0,0 +1,374 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer constBuf +// { +// +// struct PointShaderConst +// { +// +// float4x4 modelView; // Offset: 0 +// float4x4 projection; // Offset: 64 +// float4x4 lightTransform; // Offset: 128 +// float4 colors[8]; // Offset: 192 +// float4 shadowTaps[12]; // Offset: 320 +// float3 lightPos; // Offset: 512 +// float _pad0; // Offset: 524 +// float3 lightDir; // Offset: 528 +// float _pad1; // Offset: 540 +// float pointRadius; // Offset: 544 +// float pointScale; // Offset: 548 +// float spotMin; // Offset: 552 +// float spotMax; // Offset: 556 +// int mode; // Offset: 560 +// int _pad2[3]; // Offset: 576 +// +// } gParams; // Offset: 0 Size: 612 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// constBuf cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// DENSITY 0 x 1 NONE float x +// PHASE 0 x 2 NONE int x +// SV_VertexID 0 x 3 VERTID uint +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xyzw 0 NONE float xyzw +// DENSITY 0 x 1 NONE float x +// PHASE 0 x 2 NONE int x +// VERTEX 0 xyzw 3 NONE float xyzw +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[4], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.x +dcl_input v2.x +dcl_output o0.xyzw +dcl_output o1.x +dcl_output o2.x +dcl_output o3.xyzw +dcl_temps 1 +mul r0.xyzw, v0.yyyy, cb0[1].xyzw +mad r0.xyzw, cb0[0].xyzw, v0.xxxx, r0.xyzw +mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw +add o0.xyzw, r0.xyzw, cb0[3].xyzw +mov o1.x, v1.x +mov o2.x, v2.x +mov o3.xyzw, v0.xyzw +ret +// Approximately 8 instruction slots used +#endif + +const BYTE g_pointVS[] = +{ + 68, 88, 66, 67, 214, 36, + 191, 126, 186, 99, 189, 31, + 31, 225, 65, 123, 198, 88, + 217, 159, 1, 0, 0, 0, + 192, 6, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 176, 3, 0, 0, 68, 4, + 0, 0, 212, 4, 0, 0, + 36, 6, 0, 0, 82, 68, + 69, 70, 116, 3, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 64, 3, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 99, 111, 110, 115, + 116, 66, 117, 102, 0, 171, + 171, 171, 92, 0, 0, 0, + 1, 0, 0, 0, 128, 0, + 0, 0, 112, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 100, 2, + 0, 0, 2, 0, 0, 0, + 28, 3, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 103, 80, 97, 114, 97, 109, + 115, 0, 80, 111, 105, 110, + 116, 83, 104, 97, 100, 101, + 114, 67, 111, 110, 115, 116, + 0, 109, 111, 100, 101, 108, + 86, 105, 101, 119, 0, 102, + 108, 111, 97, 116, 52, 120, + 52, 0, 3, 0, 3, 0, + 4, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 203, 0, + 0, 0, 112, 114, 111, 106, + 101, 99, 116, 105, 111, 110, + 0, 108, 105, 103, 104, 116, + 84, 114, 97, 110, 115, 102, + 111, 114, 109, 0, 99, 111, + 108, 111, 114, 115, 0, 102, + 108, 111, 97, 116, 52, 0, + 1, 0, 3, 0, 1, 0, + 4, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 25, 1, 0, 0, + 115, 104, 97, 100, 111, 119, + 84, 97, 112, 115, 0, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 25, 1, 0, 0, + 108, 105, 103, 104, 116, 80, + 111, 115, 0, 102, 108, 111, + 97, 116, 51, 0, 1, 0, + 3, 0, 1, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 125, 1, 0, 0, 95, 112, + 97, 100, 48, 0, 102, 108, + 111, 97, 116, 0, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 174, 1, 0, 0, 108, 105, + 103, 104, 116, 68, 105, 114, + 0, 95, 112, 97, 100, 49, + 0, 112, 111, 105, 110, 116, + 82, 97, 100, 105, 117, 115, + 0, 112, 111, 105, 110, 116, + 83, 99, 97, 108, 101, 0, + 115, 112, 111, 116, 77, 105, + 110, 0, 115, 112, 111, 116, + 77, 97, 120, 0, 109, 111, + 100, 101, 0, 105, 110, 116, + 0, 171, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 2, + 0, 0, 95, 112, 97, 100, + 50, 0, 171, 171, 0, 0, + 2, 0, 1, 0, 1, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 19, 2, 0, 0, 193, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 248, 0, + 0, 0, 212, 0, 0, 0, + 64, 0, 0, 0, 3, 1, + 0, 0, 212, 0, 0, 0, + 128, 0, 0, 0, 18, 1, + 0, 0, 32, 1, 0, 0, + 192, 0, 0, 0, 68, 1, + 0, 0, 80, 1, 0, 0, + 64, 1, 0, 0, 116, 1, + 0, 0, 132, 1, 0, 0, + 0, 2, 0, 0, 168, 1, + 0, 0, 180, 1, 0, 0, + 12, 2, 0, 0, 216, 1, + 0, 0, 132, 1, 0, 0, + 16, 2, 0, 0, 225, 1, + 0, 0, 180, 1, 0, 0, + 28, 2, 0, 0, 231, 1, + 0, 0, 180, 1, 0, 0, + 32, 2, 0, 0, 243, 1, + 0, 0, 180, 1, 0, 0, + 36, 2, 0, 0, 254, 1, + 0, 0, 180, 1, 0, 0, + 40, 2, 0, 0, 6, 2, + 0, 0, 180, 1, 0, 0, + 44, 2, 0, 0, 14, 2, + 0, 0, 24, 2, 0, 0, + 48, 2, 0, 0, 60, 2, + 0, 0, 68, 2, 0, 0, + 64, 2, 0, 0, 5, 0, + 0, 0, 1, 0, 144, 0, + 0, 0, 15, 0, 104, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 176, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, + 140, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 1, 1, 0, 0, + 121, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 1, 1, 0, 0, + 127, 0, 0, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 68, 69, 78, + 83, 73, 84, 89, 0, 80, + 72, 65, 83, 69, 0, 83, + 86, 95, 86, 101, 114, 116, + 101, 120, 73, 68, 0, 171, + 79, 83, 71, 78, 136, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 113, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 1, 14, 0, 0, 121, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 1, 14, 0, 0, 127, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 80, 79, + 83, 73, 84, 73, 79, 78, + 0, 68, 69, 78, 83, 73, + 84, 89, 0, 80, 72, 65, + 83, 69, 0, 86, 69, 82, + 84, 69, 88, 0, 171, 171, + 83, 72, 69, 88, 72, 1, + 0, 0, 80, 0, 1, 0, + 82, 0, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 18, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 18, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 3, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 0, 0, + 0, 0, 86, 21, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 166, 26, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 54, 0, 0, 5, + 18, 32, 16, 0, 1, 0, + 0, 0, 10, 16, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 18, 32, 16, 0, + 2, 0, 0, 0, 10, 16, + 16, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 8, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/demo/d3d/shaders/shaderCommon.h b/demo/d3d/shaders/shaderCommon.h new file mode 100644 index 0000000..2a9cc67 --- /dev/null +++ b/demo/d3d/shaders/shaderCommon.h @@ -0,0 +1,254 @@ +struct MeshShaderConst +{ + float4x4 modelViewProjection; + float4x4 modelView; + float4x4 objectTransform; + float4x4 lightTransform; + + float4 clipPlane; + float4 fogColor; + float4 color; + float4 secondaryColor; + + float4 shadowTaps[12]; + + float3 lightPos; + float _pad0; + float3 lightDir; + float _pad1; + + float bias; + float expand; + float spotMin; + float spotMax; + + int grid; + int tex; + int colorArray; + int increaseGfxLoadForAsyncComputeTesting; +}; + +struct DebugRenderConst +{ + float4x4 modelView; + float4x4 projection; +}; + + +#ifndef EXCLUDE_SHADER_STRUCTS +struct MeshVertexIn +{ + float3 position : POSITION; + float3 normal : NORMAL; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +struct MeshVertexOut +{ + float4 position : SV_POSITION; + //float3 normal : NORMAL; + //float4 color : COLOR; + //float clipDistance[1] : CLIP_DISTANCE; + + float3 worldNormal: TEXCOORD0; ///< Normal in world space + float4 lightOffsetPosition: TEXCOORD1; ///< Position in light space (offset slightly) + float3 viewLightDir: TEXCOORD2; ///< Light direction in view space + float3 worldPosition: TEXCOORD3; ///< Position in worldspace + float4 color: TEXCOORD4; ///< Color + float2 texCoord: TEXCOORD5; ///< Tex coords + float4 secondaryColor: TEXCOORD6; ///< Secondary color + float4 viewPosition: TEXCOORD7; ///< Position in view space +}; +#endif + +struct PointShaderConst +{ + float4x4 modelView; + float4x4 projection; + float4x4 lightTransform; + + float4 colors[8]; + float4 shadowTaps[12]; + + float3 lightPos; + float _pad0; + float3 lightDir; + float _pad1; + + float pointRadius; // point size in world space + float pointScale; // scale to calculate size in pixels + float spotMin; + float spotMax; + + int mode; + int _pad2[3]; +}; + +#ifndef EXCLUDE_SHADER_STRUCTS +struct PointVertexIn +{ + float4 position : POSITION; + float density : DENSITY; + int phase : PHASE; +}; + +struct PointVertexOut +{ + float4 viewPosition : POSITION; + float density : DENSITY; + int phase : PHASE; + float4 modelPosition : VERTEX; +}; + +struct PointGeoOut +{ + float4 position : SV_POSITION; + + float2 texCoord: TEXCOORD0; + float4 lightOffsetPosition: TEXCOORD1; + float3 viewLightDir: TEXCOORD2; //< Light direction in view space + float4 reflectance: TEXCOORD3; + float3 modelPosition: TEXCOORD4; ///< Model space position + float3 viewPosition : TEXCOORD5; ///< View space position +}; + +#endif + +struct FluidShaderConst +{ + float4x4 modelViewProjection; + float4x4 modelView; + float4x4 projection; // ogl projection + float4x4 inverseModelView; + float4x4 inverseProjection; // ogl inverse projection + + float4 invTexScale; + + float3 invViewport; + float _pad0; + //float3 invProjection; + //float _pad1; + + float blurRadiusWorld; + float blurScale; + float blurFalloff; + int debug; + + float3 lightPos; + float _pad1; + float3 lightDir; + float _pad2; + float4x4 lightTransform; + + float4 color; + float4 clipPosToEye; + + float spotMin; + float spotMax; + float ior; + float _pad3; + + float4 shadowTaps[12]; +}; + +#ifndef EXCLUDE_SHADER_STRUCTS +struct FluidVertexIn +{ + float4 position : POSITION; + float4 q1 : U; + float4 q2 : V; + float4 q3 : W; +}; + +struct FluidVertexOut +{ + float4 position : POSITION; + float4 bounds: TEXCOORD0; // xmin, xmax, ymin, ymax + float4 invQ0: TEXCOORD1; + float4 invQ1: TEXCOORD2; + float4 invQ2: TEXCOORD3; + float4 invQ3: TEXCOORD4; + float4 ndcPos: TEXCOORD5; /// Position in normalized device coordinates (ie /w) +}; + +struct FluidGeoOut +{ + float4 position : SV_POSITION; + float4 invQ0 : TEXCOORD0; + float4 invQ1 : TEXCOORD1; + float4 invQ2 : TEXCOORD2; + float4 invQ3 : TEXCOORD3; +}; + +struct PassthroughVertexOut +{ + float4 position : SV_POSITION; + float2 texCoord : TEXCOORD; +}; +#endif + + +struct DiffuseShaderConst +{ + float3 lightPos; float pad0; + float3 lightDir; float pad1; + float4x4 lightTransform; + float4 color; + + float4x4 modelView; + float4x4 modelViewProjection; + float4x4 projection; + + float4 shadowTaps[12]; + + float diffusion; + float diffuseRadius; // point size in world space + float diffuseScale; // scale to calculate size in pixels + + float spotMin; + float spotMax; + + float motionBlurScale; + + float pad3; + float pad4; + +}; + +#ifndef EXCLUDE_SHADER_STRUCTS + +struct DiffuseVertexIn +{ + float4 position : POSITION; // lifetime in w + float4 velocity : VELOCITY; // holding velocity in u +}; + +struct DiffuseVertexOut +{ + float4 worldPos : POSITION; // lifetime in w + float4 ndcPos : NCDPOS; + float4 viewPos : VIEWPOS; + float4 viewVel : VIEWVEL; + + float4 color : COLOR; +}; + +struct DiffuseGeometryOut +{ + float4 clipPos : SV_POSITION; + + float4 worldPos : POSITION; + + float4 viewPos : VIEWPOS; + float4 viewVel : VIEWVEL; + + float4 lightDir : LIGHTDIR; + float4 color : COLOR; + + float2 uv : UV; + +}; + +#endif + diff --git a/demo/d3d/shadersDemoContext.cpp b/demo/d3d/shadersDemoContext.cpp new file mode 100644 index 0000000..d1e7c99 --- /dev/null +++ b/demo/d3d/shadersDemoContext.cpp @@ -0,0 +1,184 @@ +// to fix min max windows macros +#define NOMINMAX + +// SDL +#include + +// This +#include "shadersDemoContext.h" + +DemoContext* s_context = NULL; + +void SetDemoContext(DemoContext* context) +{ + s_context = context; +} + +DemoContext* GetDemoContext() +{ + return s_context; +} + +void ReshapeRender(SDL_Window* window) +{ + int width, height; + SDL_GetWindowSize(window, &width, &height); + s_context->onSizeChanged(width, height, false); +} + +void DestroyRender() +{ + if (s_context) + { + delete s_context; + s_context = nullptr; + } +} + +void StartFrame(Vec4 colorIn) { s_context->startFrame(colorIn); } +void EndFrame() { s_context->endFrame(); } +void PresentFrame(bool fullSync) { s_context->presentFrame(fullSync); } + +void FlushGraphicsAndWait() { s_context->flushGraphicsAndWait(); } + +void ReadFrame(int* backbuffer, int width, int height) +{ + assert(0); +} + +void GetViewRay(int x, int y, Vec3& origin, Vec3& dir) { return s_context->getViewRay(x, y, origin, dir); } + +void SetFillMode(bool wire) { s_context->setFillMode(wire); } + +void SetCullMode(bool enabled) { s_context->setCullMode(enabled); } + +void SetView(Matrix44 view, Matrix44 projection) { return s_context->setView(view, projection); } + +FluidRenderer* CreateFluidRenderer(uint32_t width, uint32_t height) { return s_context->createFluidRenderer(width, height); } + +void DestroyFluidRenderer(FluidRenderer* renderer) { return s_context->destroyFluidRenderer(renderer); } + +FluidRenderBuffers* CreateFluidRenderBuffers(int numParticles, bool enableInterop) { return s_context->createFluidRenderBuffers(numParticles, enableInterop); } + +void UpdateFluidRenderBuffers(FluidRenderBuffers* buffers, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) +{ + s_context->updateFluidRenderBuffers(buffers, particles, densities, anisotropy1, anisotropy2, anisotropy3, numParticles, indices, numIndices); +} + +void UpdateFluidRenderBuffers(FluidRenderBuffers* buffers, NvFlexSolver* flex, bool anisotropy, bool density) { return s_context->updateFluidRenderBuffers(buffers, flex, anisotropy, density); } + +void DestroyFluidRenderBuffers(FluidRenderBuffers* buffers) { return s_context->destroyFluidRenderBuffers(buffers); } + +ShadowMap* ShadowCreate() { return s_context->shadowCreate(); } + +void ShadowDestroy(ShadowMap* map) { s_context->shadowDestroy(map); } + +void ShadowBegin(ShadowMap* map) { s_context->shadowBegin(map); } + +void ShadowEnd() { s_context->shadowEnd(); } + + +void BindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float bias, Vec4 fogColor) +{ + s_context->bindSolidShader(lightPos, lightTarget, lightTransform, shadowMap, bias, fogColor); +} + +void UnbindSolidShader() { s_context->unbindSolidShader(); } + +void DrawMesh(const Mesh* m, Vec3 color) { s_context->drawMesh(m, color); } + +void DrawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth) +{ + s_context->drawCloth(positions, normals, uvs, indices, numTris, numPositions, colorIndex, expand, twosided, smooth); +} + +void DrawRope(Vec4* positions, int* indices, int numIndices, float radius, int color) +{ + s_context->drawRope(positions, indices, numIndices, radius, color); +} + +void DrawPlane(const Vec4& p, bool color) { s_context->drawPlane(p, color); } + +void DrawPlanes(Vec4* planes, int n, float bias) { s_context->drawPlanes(planes, n, bias); } + +GpuMesh* CreateGpuMesh(const Mesh* m) +{ + return m ? s_context->createGpuMesh(m) : nullptr; +} + +void DestroyGpuMesh(GpuMesh* m) { s_context->destroyGpuMesh(m); } + +void DrawGpuMesh(GpuMesh* m, const Matrix44& xform, const Vec3& color) { s_context->drawGpuMesh(m, xform, color); } + +void DrawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const Vec3& color) { s_context->drawGpuMeshInstances(m, xforms, n, color); } + +void DrawPoints(FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, bool showDensity) +{ + s_context->drawPoints(buffers, n, offset, radius, screenWidth, screenAspect, fov, lightPos, lightTarget, lightTransform, shadowTex, showDensity); +} + +void RenderEllipsoids(FluidRenderer* renderer, FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) +{ + s_context->renderEllipsoids(renderer, buffers, n, offset, radius, screenWidth, screenAspect, fov, lightPos, lightTarget, lightTransform, shadowMap, color, blur, ior, debug); +} + +DiffuseRenderBuffers* CreateDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop) { return s_context->createDiffuseRenderBuffers(numDiffuseParticles, enableInterop); } + +void DestroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers) { return s_context->destroyDiffuseRenderBuffers(buffers); } + +void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles) +{ + s_context->updateDiffuseRenderBuffers(buffers, diffusePositions, diffuseVelocities, numDiffuseParticles); +} + +void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, NvFlexSolver* solver) { return s_context->updateDiffuseRenderBuffers(buffers, solver); } + +int GetNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers) { return s_context->getNumDiffuseRenderParticles(buffers); } + +void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers* buffers, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front) +{ + s_context->drawDiffuse(render, buffers, n, radius, screenWidth, screenAspect, fov, color, lightPos, lightTarget, lightTransform, shadowMap, motionBlur, inscatter, outscatter, shadowEnabled, front); +} + +void BeginLines() { s_context->beginLines(); } + +void DrawLine(const Vec3& p, const Vec3& q, const Vec4& color) { s_context->drawLine(p, q, color); } + +void EndLines() { s_context->endLines(); } + +void BeginPoints(float size) {} +void DrawPoint(const Vec3& p, const Vec4& color) {} +void EndPoints() {} + +float RendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) +{ + return s_context->rendererGetDeviceTimestamps(begin, end, freq); +} + +void* GetGraphicsCommandQueue() { return s_context->getGraphicsCommandQueue(); } +void GraphicsTimerBegin() { s_context->graphicsTimerBegin(); } +void GraphicsTimerEnd() { s_context->graphicsTimerEnd(); } + +void StartGpuWork() { s_context->startGpuWork(); } +void EndGpuWork() { s_context->endGpuWork(); } + +void DrawImguiGraph() { return s_context->drawImguiGraph(); } + +void GetRenderDevice(void** deviceOut, void** contextOut) { return s_context->getRenderDevice(deviceOut, contextOut); } + +void InitRender(const RenderInitOptions& options) +{ + if (!s_context) + { + assert(false && "A context has not been set with SetDemoContext!"); + return; + } + if (!s_context->initialize(options)) + { + assert(!"Unable to initialize context!"); + delete s_context; + s_context = nullptr; + return; + } +} + diff --git a/demo/d3d/shadersDemoContext.h b/demo/d3d/shadersDemoContext.h new file mode 100644 index 0000000..030dee6 --- /dev/null +++ b/demo/d3d/shadersDemoContext.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include "../shaders.h" + +#include "demoContext.h" + +// This file implements the Shaders.h 'interface' through the DemoContext interface + +void SetDemoContext(DemoContext* context); +DemoContext* GetDemoContext(); + diff --git a/demo/d3d11/appD3D11Ctx.cpp b/demo/d3d11/appD3D11Ctx.cpp index 85129e5..2d6b721 100644 --- a/demo/d3d11/appD3D11Ctx.cpp +++ b/demo/d3d11/appD3D11Ctx.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * 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 @@ -25,45 +25,56 @@ #include #include -AppGraphProfiler* appGraphCreateProfiler(AppGraphCtx* ctx); -void appGraphProfilerFrameBegin(AppGraphProfiler* profiler); -void appGraphProfilerFrameEnd(AppGraphProfiler* profiler); -void appGraphProfilerEnable(AppGraphProfiler* profiler, bool enabled); -void appGraphProfilerBegin(AppGraphProfiler* profiler, const char* label); -void appGraphProfilerEnd(AppGraphProfiler* profiler, const char* label); -bool appGraphProfilerGet(AppGraphProfiler* profiler, const char** plabel, float* cpuTime, float* gpuTime, int index); -void appGraphReleaseProfiler(AppGraphProfiler* profiler); +namespace +{ + // COM object release utilities + template + void inline COMRelease(T& t) + { + if (t) t->Release(); + t = nullptr; + } + + template + void inline COMRelease(T& t, UINT arraySize) + { + for (UINT i = 0; i < arraySize; i++) + { + if (t[i]) t[i]->Release(); + t[i] = nullptr; + } + } +} -AppGraphCtx::AppGraphCtx() +AppGraphProfilerD3D11* appGraphCreateProfilerD3D11(AppGraphCtx* ctx); +void appGraphProfilerD3D11FrameBegin(AppGraphProfilerD3D11* profiler); +void appGraphProfilerD3D11FrameEnd(AppGraphProfilerD3D11* profiler); +void appGraphProfilerD3D11Enable(AppGraphProfilerD3D11* profiler, bool enabled); +void appGraphProfilerD3D11Begin(AppGraphProfilerD3D11* profiler, const char* label); +void appGraphProfilerD3D11End(AppGraphProfilerD3D11* profiler, const char* label); +bool appGraphProfilerD3D11Get(AppGraphProfilerD3D11* profiler, const char** plabel, float* cpuTime, float* gpuTime, int index); +void appGraphReleaseProfiler(AppGraphProfilerD3D11* profiler); + +AppGraphCtxD3D11::AppGraphCtxD3D11() { - m_profiler = appGraphCreateProfiler(this); - memset(&m_viewport, 0, sizeof(m_viewport)); + m_profiler = appGraphCreateProfilerD3D11(cast_from_AppGraphCtxD3D11(this)); } -AppGraphCtx::~AppGraphCtx() +AppGraphCtxD3D11::~AppGraphCtxD3D11() { - AppGraphCtxReleaseRenderTarget(this); - - COMRelease(m_swapChain); - COMRelease(m_backBuffer); - COMRelease(m_rtv); - COMRelease(m_depthStencil); - COMRelease(m_dsv); - COMRelease(m_depthSRV); - COMRelease(m_depthState); - COMRelease(m_blendState); - COMRelease(m_resolvedTarget); - COMRelease(m_resolvedTargetSRV); - COMRelease(m_deviceContext); + AppGraphCtxReleaseRenderTargetD3D11(cast_from_AppGraphCtxD3D11(this)); + COMRelease(m_device); + COMRelease(m_deviceContext); + COMRelease(m_depthState); appGraphReleaseProfiler(m_profiler); m_profiler = nullptr; } -AppGraphCtx* AppGraphCtxCreate(int deviceID) +AppGraphCtx* AppGraphCtxCreateD3D11(int deviceID) { - AppGraphCtx* context = new AppGraphCtx; + AppGraphCtxD3D11* context = new AppGraphCtxD3D11; HRESULT hr = S_OK; @@ -148,30 +159,71 @@ AppGraphCtx* AppGraphCtxCreate(int deviceID) return nullptr; } - // create blend state - D3D11_BLEND_DESC blendStateDesc = {}; - blendStateDesc.RenderTarget[0].BlendEnable = TRUE; - blendStateDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; - blendStateDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; - blendStateDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendStateDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendStateDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; - blendStateDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendStateDesc.RenderTarget[0].RenderTargetWriteMask = 0x0f; - - if (hr = context->m_device->CreateBlendState(&blendStateDesc, &context->m_blendState)) + return cast_from_AppGraphCtxD3D11(context); +} + +void AppGraphCtxInitRenderTargetD3D11(AppGraphCtx* context, SDL_Window* window, bool fullscreen, int numMSAASamples); + +bool AppGraphCtxUpdateSizeD3D11(AppGraphCtx* contextIn, SDL_Window* window, bool fullscreen, int numMSAASamples) +{ + auto context = cast_to_AppGraphCtxD3D11(contextIn); + + // TODO: fix iflip fullscreen support + fullscreen = false; + + bool sizeChanged = false; + int width, height; + SDL_GetWindowSize(window, &width, &height); + + // sync with window + { + HWND hWnd = nullptr; + // get Windows handle to this SDL window + SDL_SysWMinfo winInfo; + SDL_VERSION(&winInfo.version); + if (SDL_GetWindowWMInfo(window, &winInfo)) + { + if (winInfo.subsystem == SDL_SYSWM_WINDOWS) + { + hWnd = winInfo.info.win.window; + } + } + context->m_hWnd = hWnd; + context->m_fullscreen = fullscreen; + + HRESULT hr = S_OK; + + if (context->m_winW != width || context->m_winH != height) + { + context->m_winW = width; + context->m_winH = height; + sizeChanged = true; + context->m_valid = (context->m_winW != 0 && context->m_winH != 0); + } + } + + if (sizeChanged) { - delete context; - return nullptr; + const bool wasValid = context->m_valid; + // Release + AppGraphCtxReleaseRenderTargetD3D11(cast_from_AppGraphCtxD3D11(context)); + // If was valid recreate it + if (wasValid) + { + // Reset the size (the release sets it, to 0,0) + context->m_winW = width; + context->m_winH = height; + // + AppGraphCtxInitRenderTargetD3D11(cast_from_AppGraphCtxD3D11(context), window, fullscreen, numMSAASamples); + } } - return context; + return context->m_valid; } -void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool fullscreen, int samples) +void AppGraphCtxInitRenderTargetD3D11(AppGraphCtx* contextIn, SDL_Window* window, bool fullscreen, int numMSAASamples) { - // TODO: fix iflip fullscreen support - fullscreen = false; + auto context = cast_to_AppGraphCtxD3D11(contextIn); HWND hWnd = nullptr; // get Windows handle to this SDL window @@ -187,15 +239,11 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool context->m_hWnd = hWnd; context->m_fullscreen = fullscreen; - HRESULT hr = S_OK; - - RECT rc; - GetClientRect(context->m_hWnd, &rc); - UINT width = rc.right - rc.left; - UINT height = rc.bottom - rc.top; + // Desired size + int width, height; + SDL_GetWindowSize(window, &width, &height); - context->m_winW = width; - context->m_winH = height; + HRESULT hr = S_OK; // enumerate devices IDXGIFactory1* pFactory = NULL; @@ -207,15 +255,15 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool DXGI_SWAP_CHAIN_DESC desc; ZeroMemory(&desc, sizeof(desc)); desc.BufferCount = 1; - desc.BufferDesc.Width = context->m_winW; - desc.BufferDesc.Height = context->m_winH; + desc.BufferDesc.Width = width; + desc.BufferDesc.Height = height; desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; desc.BufferDesc.RefreshRate.Numerator = 0; desc.BufferDesc.RefreshRate.Denominator = 0; desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // DXGI_SWAP_EFFECT_FLIP_DISCARD; desc.OutputWindow = context->m_hWnd; - desc.SampleDesc.Count = samples; + desc.SampleDesc.Count = numMSAASamples; desc.SampleDesc.Quality = 0; desc.Windowed = TRUE; // m_fullscreen ? FALSE : TRUE; desc.Flags = 0u; @@ -249,8 +297,8 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool // configure scissor and viewport { - context->m_viewport.Width = float(context->m_winW); - context->m_viewport.Height = float(context->m_winH); + context->m_viewport.Width = float(width); + context->m_viewport.Height = float(height); context->m_viewport.MaxDepth = 1.f; } @@ -282,7 +330,7 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool texDesc.MipLevels = 1; texDesc.ArraySize = 1; texDesc.Format = DXGI_FORMAT_R32_TYPELESS; // DXGI_FORMAT_R24G8_TYPELESS - texDesc.SampleDesc.Count = samples; + texDesc.SampleDesc.Count = numMSAASamples; texDesc.SampleDesc.Quality = 0u; texDesc.Usage = D3D11_USAGE_DEFAULT; texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE; @@ -296,7 +344,7 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc = {}; viewDesc.Format = DXGI_FORMAT_D32_FLOAT; - viewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; + viewDesc.ViewDimension = (numMSAASamples > 1) ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D; viewDesc.Flags = 0u; viewDesc.Texture2D.MipSlice = 0; @@ -307,7 +355,7 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.Format = DXGI_FORMAT_R32_FLOAT; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS; + srvDesc.ViewDimension = (numMSAASamples > 1) ? D3D11_SRV_DIMENSION_TEXTURE2DMS : D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MipLevels = 1; srvDesc.Texture2D.MostDetailedMip = 0; @@ -316,42 +364,12 @@ void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool return; } } - - // resolved texture target (for refraction / scene sampling) - { - D3D11_TEXTURE2D_DESC texDesc = {}; - texDesc.Width = width; - texDesc.Height = height; - texDesc.MipLevels = 1; - texDesc.ArraySize = 1; - texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - texDesc.SampleDesc.Count = 1; - texDesc.SampleDesc.Quality = 0u; - texDesc.Usage = D3D11_USAGE_DEFAULT; - texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - texDesc.CPUAccessFlags = 0; - texDesc.MiscFlags = 0; - - if (hr = context->m_device->CreateTexture2D(&texDesc, nullptr, &context->m_resolvedTarget)) - { - return; - } - - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = 1; - srvDesc.Texture2D.MostDetailedMip = 0; - - if (hr = context->m_device->CreateShaderResourceView(context->m_resolvedTarget, &srvDesc, &context->m_resolvedTargetSRV)) - { - return; - } - } } -void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context) +void AppGraphCtxReleaseRenderTargetD3D11(AppGraphCtx* contextIn) { + auto context = cast_to_AppGraphCtxD3D11(contextIn); + if (context->m_swapChain == nullptr) { return; @@ -361,68 +379,78 @@ void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context) context->m_swapChain->GetFullscreenState(&bFullscreen, nullptr); if (bFullscreen == TRUE) context->m_swapChain->SetFullscreenState(FALSE, nullptr); - COMRelease(context->m_swapChain); COMRelease(context->m_backBuffer); + COMRelease(context->m_swapChain); COMRelease(context->m_rtv); COMRelease(context->m_depthStencil); COMRelease(context->m_dsv); COMRelease(context->m_depthSRV); - COMRelease(context->m_resolvedTarget); - COMRelease(context->m_resolvedTargetSRV); + + context->m_valid = false; + context->m_winW = 0u; + context->m_winH = 0u; } -void AppGraphCtxRelease(AppGraphCtx* context) +void AppGraphCtxReleaseD3D11(AppGraphCtx* context) { if (context == nullptr) return; - delete context; + delete cast_to_AppGraphCtxD3D11(context); } -void AppGraphCtxResolveFrame(AppGraphCtx* context) +void AppGraphCtxFrameStartD3D11(AppGraphCtx* contextIn, AppGraphColor clearColor) { - context->m_deviceContext->ResolveSubresource(context->m_resolvedTarget, 0, context->m_backBuffer, 0, DXGI_FORMAT_R8G8B8A8_UNORM); -} + auto context = cast_to_AppGraphCtxD3D11(contextIn); -void AppGraphCtxFrameStart(AppGraphCtx* context, float clearColor[4]) -{ - appGraphProfilerFrameBegin(context->m_profiler); + appGraphProfilerD3D11FrameBegin(context->m_profiler); context->m_deviceContext->RSSetViewports(1, &context->m_viewport); context->m_deviceContext->RSSetScissorRects(0, nullptr); context->m_deviceContext->OMSetRenderTargets(1, &context->m_rtv, context->m_dsv); - context->m_deviceContext->ClearRenderTargetView(context->m_rtv, clearColor); + context->m_deviceContext->ClearRenderTargetView(context->m_rtv, &clearColor.r); context->m_deviceContext->ClearDepthStencilView(context->m_dsv, D3D11_CLEAR_DEPTH, 1.f, 0u); context->m_deviceContext->OMSetDepthStencilState(context->m_depthState, 0u); } -void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync) +void AppGraphCtxFramePresentD3D11(AppGraphCtx* contextIn, bool fullsync) { + auto context = cast_to_AppGraphCtxD3D11(contextIn); + context->m_swapChain->Present(fullsync, 0); - - appGraphProfilerFrameEnd(context->m_profiler); + + appGraphProfilerD3D11FrameEnd(context->m_profiler); } -void AppGraphCtxProfileEnable(AppGraphCtx* context, bool enabled) +void AppGraphCtxWaitForFramesD3D11(AppGraphCtx* context, unsigned int maxFramesInFlight) { - appGraphProfilerEnable(context->m_profiler, enabled); + // TODO: Implement } -void AppGraphCtxProfileBegin(AppGraphCtx* context, const char* label) +void AppGraphCtxProfileEnableD3D11(AppGraphCtx* contextIn, bool enabled) { - appGraphProfilerBegin(context->m_profiler, label); + auto context = cast_to_AppGraphCtxD3D11(contextIn); + appGraphProfilerD3D11Enable(context->m_profiler, enabled); } -void AppGraphCtxProfileEnd(AppGraphCtx* context, const char* label) +void AppGraphCtxProfileBeginD3D11(AppGraphCtx* contextIn, const char* label) { - appGraphProfilerEnd(context->m_profiler, label); + auto context = cast_to_AppGraphCtxD3D11(contextIn); + appGraphProfilerD3D11Begin(context->m_profiler, label); } -bool AppGraphCtxProfileGet(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index) +void AppGraphCtxProfileEndD3D11(AppGraphCtx* contextIn, const char* label) { - return appGraphProfilerGet(context->m_profiler, plabel, cpuTime, gpuTime, index); + auto context = cast_to_AppGraphCtxD3D11(contextIn); + appGraphProfilerD3D11End(context->m_profiler, label); +} + +bool AppGraphCtxProfileGetD3D11(AppGraphCtx* contextIn, const char** plabel, float* cpuTime, float* gpuTime, int index) +{ + auto context = cast_to_AppGraphCtxD3D11(contextIn); + return appGraphProfilerD3D11Get(context->m_profiler, plabel, cpuTime, gpuTime, index); } // ******************************* Profiler ********************************* @@ -544,9 +572,9 @@ namespace }; } -struct AppGraphProfiler +struct AppGraphProfilerD3D11 { - AppGraphCtx* m_context; + AppGraphCtxD3D11* m_context; int m_state = 0; bool m_enabled = false; @@ -563,30 +591,30 @@ struct AppGraphProfiler TimerValue m_timerValues[m_timersCap]; int m_timerValuesSize = 0; - AppGraphProfiler(AppGraphCtx* context); - ~AppGraphProfiler(); + AppGraphProfilerD3D11(AppGraphCtx* context); + ~AppGraphProfilerD3D11(); }; -AppGraphProfiler::AppGraphProfiler(AppGraphCtx* context) : m_context(context) +AppGraphProfilerD3D11::AppGraphProfilerD3D11(AppGraphCtx* context) : m_context(cast_to_AppGraphCtxD3D11(context)) { } -AppGraphProfiler::~AppGraphProfiler() +AppGraphProfilerD3D11::~AppGraphProfilerD3D11() { COMRelease(m_disjoint); } -AppGraphProfiler* appGraphCreateProfiler(AppGraphCtx* ctx) +AppGraphProfilerD3D11* appGraphCreateProfilerD3D11(AppGraphCtx* ctx) { - return new AppGraphProfiler(ctx); + return new AppGraphProfilerD3D11(ctx); } -void appGraphReleaseProfiler(AppGraphProfiler* profiler) +void appGraphReleaseProfiler(AppGraphProfilerD3D11* profiler) { delete profiler; } -void appGraphProfilerFrameBegin(AppGraphProfiler* p) +void appGraphProfilerD3D11FrameBegin(AppGraphProfilerD3D11* p) { p->m_frameTime = (float)p->m_frameTimer.getDeltaTime(); @@ -611,7 +639,7 @@ void appGraphProfilerFrameBegin(AppGraphProfiler* p) } } -void appGraphProfilerFrameEnd(AppGraphProfiler* p) +void appGraphProfilerD3D11FrameEnd(AppGraphProfilerD3D11* p) { if (p->m_state == 1) { @@ -623,12 +651,12 @@ void appGraphProfilerFrameEnd(AppGraphProfiler* p) } } -void appGraphProfilerEnable(AppGraphProfiler* p, bool enabled) +void appGraphProfilerD3D11Enable(AppGraphProfilerD3D11* p, bool enabled) { p->m_enabled = enabled; } -void appGraphProfilerBegin(AppGraphProfiler* p, const char* label) +void appGraphProfilerD3D11Begin(AppGraphProfilerD3D11* p, const char* label) { if (p->m_state == 1 && p->m_timersSize < p->m_timersCap) { @@ -652,7 +680,7 @@ void appGraphProfilerBegin(AppGraphProfiler* p, const char* label) } } -void appGraphProfilerEnd(AppGraphProfiler* p, const char* label) +void appGraphProfilerD3D11End(AppGraphProfilerD3D11* p, const char* label) { if (p->m_state == 1) { @@ -676,7 +704,7 @@ void appGraphProfilerEnd(AppGraphProfiler* p, const char* label) } } -bool appGraphProfilerFlush(AppGraphProfiler* p) +bool appGraphProfilerD3D11Flush(AppGraphProfilerD3D11* p) { if (p->m_state == 2) { @@ -735,9 +763,9 @@ bool appGraphProfilerFlush(AppGraphProfiler* p) return false; } -bool appGraphProfilerGet(AppGraphProfiler* p, const char** plabel, float* cpuTime, float* gpuTime, int index) +bool appGraphProfilerD3D11Get(AppGraphProfilerD3D11* p, const char** plabel, float* cpuTime, float* gpuTime, int index) { - appGraphProfilerFlush(p); + appGraphProfilerD3D11Flush(p); { if (index < p->m_timerValuesSize) { @@ -755,7 +783,8 @@ bool appGraphProfilerGet(AppGraphProfiler* p, const char** plabel, float* cpuTim return false; } -size_t AppGraphCtxDedicatedVideoMemory(AppGraphCtx* context) +size_t AppGraphCtxDedicatedVideoMemoryD3D11(AppGraphCtx* contextIn) { + auto context = cast_to_AppGraphCtxD3D11(contextIn); return context->m_dedicatedVideoMemory; -} +} \ No newline at end of file diff --git a/demo/d3d11/appD3D11Ctx.h b/demo/d3d11/appD3D11Ctx.h index 071952e..80a71f8 100644 --- a/demo/d3d11/appD3D11Ctx.h +++ b/demo/d3d11/appD3D11Ctx.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * 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 @@ -10,44 +10,26 @@ #pragma once +#include "../d3d/appGraphCtx.h" + #include #include +struct AppGraphProfilerD3D11; -template -void inline COMRelease(T& t) -{ - if (t) t->Release(); - t = nullptr; -} - -template -void inline COMRelease(T& t, UINT arraySize) -{ - for (UINT i = 0; i < arraySize; i++) - { - if (t[i]) t[i]->Release(); - t[i] = nullptr; - } -} - - - -struct SDL_Window; -struct AppGraphProfiler; - -struct AppGraphCtx +struct AppGraphCtxD3D11 { HWND m_hWnd = nullptr; int m_winW = 0; int m_winH = 0; bool m_fullscreen = false; + bool m_valid = false; size_t m_dedicatedVideoMemory = 0u; // D3D11 objects - D3D11_VIEWPORT m_viewport; + D3D11_VIEWPORT m_viewport = {}; ID3D11Device* m_device = nullptr; ID3D11DeviceContext* m_deviceContext = nullptr; IDXGISwapChain* m_swapChain = nullptr; @@ -57,37 +39,43 @@ struct AppGraphCtx ID3D11DepthStencilView* m_dsv = nullptr; ID3D11ShaderResourceView* m_depthSRV = nullptr; ID3D11DepthStencilState* m_depthState = nullptr; - ID3D11BlendState* m_blendState = nullptr; + + AppGraphProfilerD3D11* m_profiler = nullptr; - ID3D11Texture2D* m_resolvedTarget = nullptr; - ID3D11ShaderResourceView* m_resolvedTargetSRV = nullptr; + AppGraphCtxD3D11(); + ~AppGraphCtxD3D11(); +}; - AppGraphProfiler* m_profiler = nullptr; +inline AppGraphCtxD3D11* cast_to_AppGraphCtxD3D11(AppGraphCtx* appctx) +{ + return (AppGraphCtxD3D11*)(appctx); +} - AppGraphCtx(); - ~AppGraphCtx(); -}; +inline AppGraphCtx* cast_from_AppGraphCtxD3D11(AppGraphCtxD3D11* appctx) +{ + return (AppGraphCtx*)(appctx); +} -AppGraphCtx* AppGraphCtxCreate(int deviceID); +APP_GRAPH_CTX_API AppGraphCtx* AppGraphCtxCreateD3D11(int deviceID); -void AppGraphCtxInitRenderTarget(AppGraphCtx* context, SDL_Window* window, bool fullscreen, int); +APP_GRAPH_CTX_API bool AppGraphCtxUpdateSizeD3D11(AppGraphCtx* context, SDL_Window* window, bool fullscreen, int numMSAASamples); -void AppGraphCtxReleaseRenderTarget(AppGraphCtx* context); +APP_GRAPH_CTX_API void AppGraphCtxReleaseRenderTargetD3D11(AppGraphCtx* context); -void AppGraphCtxRelease(AppGraphCtx* context); +APP_GRAPH_CTX_API void AppGraphCtxReleaseD3D11(AppGraphCtx* context); -void AppGraphCtxFrameStart(AppGraphCtx* context, float clearColor[4]); +APP_GRAPH_CTX_API void AppGraphCtxFrameStartD3D11(AppGraphCtx* context, AppGraphColor clearColor); -void AppGraphCtxFramePresent(AppGraphCtx* context, bool fullsync); +APP_GRAPH_CTX_API void AppGraphCtxFramePresentD3D11(AppGraphCtx* context, bool fullsync); -void AppGraphCtxResolveFrame(AppGraphCtx* context); +APP_GRAPH_CTX_API void AppGraphCtxWaitForFramesD3D11(AppGraphCtx* context, unsigned int maxFramesInFlight); -void AppGraphCtxProfileEnable(AppGraphCtx* context, bool enabled); +APP_GRAPH_CTX_API void AppGraphCtxProfileEnableD3D11(AppGraphCtx* context, bool enabled); -void AppGraphCtxProfileBegin(AppGraphCtx* context, const char* label); +APP_GRAPH_CTX_API void AppGraphCtxProfileBeginD3D11(AppGraphCtx* context, const char* label); -void AppGraphCtxProfileEnd(AppGraphCtx* context, const char* label); +APP_GRAPH_CTX_API void AppGraphCtxProfileEndD3D11(AppGraphCtx* context, const char* label); -bool AppGraphCtxProfileGet(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index); +APP_GRAPH_CTX_API bool AppGraphCtxProfileGetD3D11(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index); -size_t AppGraphCtxDedicatedVideoMemory(AppGraphCtx* context); \ No newline at end of file +APP_GRAPH_CTX_API size_t AppGraphCtxDedicatedVideoMemoryD3D11(AppGraphCtx* context); diff --git a/demo/d3d11/debugLineRender.h b/demo/d3d11/debugLineRender.h deleted file mode 100644 index 6132935..0000000 --- a/demo/d3d11/debugLineRender.h +++ /dev/null @@ -1,199 +0,0 @@ -#pragma once - - -#include "shaders/debugLineVS.hlsl.h" -#include "shaders/debugLinePS.hlsl.h" - - -struct DebugVertex -{ - Vec3 position; - Vec4 color; -}; - -struct DebugLineRender -{ - - void Init(ID3D11Device* d, ID3D11DeviceContext* c) - { - device = d; - context = c; - - // create the rasterizer state - { - D3D11_RASTERIZER_DESC desc = {}; - desc.FillMode = D3D11_FILL_SOLID; - desc.CullMode = D3D11_CULL_BACK; - desc.FrontCounterClockwise = TRUE; // This is non-default - desc.DepthBias = 0; - desc.DepthBiasClamp = 0.f; - desc.SlopeScaledDepthBias = 0.f; - desc.DepthClipEnable = TRUE; - desc.ScissorEnable = FALSE; // This is non-default - desc.MultisampleEnable = TRUE; - desc.AntialiasedLineEnable = FALSE; - - device->CreateRasterizerState(&desc, &rasterizerState); - } - - { - D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; - depthStateDesc.DepthEnable = FALSE; // disable depth test - depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; - depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; - - device->CreateDepthStencilState(&depthStateDesc, &depthStencilState); - } - - // create the input layout - { - D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - device->CreateInputLayout(inputElementDescs, 2, g_debugLineVS, sizeof(g_debugLineVS), &inputLayout); - } - - // create the blend state - { - D3D11_BLEND_DESC blendDesc = {}; - - blendDesc.AlphaToCoverageEnable = false; - blendDesc.IndependentBlendEnable = false; - blendDesc.RenderTarget[0].BlendEnable = false; - blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; - blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; - blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; - blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - - device->CreateBlendState(&blendDesc, &blendState); - } - - // create the shaders - device->CreateVertexShader(g_debugLineVS, sizeof(g_debugLineVS), nullptr, &vertexShader); - device->CreatePixelShader(g_debugLinePS, sizeof(g_debugLinePS), nullptr, &pixelShader); - - // create a constant buffer - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(Matrix44); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - device->CreateBuffer(&bufDesc, NULL, &constantBuffer); - } - } - - void Destroy() - { - COMRelease(depthStencilState); - COMRelease(rasterizerState); - COMRelease(inputLayout); - COMRelease(blendState); - COMRelease(vertexShader); - COMRelease(pixelShader); - COMRelease(constantBuffer); - COMRelease(vertexBuffer); - } - - void AddLine(const Vec3& p, const Vec3& q, const Vec4& color) - { - DebugVertex v = { p, color }; - DebugVertex w = { q, color }; - - queued.push_back(v); - queued.push_back(w); - } - - void FlushLines(const Matrix44& viewProj) - { - if (queued.empty()) - return; - - // recreate vertex buffer if not big enough for queued lines - if (vertexBufferSize < int(queued.size())) - { - if (vertexBuffer) - vertexBuffer->Release(); - - D3D11_BUFFER_DESC bufferDesc; - bufferDesc.Usage = D3D11_USAGE_DYNAMIC; - bufferDesc.ByteWidth = UINT(sizeof(DebugVertex)*queued.size()); - bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufferDesc.MiscFlags = 0; - - device->CreateBuffer(&bufferDesc, 0, &vertexBuffer); - - vertexBufferSize = int(queued.size()); - } - - // update vertex buffer - D3D11_MAPPED_SUBRESOURCE res; - context->Map(vertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, &queued[0], sizeof(DebugVertex)*queued.size()); - context->Unmap(vertexBuffer, 0); - - // update constant buffer - { - D3D11_MAPPED_SUBRESOURCE mappedResource = {}; - if (S_OK == context->Map(constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - memcpy(mappedResource.pData, &viewProj, sizeof(viewProj)); - - context->Unmap(constantBuffer, 0u); - } - } - - // configure for line renderering - context->VSSetShader(vertexShader, nullptr, 0u); - context->GSSetShader(nullptr, nullptr, 0u); - context->PSSetShader(pixelShader, nullptr, 0u); - - context->IASetInputLayout(inputLayout); - context->OMSetBlendState(blendState, nullptr, 0xFFFFFFFF); - - context->VSSetConstantBuffers(0, 1, &constantBuffer); - - context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST); - - context->RSSetState(rasterizerState); - - UINT vertexStride = sizeof(DebugVertex); - UINT offset = 0u; - context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &offset); - - - // kick - context->Draw(UINT(queued.size()), 0); - - // empty queue - queued.resize(0); - - } - - - std::vector queued; - - ID3D11Buffer* vertexBuffer = nullptr; - int vertexBufferSize = 0; - - ID3D11DepthStencilState* depthStencilState = nullptr; - ID3D11RasterizerState* rasterizerState = nullptr; - ID3D11InputLayout* inputLayout = nullptr; - ID3D11BlendState* blendState = nullptr; - ID3D11VertexShader* vertexShader = nullptr; - ID3D11PixelShader* pixelShader = nullptr; - ID3D11Buffer* constantBuffer = nullptr; - - ID3D11Device* device = nullptr; - ID3D11DeviceContext* context = nullptr; - -}; \ No newline at end of file diff --git a/demo/d3d11/debugLineRenderD3D11.cpp b/demo/d3d11/debugLineRenderD3D11.cpp new file mode 100644 index 0000000..2b0b432 --- /dev/null +++ b/demo/d3d11/debugLineRenderD3D11.cpp @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2008-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. +*/ + +#define NOMINMAX +#include + +#include + +#include "../d3d/shaders/debugLineVS.hlsl.h" +#include "../d3d/shaders/debugLinePS.hlsl.h" + +// this +#include "debugLineRenderD3D11.h" + +void DebugLineRenderD3D11::init(ID3D11Device* d, ID3D11DeviceContext* c) +{ + m_device = d; + m_context = c; + + // create the rasterizer state + { + D3D11_RASTERIZER_DESC desc = {}; + desc.FillMode = D3D11_FILL_SOLID; + desc.CullMode = D3D11_CULL_BACK; + desc.FrontCounterClockwise = TRUE; // This is non-default + desc.DepthBias = 0; + desc.DepthBiasClamp = 0.f; + desc.SlopeScaledDepthBias = 0.f; + desc.DepthClipEnable = TRUE; + desc.ScissorEnable = FALSE; // This is non-default + desc.MultisampleEnable = TRUE; + desc.AntialiasedLineEnable = FALSE; + + m_device->CreateRasterizerState(&desc, m_rasterizerState.GetAddressOf()); + } + + { + D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; + depthStateDesc.DepthEnable = FALSE; // disable depth test + depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + + m_device->CreateDepthStencilState(&depthStateDesc, m_depthStencilState.GetAddressOf()); + } + + // create the input layout + { + D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + m_device->CreateInputLayout(inputElementDescs, 2, g_debugLineVS, sizeof(g_debugLineVS), m_inputLayout.GetAddressOf()); + } + + // create the blend state + { + D3D11_BLEND_DESC blendDesc = {}; + + blendDesc.AlphaToCoverageEnable = false; + blendDesc.IndependentBlendEnable = false; + blendDesc.RenderTarget[0].BlendEnable = false; + blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; + blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + m_device->CreateBlendState(&blendDesc, m_blendState.GetAddressOf()); + } + + // create the shaders + m_device->CreateVertexShader(g_debugLineVS, sizeof(g_debugLineVS), nullptr, m_vertexShader.GetAddressOf()); + m_device->CreatePixelShader(g_debugLinePS, sizeof(g_debugLinePS), nullptr, m_pixelShader.GetAddressOf()); + + // create a constant buffer + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(Matrix44); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, NULL, m_constantBuffer.GetAddressOf()); + } +} + +void DebugLineRenderD3D11::addLine(const Vec3& p, const Vec3& q, const Vec4& color) +{ + Vertex v = { p, color }; + Vertex w = { q, color }; + + m_queued.push_back(v); + m_queued.push_back(w); +} + +void DebugLineRenderD3D11::flush(const Matrix44& viewProj) +{ + if (m_queued.empty()) + return; + + // recreate vertex buffer if not big enough for queued lines + if (m_vertexBufferSize < int(m_queued.size())) + { + m_vertexBuffer = nullptr; + + D3D11_BUFFER_DESC bufferDesc; + bufferDesc.Usage = D3D11_USAGE_DYNAMIC; + bufferDesc.ByteWidth = UINT(sizeof(Vertex)*m_queued.size()); + bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufferDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufferDesc, 0, &m_vertexBuffer); + + m_vertexBufferSize = int(m_queued.size()); + } + + // update vertex buffer + D3D11_MAPPED_SUBRESOURCE res; + m_context->Map(m_vertexBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, &m_queued[0], sizeof(Vertex)*m_queued.size()); + m_context->Unmap(m_vertexBuffer.Get(), 0); + + // update constant buffer + { + D3D11_MAPPED_SUBRESOURCE mappedResource = {}; + if (SUCCEEDED(m_context->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + memcpy(mappedResource.pData, &viewProj, sizeof(viewProj)); + m_context->Unmap(m_constantBuffer.Get(), 0u); + } + } + + // configure for line renderering + m_context->VSSetShader(m_vertexShader.Get(), nullptr, 0u); + m_context->GSSetShader(nullptr, nullptr, 0u); + m_context->PSSetShader(m_pixelShader.Get(), nullptr, 0u); + + m_context->IASetInputLayout(m_inputLayout.Get()); + m_context->OMSetBlendState(m_blendState.Get(), nullptr, 0xFFFFFFFF); + + m_context->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST); + + m_context->RSSetState(m_rasterizerState.Get()); + + UINT vertexStride = sizeof(Vertex); + UINT offset = 0u; + m_context->IASetVertexBuffers(0, 1, m_vertexBuffer.GetAddressOf(), &vertexStride, &offset); + + // kick + m_context->Draw(UINT(m_queued.size()), 0); + + // empty queue + m_queued.resize(0); + +} diff --git a/demo/d3d11/debugLineRenderD3D11.h b/demo/d3d11/debugLineRenderD3D11.h new file mode 100644 index 0000000..1509065 --- /dev/null +++ b/demo/d3d11/debugLineRenderD3D11.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include "core/maths.h" + +#include +using namespace Microsoft::WRL; + +struct DebugLineRenderD3D11 +{ + struct Vertex + { + Vec3 position; + Vec4 color; + }; + + void init(ID3D11Device* d, ID3D11DeviceContext* c); + void addLine(const Vec3& p, const Vec3& q, const Vec4& color); + void flush(const Matrix44& viewProj); + + DebugLineRenderD3D11(): + m_vertexBufferSize(0), + m_device(nullptr), + m_context(nullptr) + {} + + std::vector m_queued; + + ComPtr m_vertexBuffer; + int m_vertexBufferSize; + + ComPtr m_depthStencilState; + ComPtr m_rasterizerState; + ComPtr m_inputLayout; + ComPtr m_blendState; + ComPtr m_vertexShader; + ComPtr m_pixelShader; + ComPtr m_constantBuffer; + + ID3D11Device* m_device; + ID3D11DeviceContext* m_context; +}; \ No newline at end of file diff --git a/demo/d3d11/demoContextD3D11.cpp b/demo/d3d11/demoContextD3D11.cpp new file mode 100644 index 0000000..0eaf0f4 --- /dev/null +++ b/demo/d3d11/demoContextD3D11.cpp @@ -0,0 +1,1147 @@ +#include "core/maths.h" +#include "core/extrude.h" + +#include "shaders.h" + +#include "meshRenderD3D11.h" +#include "pointRenderD3D11.h" +#include "fluidRenderD3D11.h" +#include "diffuseRenderD3D11.h" +#include "debugLineRenderD3D11.h" + +#include "shadowMapD3D11.h" +#include "renderTargetD3D11.h" + +#include "imguiGraphD3D11.h" + +#include "appD3D11Ctx.h" + +#include "../d3d/demoContext.h" +#include "../d3d/loader.h" + +#include +#include + +#include + +// this +#include "demoContextD3D11.h" + +namespace +{ +// COM object release utilities +template +void inline COMRelease(T& t) +{ + if (t) t->Release(); + t = nullptr; +} + +template +void inline COMRelease(T& t, UINT arraySize) +{ + for (UINT i = 0; i < arraySize; i++) + { + if (t[i]) t[i]->Release(); + t[i] = nullptr; + } +} +} + +extern Colour g_colors[]; +static const int kShadowResolution = 2048; + +DemoContext* CreateDemoContextD3D11() +{ + return new DemoContextD3D11; +} + +DemoContextD3D11::DemoContextD3D11() +{ + m_appGraphCtx = nullptr; + m_appGraphCtxD3D11 = nullptr; + memset(&m_meshDrawParams, 0, sizeof(m_meshDrawParams)); + + m_spotMin = 0.5f; + m_spotMax = 1.0f; + m_shadowBias = 0.075f; + + m_shadowMap = nullptr; + m_immediateMesh = nullptr; + + m_window = nullptr; + + m_msaaSamples = 1; + + m_renderTimerDisjoint = nullptr; + m_renderTimerBegin = nullptr; + m_renderTimerEnd = nullptr; + m_renderCompletionFence = nullptr; + + m_compositeBlendState = nullptr; + + m_fluidResolvedTarget = nullptr; + m_fluidResolvedTargetSRV = nullptr; + + m_debugLineRender = new DebugLineRenderD3D11; + m_meshRenderer = new MeshRendererD3D11; + m_pointRenderer = new PointRendererD3D11; + m_diffuseRenderer = new DiffuseRendererD3D11; +} + +// convert an OpenGL style projection matrix to D3D (clip z range [0, 1]) +Matrix44 ConvertToD3DProjection(const Matrix44& proj) +{ + Matrix44 scale = Matrix44::kIdentity; + scale.columns[2][2] = 0.5f; + + Matrix44 bias = Matrix44::kIdentity; + bias.columns[3][2] = 1.0f; + + return scale*bias*proj; +} + +#define checkDxErrors(err) __checkDxErrors (err, __FILE__, __LINE__) + +inline void __checkDxErrors(HRESULT err, const char *file, const int line) +{ + if (FAILED(err)) + { + char* lpMsgBuf; + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, NULL); + + fprintf(stdout, "DX Error = %04d \"%s\" from file <%s>, line %i.\n", + err, lpMsgBuf, file, line); + + exit(EXIT_FAILURE); + } +} + +DemoContextD3D11::~DemoContextD3D11() +{ + imguiGraphDestroy(); + + COMRelease(m_renderTimerBegin); + COMRelease(m_renderTimerEnd); + COMRelease(m_renderTimerDisjoint); + COMRelease(m_renderCompletionFence); + + COMRelease(m_compositeBlendState); + + COMRelease(m_fluidResolvedTarget); + COMRelease(m_fluidResolvedTargetSRV); + + delete m_immediateMesh; + delete m_debugLineRender; + delete m_meshRenderer; + delete m_pointRenderer; + delete m_diffuseRenderer; + + // do this first, since it flushes all GPU work + AppGraphCtxReleaseRenderTarget(m_appGraphCtx); + AppGraphCtxRelease(m_appGraphCtx); +} + +bool DemoContextD3D11::initialize(const RenderInitOptions& options) +{ + { + // Load external modules + loadModules(APP_CONTEXT_D3D11); + } + + // must always have at least one sample + m_msaaSamples = Max(1, options.numMsaaSamples); + // create app graph context + m_appGraphCtx = AppGraphCtxCreate(0); + m_appGraphCtxD3D11 = cast_to_AppGraphCtxD3D11(m_appGraphCtx); + + AppGraphCtxUpdateSize(m_appGraphCtx, options.window, options.fullscreen, m_msaaSamples); + _onWindowSizeChanged(m_appGraphCtxD3D11->m_winW, m_appGraphCtxD3D11->m_winH, false); + + //AppGraphCtxInitRenderTarget(m_appGraphCtx, options.window, options.fullscreen, m_msaaSamples); + //gScene = getScene(0); + + AppGraphColor clearVal = { 0.0f, 0.0f, 0.0f, 1.0f }; + AppGraphCtxFrameStart(m_appGraphCtx, clearVal); + + ID3D11Device* device = m_appGraphCtxD3D11->m_device; + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + { + // create imgui, connect to app graph context + ImguiGraphDescD3D11 desc; + desc.device = device; + desc.deviceContext = deviceContext; + desc.winW = m_appGraphCtxD3D11->m_winW; + desc.winH = m_appGraphCtxD3D11->m_winH; + + // Use Dx11 context + const int defaultFontHeight = (options.defaultFontHeight <= 0) ? 15 : options.defaultFontHeight; + + if (!imguiGraphInit("../../data/DroidSans.ttf", float(defaultFontHeight), (ImguiGraphDesc*)&desc)) + { + return false; + } + } + + AppGraphCtxFramePresent(m_appGraphCtx, true); + + m_pointRenderer->init(device, deviceContext); + m_meshRenderer->init(device, deviceContext, options.asyncComputeBenchmark); + m_debugLineRender->init(device, deviceContext); + m_diffuseRenderer->init(device, deviceContext); + + { + // create blend state - used for composite phase of water rendering + D3D11_BLEND_DESC blendStateDesc = {}; + blendStateDesc.RenderTarget[0].BlendEnable = TRUE; + blendStateDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blendStateDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blendStateDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendStateDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendStateDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; + blendStateDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendStateDesc.RenderTarget[0].RenderTargetWriteMask = 0x0f; + + if (FAILED(device->CreateBlendState(&blendStateDesc, &m_compositeBlendState))) + { + return false; + } + } + + // create a mesh for immediate mode rendering + m_immediateMesh = new GpuMeshD3D11(device, deviceContext); + + m_window = options.window; + + D3D11_QUERY_DESC tdesc; + ZeroMemory(&tdesc, sizeof(tdesc)); + tdesc.Query = D3D11_QUERY_TIMESTAMP; + device->CreateQuery(&tdesc, &m_renderTimerBegin); + device->CreateQuery(&tdesc, &m_renderTimerEnd); + + tdesc.Query = D3D11_QUERY_EVENT; + device->CreateQuery(&tdesc, &m_renderCompletionFence); + + ZeroMemory(&tdesc, sizeof(tdesc)); + tdesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT; + device->CreateQuery(&tdesc, &m_renderTimerDisjoint); + + return true; +} + +void DemoContextD3D11::getRenderDevice(void** deviceOut, void** contextOut) +{ + *deviceOut = m_appGraphCtxD3D11->m_device; + *contextOut = m_appGraphCtxD3D11->m_deviceContext; +} + +void DemoContextD3D11::onSizeChanged(int width, int height, bool minimized) +{ + AppGraphCtxUpdateSize(m_appGraphCtx, m_window, false, m_msaaSamples); + _onWindowSizeChanged(m_appGraphCtxD3D11->m_winW, m_appGraphCtxD3D11->m_winH, false); +} + +void DemoContextD3D11::_onWindowSizeChanged(int width, int height, bool minimized) +{ + if (m_fluidResolvedTarget) + { + D3D11_TEXTURE2D_DESC desc; + m_fluidResolvedTarget->GetDesc(&desc); + if (desc.Width == width && desc.Height == height) + { + return; + } + + COMRelease(m_fluidResolvedTarget); + COMRelease(m_fluidResolvedTargetSRV); + } + + // Recreate... + + ID3D11Device* device = m_appGraphCtxD3D11->m_device; + + // resolved texture target (for refraction / scene sampling) + { + D3D11_TEXTURE2D_DESC texDesc = {}; + texDesc.Width = width; + texDesc.Height = height; + texDesc.MipLevels = 1; + texDesc.ArraySize = 1; + texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texDesc.SampleDesc.Count = 1; + texDesc.SampleDesc.Quality = 0u; + texDesc.Usage = D3D11_USAGE_DEFAULT; + texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texDesc.CPUAccessFlags = 0; + texDesc.MiscFlags = 0; + + if (FAILED(device->CreateTexture2D(&texDesc, nullptr, &m_fluidResolvedTarget))) + { + return; + } + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = 1; + srvDesc.Texture2D.MostDetailedMip = 0; + + if (FAILED(device->CreateShaderResourceView(m_fluidResolvedTarget, &srvDesc, &m_fluidResolvedTargetSRV))) + { + return; + } + } +} + +void DemoContextD3D11::startFrame(Vec4 clear) +{ + AppGraphColor clearColor = { clear.x, clear.y, clear.z, clear.w }; + AppGraphCtxFrameStart(m_appGraphCtx, clearColor); + + MeshDrawParamsD3D& meshDrawParams = m_meshDrawParams; + + memset(&meshDrawParams, 0, sizeof(MeshDrawParamsD3D)); + meshDrawParams.renderStage = MESH_DRAW_LIGHT; + meshDrawParams.renderMode = MESH_RENDER_SOLID; + meshDrawParams.cullMode = MESH_CULL_BACK; + meshDrawParams.projection = (XMMATRIX)Matrix44::kIdentity; + meshDrawParams.view = (XMMATRIX)Matrix44::kIdentity; + meshDrawParams.model = DirectX::XMMatrixMultiply( + DirectX::XMMatrixScaling(1.0f, 1.0f, 1.0f), + DirectX::XMMatrixTranslation(0.0f, 0.0f, 0.0f) + ); +} + +void DemoContextD3D11::_flushFrame() +{ + m_appGraphCtxD3D11->m_deviceContext->Flush(); +} + +void DemoContextD3D11::endFrame() +{ + _flushFrame(); + + ImguiGraphDescD3D11 desc; + + desc.device = m_appGraphCtxD3D11->m_device; + desc.deviceContext = m_appGraphCtxD3D11->m_deviceContext; + desc.winW = m_appGraphCtxD3D11->m_winW; + desc.winH = m_appGraphCtxD3D11->m_winH; + + imguiGraphUpdate((ImguiGraphDesc*)&desc); + //m_imguiGraphContext->update(&desc); +} + +void DemoContextD3D11::presentFrame(bool fullsync) +{ + AppGraphCtxFramePresent(m_appGraphCtx, fullsync); +} + +void DemoContextD3D11::getViewRay(int x, int y, Vec3& origin, Vec3& dir) +{ + using namespace DirectX; + + XMVECTOR nearVector = XMVector3Unproject(XMVectorSet(float(x), float(m_appGraphCtxD3D11->m_winH-y), 0.0f, 0.0f), 0.0f, 0.0f, (float)m_appGraphCtxD3D11->m_winW, (float)m_appGraphCtxD3D11->m_winH, 0.0f, 1.0f, (XMMATRIX)m_proj, XMMatrixIdentity(), (XMMATRIX)m_view); + XMVECTOR farVector = XMVector3Unproject(XMVectorSet(float(x), float(m_appGraphCtxD3D11->m_winH-y), 1.0f, 0.0f), 0.0f, 0.0f, (float)m_appGraphCtxD3D11->m_winW, (float)m_appGraphCtxD3D11->m_winH, 0.0f, 1.0f, (XMMATRIX)m_proj, XMMatrixIdentity(), (XMMATRIX)m_view); + + origin = Vec3(XMVectorGetX(nearVector), XMVectorGetY(nearVector), XMVectorGetZ(nearVector)); + XMVECTOR tmp = farVector - nearVector; + dir = Normalize(Vec3(XMVectorGetX(tmp), XMVectorGetY(tmp), XMVectorGetZ(tmp))); +} + +void DemoContextD3D11::setFillMode(bool wire) +{ + m_meshDrawParams.renderMode = wire ? MESH_RENDER_WIREFRAME : MESH_RENDER_SOLID; +} + +void DemoContextD3D11::setCullMode(bool enabled) +{ + m_meshDrawParams.cullMode = enabled ? MESH_CULL_BACK : MESH_CULL_NONE; +} + +void DemoContextD3D11::setView(Matrix44 view, Matrix44 projection) +{ + Matrix44 vp = projection*view; + + m_meshDrawParams.model = (XMMATRIX)Matrix44::kIdentity; + m_meshDrawParams.view = (XMMATRIX)view; + m_meshDrawParams.projection = (XMMATRIX)(ConvertToD3DProjection(projection)); + + m_view = view; + m_proj = ConvertToD3DProjection(projection); +} + +FluidRenderer* DemoContextD3D11::createFluidRenderer(uint32_t width, uint32_t height) +{ + FluidRendererD3D11* renderer = new(_aligned_malloc(sizeof(FluidRendererD3D11), 16)) FluidRendererD3D11; + renderer->init(m_appGraphCtxD3D11->m_device, m_appGraphCtxD3D11->m_deviceContext, width, height); + return (FluidRenderer*)renderer; +} + +void DemoContextD3D11::destroyFluidRenderer(FluidRenderer* rendererIn) +{ + FluidRendererD3D11* renderer = (FluidRendererD3D11*)rendererIn; + renderer->~FluidRendererD3D11(); + _aligned_free(renderer); +} + +FluidRenderBuffers* DemoContextD3D11::createFluidRenderBuffers(int numParticles, bool enableInterop) +{ + FluidRenderBuffersD3D11* buffers = new FluidRenderBuffersD3D11; + buffers->m_numParticles = numParticles; + + ID3D11Device* device = m_appGraphCtxD3D11->m_device; + + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = numParticles*sizeof(Vec4); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + bufDesc.StructureByteStride = 0; + + device->CreateBuffer(&bufDesc, NULL, &buffers->m_positions); + + device->CreateBuffer(&bufDesc, NULL, &buffers->m_anisotropiesArr[0]); + device->CreateBuffer(&bufDesc, NULL, &buffers->m_anisotropiesArr[1]); + device->CreateBuffer(&bufDesc, NULL, &buffers->m_anisotropiesArr[2]); + + bufDesc.ByteWidth = numParticles*sizeof(float); + device->CreateBuffer(&bufDesc, NULL, &buffers->m_densities); + } + + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = numParticles * sizeof(int); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + bufDesc.StructureByteStride = 0; + + device->CreateBuffer(&bufDesc, NULL, &buffers->m_indices); + } + + if (enableInterop) + { + extern NvFlexLibrary* g_flexLib; + + buffers->m_positionsBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_positions.Get(), numParticles, sizeof(Vec4)); + buffers->m_densitiesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_densities.Get(), numParticles, sizeof(float)); + buffers->m_indicesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_indices.Get(), numParticles, sizeof(int)); + + buffers->m_anisotropiesBufArr[0] = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_anisotropiesArr[0].Get(), numParticles, sizeof(Vec4)); + buffers->m_anisotropiesBufArr[1] = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_anisotropiesArr[1].Get(), numParticles, sizeof(Vec4)); + buffers->m_anisotropiesBufArr[2] = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_anisotropiesArr[2].Get(), numParticles, sizeof(Vec4)); + } + + return reinterpret_cast(buffers); +} + +void DemoContextD3D11::updateFluidRenderBuffers(FluidRenderBuffers* buffersIn, NvFlexSolver* solver, bool anisotropy, bool density) +{ + FluidRenderBuffersD3D11& buffers = *reinterpret_cast(buffersIn); + if (!anisotropy) + { + // regular particles + NvFlexGetParticles(solver, buffers.m_positionsBuf, NULL); + } + else + { + // fluid buffers + NvFlexGetSmoothParticles(solver, buffers.m_positionsBuf, NULL); + NvFlexGetAnisotropy(solver, buffers.m_anisotropiesBufArr[0], buffers.m_anisotropiesBufArr[1], buffers.m_anisotropiesBufArr[2], NULL); + } + + if (density) + { + NvFlexGetDensities(solver, buffers.m_densitiesBuf, NULL); + } + else + { + NvFlexGetPhases(solver, buffers.m_densitiesBuf, NULL); + } + + NvFlexGetActive(solver, buffers.m_indicesBuf, NULL); +} + +void DemoContextD3D11::updateFluidRenderBuffers(FluidRenderBuffers* buffersIn, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) +{ + FluidRenderBuffersD3D11& buffers = *reinterpret_cast(buffersIn); + D3D11_MAPPED_SUBRESOURCE res; + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + // vertices + if (particles) + { + deviceContext->Map(buffers.m_positions.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, particles, sizeof(Vec4)*numParticles); + deviceContext->Unmap(buffers.m_positions.Get(), 0); + } + + Vec4*const anisotropies[3] = + { + anisotropy1, + anisotropy2, + anisotropy3, + }; + + for (int i = 0; i < 3; i++) + { + const Vec4* anisotropy = anisotropies[i]; + if (anisotropy) + { + deviceContext->Map(buffers.m_anisotropiesArr[i].Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, anisotropy, sizeof(Vec4) * numParticles); + deviceContext->Unmap(buffers.m_anisotropiesArr[i].Get(), 0); + } + } + + if (densities) + { + deviceContext->Map(buffers.m_densities.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, densities, sizeof(float)*numParticles); + deviceContext->Unmap(buffers.m_densities.Get(), 0); + } + + // indices + if (indices) + { + deviceContext->Map(buffers.m_indices.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, indices, sizeof(int)*numIndices); + deviceContext->Unmap(buffers.m_indices.Get(), 0); + } +} + +void DemoContextD3D11::destroyFluidRenderBuffers(FluidRenderBuffers* buffers) +{ + delete reinterpret_cast(buffers); +} + +ShadowMap* DemoContextD3D11::shadowCreate() +{ + ShadowMapD3D11* shadowMap = new(_aligned_malloc(sizeof(ShadowMapD3D11), 16)) ShadowMapD3D11; + shadowMap->init(m_appGraphCtxD3D11->m_device, kShadowResolution); + return (ShadowMap*)shadowMap; +} + +void DemoContextD3D11::shadowDestroy(ShadowMap* map) +{ + ShadowMapD3D11* shadowMap = (ShadowMapD3D11*)map; + shadowMap->~ShadowMapD3D11(); + _aligned_free(shadowMap); +} + +void DemoContextD3D11::shadowBegin(ShadowMap* map) +{ + ShadowMapD3D11* shadowMap = (ShadowMapD3D11*)map; + shadowMap->bindAndClear(m_appGraphCtxD3D11->m_deviceContext); + + m_meshDrawParams.renderStage = MESH_DRAW_SHADOW; + m_shadowMap = shadowMap; +} + +void DemoContextD3D11::shadowEnd() +{ + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + // reset to main frame buffer + deviceContext->RSSetViewports(1, &m_appGraphCtxD3D11->m_viewport); + deviceContext->OMSetRenderTargets(1, &m_appGraphCtxD3D11->m_rtv, m_appGraphCtxD3D11->m_dsv); + deviceContext->OMSetDepthStencilState(m_appGraphCtxD3D11->m_depthState, 0u); + deviceContext->ClearDepthStencilView(m_appGraphCtxD3D11->m_dsv, D3D11_CLEAR_DEPTH, 1.0, 0); + + m_meshDrawParams.renderStage = MESH_DRAW_NULL; +} + +void DemoContextD3D11::bindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float bias, Vec4 fogColor) +{ + m_meshDrawParams.renderStage = MESH_DRAW_LIGHT; + + m_meshDrawParams.grid = 0; + m_meshDrawParams.spotMin = m_spotMin; + m_meshDrawParams.spotMax = m_spotMax; + m_meshDrawParams.fogColor = (float4&)fogColor; + + m_meshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; + + ShadowParamsD3D shadow; + RenderParamsUtilD3D::calcShadowParams(lightPos, lightTarget, lightTransform, m_shadowBias, &shadow); + + m_meshDrawParams.lightTransform = shadow.lightTransform; + m_meshDrawParams.lightDir = shadow.lightDir; + m_meshDrawParams.lightPos = shadow.lightPos; + m_meshDrawParams.bias = shadow.bias; + memcpy(m_meshDrawParams.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); + + m_shadowMap = (ShadowMapD3D11*)shadowMap; +} + +void DemoContextD3D11::unbindSolidShader() +{ + m_meshDrawParams.renderStage = MESH_DRAW_NULL; +} + +void DemoContextD3D11::graphicsTimerBegin() +{ + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + deviceContext->Begin(m_renderTimerDisjoint); + deviceContext->End(m_renderTimerBegin); // yes End. +} + +void DemoContextD3D11::graphicsTimerEnd() +{ + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + deviceContext->End(m_renderTimerEnd); + deviceContext->End(m_renderTimerDisjoint); + m_timersSet = true; +} + +float DemoContextD3D11::rendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) +{ + float renderTime = 0.0f; + + if (m_timersSet) + { + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + D3D11_QUERY_DATA_TIMESTAMP_DISJOINT tsDisjoint; + uint64_t renderBegin = 0; + uint64_t renderEnd = 0; + + while (S_OK != deviceContext->GetData(m_renderTimerDisjoint, &tsDisjoint, sizeof(tsDisjoint), 0)); + while (S_OK != deviceContext->GetData(m_renderTimerBegin, &renderBegin, sizeof(UINT64), 0)); + while (S_OK != deviceContext->GetData(m_renderTimerEnd, &renderEnd, sizeof(UINT64), 0)); + + float renderTime = float(renderEnd - renderBegin) / float(tsDisjoint.Frequency); + + if (begin) *begin = renderBegin; + if (end) *end = renderEnd; + if (freq) *freq = tsDisjoint.Frequency; + } + + return renderTime; +} + +void DemoContextD3D11::drawMesh(const Mesh* m, Vec3 color) +{ + if (m) + { + if (m->m_colours.size()) + { + m_meshDrawParams.colorArray = 1; + m_immediateMesh->updateData((Vec3*)&m->m_positions[0], &m->m_normals[0], NULL, (Vec4*)&m->m_colours[0], (int*)&m->m_indices[0], m->GetNumVertices(), int(m->GetNumFaces())); + } + else + { + m_meshDrawParams.colorArray = 0; + m_immediateMesh->updateData((Vec3*)&m->m_positions[0], &m->m_normals[0], NULL, NULL, (int*)&m->m_indices[0], m->GetNumVertices(), int(m->GetNumFaces())); + } + + m_meshDrawParams.color = (float4&)color; + m_meshDrawParams.secondaryColor = (float4&)color; + m_meshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; + m_meshDrawParams.shadowMap = (ShadowMapD3D*)m_shadowMap; + + m_meshRenderer->draw(m_immediateMesh, &m_meshDrawParams); + + if (m->m_colours.size()) + m_meshDrawParams.colorArray = 0; + + } +} + +void DemoContextD3D11::drawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth) +{ + if (!numTris) + return; + + m_immediateMesh->updateData(positions, normals, NULL, NULL, indices, numPositions, numTris); + + if (twosided) + SetCullMode(false); + + m_meshDrawParams.bias = 0.0f; + m_meshDrawParams.expand = expand; + + m_meshDrawParams.color = (const float4&)(g_colors[colorIndex + 1] * 1.5f); + m_meshDrawParams.secondaryColor = (const float4&)(g_colors[colorIndex] * 1.5f); + m_meshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; + m_meshDrawParams.shadowMap = (ShadowMapD3D*)m_shadowMap; + + m_meshRenderer->draw(m_immediateMesh, &m_meshDrawParams); + + if (twosided) + setCullMode(true); + + m_meshDrawParams.bias = m_shadowBias; + m_meshDrawParams.expand = 0.0f; +} + +void DemoContextD3D11::drawRope(Vec4* positions, int* indices, int numIndices, float radius, int color) +{ + if (numIndices < 2) + return; + + std::vector vertices; + std::vector normals; + std::vector triangles; + + // flatten curve + std::vector curve(numIndices); + for (int i = 0; i < numIndices; ++i) + curve[i] = Vec3(positions[indices[i]]); + + const int resolution = 8; + const int smoothing = 3; + + vertices.reserve(resolution*numIndices*smoothing); + normals.reserve(resolution*numIndices*smoothing); + triangles.reserve(numIndices*resolution * 6 * smoothing); + + Extrude(&curve[0], int(curve.size()), vertices, normals, triangles, radius, resolution, smoothing); + + m_immediateMesh->updateData(&vertices[0], &normals[0], NULL, NULL, &triangles[0], int(vertices.size()), int(triangles.size())/3); + + setCullMode(false); + + m_meshDrawParams.color = (const float4&)(g_colors[color % 8] * 1.5f); + m_meshDrawParams.secondaryColor = (const float4&)(g_colors[color % 8] * 1.5f); + m_meshDrawParams.objectTransform = (const float4x4&)Matrix44::kIdentity; + m_meshDrawParams.shadowMap = (ShadowMapD3D*)m_shadowMap; + + m_meshRenderer->draw(m_immediateMesh, &m_meshDrawParams); + + setCullMode(true); +} + +void DemoContextD3D11::drawPlane(const Vec4& p, bool color) +{ + std::vector vertices; + std::vector normals; + std::vector indices; + + Vec3 u, v; + BasisFromVector(Vec3(p.x, p.y, p.z), &u, &v); + + Vec3 c = Vec3(p.x, p.y, p.z)*-p.w; + + m_meshDrawParams.shadowMap = (ShadowMapD3D*)m_shadowMap; + + if (color) + m_meshDrawParams.color = (const float4&)(p * 0.5f + Vec4(0.5f, 0.5f, 0.5f, 0.5f)); + + const float kSize = 200.0f; + const int kGrid = 3; + + // draw a grid of quads, otherwise z precision suffers + for (int x = -kGrid; x <= kGrid; ++x) + { + for (int y = -kGrid; y <= kGrid; ++y) + { + Vec3 coff = c + u*float(x)*kSize*2.0f + v*float(y)*kSize*2.0f; + + int indexStart = int(vertices.size()); + + vertices.push_back(Vec3(coff + u*kSize + v*kSize)); + vertices.push_back(Vec3(coff - u*kSize + v*kSize)); + vertices.push_back(Vec3(coff - u*kSize - v*kSize)); + vertices.push_back(Vec3(coff + u*kSize - v*kSize)); + + normals.push_back(Vec3(p.x, p.y, p.z)); + normals.push_back(Vec3(p.x, p.y, p.z)); + normals.push_back(Vec3(p.x, p.y, p.z)); + normals.push_back(Vec3(p.x, p.y, p.z)); + + + indices.push_back(indexStart+0); + indices.push_back(indexStart+1); + indices.push_back(indexStart+2); + + indices.push_back(indexStart+2); + indices.push_back(indexStart+3); + indices.push_back(indexStart+0); + } + } + + m_immediateMesh->updateData(&vertices[0], &normals[0], NULL, NULL, &indices[0], int(vertices.size()), int(indices.size())/3); + m_meshRenderer->draw(m_immediateMesh, &m_meshDrawParams); +} + +void DemoContextD3D11::drawPlanes(Vec4* planes, int n, float bias) +{ + m_meshDrawParams.color = (float4&)Vec4(0.9f, 0.9f, 0.9f, 1.0f); + + m_meshDrawParams.bias = 0.0f; + m_meshDrawParams.grid = 1; + m_meshDrawParams.expand = 0; + + for (int i = 0; i < n; ++i) + { + Vec4 p = planes[i]; + p.w -= bias; + + drawPlane(p, false); + } + + m_meshDrawParams.grid = 0; + m_meshDrawParams.bias = m_shadowBias; + +} + +GpuMesh* DemoContextD3D11::createGpuMesh(const Mesh* m) +{ + GpuMeshD3D11* mesh = new GpuMeshD3D11(m_appGraphCtxD3D11->m_device, m_appGraphCtxD3D11->m_deviceContext); + mesh->updateData((Vec3*)&m->m_positions[0], &m->m_normals[0], NULL, NULL, (int*)&m->m_indices[0], m->GetNumVertices(), int(m->GetNumFaces())); + return (GpuMesh*)mesh; +} + +void DemoContextD3D11::destroyGpuMesh(GpuMesh* m) +{ + delete reinterpret_cast(m); +} + +void DemoContextD3D11::drawGpuMesh(GpuMesh* meshIn, const Matrix44& xform, const Vec3& color) +{ + if (meshIn) + { + GpuMeshD3D11* mesh = (GpuMeshD3D11*)meshIn; + + MeshDrawParamsD3D params = m_meshDrawParams; + + params.color = (float4&)color; + params.secondaryColor = (float4&)color; + params.objectTransform = (float4x4&)xform; + params.shadowMap = (ShadowMapD3D*)m_shadowMap; + + m_meshRenderer->draw(mesh, ¶ms); + } +} + +void DemoContextD3D11::drawGpuMeshInstances(GpuMesh* meshIn, const Matrix44* xforms, int n, const Vec3& color) +{ + if (meshIn) + { + GpuMeshD3D11* mesh = (GpuMeshD3D11*)meshIn; + + m_meshDrawParams.color = (float4&)color; + m_meshDrawParams.secondaryColor = (float4&)color; + m_meshDrawParams.shadowMap = (ShadowMapD3D*)m_shadowMap; + + // copy params + MeshDrawParamsD3D params(m_meshDrawParams); + + for (int i = 0; i < n; ++i) + { + params.objectTransform = (const float4x4&)xforms[i]; + m_meshRenderer->draw(mesh, ¶ms); + } + } +} + +void DemoContextD3D11::drawPoints(FluidRenderBuffers* buffersIn, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, bool showDensity) +{ + FluidRenderBuffersD3D11& buffers = *reinterpret_cast(buffersIn); + if (n == 0) + return; + + PointDrawParamsD3D params; + + params.renderMode = POINT_RENDER_SOLID; + params.cullMode = POINT_CULL_BACK; + params.model = (const XMMATRIX&)Matrix44::kIdentity; + params.view = (const XMMATRIX&)m_view; + params.projection = (const XMMATRIX&)m_proj; + + params.pointRadius = radius; + params.pointScale = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); + params.spotMin = m_spotMin; + params.spotMax = m_spotMax; + + int mode = 0; + if (showDensity) + mode = 1; + if (shadowTex == 0) + mode = 2; + params.mode = mode; + + for (int i = 0; i < 8; i++) + params.colors[i] = *((const float4*)&g_colors[i].r); + + // set shadow parameters + ShadowParamsD3D shadow; + RenderParamsUtilD3D::calcShadowParams(lightPos, lightTarget, lightTransform, m_shadowBias, &shadow); + params.lightTransform = shadow.lightTransform; + params.lightDir = shadow.lightDir; + params.lightPos = shadow.lightPos; + memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); + + if (m_meshDrawParams.renderStage == MESH_DRAW_SHADOW) + { + params.renderStage = POINT_DRAW_SHADOW; + params.mode = 2; + } + else + { + params.renderStage = POINT_DRAW_LIGHT; + } + + params.shadowMap = (ShadowMapD3D*)m_shadowMap; + + m_pointRenderer->draw(¶ms, buffers.m_positions.Get(), buffers.m_densities.Get(), buffers.m_indices.Get(), n, offset); +} + +void DemoContextD3D11::renderEllipsoids(FluidRenderer* rendererIn, FluidRenderBuffers* buffersIn, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) +{ + FluidRenderBuffersD3D11& buffers = *reinterpret_cast(buffersIn); + FluidRendererD3D11& renderer = *(FluidRendererD3D11*)rendererIn; + if (n == 0) + return; + + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + FluidDrawParamsD3D params; + + params.renderMode = FLUID_RENDER_SOLID; + params.cullMode = FLUID_CULL_BACK; + params.model = (const XMMATRIX&)Matrix44::kIdentity; + params.view = (const XMMATRIX&)m_view; + params.projection = (XMMATRIX&)m_proj; + + params.offset = offset; + params.n = n; + params.renderStage = FLUID_DRAW_LIGHT; + + const float viewHeight = tanf(fov / 2.0f); + params.invViewport = float3(1.0f / screenWidth, screenAspect / screenWidth, 1.0f); + params.invProjection = float3(screenAspect * viewHeight, viewHeight, 1.0f); + + params.shadowMap = (ShadowMapD3D*)m_shadowMap; + + renderer.m_depthTexture.bindAndClear(m_appGraphCtxD3D11->m_deviceContext); + + // draw static shapes into depth buffer + //DrawShapes(); + + renderer.drawEllipsoids(¶ms, &buffers); + + + //--------------------------------------------------------------- + // build smooth depth + + renderer.m_depthSmoothTexture.bindAndClear(deviceContext); + + params.blurRadiusWorld = radius * 0.5f; + params.blurScale = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); + params.invTexScale = float4(1.0f / screenAspect, 1.0f, 0.0f, 0.0f); + params.blurFalloff = blur; + params.debug = debug; + + renderer.drawBlurDepth(¶ms); + + //--------------------------------------------------------------- + // composite + + { + deviceContext->RSSetViewports(1, &m_appGraphCtxD3D11->m_viewport); + deviceContext->RSSetScissorRects(0, nullptr); + + deviceContext->OMSetRenderTargets(1, &m_appGraphCtxD3D11->m_rtv, m_appGraphCtxD3D11->m_dsv); + deviceContext->OMSetDepthStencilState(m_appGraphCtxD3D11->m_depthState, 0u); + + float blendFactor[4] = { 1.0, 1.0, 1.0, 1.0 }; + deviceContext->OMSetBlendState(m_compositeBlendState, blendFactor, 0xffff); + } + + params.invTexScale = (float4&)Vec2(1.0f / screenWidth, screenAspect / screenWidth); + params.clipPosToEye = (float4&)Vec2(tanf(fov*0.5f)*screenAspect, tanf(fov*0.5f)); + params.color = (float4&)color; + params.ior = ior; + params.spotMin = m_spotMin; + params.spotMax = m_spotMax; + params.debug = debug; + + params.lightPos = (const float3&)lightPos; + params.lightDir = (const float3&)-Normalize(lightTarget - lightPos); + params.lightTransform = (const XMMATRIX&)(ConvertToD3DProjection(lightTransform)); + + // Resolve MS back buffer/copy + if (m_msaaSamples > 1) + { + deviceContext->ResolveSubresource(m_fluidResolvedTarget, 0, m_appGraphCtxD3D11->m_backBuffer, 0, DXGI_FORMAT_R8G8B8A8_UNORM); + } + else + { + deviceContext->CopyResource(m_fluidResolvedTarget, m_appGraphCtxD3D11->m_backBuffer); + } + + renderer.drawComposite(¶ms, m_fluidResolvedTargetSRV); + + deviceContext->OMSetBlendState(nullptr, 0, 0xffff); +} + +DiffuseRenderBuffers* DemoContextD3D11::createDiffuseRenderBuffers(int numParticles, bool& enableInterop) +{ + ID3D11Device* device = m_appGraphCtxD3D11->m_device; + DiffuseRenderBuffersD3D11* buffers = new DiffuseRenderBuffersD3D11; + + buffers->m_numParticles = numParticles; + if (numParticles > 0) + { + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = numParticles * sizeof(Vec4); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + if (enableInterop) + { + bufDesc.CPUAccessFlags = 0; + bufDesc.Usage = D3D11_USAGE_DEFAULT; + bufDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; + } + + device->CreateBuffer(&bufDesc, NULL, buffers->m_positions.ReleaseAndGetAddressOf()); + device->CreateBuffer(&bufDesc, NULL, buffers->m_velocities.ReleaseAndGetAddressOf()); + } + + if (enableInterop) + { + extern NvFlexLibrary* g_flexLib; + + buffers->m_positionsBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_positions.Get(), numParticles, sizeof(Vec4)); + buffers->m_velocitiesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers->m_velocities.Get(), numParticles, sizeof(Vec4)); + + if (buffers->m_positionsBuf == nullptr || + buffers->m_velocitiesBuf == nullptr) + enableInterop = false; + } + } + + return reinterpret_cast(buffers); +} + +void DemoContextD3D11::destroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers) +{ + delete reinterpret_cast(buffers); +} + +void DemoContextD3D11::updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffersIn, NvFlexSolver* solver) +{ + DiffuseRenderBuffersD3D11* buffers = reinterpret_cast(buffersIn); + // diffuse particles + if (buffers->m_numParticles) + { + NvFlexGetDiffuseParticles(solver, buffers->m_positionsBuf, buffers->m_velocitiesBuf, nullptr); + } +} + +void DemoContextD3D11::updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffersIn, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles) +{ + DiffuseRenderBuffersD3D11& buffers = *reinterpret_cast(buffersIn); + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + D3D11_MAPPED_SUBRESOURCE res; + + // vertices + if (diffusePositions) + { + deviceContext->Map(buffers.m_positions.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, diffusePositions, sizeof(Vec4)*numDiffuseParticles); + deviceContext->Unmap(buffers.m_positions.Get(), 0); + } + + if (diffuseVelocities) + { + deviceContext->Map(buffers.m_velocities.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, diffuseVelocities, sizeof(Vec4)*numDiffuseParticles); + deviceContext->Unmap(buffers.m_velocities.Get(), 0); + } +} + +void DemoContextD3D11::drawDiffuse(FluidRenderer* renderIn, const DiffuseRenderBuffers* buffersIn, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front) +{ + FluidRendererD3D11* render = (FluidRendererD3D11*)renderIn; + const DiffuseRenderBuffersD3D11& buffers = *reinterpret_cast(buffersIn); + if (n == 0) + return; + + DiffuseDrawParamsD3D params; + + params.model = (const XMMATRIX&)Matrix44::kIdentity; + params.view = (const XMMATRIX&)m_view; + params.projection = (const XMMATRIX&)m_proj; + params.diffuseRadius = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); + params.diffuseScale = radius; + params.spotMin = m_spotMin; + params.spotMax = m_spotMax; + params.color = float4(1.0f, 1.0f, 1.0f, 1.0f); + params.motionScale = motionBlur; + + // set shadow parameters + ShadowParamsD3D shadow; + RenderParamsUtilD3D::calcShadowParams(lightPos, lightTarget, lightTransform, m_shadowBias, &shadow); + params.lightTransform = shadow.lightTransform; + params.lightDir = shadow.lightDir; + params.lightPos = shadow.lightPos; + params.shadowMap = (ShadowMapD3D*)m_shadowMap; + + memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); + + m_diffuseRenderer->draw(¶ms, buffers.m_positions.Get(), buffers.m_velocities.Get(), n); + + // reset depth stencil state + m_appGraphCtxD3D11->m_deviceContext->OMSetDepthStencilState(m_appGraphCtxD3D11->m_depthState, 0u); +} + +int DemoContextD3D11::getNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers) +{ + return reinterpret_cast(buffers)->m_numParticles; +} + +void DemoContextD3D11::beginLines() +{ +} + +void DemoContextD3D11::drawLine(const Vec3& p, const Vec3& q, const Vec4& color) +{ + m_debugLineRender->addLine(p, q, color); +} + +void DemoContextD3D11::endLines() +{ + // draw + Matrix44 projectionViewWorld = ((Matrix44&)(m_meshDrawParams.projection))*((Matrix44&)(m_meshDrawParams.view)); + + m_debugLineRender->flush(projectionViewWorld); +} + +void DemoContextD3D11::startGpuWork() {} +void DemoContextD3D11::endGpuWork() {} + +void DemoContextD3D11::flushGraphicsAndWait() +{ + ID3D11DeviceContext* deviceContext = m_appGraphCtxD3D11->m_deviceContext; + + deviceContext->End(m_renderCompletionFence); + while (S_OK != deviceContext->GetData(m_renderCompletionFence, 0, 0, 0)); +} + +void* DemoContextD3D11::getGraphicsCommandQueue() { return NULL; } + +void DemoContextD3D11::drawImguiGraph() +{ + imguiGraphDraw(); +} diff --git a/demo/d3d11/demoContextD3D11.h b/demo/d3d11/demoContextD3D11.h new file mode 100644 index 0000000..e01dfe2 --- /dev/null +++ b/demo/d3d11/demoContextD3D11.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + + +struct DemoContextD3D11 : public DemoContext +{ +public: + + // DemoContext Impl + virtual bool initialize(const RenderInitOptions& options); + virtual void startFrame(Vec4 colorIn); + virtual void endFrame(); + virtual void presentFrame(bool fullsync); + virtual void getViewRay(int x, int y, Vec3& origin, Vec3& dir); + virtual void setView(Matrix44 view, Matrix44 projection); + virtual void renderEllipsoids(FluidRenderer* renderer, FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug); + virtual void drawMesh(const Mesh* m, Vec3 color); + virtual void drawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth); + virtual void drawRope(Vec4* positions, int* indices, int numIndices, float radius, int color); + virtual void drawPlane(const Vec4& p, bool color); + virtual void drawPlanes(Vec4* planes, int n, float bias); + virtual void drawPoints(FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowTex, bool showDensity); + virtual void graphicsTimerBegin(); + virtual void graphicsTimerEnd(); + virtual float rendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq); + virtual void bindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float bias, Vec4 fogColor); + virtual void unbindSolidShader(); + virtual ShadowMap* shadowCreate(); + virtual void shadowDestroy(ShadowMap* map); + virtual void shadowBegin(ShadowMap* map); + virtual void shadowEnd(); + virtual FluidRenderer* createFluidRenderer(uint32_t width, uint32_t height); + virtual void destroyFluidRenderer(FluidRenderer* renderer); + virtual FluidRenderBuffers* createFluidRenderBuffers(int numParticles, bool enableInterop); + virtual void updateFluidRenderBuffers(FluidRenderBuffers* buffers, NvFlexSolver* flex, bool anisotropy, bool density); + virtual void updateFluidRenderBuffers(FluidRenderBuffers* buffers, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices); + virtual void destroyFluidRenderBuffers(FluidRenderBuffers* buffers); + virtual GpuMesh* createGpuMesh(const Mesh* m); + virtual void destroyGpuMesh(GpuMesh* mesh); + virtual void drawGpuMesh(GpuMesh* m, const Matrix44& xform, const Vec3& color); + virtual void drawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const Vec3& color); + virtual DiffuseRenderBuffers* createDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop); + virtual void destroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers); + virtual void updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles); + virtual void updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, NvFlexSolver* solver); + virtual void drawDiffuse(FluidRenderer* render, const DiffuseRenderBuffers* buffers, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front); + virtual int getNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers); + virtual void beginLines(); + virtual void drawLine(const Vec3& p, const Vec3& q, const Vec4& color); + virtual void endLines(); + virtual void onSizeChanged(int width, int height, bool minimized); + virtual void startGpuWork(); + virtual void endGpuWork(); + virtual void flushGraphicsAndWait(); + virtual void setFillMode(bool wire); + virtual void setCullMode(bool enabled); + virtual void drawImguiGraph(); + virtual void* getGraphicsCommandQueue(); + virtual void getRenderDevice(void** device, void** context); + + DemoContextD3D11(); + virtual ~DemoContextD3D11(); + +protected: + void _flushFrame(); + void _onWindowSizeChanged(int width, int height, bool minimized); + + DebugLineRenderD3D11* m_debugLineRender; + MeshRendererD3D11* m_meshRenderer; + PointRendererD3D11* m_pointRenderer; + DiffuseRendererD3D11* m_diffuseRenderer; + + // Used when blending water in the final 'composite' phase + ID3D11BlendState* m_compositeBlendState; + + // Target texture resolved/copied to for combination rendering from for water surface + ID3D11Texture2D* m_fluidResolvedTarget; + ID3D11ShaderResourceView* m_fluidResolvedTargetSRV; + + AppGraphCtx* m_appGraphCtx; + AppGraphCtxD3D11* m_appGraphCtxD3D11; + + float m_spotMin; + float m_spotMax; + float m_shadowBias; + + MeshDrawParamsD3D m_meshDrawParams; + + Matrix44 m_view; + Matrix44 m_proj; + + ShadowMapD3D11* m_shadowMap; + GpuMeshD3D11* m_immediateMesh; + + SDL_Window* m_window; + + int m_msaaSamples; + + ID3D11Query* m_renderTimerDisjoint; + ID3D11Query* m_renderTimerBegin; + ID3D11Query* m_renderTimerEnd; + ID3D11Query* m_renderCompletionFence; + bool m_timersSet = false; +}; diff --git a/demo/d3d11/diffuseRender.cpp b/demo/d3d11/diffuseRender.cpp deleted file mode 100644 index 60ced59..0000000 --- a/demo/d3d11/diffuseRender.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -//direct3d headers - -#define NOMINMAX - -#include - -// include the Direct3D Library file -#pragma comment (lib, "d3d11.lib") - -#include - -#include "appD3D11Ctx.h" - -#include "diffuseRender.h" - -#include "shaders/diffuseVS.hlsl.h" -#include "shaders/diffuseGS.hlsl.h" -#include "shaders/diffusePS.hlsl.h" - -#define EXCLUDE_SHADER_STRUCTS 1 -#include "shaders/shaderCommon.h" - - -void DiffuseRenderer::Init(ID3D11Device* device, ID3D11DeviceContext* context) -{ - m_device = device; - m_deviceContext = context; - - // create the input layout - { - D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "VELOCITY", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - m_device->CreateInputLayout(inputElementDescs, 2, g_diffuseVS, sizeof(g_diffuseVS), &m_inputLayout); - } - - // create the shaders - m_device->CreateVertexShader(g_diffuseVS, sizeof(g_diffuseVS), nullptr, &m_diffuseVS); - m_device->CreateGeometryShader(g_diffuseGS, sizeof(g_diffuseGS), nullptr, &m_diffuseGS); - m_device->CreatePixelShader(g_diffusePS, sizeof(g_diffusePS), nullptr, &m_diffusePS); - - { - D3D11_BLEND_DESC blendDesc = {}; - blendDesc.AlphaToCoverageEnable = false; - blendDesc.IndependentBlendEnable = false; - blendDesc.RenderTarget[0].BlendEnable = true; - blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; - blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; - blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - - m_device->CreateBlendState(&blendDesc, &m_blendState); - } - - { - D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; - depthStateDesc.DepthEnable = TRUE; - depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; - depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; - - device->CreateDepthStencilState(&depthStateDesc, &m_depthStencilState); - } - - // create a constant buffer - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(DiffuseShaderConst); // 64 * sizeof(float); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); - } - - // create the rastersizer state - { - D3D11_RASTERIZER_DESC desc = {}; - desc.FillMode = D3D11_FILL_SOLID; - desc.CullMode = D3D11_CULL_NONE; - desc.FrontCounterClockwise = TRUE; // This is non-default - desc.DepthBias = 0; - desc.DepthBiasClamp = 0.f; - desc.SlopeScaledDepthBias = 0.f; - desc.DepthClipEnable = TRUE; - desc.ScissorEnable = FALSE; - desc.MultisampleEnable = FALSE; - desc.AntialiasedLineEnable = FALSE; - - m_device->CreateRasterizerState(&desc, &m_rasterizerState); - } -} - -void DiffuseRenderer::Destroy() -{ - COMRelease(m_inputLayout); - COMRelease(m_diffuseVS); - COMRelease(m_diffuseGS); - COMRelease(m_diffusePS); - COMRelease(m_constantBuffer); - COMRelease(m_rasterizerState); - COMRelease(m_blendState); - COMRelease(m_depthStencilState); -} - - - -void DiffuseRenderer::Draw(const DiffuseDrawParams* params, ID3D11Buffer* positions, ID3D11Buffer* velocities, ID3D11Buffer* indices, int numParticles) -{ - using namespace DirectX; - - ID3D11DeviceContext* deviceContext = m_deviceContext; - - // update constant buffer - { - D3D11_MAPPED_SUBRESOURCE mappedResource = { 0 }; - if (S_OK == deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - DiffuseShaderConst cParams; - - cParams.modelViewProjection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params->model, params->view), params->projection)); - cParams.modelView = (float4x4&)XMMatrixMultiply(params->model, params->view); - cParams.projection = (float4x4&)params->projection; - - cParams.motionBlurScale = params->motionScale; - cParams.diffuseRadius = params->diffuseRadius; - cParams.diffuseScale = params->diffuseScale; - cParams.spotMin = params->spotMin; - cParams.spotMax = params->spotMax; - - cParams.lightTransform = (float4x4&)params->lightTransform; - cParams.lightPos = params->lightPos; - cParams.lightDir = params->lightDir; - cParams.color = params->color; - - - memcpy(cParams.shadowTaps, params->shadowTaps, sizeof(cParams.shadowTaps)); - - memcpy(mappedResource.pData, &cParams, sizeof(DiffuseShaderConst)); - - deviceContext->Unmap(m_constantBuffer, 0u); - } - } - - deviceContext->VSSetShader(m_diffuseVS, nullptr, 0u); - deviceContext->GSSetShader(m_diffuseGS, nullptr, 0u); - deviceContext->PSSetShader(m_diffusePS, nullptr, 0u); - - if (params->shadowMap) - { - ShadowMap* shadowMap = (ShadowMap*)params->shadowMap; - - ID3D11ShaderResourceView* ppSRV[1] = { shadowMap->m_depthSrv.Get() }; - deviceContext->PSSetShaderResources(0, 1, ppSRV); - ID3D11SamplerState* ppSS[1] = { shadowMap->m_linearSampler.Get() }; - deviceContext->PSSetSamplers(0, 1, ppSS); - } - - deviceContext->IASetInputLayout(m_inputLayout); - deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - - deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->GSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); - - ID3D11Buffer* vertexBuffers[2] = - { - positions, - velocities - }; - - unsigned int vertexBufferStrides[2] = - { - sizeof(float4), - sizeof(float4), - }; - - unsigned int vertexBufferOffsets[2] = { 0 }; - - deviceContext->IASetVertexBuffers(0, 2, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); - deviceContext->IASetIndexBuffer(indices, DXGI_FORMAT_R32_UINT, 0u); - - deviceContext->OMSetBlendState(m_blendState, nullptr, 0xFFFFFFFF); - deviceContext->OMSetDepthStencilState(m_depthStencilState, 0u); - - float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); - if (depthSign < 0.f) - { - deviceContext->RSSetState(m_rasterizerState); - } - - deviceContext->DrawIndexed(numParticles, 0, 0); - - if (depthSign < 0.f) - { - deviceContext->RSSetState(nullptr); - } - - deviceContext->OMSetDepthStencilState(nullptr, 0u); - deviceContext->OMSetBlendState(nullptr, nullptr, 0xFFFFFFFF); -} diff --git a/demo/d3d11/diffuseRender.h b/demo/d3d11/diffuseRender.h deleted file mode 100644 index 69517b2..0000000 --- a/demo/d3d11/diffuseRender.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include - -#include "shadowMap.h" - - -typedef DirectX::XMFLOAT3 float3; -typedef DirectX::XMFLOAT4 float4; -typedef DirectX::XMFLOAT4X4 float4x4; - -struct DiffuseDrawParams -{ - DirectX::XMMATRIX projection; - DirectX::XMMATRIX view; - DirectX::XMMATRIX model; - - float diffuseRadius; // point size in world space - float diffuseScale; // scale to calculate size in pixels - float spotMin; - float spotMax; - float motionScale; - - DirectX::XMMATRIX lightTransform; - float3 lightPos; - float3 lightDir; - - float4 color; - - float4 shadowTaps[12]; - ShadowMap* shadowMap; - - int mode; -}; - - -struct DiffuseRenderer -{ - ID3D11Device* m_device = nullptr; - ID3D11DeviceContext* m_deviceContext = nullptr; - - ID3D11InputLayout* m_inputLayout = nullptr; - - ID3D11VertexShader* m_diffuseVS = nullptr; - ID3D11GeometryShader* m_diffuseGS = nullptr; - ID3D11PixelShader* m_diffusePS = nullptr; - - ID3D11Buffer* m_constantBuffer = nullptr; - ID3D11RasterizerState* m_rasterizerState = nullptr; - - ID3D11BlendState* m_blendState = nullptr; - ID3D11DepthStencilState* m_depthStencilState = nullptr; - - void Init(ID3D11Device* device, ID3D11DeviceContext* deviceContext); - void Destroy(); - - - void Draw(const DiffuseDrawParams* params, ID3D11Buffer* positions, ID3D11Buffer* velocities, ID3D11Buffer* indices, int numParticles); -}; diff --git a/demo/d3d11/diffuseRenderD3D11.cpp b/demo/d3d11/diffuseRenderD3D11.cpp new file mode 100644 index 0000000..846a8bf --- /dev/null +++ b/demo/d3d11/diffuseRenderD3D11.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +//direct3d headers + +#define NOMINMAX + +#include + +// include the Direct3D Library file +#pragma comment (lib, "d3d11.lib") + +#include + +#include "appD3D11Ctx.h" + +#include "diffuseRenderD3D11.h" + +#include "../d3d/shaders/diffuseVS.hlsl.h" +#include "../d3d/shaders/diffuseGS.hlsl.h" +#include "../d3d/shaders/diffusePS.hlsl.h" + +#include "../d3d/shaderCommonD3D.h" + +void DiffuseRendererD3D11::init(ID3D11Device* device, ID3D11DeviceContext* context) +{ + m_device = device; + m_deviceContext = context; + + // create the input layout + { + D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "VELOCITY", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + m_device->CreateInputLayout(inputElementDescs, 2, g_diffuseVS, sizeof(g_diffuseVS), &m_inputLayout); + } + + // create the shaders + m_device->CreateVertexShader(g_diffuseVS, sizeof(g_diffuseVS), nullptr, &m_diffuseVs); + m_device->CreateGeometryShader(g_diffuseGS, sizeof(g_diffuseGS), nullptr, &m_diffuseGs); + m_device->CreatePixelShader(g_diffusePS, sizeof(g_diffusePS), nullptr, &m_diffusePs); + + { + D3D11_BLEND_DESC blendDesc = {}; + blendDesc.AlphaToCoverageEnable = false; + blendDesc.IndependentBlendEnable = false; + blendDesc.RenderTarget[0].BlendEnable = true; + blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + m_device->CreateBlendState(&blendDesc, &m_blendState); + } + + { + D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; + depthStateDesc.DepthEnable = TRUE; + depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; + depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + + device->CreateDepthStencilState(&depthStateDesc, &m_depthStencilState); + } + + // create a constant buffer + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(Hlsl::DiffuseShaderConst); // 64 * sizeof(float); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); + } + + // create the rastersizer state + { + D3D11_RASTERIZER_DESC desc = {}; + desc.FillMode = D3D11_FILL_SOLID; + desc.CullMode = D3D11_CULL_NONE; + desc.FrontCounterClockwise = TRUE; // This is non-default + desc.DepthBias = 0; + desc.DepthBiasClamp = 0.f; + desc.SlopeScaledDepthBias = 0.f; + desc.DepthClipEnable = TRUE; + desc.ScissorEnable = FALSE; + desc.MultisampleEnable = FALSE; + desc.AntialiasedLineEnable = FALSE; + + m_device->CreateRasterizerState(&desc, &m_rasterizerState); + } +} + +void DiffuseRendererD3D11::draw(const DiffuseDrawParamsD3D* params, ID3D11Buffer* positions, ID3D11Buffer* velocities, int numParticles) +{ + using namespace DirectX; + ID3D11DeviceContext* deviceContext = m_deviceContext; + + // update constant buffer + { + D3D11_MAPPED_SUBRESOURCE mappedResource = { 0 }; + if (SUCCEEDED(deviceContext->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + Hlsl::DiffuseShaderConst constBuf; + RenderParamsUtilD3D::calcDiffuseConstantBuffer(*params, constBuf); + memcpy(mappedResource.pData, &constBuf, sizeof(Hlsl::DiffuseShaderConst)); + deviceContext->Unmap(m_constantBuffer.Get(), 0u); + } + } + + deviceContext->VSSetShader(m_diffuseVs.Get(), nullptr, 0u); + deviceContext->GSSetShader(m_diffuseGs.Get(), nullptr, 0u); + deviceContext->PSSetShader(m_diffusePs.Get(), nullptr, 0u); + + if (params->shadowMap) + { + ShadowMapD3D11* shadowMap = (ShadowMapD3D11*)params->shadowMap; + + ID3D11ShaderResourceView* srvs[1] = { shadowMap->m_depthSrv.Get() }; + deviceContext->PSSetShaderResources(0, 1, srvs); + ID3D11SamplerState* samps[1] = { shadowMap->m_linearSampler.Get() }; + deviceContext->PSSetSamplers(0, 1, samps); + } + + deviceContext->IASetInputLayout(m_inputLayout.Get()); + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + + deviceContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->GSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->PSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + ID3D11Buffer* vertexBuffers[2] = + { + positions, + velocities + }; + + unsigned int vertexBufferStrides[2] = + { + sizeof(float4), + sizeof(float4), + }; + + unsigned int vertexBufferOffsets[2] = { 0 }; + + deviceContext->IASetVertexBuffers(0, 2, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); + deviceContext->IASetIndexBuffer(NV_NULL, DXGI_FORMAT_R32_UINT, 0u); + + deviceContext->OMSetBlendState(m_blendState.Get(), nullptr, 0xFFFFFFFF); + deviceContext->OMSetDepthStencilState(m_depthStencilState.Get(), 0u); + + float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); + if (depthSign < 0.f) + { + deviceContext->RSSetState(m_rasterizerState.Get()); + } + + deviceContext->Draw(numParticles, 0); + + if (depthSign < 0.f) + { + deviceContext->RSSetState(nullptr); + } + + deviceContext->GSSetShader(nullptr, nullptr, 0u); + deviceContext->OMSetDepthStencilState(nullptr, 0u); + deviceContext->OMSetBlendState(nullptr, nullptr, 0xFFFFFFFF); +} diff --git a/demo/d3d11/diffuseRenderD3D11.h b/demo/d3d11/diffuseRenderD3D11.h new file mode 100644 index 0000000..cf4231e --- /dev/null +++ b/demo/d3d11/diffuseRenderD3D11.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include + +#include "shadowMapD3D11.h" +#include "../include/NvFlex.h" +#include "../d3d/renderParamsD3D.h" +#include "shaders.h" + +#include +using namespace Microsoft::WRL; + +// vertex buffers for diffuse particles +struct DiffuseRenderBuffersD3D11 +{ + DiffuseRenderBuffersD3D11() : + m_positionsBuf(nullptr), + m_velocitiesBuf(nullptr) + { + m_numParticles = 0; + } + + ~DiffuseRenderBuffersD3D11() + { + if (m_numParticles > 0) + { + NvFlexUnregisterD3DBuffer(m_positionsBuf); + NvFlexUnregisterD3DBuffer(m_velocitiesBuf); + } + } + + int m_numParticles; + + ComPtr m_positions; + ComPtr m_velocities; + + NvFlexBuffer* m_positionsBuf; + NvFlexBuffer* m_velocitiesBuf; +}; + +struct DiffuseRendererD3D11 +{ + void init(ID3D11Device* device, ID3D11DeviceContext* deviceContext); + + void draw(const DiffuseDrawParamsD3D* params, ID3D11Buffer* positions, ID3D11Buffer* velocities, int numParticles); + + DiffuseRendererD3D11(): + m_device(nullptr), + m_deviceContext(nullptr) + {} + + ID3D11Device* m_device; + ID3D11DeviceContext* m_deviceContext; + + ComPtr m_inputLayout; + + ComPtr m_diffuseVs; + ComPtr m_diffuseGs; + ComPtr m_diffusePs; + + ComPtr m_constantBuffer; + ComPtr m_rasterizerState; + + ComPtr m_blendState; + ComPtr m_depthStencilState; +}; diff --git a/demo/d3d11/fluidRender.cpp b/demo/d3d11/fluidRender.cpp deleted file mode 100644 index f9dd767..0000000 --- a/demo/d3d11/fluidRender.cpp +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -//direct3d headers - -#define NOMINMAX - -#include - -// include the Direct3D Library file -#pragma comment (lib, "d3d11.lib") - -#include - -#include "appD3D11Ctx.h" - -#include "fluidRender.h" - -#include "shaders/ellipsoidDepthVS.hlsl.h" -#include "shaders/ellipsoidDepthGS.hlsl.h" -#include "shaders/ellipsoidDepthPS.hlsl.h" -#include "shaders/passThroughVS.hlsl.h" -#include "shaders/blurDepthPS.hlsl.h" -#include "shaders/compositePS.hlsl.h" - -#define EXCLUDE_SHADER_STRUCTS 1 -#include "shaders/shaderCommon.h" - -#include "renderTarget.h" -#include "shadowMap.h" - -#include "shaders.h" - -typedef DirectX::XMFLOAT2 float2; - -using namespace DirectX; - - -struct PassthroughVertex -{ - float x, y; - float u, v; -}; - -void FluidRenderer::Init(ID3D11Device* device, ID3D11DeviceContext* context, int width, int height) -{ - mSceneWidth = width; - mSceneHeight = height; - - mDepthTex.Init(device, width, height); - mDepthSmoothTex.Init(device, width, height, false); - - m_device = device; - m_deviceContext = context; - - // create the input layout - { - D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "U", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "V", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "W", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - m_device->CreateInputLayout(inputElementDescs, 4, g_ellipsoidDepthVS, sizeof(g_ellipsoidDepthVS), &m_ellipsoidDepthLayout); - } - - // create the shaders - m_device->CreateVertexShader(g_ellipsoidDepthVS, sizeof(g_ellipsoidDepthVS), nullptr, &m_ellipsoidDepthVS); - m_device->CreateGeometryShader(g_ellipsoidDepthGS, sizeof(g_ellipsoidDepthGS), nullptr, &m_ellipsoidDepthGS); - m_device->CreatePixelShader(g_ellipsoidDepthPS, sizeof(g_ellipsoidDepthPS), nullptr, &m_ellipsoidDepthPS); - - // create the input layout - { - D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - m_device->CreateInputLayout(inputElementDescs, 2, g_passThroughVS, sizeof(g_passThroughVS), &m_passThroughLayout); - } - - // pass through shader - m_device->CreateVertexShader(g_passThroughVS, sizeof(g_passThroughVS), nullptr, &m_passThroughVS); - - // full screen pixel shaders - m_device->CreatePixelShader(g_blurDepthPS, sizeof(g_blurDepthPS), nullptr, &m_blurDepthPS); - m_device->CreatePixelShader(g_compositePS, sizeof(g_compositePS), nullptr, &m_compositePS); - - // create a constant buffer - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(FluidShaderConst); // 64 * sizeof(float); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); - } - - // create the rastersizer state - for (int i = 0; i < NUM_FLUID_RENDER_MODES; i++) - { - for (int j = 0; j < NUM_FLUID_CULL_MODES; j++) - - { - D3D11_RASTERIZER_DESC desc = {}; - desc.FillMode = (D3D11_FILL_MODE)(D3D11_FILL_WIREFRAME + i); - desc.CullMode = (D3D11_CULL_MODE)(D3D11_CULL_NONE + j); - desc.FrontCounterClockwise = TRUE; // This is non-default - desc.DepthBias = 0; - desc.DepthBiasClamp = 0.f; - desc.SlopeScaledDepthBias = 0.f; - desc.DepthClipEnable = TRUE; - desc.ScissorEnable = FALSE; - desc.MultisampleEnable = FALSE; - desc.AntialiasedLineEnable = FALSE; - - m_device->CreateRasterizerState(&desc, &m_rasterizerStateRH[i][j]); - } - } - - CreateScreenQuad(); -} - -void FluidRenderer::Destroy() -{ - COMRelease(m_ellipsoidDepthLayout); - COMRelease(m_ellipsoidDepthVS); - COMRelease(m_ellipsoidDepthGS); - COMRelease(m_ellipsoidDepthPS); - - COMRelease(m_passThroughLayout); - COMRelease(m_passThroughVS); - - COMRelease(m_blurDepthPS); - COMRelease(m_compositePS); - - COMRelease(m_constantBuffer); - - for (int i = 0; i < NUM_FLUID_RENDER_MODES; i++) - for (int j = 0; j < NUM_FLUID_CULL_MODES; j++) - COMRelease(m_rasterizerStateRH[i][j]); - - COMRelease(m_quadVertexBuffer); - COMRelease(m_quadIndexBuffer); -} - -void FluidRenderer::CreateScreenQuad() -{ - // create an index buffer - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = 4*sizeof(UINT); - bufDesc.Usage = D3D11_USAGE_IMMUTABLE; - bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; - bufDesc.CPUAccessFlags = DXGI_CPU_ACCESS_NONE; - bufDesc.MiscFlags = 0; - - unsigned int quad_indices[4] = { 0, 1, 3, 2 }; - - D3D11_SUBRESOURCE_DATA data = { 0 }; - data.pSysMem = quad_indices; - - m_device->CreateBuffer(&bufDesc, &data, &m_quadIndexBuffer); - } - - // create a vertex buffer - { - - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = 4*sizeof(PassthroughVertex); - bufDesc.Usage = D3D11_USAGE_IMMUTABLE; - bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bufDesc.CPUAccessFlags = DXGI_CPU_ACCESS_NONE; - bufDesc.MiscFlags = 0; - - D3D11_SUBRESOURCE_DATA data = { 0 }; - - - float4 vertices[4] = - { - float4(-1.0f, -1.0f, 0.0f, 0.0f), - float4(1.0f, -1.0f, 1.0f, 0.0f), - float4(1.0f, 1.0f, 1.0f, 1.0f), - float4(-1.0f, 1.0f, 0.0f, 1.0f), - }; - - data.pSysMem = vertices; - - m_device->CreateBuffer(&bufDesc, &data, &m_quadVertexBuffer); - } -} - -void FluidRenderer::DrawEllipsoids(const FluidDrawParams* params, const FluidRenderBuffers* buffers) -{ - ID3D11DeviceContext* deviceContext = m_deviceContext; - - // update constant buffer - { - - D3D11_BUFFER_DESC desc; - m_constantBuffer->GetDesc(&desc); - - D3D11_MAPPED_SUBRESOURCE mappedResource = {}; - if (S_OK == deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - FluidShaderConst cParams; - - cParams.modelviewprojection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params->model, params->view), params->projection)); - cParams.projection = (float4x4&)params->projection; - cParams.modelview_inverse = (float4x4&)XMMatrixInverse(nullptr, XMMatrixMultiply(params->model, params->view)); - cParams.projection_inverse = (float4x4&)XMMatrixInverse(nullptr, params->projection); - - //cParams.invTexScale = invTexScale; - //cParams.invProjection = invProjection; - cParams.invViewport = params->invViewport; - - - cParams.blurRadiusWorld = params->blurRadiusWorld; - cParams.blurScale = params->blurScale; - cParams.blurFalloff = params->blurFalloff; - cParams.debug = params->debug; - - memcpy(mappedResource.pData, &cParams, sizeof(FluidShaderConst)); - - deviceContext->Unmap(m_constantBuffer, 0u); - } - } - - deviceContext->VSSetShader(m_ellipsoidDepthVS, nullptr, 0u); - deviceContext->GSSetShader(m_ellipsoidDepthGS, nullptr, 0u); - deviceContext->PSSetShader(m_ellipsoidDepthPS, nullptr, 0u); - - deviceContext->IASetInputLayout(m_ellipsoidDepthLayout); - deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - - deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->GSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); - - ID3D11Buffer* vertexBuffers[4] = - { - buffers->mPositionVBO, - buffers->mAnisotropyVBO[0], - buffers->mAnisotropyVBO[1], - buffers->mAnisotropyVBO[2] - }; - - unsigned int vertexBufferStrides[4] = - { - sizeof(float4), - sizeof(float4), - sizeof(float4), - sizeof(float4) - }; - - unsigned int vertexBufferOffsets[4] = { 0 }; - - deviceContext->IASetVertexBuffers(0, 4, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); - deviceContext->IASetIndexBuffer(buffers->mIndices, DXGI_FORMAT_R32_UINT, 0u); - - float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); - if (depthSign < 0.f) - { - deviceContext->RSSetState(m_rasterizerStateRH[params->renderMode][params->cullMode]); - } - - deviceContext->DrawIndexed(params->n, params->offset, 0); - - if (depthSign < 0.f) - { - deviceContext->RSSetState(nullptr); - } -} - -void FluidRenderer::DrawBlurDepth(const FluidDrawParams* params) -{ - ID3D11DeviceContext* deviceContext = m_deviceContext; - - // update constant buffer - { - D3D11_MAPPED_SUBRESOURCE mappedResource = {}; - if (S_OK == deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - FluidShaderConst cParams; - - cParams.modelviewprojection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params->model, params->view), params->projection)); - cParams.projection = (float4x4&)params->projection; - cParams.modelview_inverse = (float4x4&)XMMatrixInverse(nullptr, XMMatrixMultiply(params->model, params->view)); - cParams.projection_inverse = (float4x4&)XMMatrixInverse(nullptr, params->projection); - - //cParams.invTexScale = params->invTexScale; - //cParams.invViewport = params->invViewport; - //cParams.invProjection = params->invProjection; - - cParams.blurRadiusWorld = params->blurRadiusWorld; - cParams.blurScale = params->blurScale; - cParams.blurFalloff = params->blurFalloff; - cParams.debug = params->debug; - - memcpy(mappedResource.pData, &cParams, sizeof(FluidShaderConst)); - - deviceContext->Unmap(m_constantBuffer, 0u); - } - } - - deviceContext->VSSetShader(m_passThroughVS, nullptr, 0u); - deviceContext->GSSetShader(nullptr, nullptr, 0u); - deviceContext->PSSetShader(m_blurDepthPS, nullptr, 0u); - - ID3D11ShaderResourceView* ppSRV[1] = { mDepthTex.m_backSrv.Get() }; - deviceContext->PSSetShaderResources(0, 1, ppSRV); - - deviceContext->IASetInputLayout(m_passThroughLayout); - deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); - - UINT vertexStride = sizeof(PassthroughVertex); - UINT offset = 0u; - deviceContext->IASetVertexBuffers(0, 1, &m_quadVertexBuffer, &vertexStride, &offset); - deviceContext->IASetIndexBuffer(m_quadIndexBuffer, DXGI_FORMAT_R32_UINT, 0u); - - float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); - if (depthSign < 0.f) - { - deviceContext->RSSetState(m_rasterizerStateRH[params->renderMode][params->cullMode]); - } - - deviceContext->DrawIndexed((UINT)4, 0, 0); - - if (depthSign < 0.f) - { - deviceContext->RSSetState(nullptr); - } -} - -void FluidRenderer::DrawComposite(const FluidDrawParams* params, ID3D11ShaderResourceView* sceneMap) -{ - ID3D11DeviceContext* deviceContext = m_deviceContext; - - // update constant buffer - { - D3D11_MAPPED_SUBRESOURCE mappedResource = {}; - if (S_OK == deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - FluidShaderConst cParams; - - cParams.modelviewprojection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params->model, params->view), params->projection)); - cParams.modelview = (float4x4&)XMMatrixMultiply(params->model, params->view); - cParams.projection = (float4x4&)params->projection; - cParams.modelview_inverse = (float4x4&)XMMatrixInverse(nullptr, XMMatrixMultiply(params->model, params->view)); - cParams.projection_inverse = (float4x4&)XMMatrixInverse(nullptr, params->projection); - - cParams.lightTransform = (float4x4&)params->lightTransform; - - cParams.invTexScale = params->invTexScale; - - //cParams.invViewport = params->invViewport; - //cParams.invProjection = params->invProjection; - - cParams.blurRadiusWorld = params->blurRadiusWorld; - cParams.blurScale = params->blurScale; - cParams.blurFalloff = params->blurFalloff; - cParams.debug = params->debug; - - cParams.clipPosToEye = params->clipPosToEye; - cParams.color = params->color; - cParams.ior = params->ior; - cParams.spotMin = params->spotMin; - cParams.spotMax = params->spotMax; - - cParams.lightPos = params->lightPos; - cParams.lightDir = params->lightDir; - - memcpy(mappedResource.pData, &cParams, sizeof(FluidShaderConst)); - - deviceContext->Unmap(m_constantBuffer, 0u); - - const float2 taps[] = - { - float2(-0.326212f,-0.40581f), float2(-0.840144f,-0.07358f), - float2(-0.695914f,0.457137f), float2(-0.203345f,0.620716f), - float2(0.96234f,-0.194983f), float2(0.473434f,-0.480026f), - float2(0.519456f,0.767022f), float2(0.185461f,-0.893124f), - float2(0.507431f,0.064425f), float2(0.89642f,0.412458f), - float2(-0.32194f,-0.932615f), float2(-0.791559f,-0.59771f) - }; - memcpy(cParams.shadowTaps, taps, sizeof(taps)); - } - } - - deviceContext->VSSetShader(m_passThroughVS, nullptr, 0u); - deviceContext->GSSetShader(nullptr, nullptr, 0u); - deviceContext->PSSetShader(m_compositePS, nullptr, 0u); - - - RenderTarget* depthMap = &mDepthSmoothTex; - ShadowMap* shadowMap = (ShadowMap*)params->shadowMap; - - ID3D11ShaderResourceView* ppSRV[3] = - { - depthMap->m_backSrv.Get(), - sceneMap, - shadowMap->m_depthSrv.Get() - - }; - deviceContext->PSSetShaderResources(0, 3, ppSRV); - - ID3D11SamplerState* ppSS[2] = - { - depthMap->m_linearSampler.Get() , - shadowMap->m_linearSampler.Get() - }; - deviceContext->PSSetSamplers(0, 2, ppSS); - - - deviceContext->IASetInputLayout(m_passThroughLayout); - deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); - - UINT vertexStride = sizeof(PassthroughVertex); - UINT offset = 0u; - deviceContext->IASetVertexBuffers(0, 1, &m_quadVertexBuffer, &vertexStride, &offset); - deviceContext->IASetIndexBuffer(m_quadIndexBuffer, DXGI_FORMAT_R32_UINT, 0u); - - float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); - if (depthSign < 0.f) - { - deviceContext->RSSetState(m_rasterizerStateRH[params->renderMode][params->cullMode]); - } - - deviceContext->DrawIndexed((UINT)4, 0, 0); - - if (depthSign < 0.f) - { - deviceContext->RSSetState(nullptr); - } - - // reset srvs - ID3D11ShaderResourceView* zero[3] = { NULL, NULL, NULL }; - deviceContext->PSSetShaderResources(0, 3, zero); -} - diff --git a/demo/d3d11/fluidRender.h b/demo/d3d11/fluidRender.h deleted file mode 100644 index 43fee4b..0000000 --- a/demo/d3d11/fluidRender.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include - -#include - -#include "renderTarget.h" -#include "shadowMap.h" - -struct FluidRenderBuffers; - -enum FluidRenderMode -{ - FLUID_RENDER_WIREFRAME, - FLUID_RENDER_SOLID, - NUM_FLUID_RENDER_MODES -}; - -enum FluidCullMode -{ - FLUID_CULL_NONE, - FLUID_CULL_FRONT, - FLUID_CULL_BACK, - NUM_FLUID_CULL_MODES -}; - -enum FluidDrawStage -{ - FLUID_DRAW_NULL, - FLUID_DRAW_SHADOW, - FLUID_DRAW_REFLECTION, - FLUID_DRAW_LIGHT -}; - -typedef DirectX::XMFLOAT3 float3; -typedef DirectX::XMFLOAT4 float4; -typedef DirectX::XMFLOAT4X4 float4x4; - -struct FluidDrawParams -{ - FluidRenderMode renderMode; - FluidCullMode cullMode; - FluidDrawStage renderStage; - - int offset; - int n; - - DirectX::XMMATRIX projection; - DirectX::XMMATRIX view; - DirectX::XMMATRIX model; - - float4 invTexScale; - - float3 invViewport; - float3 invProjection; - - float blurRadiusWorld; - float blurScale; - float blurFalloff; - int debug; - - float3 lightPos; - float3 lightDir; - DirectX::XMMATRIX lightTransform; - - float4 color; - float4 clipPosToEye; - - float spotMin; - float spotMax; - float ior; - - ShadowMap* shadowMap; -}; - - -struct FluidRenderer -{ - ID3D11Device* m_device = nullptr; - ID3D11DeviceContext* m_deviceContext = nullptr; - - ID3D11InputLayout* m_ellipsoidDepthLayout = nullptr; - ID3D11VertexShader* m_ellipsoidDepthVS = nullptr; - ID3D11GeometryShader* m_ellipsoidDepthGS = nullptr; - ID3D11PixelShader* m_ellipsoidDepthPS = nullptr; - - ID3D11InputLayout* m_passThroughLayout = nullptr; - ID3D11VertexShader* m_passThroughVS = nullptr; - - ID3D11PixelShader* m_blurDepthPS = nullptr; - ID3D11PixelShader* m_compositePS = nullptr; - - ID3D11Buffer* m_constantBuffer = nullptr; - ID3D11RasterizerState* m_rasterizerStateRH[NUM_FLUID_RENDER_MODES][NUM_FLUID_CULL_MODES]; - - ID3D11Buffer* m_quadVertexBuffer; - ID3D11Buffer* m_quadIndexBuffer; - - RenderTarget mDepthTex; - RenderTarget mDepthSmoothTex; - RenderTarget mThicknessTex; - - int mSceneWidth; - int mSceneHeight; - - void Init(ID3D11Device* device, ID3D11DeviceContext* context, int width, int height); - void Destroy(); - - void DrawEllipsoids(const FluidDrawParams* params, const FluidRenderBuffers* buffers); - void DrawBlurDepth(const FluidDrawParams* params); - void DrawComposite(const FluidDrawParams* params, ID3D11ShaderResourceView* sceneMap); - - void CreateScreenQuad(); -}; - - diff --git a/demo/d3d11/fluidRenderD3D11.cpp b/demo/d3d11/fluidRenderD3D11.cpp new file mode 100644 index 0000000..fa36f9b --- /dev/null +++ b/demo/d3d11/fluidRenderD3D11.cpp @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +//direct3d headers + +#define NOMINMAX + +#include + +// include the Direct3D Library file +#pragma comment (lib, "d3d11.lib") + +#include + +#include "appD3D11Ctx.h" + +#include "fluidRenderD3D11.h" + +#include "../d3d/shaders/ellipsoidDepthVS.hlsl.h" +#include "../d3d/shaders/ellipsoidDepthGS.hlsl.h" +#include "../d3d/shaders/ellipsoidDepthPS.hlsl.h" +#include "../d3d/shaders/passThroughVS.hlsl.h" +#include "../d3d/shaders/blurDepthPS.hlsl.h" +#include "../d3d/shaders/compositePS.hlsl.h" + +#include "../d3d/shaderCommonD3D.h" + +#include "renderTargetD3D11.h" +#include "shadowMapD3D11.h" + +#include "shaders.h" + +typedef DirectX::XMFLOAT2 float2; + +using namespace DirectX; + +struct PassthroughVertex +{ + float3 position; + float3 normal; + float2 texcoords; + float4 color; +}; + +void FluidRendererD3D11::init(ID3D11Device* device, ID3D11DeviceContext* context, int width, int height) +{ + m_sceneWidth = width; + m_sceneHeight = height; + + m_depthTexture.init(device, width, height); + m_depthSmoothTexture.init(device, width, height, false); + + m_device = device; + m_deviceContext = context; + + // create the input layout + { + D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "U", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "V", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "W", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + m_device->CreateInputLayout(inputElementDescs, 4, g_ellipsoidDepthVS, sizeof(g_ellipsoidDepthVS), &m_ellipsoidDepthLayout); + } + + // create the shaders + m_device->CreateVertexShader(g_ellipsoidDepthVS, sizeof(g_ellipsoidDepthVS), nullptr, &m_ellipsoidDepthVs); + m_device->CreateGeometryShader(g_ellipsoidDepthGS, sizeof(g_ellipsoidDepthGS), nullptr, &m_ellipsoidDepthGs); + m_device->CreatePixelShader(g_ellipsoidDepthPS, sizeof(g_ellipsoidDepthPS), nullptr, &m_ellipsoidDepthPs); + + // create the input layout + { + D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } + }; + + m_device->CreateInputLayout(inputElementDescs, 4, g_passThroughVS, sizeof(g_passThroughVS), &m_passThroughLayout); + } + + // pass through shader + m_device->CreateVertexShader(g_passThroughVS, sizeof(g_passThroughVS), nullptr, &m_passThroughVs); + + // full screen pixel shaders + m_device->CreatePixelShader(g_blurDepthPS, sizeof(g_blurDepthPS), nullptr, &m_blurDepthPs); + m_device->CreatePixelShader(g_compositePS, sizeof(g_compositePS), nullptr, &m_compositePs); + + // create a constant buffer + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(Hlsl::FluidShaderConst); // 64 * sizeof(float); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); + } + + // create the rastersizer state + for (int i = 0; i < NUM_FLUID_RENDER_MODES; i++) + { + for (int j = 0; j < NUM_FLUID_CULL_MODES; j++) + { + D3D11_RASTERIZER_DESC desc = {}; + desc.FillMode = (D3D11_FILL_MODE)(D3D11_FILL_WIREFRAME + i); + desc.CullMode = (D3D11_CULL_MODE)(D3D11_CULL_NONE + j); + desc.FrontCounterClockwise = TRUE; // This is non-default + desc.DepthBias = 0; + desc.DepthBiasClamp = 0.f; + desc.SlopeScaledDepthBias = 0.f; + desc.DepthClipEnable = TRUE; + desc.ScissorEnable = FALSE; + desc.MultisampleEnable = FALSE; + desc.AntialiasedLineEnable = FALSE; + + m_device->CreateRasterizerState(&desc, &m_rasterizerState[i][j]); + } + } + + _createScreenQuad(); +} + +void FluidRendererD3D11::_createScreenQuad() +{ + // create an index buffer + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = 4*sizeof(UINT); + bufDesc.Usage = D3D11_USAGE_IMMUTABLE; + bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + bufDesc.CPUAccessFlags = DXGI_CPU_ACCESS_NONE; + bufDesc.MiscFlags = 0; + + unsigned int quad_indices[4] = { 0, 1, 3, 2 }; + + D3D11_SUBRESOURCE_DATA data = { 0 }; + data.pSysMem = quad_indices; + + m_device->CreateBuffer(&bufDesc, &data, &m_quadIndexBuffer); + } + + // create a vertex buffer + { + + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = 4*sizeof(PassthroughVertex); + bufDesc.Usage = D3D11_USAGE_IMMUTABLE; + bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufDesc.CPUAccessFlags = DXGI_CPU_ACCESS_NONE; + bufDesc.MiscFlags = 0; + + D3D11_SUBRESOURCE_DATA data = { 0 }; + + + PassthroughVertex vertices[4] = + { + { {-1.0f, -1.0f, 0.0f}, {0, 1, 0}, {0.0f, 0.0f}, {1, 1, 1, 1}}, + { { 1.0f, -1.0f, 0.0f}, {0, 1, 0}, {1.0f, 0.0f}, {1, 1, 1, 1}}, + { { 1.0f, 1.0f, 0.0f}, {0, 1, 0}, {1.0f, 1.0f}, {1, 1, 1, 1}}, + { {-1.0f, 1.0f, 0.0f}, {0, 1, 0}, {0.0f, 1.0f}, {1, 1, 1, 1}}, + }; + + data.pSysMem = vertices; + + m_device->CreateBuffer(&bufDesc, &data, &m_quadVertexBuffer); + } +} + +void FluidRendererD3D11::drawEllipsoids(const FluidDrawParamsD3D* params, const FluidRenderBuffersD3D11* buffers) +{ + ID3D11DeviceContext* deviceContext = m_deviceContext; + + // update constant buffer + { + + D3D11_BUFFER_DESC desc; + m_constantBuffer->GetDesc(&desc); + + D3D11_MAPPED_SUBRESOURCE mappedResource = {}; + if (SUCCEEDED(deviceContext->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + Hlsl::FluidShaderConst constBuf; + RenderParamsUtilD3D::calcFluidConstantBuffer(*params, constBuf); + memcpy(mappedResource.pData, &constBuf, sizeof(Hlsl::FluidShaderConst)); + deviceContext->Unmap(m_constantBuffer.Get(), 0u); + } + } + + deviceContext->VSSetShader(m_ellipsoidDepthVs.Get(), nullptr, 0u); + deviceContext->GSSetShader(m_ellipsoidDepthGs.Get(), nullptr, 0u); + deviceContext->PSSetShader(m_ellipsoidDepthPs.Get(), nullptr, 0u); + + deviceContext->IASetInputLayout(m_ellipsoidDepthLayout.Get()); + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + + deviceContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->GSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->PSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + ID3D11Buffer* vertexBuffers[4] = + { + buffers->m_positions.Get(), + buffers->m_anisotropiesArr[0].Get(), + buffers->m_anisotropiesArr[1].Get(), + buffers->m_anisotropiesArr[2].Get() + }; + + unsigned int vertexBufferStrides[4] = + { + sizeof(float4), + sizeof(float4), + sizeof(float4), + sizeof(float4) + }; + + unsigned int vertexBufferOffsets[4] = { 0 }; + + deviceContext->IASetVertexBuffers(0, 4, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); + deviceContext->IASetIndexBuffer(buffers->m_indices.Get(), DXGI_FORMAT_R32_UINT, 0u); + + float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); + if (depthSign < 0.f) + { + deviceContext->RSSetState(m_rasterizerState[params->renderMode][params->cullMode].Get()); + } + + deviceContext->DrawIndexed(params->n, params->offset, 0); + + if (depthSign < 0.f) + { + deviceContext->RSSetState(nullptr); + } +} + +void FluidRendererD3D11::drawBlurDepth(const FluidDrawParamsD3D* params) +{ + ID3D11DeviceContext* deviceContext = m_deviceContext; + + // update constant buffer + { + D3D11_MAPPED_SUBRESOURCE mappedResource = {}; + if (SUCCEEDED(deviceContext->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + Hlsl::FluidShaderConst constBuf; + RenderParamsUtilD3D::calcFluidConstantBuffer(*params, constBuf); + memcpy(mappedResource.pData, &constBuf, sizeof(Hlsl::FluidShaderConst)); + deviceContext->Unmap(m_constantBuffer.Get(), 0u); + } + } + + deviceContext->VSSetShader(m_passThroughVs.Get(), nullptr, 0u); + deviceContext->GSSetShader(nullptr, nullptr, 0u); + deviceContext->PSSetShader(m_blurDepthPs.Get(), nullptr, 0u); + + ID3D11ShaderResourceView* srvs[1] = { m_depthTexture.m_backSrv.Get() }; + deviceContext->PSSetShaderResources(0, 1, srvs); + + deviceContext->IASetInputLayout(m_passThroughLayout.Get()); + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + deviceContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->PSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + UINT vertexStride = sizeof(PassthroughVertex); + UINT offset = 0u; + deviceContext->IASetVertexBuffers(0, 1, m_quadVertexBuffer.GetAddressOf(), &vertexStride, &offset); + deviceContext->IASetIndexBuffer(m_quadIndexBuffer.Get(), DXGI_FORMAT_R32_UINT, 0u); + + float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); + if (depthSign < 0.f) + { + deviceContext->RSSetState(m_rasterizerState[params->renderMode][params->cullMode].Get()); + } + + deviceContext->DrawIndexed((UINT)4, 0, 0); + + if (depthSign < 0.f) + { + deviceContext->RSSetState(nullptr); + } +} + +void FluidRendererD3D11::drawComposite(const FluidDrawParamsD3D* params, ID3D11ShaderResourceView* sceneMap) +{ + ID3D11DeviceContext* deviceContext = m_deviceContext; + + // update constant buffer + { + D3D11_MAPPED_SUBRESOURCE mappedResource = {}; + if (SUCCEEDED(deviceContext->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + Hlsl::FluidShaderConst constBuf; + RenderParamsUtilD3D::calcFluidCompositeConstantBuffer(*params, constBuf); + memcpy(mappedResource.pData, &constBuf, sizeof(Hlsl::FluidShaderConst)); + deviceContext->Unmap(m_constantBuffer.Get(), 0u); + } + } + + deviceContext->VSSetShader(m_passThroughVs.Get(), nullptr, 0u); + deviceContext->GSSetShader(nullptr, nullptr, 0u); + deviceContext->PSSetShader(m_compositePs.Get(), nullptr, 0u); + + RenderTargetD3D11* depthMap = &m_depthSmoothTexture; + ShadowMapD3D11* shadowMap = (ShadowMapD3D11*)params->shadowMap; + + ID3D11ShaderResourceView* srvs[3] = + { + depthMap->m_backSrv.Get(), + sceneMap, + shadowMap->m_depthSrv.Get() + + }; + deviceContext->PSSetShaderResources(0, 3, srvs); + + ID3D11SamplerState* samps[2] = + { + depthMap->m_linearSampler.Get() , + shadowMap->m_linearSampler.Get() + }; + deviceContext->PSSetSamplers(0, 2, samps); + + + deviceContext->IASetInputLayout(m_passThroughLayout.Get()); + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + deviceContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->PSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + UINT vertexStride = sizeof(PassthroughVertex); + UINT offset = 0u; + deviceContext->IASetVertexBuffers(0, 1, m_quadVertexBuffer.GetAddressOf(), &vertexStride, &offset); + deviceContext->IASetIndexBuffer(m_quadIndexBuffer.Get(), DXGI_FORMAT_R32_UINT, 0u); + + float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); + if (depthSign < 0.f) + { + deviceContext->RSSetState(m_rasterizerState[params->renderMode][params->cullMode].Get()); + } + + deviceContext->DrawIndexed((UINT)4, 0, 0); + + if (depthSign < 0.f) + { + deviceContext->RSSetState(nullptr); + } + + // reset srvs + ID3D11ShaderResourceView* zero[3] = { NULL, NULL, NULL }; + deviceContext->PSSetShaderResources(0, 3, zero); +} + diff --git a/demo/d3d11/fluidRenderD3D11.h b/demo/d3d11/fluidRenderD3D11.h new file mode 100644 index 0000000..ad59534 --- /dev/null +++ b/demo/d3d11/fluidRenderD3D11.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include + +#include + +#include "renderTargetD3D11.h" +#include "shadowMapD3D11.h" +#include "../include/NvFlex.h" +#include "../d3d/renderParamsD3D.h" +#include "shaders.h" + + +struct FluidRenderBuffersD3D11 +{ + FluidRenderBuffersD3D11(): + m_positionsBuf(nullptr), + m_densitiesBuf(nullptr), + m_indicesBuf(nullptr) + { + for (int i = 0; i < 3; i++) + { + m_anisotropiesBufArr[i] = nullptr; + } + m_numParticles = 0; + } + ~FluidRenderBuffersD3D11() + { + NvFlexUnregisterD3DBuffer(m_positionsBuf); + NvFlexUnregisterD3DBuffer(m_densitiesBuf); + NvFlexUnregisterD3DBuffer(m_indicesBuf); + + for (int i = 0; i < 3; i++) + { + NvFlexUnregisterD3DBuffer(m_anisotropiesBufArr[i]); + } + } + + int m_numParticles; + ComPtr m_positions; + ComPtr m_densities; + ComPtr m_anisotropiesArr[3]; + ComPtr m_indices; + + ComPtr m_fluid; // to be removed + + // wrapper buffers that allow Flex to write directly to VBOs + NvFlexBuffer* m_positionsBuf; + NvFlexBuffer* m_densitiesBuf; + NvFlexBuffer* m_anisotropiesBufArr[3]; + NvFlexBuffer* m_indicesBuf; +}; + +struct FluidRendererD3D11 +{ + void init(ID3D11Device* device, ID3D11DeviceContext* context, int width, int height); + + void drawEllipsoids(const FluidDrawParamsD3D* params, const FluidRenderBuffersD3D11* buffers); + void drawBlurDepth(const FluidDrawParamsD3D* params); + void drawComposite(const FluidDrawParamsD3D* params, ID3D11ShaderResourceView* sceneMap); + + FluidRendererD3D11(): + m_device(nullptr), + m_deviceContext(nullptr) + {} + + void _createScreenQuad(); + + ID3D11Device* m_device; + ID3D11DeviceContext* m_deviceContext; + + ComPtr m_ellipsoidDepthLayout; + ComPtr m_ellipsoidDepthVs; + ComPtr m_ellipsoidDepthGs; + ComPtr m_ellipsoidDepthPs; + + ComPtr m_passThroughLayout; + ComPtr m_passThroughVs; + + ComPtr m_blurDepthPs; + ComPtr m_compositePs; + + ComPtr m_constantBuffer; + + // Right handed rasterizer state + ComPtr m_rasterizerState[NUM_FLUID_RENDER_MODES][NUM_FLUID_CULL_MODES]; + + ComPtr m_quadVertexBuffer; + ComPtr m_quadIndexBuffer; + + RenderTargetD3D11 m_depthTexture; + RenderTargetD3D11 m_depthSmoothTexture; + RenderTargetD3D11 m_thicknessTexture; + + int m_sceneWidth; + int m_sceneHeight; +}; + + diff --git a/demo/d3d11/imguiGraph.cpp b/demo/d3d11/imguiGraph.cpp deleted file mode 100644 index 011e71b..0000000 --- a/demo/d3d11/imguiGraph.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Copyright (c) 2008-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. - */ - -#define _USE_MATH_DEFINES -#include -#include "imgui.h" - -#include -#include - -#include "imguiGraph.h" -#include "imguiGraphD3D11.h" - -// Some math headers don't have PI defined. -static const float PI = 3.14159265f; - -void imguifree(void* ptr, void* userptr); -void* imguimalloc(size_t size, void* userptr); - -#define STBTT_malloc(x,y) imguimalloc(x,y) -#define STBTT_free(x,y) imguifree(x,y) -#define STB_TRUETYPE_IMPLEMENTATION -#include "stb_truetype.h" - -void imguifree(void* ptr, void* /*userptr*/) -{ - free(ptr); -} - -void* imguimalloc(size_t size, void* /*userptr*/) -{ - return malloc(size); -} - -static const unsigned TEMP_COORD_COUNT = 100; -static float g_tempCoords[TEMP_COORD_COUNT * 2]; -static float g_tempNormals[TEMP_COORD_COUNT * 2]; - -static const int CIRCLE_VERTS = 8 * 4; -static float g_circleVerts[CIRCLE_VERTS * 2]; - -static stbtt_bakedchar g_cdata[96]; // ASCII 32..126 is 95 glyphs - -inline unsigned int RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) -{ - return (r) | (g << 8) | (b << 16) | (a << 24); -} - -static void drawPolygon(const float* coords, unsigned numCoords, float r, unsigned int col) -{ - if (numCoords > TEMP_COORD_COUNT) numCoords = TEMP_COORD_COUNT; - - for (unsigned i = 0, j = numCoords - 1; i < numCoords; j = i++) - { - const float* v0 = &coords[j * 2]; - const float* v1 = &coords[i * 2]; - float dx = v1[0] - v0[0]; - float dy = v1[1] - v0[1]; - float d = sqrtf(dx*dx + dy*dy); - if (d > 0) - { - d = 1.0f / d; - dx *= d; - dy *= d; - } - g_tempNormals[j * 2 + 0] = dy; - g_tempNormals[j * 2 + 1] = -dx; - } - - for (unsigned i = 0, j = numCoords - 1; i < numCoords; j = i++) - { - float dlx0 = g_tempNormals[j * 2 + 0]; - float dly0 = g_tempNormals[j * 2 + 1]; - float dlx1 = g_tempNormals[i * 2 + 0]; - float dly1 = g_tempNormals[i * 2 + 1]; - float dmx = (dlx0 + dlx1) * 0.5f; - float dmy = (dly0 + dly1) * 0.5f; - float dmr2 = dmx*dmx + dmy*dmy; - if (dmr2 > 0.000001f) - { - float scale = 1.0f / dmr2; - if (scale > 10.0f) scale = 10.0f; - dmx *= scale; - dmy *= scale; - } - g_tempCoords[i * 2 + 0] = coords[i * 2 + 0] + dmx*r; - g_tempCoords[i * 2 + 1] = coords[i * 2 + 1] + dmy*r; - } - - unsigned int colTrans = RGBA(col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff, 0); - - imguiGraphColor4ubv((uint8_t*)&col); - - for (unsigned i = 0, j = numCoords - 1; i < numCoords; j = i++) - { - imguiGraphVertex2fv(&coords[i * 2]); - imguiGraphVertex2fv(&coords[j * 2]); - imguiGraphColor4ubv((uint8_t*)&colTrans); - imguiGraphVertex2fv(&g_tempCoords[j * 2]); - - imguiGraphVertex2fv(&g_tempCoords[j * 2]); - imguiGraphVertex2fv(&g_tempCoords[i * 2]); - - imguiGraphColor4ubv((uint8_t*)&col); - imguiGraphVertex2fv(&coords[i * 2]); - } - - imguiGraphColor4ubv((uint8_t*)&col); - for (unsigned i = 2; i < numCoords; ++i) - { - imguiGraphVertex2fv(&coords[0]); - imguiGraphVertex2fv(&coords[(i - 1) * 2]); - imguiGraphVertex2fv(&coords[i * 2]); - } -} - -static void drawRect(float x, float y, float w, float h, float fth, unsigned int col) -{ - float verts[4 * 2] = - { - x + 0.5f, y + 0.5f, - x + w - 0.5f, y + 0.5f, - x + w - 0.5f, y + h - 0.5f, - x + 0.5f, y + h - 0.5f, - }; - drawPolygon(verts, 4, fth, col); -} - -/* -static void drawEllipse(float x, float y, float w, float h, float fth, unsigned int col) -{ -float verts[CIRCLE_VERTS*2]; -const float* cverts = g_circleVerts; -float* v = verts; - -for (int i = 0; i < CIRCLE_VERTS; ++i) -{ -*v++ = x + cverts[i*2]*w; -*v++ = y + cverts[i*2+1]*h; -} - -drawPolygon(verts, CIRCLE_VERTS, fth, col); -} -*/ - -static void drawRoundedRect(float x, float y, float w, float h, float r, float fth, unsigned int col) -{ - const unsigned n = CIRCLE_VERTS / 4; - float verts[(n + 1) * 4 * 2]; - const float* cverts = g_circleVerts; - float* v = verts; - - for (unsigned i = 0; i <= n; ++i) - { - *v++ = x + w - r + cverts[i * 2] * r; - *v++ = y + h - r + cverts[i * 2 + 1] * r; - } - - for (unsigned i = n; i <= n * 2; ++i) - { - *v++ = x + r + cverts[i * 2] * r; - *v++ = y + h - r + cverts[i * 2 + 1] * r; - } - - for (unsigned i = n * 2; i <= n * 3; ++i) - { - *v++ = x + r + cverts[i * 2] * r; - *v++ = y + r + cverts[i * 2 + 1] * r; - } - - for (unsigned i = n * 3; i < n * 4; ++i) - { - *v++ = x + w - r + cverts[i * 2] * r; - *v++ = y + r + cverts[i * 2 + 1] * r; - } - *v++ = x + w - r + cverts[0] * r; - *v++ = y + r + cverts[1] * r; - - drawPolygon(verts, (n + 1) * 4, fth, col); -} - - -static void drawLine(float x0, float y0, float x1, float y1, float r, float fth, unsigned int col) -{ - float dx = x1 - x0; - float dy = y1 - y0; - float d = sqrtf(dx*dx + dy*dy); - if (d > 0.0001f) - { - d = 1.0f / d; - dx *= d; - dy *= d; - } - float nx = dy; - float ny = -dx; - float verts[4 * 2]; - r -= fth; - r *= 0.5f; - if (r < 0.01f) r = 0.01f; - dx *= r; - dy *= r; - nx *= r; - ny *= r; - - verts[0] = x0 - dx - nx; - verts[1] = y0 - dy - ny; - - verts[2] = x0 - dx + nx; - verts[3] = y0 - dy + ny; - - verts[4] = x1 + dx + nx; - verts[5] = y1 + dy + ny; - - verts[6] = x1 + dx - nx; - verts[7] = y1 + dy - ny; - - drawPolygon(verts, 4, fth, col); -} - - -bool imguiGraphInit(const char* fontpath, const ImguiGraphDesc* desc) -{ - imguiGraphContextInit(desc); - - for (int i = 0; i < CIRCLE_VERTS; ++i) - { - float a = (float)i / (float)CIRCLE_VERTS * PI * 2; - g_circleVerts[i * 2 + 0] = cosf(a); - g_circleVerts[i * 2 + 1] = sinf(a); - } - - // Load font. - FILE* fp = fopen(fontpath, "rb"); - if (!fp) return false; - fseek(fp, 0, SEEK_END); - int size = ftell(fp); - fseek(fp, 0, SEEK_SET); - - unsigned char* ttfBuffer = (unsigned char*)malloc(size); - if (!ttfBuffer) - { - fclose(fp); - return false; - } - - size_t len = fread(ttfBuffer, 1, size, fp); - (void)len; - - fclose(fp); - fp = 0; - - unsigned char* bmap = (unsigned char*)malloc(512 * 512); - if (!bmap) - { - free(ttfBuffer); - return false; - } - - stbtt_BakeFontBitmap(ttfBuffer, 0, 15.0f, bmap, 512, 512, 32, 96, g_cdata); - - // can free ttf_buffer at this point - imguiGraphFontTextureInit(bmap); - - free(ttfBuffer); - free(bmap); - - return true; -} - -void imguiGraphUpdate(const ImguiGraphDesc* desc) -{ - imguiGraphContextUpdate(desc); -} - -void imguiGraphDestroy() -{ - imguiGraphFontTextureRelease(); - - imguiGraphContextDestroy(); -} - -static void getBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, - float *xpos, float *ypos, stbtt_aligned_quad *q) -{ - stbtt_bakedchar *b = chardata + char_index; - int round_x = STBTT_ifloor(*xpos + b->xoff); - int round_y = STBTT_ifloor(*ypos - b->yoff); - - q->x0 = (float)round_x; - q->y0 = (float)round_y; - q->x1 = (float)round_x + b->x1 - b->x0; - q->y1 = (float)round_y - b->y1 + b->y0; - - q->s0 = b->x0 / (float)pw; - q->t0 = b->y0 / (float)pw; - q->s1 = b->x1 / (float)ph; - q->t1 = b->y1 / (float)ph; - - *xpos += b->xadvance; -} - -static const float g_tabStops[4] = { 150, 210, 270, 330 }; - -static float getTextLength(stbtt_bakedchar *chardata, const char* text) -{ - float xpos = 0; - float len = 0; - while (*text) - { - int c = (unsigned char)*text; - if (c == '\t') - { - for (int i = 0; i < 4; ++i) - { - if (xpos < g_tabStops[i]) - { - xpos = g_tabStops[i]; - break; - } - } - } - else if (c >= 32 && c < 128) - { - stbtt_bakedchar *b = chardata + c - 32; - int round_x = STBTT_ifloor((xpos + b->xoff) + 0.5); - len = round_x + b->x1 - b->x0 + 0.5f; - xpos += b->xadvance; - } - ++text; - } - return len; -} - -static void drawText(float x, float y, const char *text, int align, unsigned int col) -{ - if (!text) return; - - if (align == IMGUI_ALIGN_CENTER) - x -= getTextLength(g_cdata, text) / 2; - else if (align == IMGUI_ALIGN_RIGHT) - x -= getTextLength(g_cdata, text); - - imguiGraphColor4ub(col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff, (col >> 24) & 0xff); - - imguiGraphFontTextureEnable(); - - // assume orthographic projection with units = screen pixels, origin at top left - const float ox = x; - - while (*text) - { - int c = (unsigned char)*text; - if (c == '\t') - { - for (int i = 0; i < 4; ++i) - { - if (x < g_tabStops[i] + ox) - { - x = g_tabStops[i] + ox; - break; - } - } - } - else if (c >= 32 && c < 128) - { - stbtt_aligned_quad q; - getBakedQuad(g_cdata, 512, 512, c - 32, &x, &y, &q); - - imguiGraphTexCoord2f(q.s0, q.t0); - imguiGraphVertex2f(q.x0, q.y0); - imguiGraphTexCoord2f(q.s1, q.t1); - imguiGraphVertex2f(q.x1, q.y1); - imguiGraphTexCoord2f(q.s1, q.t0); - imguiGraphVertex2f(q.x1, q.y0); - - imguiGraphTexCoord2f(q.s0, q.t0); - imguiGraphVertex2f(q.x0, q.y0); - imguiGraphTexCoord2f(q.s0, q.t1); - imguiGraphVertex2f(q.x0, q.y1); - imguiGraphTexCoord2f(q.s1, q.t1); - imguiGraphVertex2f(q.x1, q.y1); - } - ++text; - } - - imguiGraphFontTextureDisable(); -} - - -void imguiGraphDraw() -{ - const imguiGfxCmd* q = imguiGetRenderQueue(); - int nq = imguiGetRenderQueueSize(); - - const float s = 1.0f / 8.0f; - - imguiGraphRecordBegin(); - - imguiGraphDisableScissor(); - for (int i = 0; i < nq; ++i) - { - const imguiGfxCmd& cmd = q[i]; - if (cmd.type == IMGUI_GFXCMD_RECT) - { - if (cmd.rect.r == 0) - { - drawRect((float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, - (float)cmd.rect.w*s - 1, (float)cmd.rect.h*s - 1, - 1.0f, cmd.col); - } - else - { - drawRoundedRect((float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, - (float)cmd.rect.w*s - 1, (float)cmd.rect.h*s - 1, - (float)cmd.rect.r*s, 1.0f, cmd.col); - } - } - else if (cmd.type == IMGUI_GFXCMD_LINE) - { - drawLine(cmd.line.x0*s, cmd.line.y0*s, cmd.line.x1*s, cmd.line.y1*s, cmd.line.r*s, 1.0f, cmd.col); - } - else if (cmd.type == IMGUI_GFXCMD_TRIANGLE) - { - if (cmd.flags == 1) - { - const float verts[3 * 2] = - { - (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, - (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s - 1, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s / 2 - 0.5f, - (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, - }; - drawPolygon(verts, 3, 1.0f, cmd.col); - } - if (cmd.flags == 2) - { - const float verts[3 * 2] = - { - (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, - (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s / 2 - 0.5f, (float)cmd.rect.y*s + 0.5f, - (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s - 1, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, - }; - drawPolygon(verts, 3, 1.0f, cmd.col); - } - } - else if (cmd.type == IMGUI_GFXCMD_TEXT) - { - drawText(cmd.text.x, cmd.text.y, cmd.text.text, cmd.text.align, cmd.col); - } - else if (cmd.type == IMGUI_GFXCMD_SCISSOR) - { - if (cmd.flags) - { - imguiGraphEnableScissor(cmd.rect.x, cmd.rect.y, cmd.rect.w, cmd.rect.h); - } - else - { - imguiGraphDisableScissor(); - } - } - } - imguiGraphDisableScissor(); - - imguiGraphRecordEnd(); -} - diff --git a/demo/d3d11/imguiGraph.h b/demo/d3d11/imguiGraph.h deleted file mode 100644 index e6e5eb4..0000000 --- a/demo/d3d11/imguiGraph.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include - -#define IMGUI_GRAPH_API extern "C" __declspec(dllexport) - -struct ImguiGraphDesc; - -typedef bool (*imguiGraphInit_t)(const char* fontpath, const ImguiGraphDesc* desc); - -typedef void (*imguiGraphUpdate_t)(const ImguiGraphDesc* desc); - -bool imguiGraphInit(const char* fontpath, const ImguiGraphDesc* desc); - -void imguiGraphUpdate(const ImguiGraphDesc* desc); - -void imguiGraphDestroy(); - -void imguiGraphDraw(); \ No newline at end of file diff --git a/demo/d3d11/imguiGraphD3D11.cpp b/demo/d3d11/imguiGraphD3D11.cpp index 89c8c91..2df555d 100644 --- a/demo/d3d11/imguiGraphD3D11.cpp +++ b/demo/d3d11/imguiGraphD3D11.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * 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 @@ -13,8 +13,8 @@ //direct3d headers #include -#include "shaders/imguiVS.hlsl.h" -#include "shaders/imguiPS.hlsl.h" +#include "../d3d/shaders/imguiVS.hlsl.h" +#include "../d3d/shaders/imguiPS.hlsl.h" namespace { @@ -77,7 +77,7 @@ namespace }; } -void imguiGraphContextDestroy() +void imguiGraphContextDestroyD3D11() { COMRelease(m_rasterizerState); COMRelease(m_samplerState); @@ -89,8 +89,10 @@ void imguiGraphContextDestroy() COMRelease(m_vertexBuffer); } -void imguiGraphContextInit(const ImguiGraphDesc* desc) +void imguiGraphContextInitD3D11(const ImguiGraphDesc* descIn) { + const auto desc = cast_to_imguiGraphDescD3D11(descIn); + m_device = desc->device; m_deviceContext = desc->deviceContext; m_winW = desc->winW; @@ -202,15 +204,17 @@ void imguiGraphContextInit(const ImguiGraphDesc* desc) } } -void imguiGraphContextUpdate(const ImguiGraphDesc* desc) +void imguiGraphContextUpdateD3D11(const ImguiGraphDesc* descIn) { + const auto desc = cast_to_imguiGraphDescD3D11(descIn); + m_device = desc->device; m_deviceContext = desc->deviceContext; m_winW = desc->winW; m_winH = desc->winH; } -void imguiGraphRecordBegin() +void imguiGraphRecordBeginD3D11() { Params params = { 2.f / float(m_winW), 0.f, 0.f, -1.f, @@ -319,7 +323,7 @@ static void imguiGraphFlush() } } -void imguiGraphRecordEnd() +void imguiGraphRecordEndD3D11() { ID3D11DeviceContext* context = m_deviceContext; @@ -341,7 +345,7 @@ void imguiGraphRecordEnd() context->RSSetState(nullptr); } -void imguiGraphEnableScissor(int x, int y, int width, int height) +void imguiGraphEnableScissorD3D11(int x, int y, int width, int height) { // mark end of last region m_stateScissor.stopIdx = m_stateVertIdx; @@ -356,7 +360,7 @@ void imguiGraphEnableScissor(int x, int y, int width, int height) m_stateScissor.height = height; } -void imguiGraphDisableScissor() +void imguiGraphDisableScissorD3D11() { if (m_stateVertIdx == 0) return; @@ -373,13 +377,13 @@ void imguiGraphDisableScissor() m_stateScissor.height = m_winH; } -void imguiGraphVertex2f(float x, float y) +void imguiGraphVertex2fD3D11(float x, float y) { float v[2] = { x,y }; - imguiGraphVertex2fv(v); + imguiGraphVertex2fvD3D11(v); } -void imguiGraphVertex2fv(const float* v) +void imguiGraphVertex2fvD3D11(const float* v) { // update state m_stateVert.x = v[0]; @@ -394,13 +398,13 @@ void imguiGraphVertex2fv(const float* v) } } -void imguiGraphTexCoord2f(float u, float v) +void imguiGraphTexCoord2fD3D11(float u, float v) { m_stateVert.u = u; m_stateVert.v = v; } -void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) +void imguiGraphColor4ubD3D11(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) { m_stateVert.rgba[0] = red; m_stateVert.rgba[1] = green; @@ -408,7 +412,7 @@ void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) m_stateVert.rgba[3] = alpha; } -void imguiGraphColor4ubv(const uint8_t* v) +void imguiGraphColor4ubvD3D11(const uint8_t* v) { m_stateVert.rgba[0] = v[0]; m_stateVert.rgba[1] = v[1]; @@ -416,18 +420,18 @@ void imguiGraphColor4ubv(const uint8_t* v) m_stateVert.rgba[3] = v[3]; } -void imguiGraphFontTextureEnable() +void imguiGraphFontTextureEnableD3D11() { } -void imguiGraphFontTextureDisable() +void imguiGraphFontTextureDisableD3D11() { m_stateVert.u = -1.f; m_stateVert.v = -1.f; } -void imguiGraphFontTextureInit(unsigned char* data) +void imguiGraphFontTextureInitD3D11(unsigned char* data) { ID3D11DeviceContext* context = m_deviceContext; @@ -466,7 +470,7 @@ void imguiGraphFontTextureInit(unsigned char* data) } -void imguiGraphFontTextureRelease() +void imguiGraphFontTextureReleaseD3D11() { COMRelease(m_texture); COMRelease(m_textureSRV); diff --git a/demo/d3d11/imguiGraphD3D11.h b/demo/d3d11/imguiGraphD3D11.h index be9c88b..8f521a9 100644 --- a/demo/d3d11/imguiGraphD3D11.h +++ b/demo/d3d11/imguiGraphD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * 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 @@ -13,12 +13,12 @@ #include -#include "imguiGraph.h" +#include "../d3d/imguiGraph.h" struct ID3D11Device; struct ID3D11DeviceContext; -struct ImguiGraphDesc +struct ImguiGraphDescD3D11 { ID3D11Device* device = nullptr; ID3D11DeviceContext* deviceContext = nullptr; @@ -27,41 +27,49 @@ struct ImguiGraphDesc uint32_t maxVertices = 64 * 4096u; - ImguiGraphDesc() {} + ImguiGraphDescD3D11() {} }; -// Below are the functions that must be implemented per graphics API +inline const ImguiGraphDescD3D11* cast_to_imguiGraphDescD3D11(const ImguiGraphDesc* desc) +{ + return (const ImguiGraphDescD3D11*)(desc); +} + +inline ImguiGraphDesc* cast_from_imguiGraphDescD3D11(ImguiGraphDescD3D11* desc) +{ + return (ImguiGraphDesc*)(desc); +} -void imguiGraphContextInit(const ImguiGraphDesc* desc); +IMGUI_GRAPH_API void imguiGraphContextInitD3D11(const ImguiGraphDesc* desc); -void imguiGraphContextUpdate(const ImguiGraphDesc* desc); +IMGUI_GRAPH_API void imguiGraphContextUpdateD3D11(const ImguiGraphDesc* desc); -void imguiGraphContextDestroy(); +IMGUI_GRAPH_API void imguiGraphContextDestroyD3D11(); -void imguiGraphRecordBegin(); +IMGUI_GRAPH_API void imguiGraphRecordBeginD3D11(); -void imguiGraphRecordEnd(); +IMGUI_GRAPH_API void imguiGraphRecordEndD3D11(); -void imguiGraphVertex2f(float x, float y); +IMGUI_GRAPH_API void imguiGraphVertex2fD3D11(float x, float y); -void imguiGraphVertex2fv(const float* v); +IMGUI_GRAPH_API void imguiGraphVertex2fvD3D11(const float* v); -void imguiGraphTexCoord2f(float u, float v); +IMGUI_GRAPH_API void imguiGraphTexCoord2fD3D11(float u, float v); -void imguiGraphColor4ub(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha); +IMGUI_GRAPH_API void imguiGraphColor4ubD3D11(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha); -void imguiGraphColor4ubv(const uint8_t* v); +IMGUI_GRAPH_API void imguiGraphColor4ubvD3D11(const uint8_t* v); -void imguiGraphFontTextureEnable(); +IMGUI_GRAPH_API void imguiGraphFontTextureEnableD3D11(); -void imguiGraphFontTextureDisable(); +IMGUI_GRAPH_API void imguiGraphFontTextureDisableD3D11(); -void imguiGraphEnableScissor(int x, int y, int width, int height); +IMGUI_GRAPH_API void imguiGraphEnableScissorD3D11(int x, int y, int width, int height); -void imguiGraphDisableScissor(); +IMGUI_GRAPH_API void imguiGraphDisableScissorD3D11(); -void imguiGraphFontTextureInit(unsigned char* data); +IMGUI_GRAPH_API void imguiGraphFontTextureInitD3D11(unsigned char* data); -void imguiGraphFontTextureRelease(); +IMGUI_GRAPH_API void imguiGraphFontTextureReleaseD3D11(); #endif \ No newline at end of file diff --git a/demo/d3d11/imguiInteropD3D11.cpp b/demo/d3d11/imguiInteropD3D11.cpp new file mode 100644 index 0000000..5d22d2e --- /dev/null +++ b/demo/d3d11/imguiInteropD3D11.cpp @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +//direct3d headers +#include + +#include "appD3D11Ctx.h" + +// include the Direct3D Library file +#pragma comment (lib, "d3d11.lib") + +#include "appD3D11Ctx.h" +#include "imguiGraphD3D11.h" + +IMGUI_GRAPH_API bool imguiInteropGraphInitD3D11(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx); + +IMGUI_GRAPH_API void imguiInteropGraphUpdateD3D11(imguiGraphUpdate_t func, AppGraphCtx* appctx); + +bool imguiInteropGraphInitD3D11(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctxIn) +{ + ImguiGraphDescD3D11 desc; + + AppGraphCtxD3D11* appctx = cast_to_AppGraphCtxD3D11(appctxIn); + + desc.device = appctx->m_device; + desc.deviceContext = appctx->m_deviceContext; + desc.winW = appctx->m_winW; + desc.winH = appctx->m_winH; + + return func(fontpath, cast_from_imguiGraphDescD3D11(&desc)); +} + +void imguiInteropGraphUpdateD3D11(imguiGraphUpdate_t func, AppGraphCtx* appctxIn) +{ + ImguiGraphDescD3D11 desc; + AppGraphCtxD3D11* appctx = cast_to_AppGraphCtxD3D11(appctxIn); + + desc.device = appctx->m_device; + desc.deviceContext = appctx->m_deviceContext; + desc.winW = appctx->m_winW; + desc.winH = appctx->m_winH; + + return func(cast_from_imguiGraphDescD3D11(&desc)); +} \ No newline at end of file diff --git a/demo/d3d11/meshRender.cpp b/demo/d3d11/meshRender.cpp deleted file mode 100644 index b07397b..0000000 --- a/demo/d3d11/meshRender.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -//direct3d headers - -#define NOMINMAX - -#include - -// include the Direct3D Library file -#pragma comment (lib, "d3d11.lib") - -#include - -#include "meshRender.h" -#include "appD3d11Ctx.h" - - -#include "shaders/meshVS.hlsl.h" -#include "shaders/meshPS.hlsl.h" -#include "shaders/meshShadowPS.hlsl.h" - -#define EXCLUDE_SHADER_STRUCTS 1 -#include "shaders/shaderCommon.h" - -#include "shadowMap.h" - - -void MeshRenderer::Init(ID3D11Device* device, ID3D11DeviceContext* context) -{ - for (int i = 0; i < NUM_MESH_RENDER_MODES; i++) - for (int j = 0; j < NUM_MESH_CULL_MODES; j++) - m_rasterizerStateRH[i][j] = nullptr; - - m_device = device; - m_deviceContext = context; - - // create the input layout - { - D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - m_device->CreateInputLayout(inputElementDescs, 4, g_meshVS, sizeof(g_meshVS), &m_inputLayout); - } - - // create the shaders - m_device->CreateVertexShader(g_meshVS, sizeof(g_meshVS), nullptr, &m_meshVS); - m_device->CreatePixelShader(g_meshPS, sizeof(g_meshPS), nullptr, &m_meshPS); - m_device->CreatePixelShader(g_meshPS_Shadow, sizeof(g_meshPS_Shadow), nullptr, &m_meshPS_Shadow); - - // create a constant buffer - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(MeshShaderConst); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); - } - - // create the rastersizer state - for (int i = 0; i < NUM_MESH_RENDER_MODES; i++) - { - for (int j = 0; j < NUM_MESH_CULL_MODES; j++) - - { - D3D11_RASTERIZER_DESC desc = {}; - desc.FillMode = (D3D11_FILL_MODE)(D3D11_FILL_WIREFRAME + i); - desc.CullMode = (D3D11_CULL_MODE)(D3D11_CULL_NONE + j); - desc.FrontCounterClockwise = TRUE; // This is non-default - desc.DepthBias = 0; - desc.DepthBiasClamp = 0.f; - desc.SlopeScaledDepthBias = 0.f; - desc.DepthClipEnable = TRUE; - desc.ScissorEnable = FALSE; - desc.MultisampleEnable = FALSE; - desc.AntialiasedLineEnable = FALSE; - - m_device->CreateRasterizerState(&desc, &m_rasterizerStateRH[i][j]); - } - } - -} - -void MeshRenderer::Destroy() -{ - COMRelease(m_inputLayout); - COMRelease(m_meshVS); - COMRelease(m_meshPS); - COMRelease(m_meshPS_Shadow); - COMRelease(m_constantBuffer); - - for (int i = 0; i < NUM_MESH_RENDER_MODES; i++) - for (int j = 0; j < NUM_MESH_CULL_MODES; j++) - COMRelease(m_rasterizerStateRH[i][j]); -} - - -void MeshRenderer::Draw(const GpuMesh* mesh, const MeshDrawParams* params) -{ - using namespace DirectX; - - // update constant buffer - { - D3D11_MAPPED_SUBRESOURCE mappedResource = {}; - if (S_OK == m_deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - MeshShaderConst cParams; - - cParams.modelviewprojection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params->model, params->view), params->projection)); - - cParams.modelview = (float4x4&)XMMatrixMultiply(params->model, params->view); - - cParams.objectTransform = (float4x4&)params->objectTransform; - cParams.lightTransform = (float4x4&)params->lightTransform; - - cParams.clipPlane = params->clipPlane; - cParams.fogColor = params->fogColor; - cParams.color = params->color; - cParams.secondaryColor = params->secondaryColor; - - cParams.lightPos = params->lightPos; - cParams.lightDir = params->lightDir; - - cParams.bias = params->bias; - cParams.expand = params->expand; - cParams.spotMin = params->spotMin; - cParams.spotMax = params->spotMax; - - cParams.grid = params->grid; - cParams.tex = params->tex; - cParams.colorArray = params->colorArray; - - memcpy(cParams.shadowTaps, params->shadowTaps, sizeof(cParams.shadowTaps)); - - memcpy(mappedResource.pData, &cParams, sizeof(MeshShaderConst)); - - m_deviceContext->Unmap(m_constantBuffer, 0u); - } - } - - m_deviceContext->VSSetShader(m_meshVS, nullptr, 0u); - m_deviceContext->GSSetShader(nullptr, nullptr, 0u); - - switch (params->renderStage) - { - case MESH_DRAW_SHADOW: - { - m_deviceContext->PSSetShader(m_meshPS_Shadow, nullptr, 0u); - break; - } - case MESH_DRAW_LIGHT: - { - m_deviceContext->PSSetShader(m_meshPS, nullptr, 0u); - - ShadowMap* shadowMap = (ShadowMap*)params->shadowMap; - ID3D11ShaderResourceView* ppSRV[1] = { shadowMap->m_depthSrv.Get() }; - m_deviceContext->PSSetShaderResources(0, 1, ppSRV); - ID3D11SamplerState* ppSS[1] = { shadowMap->m_linearSampler.Get() }; - m_deviceContext->PSSetSamplers(0, 1, ppSS); - break; - } - default: - assert(false); - break; - } - - m_deviceContext->IASetInputLayout(m_inputLayout); - m_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - m_deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); - m_deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); - - ID3D11Buffer* vertexBuffers[4] = - { - mesh->positionBuffer, - mesh->normalBuffer, - mesh->texcoordBuffer, - mesh->colorBuffer, - }; - - unsigned int vertexBufferStrides[4] = - { - sizeof(Vec3), - sizeof(Vec3), - sizeof(Vec2), - sizeof(Vec4) - }; - - unsigned int vertexBufferOffsets[4] = { 0, 0, 0, 0 }; - - m_deviceContext->IASetVertexBuffers(0, 4, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); - m_deviceContext->IASetIndexBuffer(mesh->indexBuffer, DXGI_FORMAT_R32_UINT, 0u); - - float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); - if (depthSign < 0.f) - { - m_deviceContext->RSSetState(m_rasterizerStateRH[params->renderMode][params->cullMode]); - } - - m_deviceContext->DrawIndexed((UINT)mesh->mNumFaces*3, 0, 0); - - if (depthSign < 0.f) - { - m_deviceContext->RSSetState(nullptr); - } -} diff --git a/demo/d3d11/meshRender.h b/demo/d3d11/meshRender.h deleted file mode 100644 index 01ad181..0000000 --- a/demo/d3d11/meshRender.h +++ /dev/null @@ -1,297 +0,0 @@ - -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include - -#include "appD3D11Ctx.h" - -#include "core/maths.h" - -struct ShadowMap; - -struct GpuMesh -{ - ID3D11Buffer* positionBuffer; - ID3D11Buffer* normalBuffer; - ID3D11Buffer* texcoordBuffer; - ID3D11Buffer* colorBuffer; - - ID3D11Buffer* indexBuffer; - - GpuMesh(ID3D11Device* device, ID3D11DeviceContext* deviceContext) - : positionBuffer(NULL) - , normalBuffer(NULL) - , texcoordBuffer(NULL) - , colorBuffer(NULL) - , indexBuffer(NULL) - , mDevice(device) - , mDeviceContext(deviceContext) - , mNumFaces(0) - , mNumVertices(0) - {} - - ~GpuMesh() - { - Release(); - } - - void Release() - { - COMRelease(positionBuffer); - COMRelease(normalBuffer); - COMRelease(texcoordBuffer); - COMRelease(colorBuffer); - COMRelease(indexBuffer); - } - - void Resize(int numVertices, int numFaces) - { - Release(); - - { - // vertex buffers - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(Vec3)*numVertices; - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - mDevice->CreateBuffer(&bufDesc, NULL, &positionBuffer); - mDevice->CreateBuffer(&bufDesc, NULL, &normalBuffer); - - bufDesc.ByteWidth = sizeof(Vec2)*numVertices; - mDevice->CreateBuffer(&bufDesc, NULL, &texcoordBuffer); - - bufDesc.ByteWidth = sizeof(Vec4)*numVertices; - mDevice->CreateBuffer(&bufDesc, NULL, &colorBuffer); - } - - { - // index buffer - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(int)*numFaces*3; - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - mDevice->CreateBuffer(&bufDesc, NULL, &indexBuffer); - } - - mMaxVertices = numVertices; - mMaxFaces = numFaces; - } - - void UpdateData(const Vec3* positions, const Vec3* normals, const Vec2* texcoords, const Vec4* colors, const int* indices, int numVertices, int numFaces) - { - if (numVertices > mMaxVertices || numFaces > mMaxFaces) - { - Resize(numVertices, numFaces); - } - - D3D11_MAPPED_SUBRESOURCE res; - - // vertices - if (positions) - { - mDeviceContext->Map(positionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, positions, sizeof(Vec3)*numVertices); - mDeviceContext->Unmap(positionBuffer, 0); - } - - if (normals) - { - mDeviceContext->Map(normalBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, normals, sizeof(Vec3)*numVertices); - mDeviceContext->Unmap(normalBuffer, 0); - } - - if (texcoords) - { - mDeviceContext->Map(texcoordBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, texcoords, sizeof(Vec2)*numVertices); - mDeviceContext->Unmap(texcoordBuffer, 0); - } - - if (colors) - { - mDeviceContext->Map(colorBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, colors, sizeof(Vec4)*numVertices); - mDeviceContext->Unmap(colorBuffer, 0); - } - - // indices - if (indices) - { - mDeviceContext->Map(indexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, indices, sizeof(int)*numFaces*3); - mDeviceContext->Unmap(indexBuffer, 0); - } - - mNumVertices = numVertices; - mNumFaces = numFaces; - } - - // duplicate method to handle conversion from vec4 to vec3 positions / normals - void UpdateData(const Vec4* positions, const Vec4* normals, const Vec2* texcoords, const Vec4* colors, const int* indices, int numVertices, int numFaces) - { - if (numVertices > mMaxVertices || numFaces > mMaxFaces) - { - Resize(numVertices, numFaces); - } - - D3D11_MAPPED_SUBRESOURCE res; - - // vertices - if (positions) - { - mDeviceContext->Map(positionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - for (int i=0; i < numVertices; ++i) - ((Vec3*)res.pData)[i] = Vec3(positions[i]); - mDeviceContext->Unmap(positionBuffer, 0); - } - - if (normals) - { - mDeviceContext->Map(normalBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - for (int i=0; i < numVertices; ++i) - ((Vec3*)res.pData)[i] = Vec3(normals[i]); - mDeviceContext->Unmap(normalBuffer, 0); - } - - if (texcoords) - { - mDeviceContext->Map(texcoordBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, texcoords, sizeof(Vec2)*numVertices); - mDeviceContext->Unmap(texcoordBuffer, 0); - } - - if (colors) - { - mDeviceContext->Map(colorBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, colors, sizeof(Vec4)*numVertices); - mDeviceContext->Unmap(colorBuffer, 0); - } - - // indices - if (indices) - { - mDeviceContext->Map(indexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, indices, sizeof(int)*numFaces*3); - mDeviceContext->Unmap(indexBuffer, 0); - } - - mNumVertices = numVertices; - mNumFaces = numFaces; - } - - int mNumVertices = 0; - int mNumFaces = 0; - - int mMaxVertices = 0; - int mMaxFaces = 0; - - ID3D11Device* mDevice; - ID3D11DeviceContext* mDeviceContext; -}; - - - -enum MeshRenderMode -{ - MESH_RENDER_WIREFRAME, - MESH_RENDER_SOLID, - NUM_MESH_RENDER_MODES -}; - -enum MeshCullMode -{ - MESH_CULL_NONE, - MESH_CULL_FRONT, - MESH_CULL_BACK, - NUM_MESH_CULL_MODES -}; - -enum MeshDrawStage -{ - MESH_DRAW_NULL, - MESH_DRAW_SHADOW, - MESH_DRAW_REFLECTION, - MESH_DRAW_LIGHT -}; - -typedef DirectX::XMFLOAT3 float3; -typedef DirectX::XMFLOAT4 float4; -typedef DirectX::XMFLOAT4X4 float4x4; - -struct MeshDrawParams -{ - MeshRenderMode renderMode; - MeshCullMode cullMode; - MeshDrawStage renderStage; - - DirectX::XMMATRIX projection; - DirectX::XMMATRIX view; - DirectX::XMMATRIX model; - - float4x4 objectTransform; - - DirectX::XMMATRIX lightTransform; - float3 lightPos; - float3 lightDir; - - float4 clipPlane; - float4 fogColor; - float4 color; - float4 secondaryColor; - - float bias; - float expand; - float spotMin; - float spotMax; - - int grid; - int tex; - int colorArray; - - float4 shadowTaps[12]; - ShadowMap* shadowMap; -}; - -struct MeshRenderer -{ - ID3D11Device* m_device = nullptr; - ID3D11DeviceContext* m_deviceContext = nullptr; - - ID3D11InputLayout* m_inputLayout = nullptr; - ID3D11VertexShader* m_meshVS = nullptr; - ID3D11PixelShader* m_meshPS = nullptr; - ID3D11PixelShader* m_meshPS_Shadow = nullptr; - ID3D11Buffer* m_constantBuffer = nullptr; - ID3D11RasterizerState* m_rasterizerStateRH[NUM_MESH_RENDER_MODES][NUM_MESH_CULL_MODES]; - - ~MeshRenderer() - { - Destroy(); - } - - void Init(ID3D11Device* device, ID3D11DeviceContext* context); - void Destroy(); - - void Draw(const GpuMesh* mesh, const MeshDrawParams* params); - -}; - - - diff --git a/demo/d3d11/meshRenderD3D11.cpp b/demo/d3d11/meshRenderD3D11.cpp new file mode 100644 index 0000000..8936f04 --- /dev/null +++ b/demo/d3d11/meshRenderD3D11.cpp @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +//direct3d headers + +#define NOMINMAX + +#include + +// include the Direct3D Library file +#pragma comment (lib, "d3d11.lib") + +#include + +#include "meshRenderD3D11.h" +#include "appD3d11Ctx.h" + + +#include "../d3d/shaders/meshVS.hlsl.h" +#include "../d3d/shaders/meshPS.hlsl.h" +#include "../d3d/shaders/meshShadowPS.hlsl.h" + +#include "../d3d/shaderCommonD3D.h" + +#include "shadowMapD3D11.h" + +// Make async compute benchmark shader have a unique name +namespace AsyncComputeBench +{ +#include "../d3d/shaders/meshAsyncComputeBenchPS.hlsl.h" +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GpuMeshD3D11 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +GpuMeshD3D11::GpuMeshD3D11(ID3D11Device* device, ID3D11DeviceContext* deviceContext) + : m_device(device) + , m_deviceContext(deviceContext) + , m_numFaces(0) + , m_numVertices(0) + , m_maxVertices(0) + , m_maxFaces(0) +{ +} + +void GpuMeshD3D11::resize(int numVertices, int numFaces) +{ + { + // vertex buffers + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(Vec3)*numVertices; + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, NULL, m_positionBuffer.ReleaseAndGetAddressOf()); + m_device->CreateBuffer(&bufDesc, NULL, m_normalBuffer.ReleaseAndGetAddressOf()); + + bufDesc.ByteWidth = sizeof(Vec2)*numVertices; + m_device->CreateBuffer(&bufDesc, NULL, m_texcoordBuffer.ReleaseAndGetAddressOf()); + + bufDesc.ByteWidth = sizeof(Vec4)*numVertices; + m_device->CreateBuffer(&bufDesc, NULL, m_colorBuffer.ReleaseAndGetAddressOf()); + } + + { + // index buffer + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(int)*numFaces * 3; + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, NULL, &m_indexBuffer); + } + + m_maxVertices = numVertices; + m_maxFaces = numFaces; +} + +void GpuMeshD3D11::updateData(const Vec3* positions, const Vec3* normals, const Vec2* texcoords, const Vec4* colors, const int* indices, int numVertices, int numFaces) +{ + if (numVertices > m_maxVertices || numFaces > m_maxFaces) + { + resize(numVertices, numFaces); + } + + D3D11_MAPPED_SUBRESOURCE res; + + // vertices + if (positions) + { + m_deviceContext->Map(m_positionBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, positions, sizeof(Vec3)*numVertices); + m_deviceContext->Unmap(m_positionBuffer.Get(), 0); + } + + if (normals) + { + m_deviceContext->Map(m_normalBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, normals, sizeof(Vec3)*numVertices); + m_deviceContext->Unmap(m_normalBuffer.Get(), 0); + } + + if (texcoords) + { + m_deviceContext->Map(m_texcoordBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, texcoords, sizeof(Vec2)*numVertices); + m_deviceContext->Unmap(m_texcoordBuffer.Get(), 0); + } + + if (colors) + { + m_deviceContext->Map(m_colorBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, colors, sizeof(Vec4)*numVertices); + m_deviceContext->Unmap(m_colorBuffer.Get(), 0); + } + + // indices + if (indices) + { + m_deviceContext->Map(m_indexBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, indices, sizeof(int)*numFaces * 3); + m_deviceContext->Unmap(m_indexBuffer.Get(), 0); + } + + m_numVertices = numVertices; + m_numFaces = numFaces; +} + +void GpuMeshD3D11::updateData(const Vec4* positions, const Vec4* normals, const Vec2* texcoords, const Vec4* colors, const int* indices, int numVertices, int numFaces) +{ + if (numVertices > m_maxVertices || numFaces > m_maxFaces) + { + resize(numVertices, numFaces); + } + + D3D11_MAPPED_SUBRESOURCE res; + + // vertices + if (positions) + { + m_deviceContext->Map(m_positionBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + for (int i = 0; i < numVertices; ++i) + ((Vec3*)res.pData)[i] = Vec3(positions[i]); + m_deviceContext->Unmap(m_positionBuffer.Get(), 0); + } + + if (normals) + { + m_deviceContext->Map(m_normalBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + for (int i = 0; i < numVertices; ++i) + ((Vec3*)res.pData)[i] = Vec3(normals[i]); + m_deviceContext->Unmap(m_normalBuffer.Get(), 0); + } + + if (texcoords) + { + m_deviceContext->Map(m_texcoordBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, texcoords, sizeof(Vec2)*numVertices); + m_deviceContext->Unmap(m_texcoordBuffer.Get(), 0); + } + + if (colors) + { + m_deviceContext->Map(m_colorBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, colors, sizeof(Vec4)*numVertices); + m_deviceContext->Unmap(m_colorBuffer.Get(), 0); + } + + // indices + if (indices) + { + m_deviceContext->Map(m_indexBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &res); + memcpy(res.pData, indices, sizeof(int)*numFaces * 3); + m_deviceContext->Unmap(m_indexBuffer.Get(), 0); + } + + m_numVertices = numVertices; + m_numFaces = numFaces; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! MeshRendererD3D11 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void MeshRendererD3D11::init(ID3D11Device* device, ID3D11DeviceContext* context, bool asyncComputeBenchmark) +{ + m_device = device; + m_deviceContext = context; + + // create the input layout + { + D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + m_device->CreateInputLayout(inputElementDescs, 4, g_meshVS, sizeof(g_meshVS), &m_inputLayout); + } + + // create the shaders + + if (asyncComputeBenchmark) + { + m_device->CreatePixelShader(AsyncComputeBench::g_meshPS, sizeof(AsyncComputeBench::g_meshPS), nullptr, &m_meshPs); + } + else + { + m_device->CreatePixelShader(g_meshPS, sizeof(g_meshPS), nullptr, &m_meshPs); + } + + m_device->CreateVertexShader(g_meshVS, sizeof(g_meshVS), nullptr, &m_meshVs); + m_device->CreatePixelShader(g_meshPS_Shadow, sizeof(g_meshPS_Shadow), nullptr, &m_meshShadowPs); + + // create a constant buffer + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(Hlsl::MeshShaderConst); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); + } + + // create the rastersizer state + for (int i = 0; i < NUM_MESH_RENDER_MODES; i++) + { + for (int j = 0; j < NUM_MESH_CULL_MODES; j++) + + { + D3D11_RASTERIZER_DESC desc = {}; + desc.FillMode = (D3D11_FILL_MODE)(D3D11_FILL_WIREFRAME + i); + desc.CullMode = (D3D11_CULL_MODE)(D3D11_CULL_NONE + j); + desc.FrontCounterClockwise = TRUE; // This is non-default + desc.DepthBias = 0; + desc.DepthBiasClamp = 0.f; + desc.SlopeScaledDepthBias = 0.f; + desc.DepthClipEnable = TRUE; + desc.ScissorEnable = FALSE; + desc.MultisampleEnable = FALSE; + desc.AntialiasedLineEnable = FALSE; + + m_device->CreateRasterizerState(&desc, &m_rasterizerState[i][j]); + } + } +} + +void MeshRendererD3D11::draw(const GpuMeshD3D11* mesh, const MeshDrawParamsD3D* params) +{ + using namespace DirectX; + + // update constant buffer + { + D3D11_MAPPED_SUBRESOURCE mappedResource = {}; + if (SUCCEEDED(m_deviceContext->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + Hlsl::MeshShaderConst constBuf; + RenderParamsUtilD3D::calcMeshConstantBuffer(*params, constBuf); + memcpy(mappedResource.pData, &constBuf, sizeof(Hlsl::MeshShaderConst)); + m_deviceContext->Unmap(m_constantBuffer.Get(), 0u); + } + } + + m_deviceContext->VSSetShader(m_meshVs.Get(), nullptr, 0u); + m_deviceContext->GSSetShader(nullptr, nullptr, 0u); + + switch (params->renderStage) + { + case MESH_DRAW_SHADOW: + { + m_deviceContext->PSSetShader(m_meshShadowPs.Get(), nullptr, 0u); + break; + } + case MESH_DRAW_LIGHT: + { + m_deviceContext->PSSetShader(m_meshPs.Get(), nullptr, 0u); + + ShadowMapD3D11* shadowMap = (ShadowMapD3D11*)params->shadowMap; + ID3D11ShaderResourceView* srvs[1] = { shadowMap->m_depthSrv.Get() }; + m_deviceContext->PSSetShaderResources(0, 1, srvs); + ID3D11SamplerState* sampStates[1] = { shadowMap->m_linearSampler.Get() }; + m_deviceContext->PSSetSamplers(0, 1, sampStates); + break; + } + default: + assert(false); + break; + } + + m_deviceContext->IASetInputLayout(m_inputLayout.Get()); + m_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + + m_deviceContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + m_deviceContext->PSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + ID3D11Buffer* vertexBuffers[4] = + { + mesh->m_positionBuffer.Get(), + mesh->m_normalBuffer.Get(), + mesh->m_texcoordBuffer.Get(), + mesh->m_colorBuffer.Get(), + }; + + unsigned int vertexBufferStrides[4] = + { + sizeof(Vec3), + sizeof(Vec3), + sizeof(Vec2), + sizeof(Vec4) + }; + + unsigned int vertexBufferOffsets[4] = { 0, 0, 0, 0 }; + + m_deviceContext->IASetVertexBuffers(0, 4, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); + m_deviceContext->IASetIndexBuffer(mesh->m_indexBuffer.Get(), DXGI_FORMAT_R32_UINT, 0u); + + float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); + if (depthSign < 0.f) + { + m_deviceContext->RSSetState(m_rasterizerState[params->renderMode][params->cullMode].Get()); + } + + m_deviceContext->DrawIndexed((UINT)mesh->m_numFaces*3, 0, 0); + + if (depthSign < 0.f) + { + m_deviceContext->RSSetState(nullptr); + } +} diff --git a/demo/d3d11/meshRenderD3D11.h b/demo/d3d11/meshRenderD3D11.h new file mode 100644 index 0000000..d7d6d1c --- /dev/null +++ b/demo/d3d11/meshRenderD3D11.h @@ -0,0 +1,74 @@ + +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include + +#include "appD3D11Ctx.h" + +#include "core/maths.h" +#include "../d3d/renderParamsD3D.h" + +#include +using namespace Microsoft::WRL; + +struct GpuMeshD3D11 +{ + GpuMeshD3D11(ID3D11Device* device, ID3D11DeviceContext* deviceContext) ; + + void resize(int numVertices, int numFaces); + + void updateData(const Vec3* positions, const Vec3* normals, const Vec2* texcoords, const Vec4* colors, const int* indices, int numVertices, int numFaces); + // duplicate method to handle conversion from vec4 to vec3 positions / normals + void updateData(const Vec4* positions, const Vec4* normals, const Vec2* texcoords, const Vec4* colors, const int* indices, int numVertices, int numFaces); + + ComPtr m_positionBuffer; + ComPtr m_normalBuffer; + ComPtr m_texcoordBuffer; + ComPtr m_colorBuffer; + + ComPtr m_indexBuffer; + + int m_numVertices; + int m_numFaces; + + int m_maxVertices; + int m_maxFaces; + + ID3D11Device* m_device; + ID3D11DeviceContext* m_deviceContext; +}; + + +struct MeshRendererD3D11 +{ + void init(ID3D11Device* device, ID3D11DeviceContext* context, bool asyncComputeBenchmark); + void draw(const GpuMeshD3D11* mesh, const MeshDrawParamsD3D* params); + + MeshRendererD3D11(): + m_device(nullptr), + m_deviceContext(nullptr) + {} + + ID3D11Device* m_device; + ID3D11DeviceContext* m_deviceContext; + + ComPtr m_inputLayout; + ComPtr m_meshVs; + ComPtr m_meshPs; + ComPtr m_meshShadowPs; + ComPtr m_constantBuffer; + ComPtr m_rasterizerState[NUM_MESH_RENDER_MODES][NUM_MESH_CULL_MODES]; +}; + + + diff --git a/demo/d3d11/pointRender.cpp b/demo/d3d11/pointRender.cpp deleted file mode 100644 index 1d3a8b0..0000000 --- a/demo/d3d11/pointRender.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -//direct3d headers - -#define NOMINMAX - -#include - -// include the Direct3D Library file -#pragma comment (lib, "d3d11.lib") - -#include - -#include "appD3D11Ctx.h" - -#include "pointRender.h" - -#include "shaders/pointVS.hlsl.h" -#include "shaders/pointGS.hlsl.h" -#include "shaders/pointPS.hlsl.h" - -#define EXCLUDE_SHADER_STRUCTS 1 -#include "shaders/shaderCommon.h" - - -void PointRenderer::Init(ID3D11Device* device, ID3D11DeviceContext* context) -{ - m_device = device; - m_deviceContext = context; - - // create the input layout - { - D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "DENSITY", 0, DXGI_FORMAT_R32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "PHASE", 0, DXGI_FORMAT_R32_SINT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - m_device->CreateInputLayout(inputElementDescs, 3, g_pointVS, sizeof(g_pointVS), &m_inputLayout); - } - - // create the shaders - m_device->CreateVertexShader(g_pointVS, sizeof(g_pointVS), nullptr, &m_pointVS); - m_device->CreateGeometryShader(g_pointGS, sizeof(g_pointGS), nullptr, &m_pointGS); - m_device->CreatePixelShader(g_pointPS, sizeof(g_pointPS), nullptr, &m_pointPS); - - // create a constant buffer - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = sizeof(PointShaderConst); // 64 * sizeof(float); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - - m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); - } - - // create the rastersizer state - for (int i = 0; i < NUM_POINT_RENDER_MODES; i++) - { - for (int j = 0; j < NUM_POINT_CULL_MODES; j++) - - { - D3D11_RASTERIZER_DESC desc = {}; - desc.FillMode = (D3D11_FILL_MODE)(D3D11_FILL_WIREFRAME + i); - desc.CullMode = (D3D11_CULL_MODE)(D3D11_CULL_NONE + j); - desc.FrontCounterClockwise = TRUE; // This is non-default - desc.DepthBias = 0; - desc.DepthBiasClamp = 0.f; - desc.SlopeScaledDepthBias = 0.f; - desc.DepthClipEnable = TRUE; - desc.ScissorEnable = FALSE; - desc.MultisampleEnable = FALSE; - desc.AntialiasedLineEnable = FALSE; - - m_device->CreateRasterizerState(&desc, &m_rasterizerStateRH[i][j]); - } - } -} - -void PointRenderer::Destroy() -{ - COMRelease(m_inputLayout); - COMRelease(m_pointVS); - COMRelease(m_pointGS); - COMRelease(m_pointPS); - COMRelease(m_constantBuffer); - - for (int i = 0; i < NUM_POINT_RENDER_MODES; i++) - for (int j = 0; j < NUM_POINT_CULL_MODES; j++) - COMRelease(m_rasterizerStateRH[i][j]); -} - - - -void PointRenderer::Draw(const PointDrawParams* params, ID3D11Buffer* positions, ID3D11Buffer* colors, ID3D11Buffer* indices, int numParticles, int offset) -{ - using namespace DirectX; - - ID3D11DeviceContext* deviceContext = m_deviceContext; - - // update constant buffer - { - D3D11_MAPPED_SUBRESOURCE mappedResource = {}; - if (S_OK == deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) - { - PointShaderConst cParams; - - cParams.modelview = (float4x4&)XMMatrixMultiply(params->model, params->view); - cParams.projection = (float4x4&)params->projection; - - cParams.pointRadius = params->pointRadius; - cParams.pointScale = params->pointScale; - cParams.spotMin = params->spotMin; - cParams.spotMax = params->spotMax; - - cParams.lightTransform = (float4x4&)params->lightTransform; - cParams.lightPos = params->lightPos; - cParams.lightDir = params->lightDir; - - for (int i = 0; i < 8; i++) - cParams.colors[i] = params->colors[i]; - - memcpy(cParams.shadowTaps, params->shadowTaps, sizeof(cParams.shadowTaps)); - - cParams.mode = params->mode; - - memcpy(mappedResource.pData, &cParams, sizeof(PointShaderConst)); - - deviceContext->Unmap(m_constantBuffer, 0u); - } - } - - deviceContext->VSSetShader(m_pointVS, nullptr, 0u); - deviceContext->GSSetShader(m_pointGS, nullptr, 0u); - deviceContext->PSSetShader(m_pointPS, nullptr, 0u); - - if (params->shadowMap) - { - ShadowMap* shadowMap = (ShadowMap*)params->shadowMap; - if (params->renderStage == POINT_DRAW_SHADOW) - { - ID3D11ShaderResourceView* ppSRV[1] = { nullptr }; - deviceContext->PSSetShaderResources(0, 1, ppSRV); - ID3D11SamplerState* ppSS[1] = { shadowMap->m_linearSampler.Get() }; - deviceContext->PSSetSamplers(0, 1, ppSS); - } - else - { - ID3D11ShaderResourceView* ppSRV[1] = { shadowMap->m_depthSrv.Get() }; - deviceContext->PSSetShaderResources(0, 1, ppSRV); - ID3D11SamplerState* ppSS[1] = { shadowMap->m_linearSampler.Get() }; - deviceContext->PSSetSamplers(0, 1, ppSS); - } - } - - deviceContext->IASetInputLayout(m_inputLayout); - deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - - deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->GSSetConstantBuffers(0, 1, &m_constantBuffer); - deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); - - ID3D11Buffer* vertexBuffers[3] = - { - positions, - colors, // will be interpreted as density - colors, // will be interpreted as phase - }; - - unsigned int vertexBufferStrides[3] = - { - sizeof(float4), - sizeof(float), - sizeof(int) - }; - - unsigned int vertexBufferOffsets[3] = { 0 }; - - deviceContext->IASetVertexBuffers(0, 3, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); - deviceContext->IASetIndexBuffer(indices, DXGI_FORMAT_R32_UINT, 0u); - - - float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); - if (depthSign < 0.f) - { - deviceContext->RSSetState(m_rasterizerStateRH[params->renderMode][params->cullMode]); - } - - deviceContext->DrawIndexed(numParticles, offset, 0); - - if (depthSign < 0.f) - { - deviceContext->RSSetState(nullptr); - } -} diff --git a/demo/d3d11/pointRender.h b/demo/d3d11/pointRender.h deleted file mode 100644 index 9631287..0000000 --- a/demo/d3d11/pointRender.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include - -#include "shadowMap.h" - -enum PointRenderMode -{ - POINT_RENDER_WIREFRAME, - POINT_RENDER_SOLID, - NUM_POINT_RENDER_MODES -}; - -enum PointCullMode -{ - POINT_CULL_NONE, - POINT_CULL_FRONT, - POINT_CULL_BACK, - NUM_POINT_CULL_MODES -}; - -enum PointDrawStage -{ - POINT_DRAW_NULL, - POINT_DRAW_SHADOW, - POINT_DRAW_REFLECTION, - POINT_DRAW_LIGHT -}; - -typedef DirectX::XMFLOAT3 float3; -typedef DirectX::XMFLOAT4 float4; -typedef DirectX::XMFLOAT4X4 float4x4; - -struct PointDrawParams -{ - PointRenderMode renderMode; - PointCullMode cullMode; - PointDrawStage renderStage; - - DirectX::XMMATRIX projection; - DirectX::XMMATRIX view; - DirectX::XMMATRIX model; - - float pointRadius; // point size in world space - float pointScale; // scale to calculate size in pixels - float spotMin; - float spotMax; - - DirectX::XMMATRIX lightTransform; - float3 lightPos; - float3 lightDir; - - float4 colors[8]; - - float4 shadowTaps[12]; - ShadowMap* shadowMap; - - int mode; -}; - - -struct PointRenderer -{ - ID3D11Device* m_device = nullptr; - ID3D11DeviceContext* m_deviceContext = nullptr; - - ID3D11InputLayout* m_inputLayout = nullptr; - ID3D11VertexShader* m_pointVS = nullptr; - ID3D11GeometryShader* m_pointGS = nullptr; - ID3D11PixelShader* m_pointPS = nullptr; - ID3D11Buffer* m_constantBuffer = nullptr; - ID3D11RasterizerState* m_rasterizerStateRH[NUM_POINT_RENDER_MODES][NUM_POINT_CULL_MODES]; - - void Init(ID3D11Device* device, ID3D11DeviceContext* deviceContext); - void Destroy(); - - void Draw(const PointDrawParams* params, ID3D11Buffer* positions, ID3D11Buffer* colors, ID3D11Buffer* indices, int numParticles, int offset); -}; diff --git a/demo/d3d11/pointRenderD3D11.cpp b/demo/d3d11/pointRenderD3D11.cpp new file mode 100644 index 0000000..20dde46 --- /dev/null +++ b/demo/d3d11/pointRenderD3D11.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +//direct3d headers + +#define NOMINMAX + +#include + +// include the Direct3D Library file +#pragma comment (lib, "d3d11.lib") + +#include + +#include "appD3D11Ctx.h" + +#include "shadowMapD3D11.h" + +#include "pointRenderD3D11.h" + +#include "../d3d/shaders/pointVS.hlsl.h" +#include "../d3d/shaders/pointGS.hlsl.h" +#include "../d3d/shaders/pointPS.hlsl.h" +#include "../d3d/shaders/pointShadowPS.hlsl.h" + +#include "../d3d/shaderCommonD3D.h" + +void PointRendererD3D11::init(ID3D11Device* device, ID3D11DeviceContext* context) +{ + m_device = device; + m_deviceContext = context; + + // create the input layout + { + D3D11_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "DENSITY", 0, DXGI_FORMAT_R32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "PHASE", 0, DXGI_FORMAT_R32_SINT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + m_device->CreateInputLayout(inputElementDescs, 3, g_pointVS, sizeof(g_pointVS), &m_inputLayout); + } + + // create the shaders + m_device->CreateVertexShader(g_pointVS, sizeof(g_pointVS), nullptr, &m_pointVs); + m_device->CreateGeometryShader(g_pointGS, sizeof(g_pointGS), nullptr, &m_pointGs); + m_device->CreatePixelShader(g_pointPS, sizeof(g_pointPS), nullptr, &m_pointPs); + m_device->CreatePixelShader(g_pointShadowPS, sizeof(g_pointShadowPS), nullptr, &m_pointShadowPs); + + // create a constant buffer + { + D3D11_BUFFER_DESC bufDesc; + bufDesc.ByteWidth = sizeof(Hlsl::PointShaderConst); // 64 * sizeof(float); + bufDesc.Usage = D3D11_USAGE_DYNAMIC; + bufDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufDesc.MiscFlags = 0; + + m_device->CreateBuffer(&bufDesc, nullptr, &m_constantBuffer); + } + + // create the rasterizer state + for (int i = 0; i < NUM_POINT_RENDER_MODES; i++) + { + for (int j = 0; j < NUM_POINT_CULL_MODES; j++) + + { + D3D11_RASTERIZER_DESC desc = {}; + desc.FillMode = (D3D11_FILL_MODE)(D3D11_FILL_WIREFRAME + i); + desc.CullMode = (D3D11_CULL_MODE)(D3D11_CULL_NONE + j); + desc.FrontCounterClockwise = TRUE; // This is non-default + desc.DepthBias = 0; + desc.DepthBiasClamp = 0.f; + desc.SlopeScaledDepthBias = 0.f; + desc.DepthClipEnable = TRUE; + desc.ScissorEnable = FALSE; + desc.MultisampleEnable = FALSE; + desc.AntialiasedLineEnable = FALSE; + + m_device->CreateRasterizerState(&desc, &m_rasterizerState[i][j]); + } + } +} + +void PointRendererD3D11::draw(const PointDrawParamsD3D* params, ID3D11Buffer* positions, ID3D11Buffer* colors, ID3D11Buffer* indices, int numParticles, int offset) +{ + using namespace DirectX; + + ID3D11DeviceContext* deviceContext = m_deviceContext; + + // update constant buffer + { + D3D11_MAPPED_SUBRESOURCE mappedResource = {}; + if (SUCCEEDED(deviceContext->Map(m_constantBuffer.Get(), 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))) + { + Hlsl::PointShaderConst constBuf; + RenderParamsUtilD3D::calcPointConstantBuffer(*params, constBuf); + memcpy(mappedResource.pData, &constBuf, sizeof(Hlsl::PointShaderConst)); + deviceContext->Unmap(m_constantBuffer.Get(), 0u); + } + } + + deviceContext->VSSetShader(m_pointVs.Get(), nullptr, 0u); + deviceContext->GSSetShader(m_pointGs.Get(), nullptr, 0u); + deviceContext->PSSetShader(m_pointPs.Get(), nullptr, 0u); + + if (params->shadowMap) + { + ShadowMapD3D11* shadowMap = (ShadowMapD3D11*)params->shadowMap; + if (params->renderStage == POINT_DRAW_SHADOW) + { + ID3D11ShaderResourceView* srvs[1] = { nullptr }; + deviceContext->PSSetShaderResources(0, 1, srvs); + ID3D11SamplerState* samps[1] = { shadowMap->m_linearSampler.Get() }; + deviceContext->PSSetSamplers(0, 1, samps); + deviceContext->PSSetShader(m_pointShadowPs.Get(), nullptr, 0u); + } + else + { + ID3D11ShaderResourceView* srvs[1] = { shadowMap->m_depthSrv.Get() }; + deviceContext->PSSetShaderResources(0, 1, srvs); + ID3D11SamplerState* samps[1] = { shadowMap->m_linearSampler.Get() }; + deviceContext->PSSetSamplers(0, 1, samps); + } + } + + deviceContext->IASetInputLayout(m_inputLayout.Get()); + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + + deviceContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->GSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + deviceContext->PSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); + + ID3D11Buffer* vertexBuffers[3] = + { + positions, + colors, // will be interpreted as density + colors, // will be interpreted as phase + }; + + unsigned int vertexBufferStrides[3] = + { + sizeof(float4), + sizeof(float), + sizeof(int) + }; + + unsigned int vertexBufferOffsets[3] = { 0 }; + + deviceContext->IASetVertexBuffers(0, 3, vertexBuffers, vertexBufferStrides, vertexBufferOffsets); + deviceContext->IASetIndexBuffer(indices, DXGI_FORMAT_R32_UINT, 0u); + + float depthSign = DirectX::XMVectorGetW(params->projection.r[2]); + if (depthSign < 0.f) + { + deviceContext->RSSetState(m_rasterizerState[params->renderMode][params->cullMode].Get()); + } + + deviceContext->DrawIndexed(numParticles, offset, 0); + + if (depthSign < 0.f) + { + deviceContext->RSSetState(nullptr); + } +} diff --git a/demo/d3d11/pointRenderD3D11.h b/demo/d3d11/pointRenderD3D11.h new file mode 100644 index 0000000..71a6247 --- /dev/null +++ b/demo/d3d11/pointRenderD3D11.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include "../d3d/renderParamsD3D.h" + +#include +#include +using namespace Microsoft::WRL; + + +struct PointRendererD3D11 +{ + void init(ID3D11Device* device, ID3D11DeviceContext* deviceContext); + + void draw(const PointDrawParamsD3D* params, ID3D11Buffer* positions, ID3D11Buffer* colors, ID3D11Buffer* indices, int numParticles, int offset); + + PointRendererD3D11(): + m_device(nullptr), + m_deviceContext(nullptr) + {} + + ID3D11Device* m_device; + ID3D11DeviceContext* m_deviceContext; + + ComPtr m_inputLayout; + ComPtr m_pointVs; + ComPtr m_pointGs; + ComPtr m_pointPs; + ComPtr m_pointShadowPs; + ComPtr m_constantBuffer; + + // Assumes right handed + ComPtr m_rasterizerState[NUM_POINT_RENDER_MODES][NUM_POINT_CULL_MODES]; +}; diff --git a/demo/d3d11/renderTarget.cpp b/demo/d3d11/renderTarget.cpp deleted file mode 100644 index da71e4f..0000000 --- a/demo/d3d11/renderTarget.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2008-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 "renderTarget.h" - -RenderTarget::RenderTarget() -{ -} - -static D3D11_TEXTURE2D_DESC _getTextureDesc(DXGI_FORMAT format, UINT width, UINT height, - UINT bindFlags, UINT sampleCount = 1, D3D11_USAGE usage = D3D11_USAGE_DEFAULT, UINT cpuAccessFlags = 0, - UINT miscFlags = 0, UINT arraySize = 1, UINT mipLevels = 1) -{ - D3D11_TEXTURE2D_DESC desc; - desc.Format = format; - desc.Width = width; - desc.Height = height; - - desc.ArraySize = arraySize; - desc.MiscFlags = miscFlags; - desc.MipLevels = mipLevels; - - desc.SampleDesc.Count = sampleCount; - desc.SampleDesc.Quality = 0; - desc.BindFlags = bindFlags; - desc.Usage = usage; - desc.CPUAccessFlags = cpuAccessFlags; - return desc; -} - -static D3D11_DEPTH_STENCIL_VIEW_DESC _getDsvDesc(DXGI_FORMAT format, D3D11_DSV_DIMENSION viewDimension, UINT flags = 0, UINT mipSlice = 0) -{ - D3D11_DEPTH_STENCIL_VIEW_DESC desc; - desc.Format = format; - desc.ViewDimension = viewDimension; - desc.Flags = flags; - desc.Texture2D.MipSlice = mipSlice; - return desc; -} - -static D3D11_SHADER_RESOURCE_VIEW_DESC _getSrvDesc(DXGI_FORMAT format) -{ - D3D11_SHADER_RESOURCE_VIEW_DESC desc; - desc.Format = format; - desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - desc.Texture2D.MostDetailedMip = 0; - desc.Texture2D.MipLevels = -1; - - return desc; -} - -HRESULT RenderTarget::Init(ID3D11Device* device, int width, int height, bool depthTest) -{ - // set viewport - { - m_viewport.Width = float(width); - m_viewport.Height = float(height); - m_viewport.MinDepth = 0; - m_viewport.MaxDepth = 1; - m_viewport.TopLeftX = 0; - m_viewport.TopLeftY = 0; - } - - // create shadow render target - { - D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_FLOAT, UINT(width), UINT(height), - D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); - - NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_backTexture.ReleaseAndGetAddressOf())); - NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_backTexture.Get(), NV_NULL, m_backSrv.ReleaseAndGetAddressOf())); - NV_RETURN_ON_FAIL(device->CreateRenderTargetView(m_backTexture.Get(), NV_NULL, m_backRtv.ReleaseAndGetAddressOf())); - } - - // create shadow depth stencil - { - D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_TYPELESS, UINT(width), UINT(height), - D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE); - NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_depthTexture.ReleaseAndGetAddressOf())); - - D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = _getDsvDesc(DXGI_FORMAT_D32_FLOAT, D3D11_DSV_DIMENSION_TEXTURE2D); - NV_RETURN_ON_FAIL(device->CreateDepthStencilView(m_depthTexture.Get(), &dsvDesc, m_depthDsv.ReleaseAndGetAddressOf())); - - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = _getSrvDesc(DXGI_FORMAT_R32_FLOAT); - NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_depthTexture.Get(), &srvDesc, m_depthSrv.ReleaseAndGetAddressOf())); - } - - { - D3D11_SAMPLER_DESC samplerDesc = - { - D3D11_FILTER_MIN_MAG_MIP_LINEAR, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - 0.0, 0, D3D11_COMPARISON_NEVER, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, D3D11_FLOAT32_MAX, - }; - NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_linearSampler.ReleaseAndGetAddressOf())); - } - { - D3D11_SAMPLER_DESC samplerDesc = - { - D3D11_FILTER_MIN_MAG_MIP_POINT, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - 0.0, 0, D3D11_COMPARISON_NEVER, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, D3D11_FLOAT32_MAX, - }; - NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_pointSampler.ReleaseAndGetAddressOf())); - } - - { - D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; - depthStateDesc.DepthEnable = depthTest; - depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; - depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; - - NV_RETURN_ON_FAIL(device->CreateDepthStencilState(&depthStateDesc, m_depthStencilState.ReleaseAndGetAddressOf())); - } - - return S_OK; -} - -void RenderTarget::BindAndClear(ID3D11DeviceContext* context) -{ - ID3D11RenderTargetView* ppRtv[1] = { m_backRtv.Get() }; - context->OMSetRenderTargets(1, ppRtv, m_depthDsv.Get()); - context->OMSetDepthStencilState(m_depthStencilState.Get(), 0u); - - context->RSSetViewports(1, &m_viewport); - - float clearDepth = 0.0f; - float clearColor[4] = { clearDepth, clearDepth, clearDepth, clearDepth }; - - context->ClearRenderTargetView(m_backRtv.Get(), clearColor); - context->ClearDepthStencilView(m_depthDsv.Get(), D3D11_CLEAR_DEPTH, 1.0, 0); -} diff --git a/demo/d3d11/renderTarget.h b/demo/d3d11/renderTarget.h deleted file mode 100644 index ae5ff40..0000000 --- a/demo/d3d11/renderTarget.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include -#include -#include - -using namespace DirectX; -using namespace Microsoft::WRL; - -#define NV_NULL nullptr -#define NV_RETURN_ON_FAIL(x) { HRESULT _res = (x); if (FAILED(_res)) { return _res; } } - -struct RenderTarget -{ -public: - - RenderTarget(); - - HRESULT Init(ID3D11Device* device, int width, int height, bool depthTest = true); - - void BindAndClear(ID3D11DeviceContext* context); - - XMMATRIX m_lightView; - XMMATRIX m_lightProjection; - XMMATRIX m_lightWorldToTex; - - ComPtr m_backTexture; - ComPtr m_backRtv; - ComPtr m_backSrv; - - ComPtr m_depthTexture; - ComPtr m_depthDsv; - ComPtr m_depthSrv; - - ComPtr m_linearSampler; - ComPtr m_pointSampler; - - ComPtr m_depthStencilState; - - D3D11_VIEWPORT m_viewport; -}; diff --git a/demo/d3d11/renderTargetD3D11.cpp b/demo/d3d11/renderTargetD3D11.cpp new file mode 100644 index 0000000..4035039 --- /dev/null +++ b/demo/d3d11/renderTargetD3D11.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2008-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 "renderTargetD3D11.h" + +RenderTargetD3D11::RenderTargetD3D11() +{ +} + +static D3D11_TEXTURE2D_DESC _getTextureDesc(DXGI_FORMAT format, UINT width, UINT height, + UINT bindFlags, UINT sampleCount = 1, D3D11_USAGE usage = D3D11_USAGE_DEFAULT, UINT cpuAccessFlags = 0, + UINT miscFlags = 0, UINT arraySize = 1, UINT mipLevels = 1) +{ + D3D11_TEXTURE2D_DESC desc; + desc.Format = format; + desc.Width = width; + desc.Height = height; + + desc.ArraySize = arraySize; + desc.MiscFlags = miscFlags; + desc.MipLevels = mipLevels; + + desc.SampleDesc.Count = sampleCount; + desc.SampleDesc.Quality = 0; + desc.BindFlags = bindFlags; + desc.Usage = usage; + desc.CPUAccessFlags = cpuAccessFlags; + return desc; +} + +static D3D11_DEPTH_STENCIL_VIEW_DESC _getDsvDesc(DXGI_FORMAT format, D3D11_DSV_DIMENSION viewDimension, UINT flags = 0, UINT mipSlice = 0) +{ + D3D11_DEPTH_STENCIL_VIEW_DESC desc; + desc.Format = format; + desc.ViewDimension = viewDimension; + desc.Flags = flags; + desc.Texture2D.MipSlice = mipSlice; + return desc; +} + +static D3D11_SHADER_RESOURCE_VIEW_DESC _getSrvDesc(DXGI_FORMAT format) +{ + D3D11_SHADER_RESOURCE_VIEW_DESC desc; + desc.Format = format; + desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + desc.Texture2D.MostDetailedMip = 0; + desc.Texture2D.MipLevels = -1; + + return desc; +} + +HRESULT RenderTargetD3D11::init(ID3D11Device* device, int width, int height, bool depthTest) +{ + // set viewport + { + m_viewport.Width = float(width); + m_viewport.Height = float(height); + m_viewport.MinDepth = 0; + m_viewport.MaxDepth = 1; + m_viewport.TopLeftX = 0; + m_viewport.TopLeftY = 0; + } + + // create shadow render target + { + D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_FLOAT, UINT(width), UINT(height), + D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); + + NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_backTexture.ReleaseAndGetAddressOf())); + NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_backTexture.Get(), NV_NULL, m_backSrv.ReleaseAndGetAddressOf())); + NV_RETURN_ON_FAIL(device->CreateRenderTargetView(m_backTexture.Get(), NV_NULL, m_backRtv.ReleaseAndGetAddressOf())); + } + + // create shadow depth stencil + { + D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_TYPELESS, UINT(width), UINT(height), + D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE); + NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_depthTexture.ReleaseAndGetAddressOf())); + + D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = _getDsvDesc(DXGI_FORMAT_D32_FLOAT, D3D11_DSV_DIMENSION_TEXTURE2D); + NV_RETURN_ON_FAIL(device->CreateDepthStencilView(m_depthTexture.Get(), &dsvDesc, m_depthDsv.ReleaseAndGetAddressOf())); + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = _getSrvDesc(DXGI_FORMAT_R32_FLOAT); + NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_depthTexture.Get(), &srvDesc, m_depthSrv.ReleaseAndGetAddressOf())); + } + + { + D3D11_SAMPLER_DESC samplerDesc = + { + D3D11_FILTER_MIN_MAG_MIP_LINEAR, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + 0.0, 0, D3D11_COMPARISON_NEVER, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, D3D11_FLOAT32_MAX, + }; + NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_linearSampler.ReleaseAndGetAddressOf())); + } + { + D3D11_SAMPLER_DESC samplerDesc = + { + D3D11_FILTER_MIN_MAG_MIP_POINT, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + 0.0, 0, D3D11_COMPARISON_NEVER, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, D3D11_FLOAT32_MAX, + }; + NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_pointSampler.ReleaseAndGetAddressOf())); + } + + { + D3D11_DEPTH_STENCIL_DESC depthStateDesc = {}; + depthStateDesc.DepthEnable = depthTest; + depthStateDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + depthStateDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + + NV_RETURN_ON_FAIL(device->CreateDepthStencilState(&depthStateDesc, m_depthStencilState.ReleaseAndGetAddressOf())); + } + + return S_OK; +} + +void RenderTargetD3D11::bindAndClear(ID3D11DeviceContext* context) +{ + ID3D11RenderTargetView* ppRtv[1] = { m_backRtv.Get() }; + context->OMSetRenderTargets(1, ppRtv, m_depthDsv.Get()); + context->OMSetDepthStencilState(m_depthStencilState.Get(), 0u); + + context->RSSetViewports(1, &m_viewport); + + float clearDepth = 0.0f; + float clearColor[4] = { clearDepth, clearDepth, clearDepth, clearDepth }; + + context->ClearRenderTargetView(m_backRtv.Get(), clearColor); + context->ClearDepthStencilView(m_depthDsv.Get(), D3D11_CLEAR_DEPTH, 1.0, 0); +} diff --git a/demo/d3d11/renderTargetD3D11.h b/demo/d3d11/renderTargetD3D11.h new file mode 100644 index 0000000..b299bec --- /dev/null +++ b/demo/d3d11/renderTargetD3D11.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include +#include +#include + +using namespace DirectX; +using namespace Microsoft::WRL; + +#define NV_NULL nullptr +#define NV_RETURN_ON_FAIL(x) { HRESULT _res = (x); if (FAILED(_res)) { return _res; } } + +struct RenderTargetD3D11 +{ +public: + + RenderTargetD3D11(); + + HRESULT init(ID3D11Device* device, int width, int height, bool depthTest = true); + + void bindAndClear(ID3D11DeviceContext* context); + + XMMATRIX m_lightView; + XMMATRIX m_lightProjection; + XMMATRIX m_lightWorldToTex; + + ComPtr m_backTexture; + ComPtr m_backRtv; + ComPtr m_backSrv; + + ComPtr m_depthTexture; + ComPtr m_depthDsv; + ComPtr m_depthSrv; + + ComPtr m_linearSampler; + ComPtr m_pointSampler; + + ComPtr m_depthStencilState; + + D3D11_VIEWPORT m_viewport; +}; diff --git a/demo/d3d11/shaders/blurDepthPS.hlsl b/demo/d3d11/shaders/blurDepthPS.hlsl deleted file mode 100644 index a2eee0a..0000000 --- a/demo/d3d11/shaders/blurDepthPS.hlsl +++ /dev/null @@ -1,91 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - FluidShaderConst gParams; -}; - -Texture2D depthTex : register(t0); - -float sqr(float x) { return x*x; } - -float4 blurDepthPS(PassthroughVertexOut input) : SV_TARGET -{ - float4 gl_FragColor = float4(0.0, 0.0, 0.0, 0.0); - float4 gl_FragCoord = input.position; - - // debug: return the center depth sample - //float d = depthTex.Load(int3(gl_FragCoord.xy, 0)).x; - //return d; - - const float blurRadiusWorld = gParams.blurRadiusWorld; - const float blurScale = gParams.blurScale; - const float blurFalloff = gParams.blurFalloff; - - // eye-space depth of center sample - float depth = depthTex.Load(int3(gl_FragCoord.xy, 0)).x; - float thickness = 0.0f; //texture2D(thicknessTex, gl_TexCoord[0].xy).x; - - /* - // threshold on thickness to create nice smooth silhouettes - if (depth == 0.0) - { - gl_FragColor.x = 0.0; - return gl_FragColor; - } - */ - - float blurDepthFalloff = 5.5; - float maxBlurRadius = 5.0; - - //discontinuities between different tap counts are visible. to avoid this we - //use fractional contributions between #taps = ceil(radius) and floor(radius) - float radius = min(maxBlurRadius, blurScale * (blurRadiusWorld / -depth)); - float radiusInv = 1.0 / radius; - float taps = ceil(radius); - float frac = taps - radius; - - float sum = 0.0; - float wsum = 0.0; - float count = 0.0; - - for (float y = -taps; y <= taps; y += 1.0) - { - for (float x = -taps; x <= taps; x += 1.0) - { - float2 offset = float2(x, y); - - //float sample = texture2DRect(depthTex, gl_FragCoord.xy + offset).x; - float sample = depthTex.Load(int3(gl_FragCoord.xy + offset, 0)).x; - - //if (sample < -10000.0 * 0.5) - //continue; - - // spatial domain - float r1 = length(float2(x, y))*radiusInv; - float w = exp(-(r1*r1)); - - // range domain (based on depth difference) - float r2 = (sample - depth) * blurDepthFalloff; - float g = exp(-(r2*r2)); - - //fractional radius contributions - float wBoundary = step(radius, max(abs(x), abs(y))); - float wFrac = 1.0 - wBoundary*frac; - - sum += sample * w * g * wFrac; - wsum += w * g * wFrac; - count += g * wFrac; - } - } - - if (wsum > 0.0) - { - sum /= wsum; - } - - float blend = count / sqr(2.0 * radius + 1.0); - gl_FragColor.x = lerp(depth, sum, blend); - - return gl_FragColor; -} diff --git a/demo/d3d11/shaders/blurDepthPS.hlsl.h b/demo/d3d11/shaders/blurDepthPS.hlsl.h deleted file mode 100644 index ff191f8..0000000 --- a/demo/d3d11/shaders/blurDepthPS.hlsl.h +++ /dev/null @@ -1,664 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct FluidShaderConst -// { -// -// float4x4 modelviewprojection; // Offset: 0 -// float4x4 modelview; // Offset: 64 -// float4x4 projection; // Offset: 128 -// float4x4 modelview_inverse; // Offset: 192 -// float4x4 projection_inverse; // Offset: 256 -// float4 invTexScale; // Offset: 320 -// float3 invViewport; // Offset: 336 -// float _pad0; // Offset: 348 -// float blurRadiusWorld; // Offset: 352 -// float blurScale; // Offset: 356 -// float blurFalloff; // Offset: 360 -// int debug; // Offset: 364 -// float3 lightPos; // Offset: 368 -// float _pad1; // Offset: 380 -// float3 lightDir; // Offset: 384 -// float _pad2; // Offset: 396 -// float4x4 lightTransform; // Offset: 400 -// float4 color; // Offset: 464 -// float4 clipPosToEye; // Offset: 480 -// float spotMin; // Offset: 496 -// float spotMax; // Offset: 500 -// float ior; // Offset: 504 -// float _pad3; // Offset: 508 -// float4 shadowTaps[12]; // Offset: 512 -// -// } gParams; // Offset: 0 Size: 704 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// depthTex texture float 2d 0 1 -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xy -// TEXCOORD 0 xy 1 NONE float -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[23], immediateIndexed -dcl_resource_texture2d (float,float,float,float) t0 -dcl_input_ps_siv linear noperspective v0.xy, position -dcl_output o0.xyzw -dcl_temps 5 -ftoi r0.xy, v0.xyxx -mov r0.zw, l(0,0,0,0) -ld_indexable(texture2d)(float,float,float,float) r0.x, r0.xyzw, t0.xyzw -div r0.y, cb0[22].x, -r0.x -mul r0.y, r0.y, cb0[22].y -min r0.y, r0.y, l(5.000000) -div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y -round_pi r0.w, r0.y -add r1.x, -r0.y, r0.w -mov r2.zw, l(0,0,0,0) -mov r1.yzw, l(0,0,0,0) -mov r3.y, -r0.w -loop - lt r3.z, r0.w, r3.y - breakc_nz r3.z - mov r4.xyz, r1.yzwy - mov r4.w, -r0.w - loop - lt r3.z, r0.w, r4.w - breakc_nz r3.z - mov r3.x, r4.w - add r3.zw, r3.xxxy, v0.xxxy - ftoi r2.xy, r3.zwzz - ld_indexable(texture2d)(float,float,float,float) r2.x, r2.xyzw, t0.xyzw - dp2 r2.y, r3.xyxx, r3.xyxx - sqrt r2.y, r2.y - mul r2.y, r0.z, r2.y - mul r2.y, r2.y, r2.y - mul r2.y, r2.y, l(-1.442695) - exp r2.y, r2.y - add r3.x, -r0.x, r2.x - mul r3.x, r3.x, l(5.500000) - mul r3.x, r3.x, r3.x - mul r3.x, r3.x, l(-1.442695) - exp r3.x, r3.x - max r3.z, |r3.y|, |r4.w| - ge r3.z, r3.z, r0.y - and r3.z, r3.z, l(0x3f800000) - mad r3.z, -r3.z, r1.x, l(1.000000) - mul r2.x, r2.y, r2.x - mul r2.x, r3.x, r2.x - mad r4.x, r2.x, r3.z, r4.x - mul r2.x, r2.y, r3.x - mad r4.y, r2.x, r3.z, r4.y - mad r4.z, r3.x, r3.z, r4.z - add r4.w, r4.w, l(1.000000) - endloop - mov r1.yzw, r4.xxyz - add r3.y, r3.y, l(1.000000) -endloop -lt r0.z, l(0.000000), r1.z -div r0.w, r1.y, r1.z -movc r0.z, r0.z, r0.w, r1.y -mad r0.y, r0.y, l(2.000000), l(1.000000) -mul r0.y, r0.y, r0.y -div r0.y, r1.w, r0.y -add r0.z, -r0.x, r0.z -mad o0.x, r0.y, r0.z, r0.x -mov o0.yzw, l(0,0,0,0) -ret -// Approximately 60 instruction slots used -#endif - -const BYTE g_blurDepthPS[] = -{ - 68, 88, 66, 67, 244, 233, - 190, 43, 161, 207, 241, 98, - 173, 248, 128, 15, 40, 190, - 66, 70, 1, 0, 0, 0, - 76, 12, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 156, 4, 0, 0, 244, 4, - 0, 0, 40, 5, 0, 0, - 176, 11, 0, 0, 82, 68, - 69, 70, 96, 4, 0, 0, - 1, 0, 0, 0, 144, 0, - 0, 0, 2, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 44, 4, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 124, 0, 0, 0, 2, 0, - 0, 0, 5, 0, 0, 0, - 4, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 133, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 100, 101, - 112, 116, 104, 84, 101, 120, - 0, 99, 111, 110, 115, 116, - 66, 117, 102, 0, 171, 171, - 133, 0, 0, 0, 1, 0, - 0, 0, 168, 0, 0, 0, - 192, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 208, 0, 0, 0, 0, 0, - 0, 0, 192, 2, 0, 0, - 2, 0, 0, 0, 8, 4, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 103, 80, - 97, 114, 97, 109, 115, 0, - 70, 108, 117, 105, 100, 83, - 104, 97, 100, 101, 114, 67, - 111, 110, 115, 116, 0, 109, - 111, 100, 101, 108, 118, 105, - 101, 119, 112, 114, 111, 106, - 101, 99, 116, 105, 111, 110, - 0, 102, 108, 111, 97, 116, - 52, 120, 52, 0, 171, 171, - 3, 0, 3, 0, 4, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 253, 0, 0, 0, - 109, 111, 100, 101, 108, 118, - 105, 101, 119, 0, 112, 114, - 111, 106, 101, 99, 116, 105, - 111, 110, 0, 109, 111, 100, - 101, 108, 118, 105, 101, 119, - 95, 105, 110, 118, 101, 114, - 115, 101, 0, 112, 114, 111, - 106, 101, 99, 116, 105, 111, - 110, 95, 105, 110, 118, 101, - 114, 115, 101, 0, 105, 110, - 118, 84, 101, 120, 83, 99, - 97, 108, 101, 0, 102, 108, - 111, 97, 116, 52, 0, 171, - 171, 171, 1, 0, 3, 0, - 1, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 114, 1, - 0, 0, 105, 110, 118, 86, - 105, 101, 119, 112, 111, 114, - 116, 0, 102, 108, 111, 97, - 116, 51, 0, 171, 1, 0, - 3, 0, 1, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 172, 1, 0, 0, 95, 112, - 97, 100, 48, 0, 102, 108, - 111, 97, 116, 0, 0, 0, - 3, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 222, 1, 0, 0, 98, 108, - 117, 114, 82, 97, 100, 105, - 117, 115, 87, 111, 114, 108, - 100, 0, 98, 108, 117, 114, - 83, 99, 97, 108, 101, 0, - 98, 108, 117, 114, 70, 97, - 108, 108, 111, 102, 102, 0, - 100, 101, 98, 117, 103, 0, - 105, 110, 116, 0, 0, 0, - 2, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 52, 2, 0, 0, 108, 105, - 103, 104, 116, 80, 111, 115, - 0, 95, 112, 97, 100, 49, - 0, 108, 105, 103, 104, 116, - 68, 105, 114, 0, 95, 112, - 97, 100, 50, 0, 108, 105, - 103, 104, 116, 84, 114, 97, - 110, 115, 102, 111, 114, 109, - 0, 99, 111, 108, 111, 114, - 0, 99, 108, 105, 112, 80, - 111, 115, 84, 111, 69, 121, - 101, 0, 115, 112, 111, 116, - 77, 105, 110, 0, 115, 112, - 111, 116, 77, 97, 120, 0, - 105, 111, 114, 0, 95, 112, - 97, 100, 51, 0, 115, 104, - 97, 100, 111, 119, 84, 97, - 112, 115, 0, 171, 171, 171, - 1, 0, 3, 0, 1, 0, - 4, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 114, 1, 0, 0, - 233, 0, 0, 0, 8, 1, - 0, 0, 0, 0, 0, 0, - 44, 1, 0, 0, 8, 1, - 0, 0, 64, 0, 0, 0, - 54, 1, 0, 0, 8, 1, - 0, 0, 128, 0, 0, 0, - 65, 1, 0, 0, 8, 1, - 0, 0, 192, 0, 0, 0, - 83, 1, 0, 0, 8, 1, - 0, 0, 0, 1, 0, 0, - 102, 1, 0, 0, 124, 1, - 0, 0, 64, 1, 0, 0, - 160, 1, 0, 0, 180, 1, - 0, 0, 80, 1, 0, 0, - 216, 1, 0, 0, 228, 1, - 0, 0, 92, 1, 0, 0, - 8, 2, 0, 0, 228, 1, - 0, 0, 96, 1, 0, 0, - 24, 2, 0, 0, 228, 1, - 0, 0, 100, 1, 0, 0, - 34, 2, 0, 0, 228, 1, - 0, 0, 104, 1, 0, 0, - 46, 2, 0, 0, 56, 2, - 0, 0, 108, 1, 0, 0, - 92, 2, 0, 0, 180, 1, - 0, 0, 112, 1, 0, 0, - 101, 2, 0, 0, 228, 1, - 0, 0, 124, 1, 0, 0, - 107, 2, 0, 0, 180, 1, - 0, 0, 128, 1, 0, 0, - 116, 2, 0, 0, 228, 1, - 0, 0, 140, 1, 0, 0, - 122, 2, 0, 0, 8, 1, - 0, 0, 144, 1, 0, 0, - 137, 2, 0, 0, 124, 1, - 0, 0, 208, 1, 0, 0, - 143, 2, 0, 0, 124, 1, - 0, 0, 224, 1, 0, 0, - 156, 2, 0, 0, 228, 1, - 0, 0, 240, 1, 0, 0, - 164, 2, 0, 0, 228, 1, - 0, 0, 244, 1, 0, 0, - 172, 2, 0, 0, 228, 1, - 0, 0, 248, 1, 0, 0, - 176, 2, 0, 0, 228, 1, - 0, 0, 252, 1, 0, 0, - 182, 2, 0, 0, 196, 2, - 0, 0, 0, 2, 0, 0, - 5, 0, 0, 0, 1, 0, - 176, 0, 0, 0, 24, 0, - 232, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 216, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 80, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 3, - 0, 0, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 171, - 171, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 128, 6, - 0, 0, 80, 0, 0, 0, - 160, 1, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 23, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 100, 32, - 0, 4, 50, 16, 16, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 104, 0, 0, 2, - 5, 0, 0, 0, 27, 0, - 0, 5, 50, 0, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 8, 194, 0, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 45, 0, 0, 137, - 194, 0, 0, 128, 67, 85, - 21, 0, 18, 0, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 70, 126, 16, 0, 0, 0, - 0, 0, 14, 0, 0, 9, - 34, 0, 16, 0, 0, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 22, 0, - 0, 0, 10, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 8, - 34, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 26, 128, - 32, 0, 0, 0, 0, 0, - 22, 0, 0, 0, 51, 0, - 0, 7, 34, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 160, 64, 14, 0, 0, 10, - 66, 0, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 128, 63, 26, 0, - 16, 0, 0, 0, 0, 0, - 66, 0, 0, 5, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 18, 0, 16, 0, 1, 0, - 0, 0, 26, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 8, 194, 0, 16, 0, - 2, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 54, 0, 0, 8, 226, 0, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 34, 0, 16, 0, 3, 0, - 0, 0, 58, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 48, 0, 0, 1, - 49, 0, 0, 7, 66, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 3, 0, 0, 0, 3, 0, - 4, 3, 42, 0, 16, 0, - 3, 0, 0, 0, 54, 0, - 0, 5, 114, 0, 16, 0, - 4, 0, 0, 0, 150, 7, - 16, 0, 1, 0, 0, 0, - 54, 0, 0, 6, 130, 0, - 16, 0, 4, 0, 0, 0, - 58, 0, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 48, 0, 0, 1, 49, 0, - 0, 7, 66, 0, 16, 0, - 3, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 4, 0, - 0, 0, 3, 0, 4, 3, - 42, 0, 16, 0, 3, 0, - 0, 0, 54, 0, 0, 5, - 18, 0, 16, 0, 3, 0, - 0, 0, 58, 0, 16, 0, - 4, 0, 0, 0, 0, 0, - 0, 7, 194, 0, 16, 0, - 3, 0, 0, 0, 6, 4, - 16, 0, 3, 0, 0, 0, - 6, 20, 16, 0, 0, 0, - 0, 0, 27, 0, 0, 5, - 50, 0, 16, 0, 2, 0, - 0, 0, 230, 10, 16, 0, - 3, 0, 0, 0, 45, 0, - 0, 137, 194, 0, 0, 128, - 67, 85, 21, 0, 18, 0, - 16, 0, 2, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 15, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 70, 0, - 16, 0, 3, 0, 0, 0, - 70, 0, 16, 0, 3, 0, - 0, 0, 75, 0, 0, 5, - 34, 0, 16, 0, 2, 0, - 0, 0, 26, 0, 16, 0, - 2, 0, 0, 0, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 2, 0, - 0, 0, 56, 0, 0, 7, - 34, 0, 16, 0, 2, 0, - 0, 0, 26, 0, 16, 0, - 2, 0, 0, 0, 26, 0, - 16, 0, 2, 0, 0, 0, - 56, 0, 0, 7, 34, 0, - 16, 0, 2, 0, 0, 0, - 26, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 59, 170, 184, 191, 25, 0, - 0, 5, 34, 0, 16, 0, - 2, 0, 0, 0, 26, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 8, 18, 0, - 16, 0, 3, 0, 0, 0, - 10, 0, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 56, 0, 0, 7, - 18, 0, 16, 0, 3, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 176, 64, - 56, 0, 0, 7, 18, 0, - 16, 0, 3, 0, 0, 0, - 10, 0, 16, 0, 3, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 56, 0, - 0, 7, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 0, - 16, 0, 3, 0, 0, 0, - 1, 64, 0, 0, 59, 170, - 184, 191, 25, 0, 0, 5, - 18, 0, 16, 0, 3, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 52, 0, - 0, 9, 66, 0, 16, 0, - 3, 0, 0, 0, 26, 0, - 16, 128, 129, 0, 0, 0, - 3, 0, 0, 0, 58, 0, - 16, 128, 129, 0, 0, 0, - 4, 0, 0, 0, 29, 0, - 0, 7, 66, 0, 16, 0, - 3, 0, 0, 0, 42, 0, - 16, 0, 3, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 1, 0, 0, 7, - 66, 0, 16, 0, 3, 0, - 0, 0, 42, 0, 16, 0, - 3, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 50, 0, 0, 10, 66, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 128, 65, 0, - 0, 0, 3, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 7, 18, 0, 16, 0, - 2, 0, 0, 0, 26, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 56, 0, 0, 7, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 10, 0, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 9, 18, 0, - 16, 0, 4, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 42, 0, 16, 0, - 3, 0, 0, 0, 10, 0, - 16, 0, 4, 0, 0, 0, - 56, 0, 0, 7, 18, 0, - 16, 0, 2, 0, 0, 0, - 26, 0, 16, 0, 2, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 9, 34, 0, 16, 0, - 4, 0, 0, 0, 10, 0, - 16, 0, 2, 0, 0, 0, - 42, 0, 16, 0, 3, 0, - 0, 0, 26, 0, 16, 0, - 4, 0, 0, 0, 50, 0, - 0, 9, 66, 0, 16, 0, - 4, 0, 0, 0, 10, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 3, 0, - 0, 0, 42, 0, 16, 0, - 4, 0, 0, 0, 0, 0, - 0, 7, 130, 0, 16, 0, - 4, 0, 0, 0, 58, 0, - 16, 0, 4, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 22, 0, 0, 1, - 54, 0, 0, 5, 226, 0, - 16, 0, 1, 0, 0, 0, - 6, 9, 16, 0, 4, 0, - 0, 0, 0, 0, 0, 7, - 34, 0, 16, 0, 3, 0, - 0, 0, 26, 0, 16, 0, - 3, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 22, 0, 0, 1, 49, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 14, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 1, 0, 0, 0, 42, 0, - 16, 0, 1, 0, 0, 0, - 55, 0, 0, 9, 66, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 9, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 64, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 7, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 14, 0, - 0, 7, 34, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 1, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 66, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 9, 18, 32, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 8, 226, 32, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 60, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 38, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/compositePS.hlsl b/demo/d3d11/shaders/compositePS.hlsl deleted file mode 100644 index b082aa6..0000000 --- a/demo/d3d11/shaders/compositePS.hlsl +++ /dev/null @@ -1,194 +0,0 @@ -#include "shaderCommon.h" - -#define ENABLE_SIMPLE_FLUID 1 - -cbuffer constBuf : register(b0) -{ - FluidShaderConst gParams; -}; - -Texture2D depthTex : register(t0); -Texture2D sceneTex : register(t1); -Texture2D shadowTex : register(t2); // shadow map - -SamplerState texSampler : register(s0); -SamplerComparisonState shadowSampler : register(s1); // texture sample used to sample depth from shadow texture in this sample - -// sample shadow map -float shadowSample(float3 worldPos, out float attenuation) -{ -#if 0 - attenuation = 0.0f; - return 0.5; -#else - - float4 pos = mul(gParams.lightTransform, float4(worldPos + gParams.lightDir*0.15, 1.0)); - pos /= pos.w; - float3 uvw = (pos.xyz * float3(0.5, 0.5, 1.0)) + float3(0.5, 0.5, 0.0); - - attenuation = 1.0;//max(smoothstep(spotMax, spotMin, dot(pos.xy, pos.xy)), 0.05); - - // user clip - if (uvw.x < 0.0 || uvw.x > 1.0) - return 1.0; - if (uvw.y < 0.0 || uvw.y > 1.0) - return 1.0; - - float s = 0.0; - float radius = 0.002; - - uvw.y = 1.0f - uvw.y; - - [unroll] - for (int i = 0; i < 8; i++) - { - float2 shadowTaps = gParams.shadowTaps[i].xy; - shadowTaps.y = 1.0f - shadowTaps.y; - s += shadowTex.SampleCmpLevelZero(shadowSampler, uvw.xy + shadowTaps * radius, uvw.z); - - //s += shadow2D(shadowTex, vec3(uvw.xy + shadowTaps[i] * radius, uvw.z)).r; - } - - s /= 8.0; - return s; -#endif -} - -float3 viewportToEyeSpace(float2 coord, float eyeZ) -{ - float2 clipPosToEye = gParams.clipPosToEye.xy; - - // find position at z=1 plane - //float2 uv = (coord * 2.0 - float2(1.0, 1.0)) * clipPosToEye; - float2 uv = float2(coord.x*2.0f-1.0f, (1.0f-coord.y)*2.0f - 1.0f)*clipPosToEye; - - return float3(-uv * eyeZ, eyeZ); -} - -float3 srgbToLinear(float3 c) { const float v = 2.2; return pow(c, float3(v, v, v)); } -float3 linearToSrgb(float3 c) { const float v = 1.0 / 2.2; return pow(c, float3(v, v, v)); } - -float sqr(float x) { return x*x; } -float cube(float x) { return x*x*x; } - -float4 compositePS(PassthroughVertexOut input - , out float gl_FragDepth : SV_DEPTH -) : SV_TARGET -{ - - float4 gl_FragColor; - - const float4x4 gl_ProjectionMatrix = gParams.projection; - const float4x4 gl_ModelViewMatrix = gParams.modelview; - const float4x4 gl_ModelViewMatrixInverse = gParams.modelview_inverse; - - const float2 invTexScale = gParams.invTexScale.xy; - - const float3 lightDir = gParams.lightDir; - const float3 lightPos = gParams.lightPos; - const float spotMin = gParams.spotMin; - const float spotMax = gParams.spotMax; - const float ior = gParams.ior; - const float4 color = gParams.color; - - // flip uv y-coordinate - float2 uvCoord = float2(input.texCoord[0].x, 1.0f-input.texCoord[0].y); - - float eyeZ = depthTex.Sample(texSampler, uvCoord).x; - - if (eyeZ == 0.0) - discard; - - // reconstruct eye space pos from depth - float3 eyePos = viewportToEyeSpace(uvCoord, eyeZ); - - - // finite difference approx for normals, can't take dFdx because - // the one-sided difference is incorrect at shape boundaries - float3 zl = eyePos - viewportToEyeSpace(uvCoord - float2(invTexScale.x, 0.0), depthTex.Sample(texSampler, uvCoord - float2(invTexScale.x, 0.0)).x); - float3 zr = viewportToEyeSpace(uvCoord + float2(invTexScale.x, 0.0), depthTex.Sample(texSampler, uvCoord + float2(invTexScale.x, 0.0)).x) - eyePos; - float3 zt = viewportToEyeSpace(uvCoord + float2(0.0, invTexScale.y), depthTex.Sample(texSampler, uvCoord + float2(0.0, invTexScale.y)).x) - eyePos; - float3 zb = eyePos - viewportToEyeSpace(uvCoord - float2(0.0, invTexScale.y), depthTex.Sample(texSampler, uvCoord - float2(0.0, invTexScale.y)).x); - - float3 dx = zl; - float3 dy = zt; - - if (abs(zr.z) < abs(zl.z)) - dx = zr; - - if (abs(zb.z) < abs(zt.z)) - dy = zb; - - - //float3 dx = ddx(eyePos.xyz); - //float3 dy = -ddy(eyePos.xyz); - - float4 worldPos = mul(gl_ModelViewMatrixInverse, float4(eyePos, 1.0)); - - float attenuation; - float shadow = shadowSample(worldPos.xyz, attenuation); - - float3 l = mul(gl_ModelViewMatrix, float4(lightDir, 0.0)).xyz; - float3 v = -normalize(eyePos); - - float3 n = -normalize(cross(dx, dy)); // sign difference from texcoord coordinate difference between OpenGL - float3 h = normalize(v + l); - - float3 skyColor = float3(0.1, 0.2, 0.4)*1.2; - float3 groundColor = float3(0.1, 0.1, 0.2); - - float fresnel = 0.1 + (1.0 - 0.1)*cube(1.0 - max(dot(n, v), 0.0)); - - float3 lVec = normalize(worldPos.xyz - lightPos); - - float ln = dot(l, n)*attenuation; - - float3 rEye = reflect(-v, n).xyz; - float3 rWorld = mul(gl_ModelViewMatrixInverse, float4(rEye, 0.0)).xyz; - - float2 texScale = float2(0.75, 1.0); // to account for backbuffer aspect ratio (todo: pass in) - - float refractScale = ior*0.025; - float reflectScale = ior*0.1; - - // attenuate refraction near ground (hack) - refractScale *= smoothstep(0.1, 0.4, worldPos.y); - - float2 refractCoord = uvCoord + n.xy*refractScale*texScale; - - // read thickness from refracted coordinate otherwise we get halos around objectsw - float thickness = 0.8f;//max(texture2D(thicknessTex, refractCoord).x, 0.3); - - //vec3 transmission = exp(-(vec3(1.0)-color.xyz)*thickness); - float3 transmission = (1.0 - (1.0 - color.xyz)*thickness*0.8)*color.w; - float3 refract = sceneTex.Sample(texSampler, refractCoord).xyz*transmission; - - float2 sceneReflectCoord = uvCoord - rEye.xy*texScale*reflectScale / eyePos.z; - float3 sceneReflect = sceneTex.Sample(texSampler, sceneReflectCoord).xyz*shadow; - //vec3 planarReflect = texture2D(reflectTex, gl_TexCoord[0].xy).xyz; - float3 planarReflect = float3(0.0, 0.0, 0.0); - - // fade out planar reflections above the ground - //float3 reflect = lerp(planarReflect, sceneReflect, smoothstep(0.05, 0.3, worldPos.y)) + lerp(groundColor, skyColor, smoothstep(0.15, 0.25, rWorld.y)*shadow); - float3 reflect = sceneReflect + lerp(groundColor, skyColor, smoothstep(0.15, 0.25, rWorld.y)*shadow); - - // lighting - float3 diffuse = color.xyz * lerp(float3(0.29, 0.379, 0.59), float3(1.0, 1.0, 1.0), (ln*0.5 + 0.5)*max(shadow, 0.4))*(1.0 - color.w); - float specular = 1.2*pow(max(dot(h, n), 0.0), 400.0); - - gl_FragColor.xyz = diffuse + (lerp(refract, reflect, fresnel) + specular)*color.w; - gl_FragColor.w = 1.0; - - // visualize normals - //gl_FragColor = float4(n*0.5 + 0.5, 1.0); - //gl_FragColor.xyz = float3(fresnel, fresnel, fresnel); - //gl_FragColor.xyz = n; - - // write valid z - float4 clipPos = mul(gl_ProjectionMatrix, float4(0.0, 0.0, eyeZ, 1.0)); - clipPos.z /= clipPos.w; - gl_FragDepth = clipPos.z; - - return gl_FragColor; - -} diff --git a/demo/d3d11/shaders/compositePS.hlsl.h b/demo/d3d11/shaders/compositePS.hlsl.h deleted file mode 100644 index 77d3814..0000000 --- a/demo/d3d11/shaders/compositePS.hlsl.h +++ /dev/null @@ -1,1643 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct FluidShaderConst -// { -// -// float4x4 modelviewprojection; // Offset: 0 -// float4x4 modelview; // Offset: 64 -// float4x4 projection; // Offset: 128 -// float4x4 modelview_inverse; // Offset: 192 -// float4x4 projection_inverse; // Offset: 256 -// float4 invTexScale; // Offset: 320 -// float3 invViewport; // Offset: 336 -// float _pad0; // Offset: 348 -// float blurRadiusWorld; // Offset: 352 -// float blurScale; // Offset: 356 -// float blurFalloff; // Offset: 360 -// int debug; // Offset: 364 -// float3 lightPos; // Offset: 368 -// float _pad1; // Offset: 380 -// float3 lightDir; // Offset: 384 -// float _pad2; // Offset: 396 -// float4x4 lightTransform; // Offset: 400 -// float4 color; // Offset: 464 -// float4 clipPosToEye; // Offset: 480 -// float spotMin; // Offset: 496 -// float spotMax; // Offset: 500 -// float ior; // Offset: 504 -// float _pad3; // Offset: 508 -// float4 shadowTaps[12]; // Offset: 512 -// -// } gParams; // Offset: 0 Size: 704 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// texSampler sampler NA NA 0 1 -// shadowSampler sampler_c NA NA 1 1 -// depthTex texture float 2d 0 1 -// sceneTex texture float3 2d 1 1 -// shadowTex texture float 2d 2 1 -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xy 1 NONE float xy -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// SV_DEPTH 0 N/A oDepth DEPTH float YES -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[40], immediateIndexed -dcl_sampler s0, mode_default -dcl_sampler s1, mode_comparison -dcl_resource_texture2d (float,float,float,float) t0 -dcl_resource_texture2d (float,float,float,float) t1 -dcl_resource_texture2d (float,float,float,float) t2 -dcl_input_ps linear v1.xy -dcl_output o0.xyzw -dcl_output oDepth -dcl_temps 8 -mad r0.xy, v1.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(0.000000, 1.000000, 0.000000, 0.000000) -sample_indexable(texture2d)(float,float,float,float) r1.z, r0.xyxx, t0.yzxw, s0 -eq r0.z, r1.z, l(0.000000) -discard_nz r0.z -mad r0.zw, v1.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000) -mul r0.zw, r0.zzzw, cb0[30].xxxy -mul r1.xy, r1.zzzz, -r0.zwzz -mov r2.y, cb0[20].x -mov r2.z, l(0) -add r0.zw, r0.xxxy, -r2.yyyz -sample_indexable(texture2d)(float,float,float,float) r2.x, r0.zwzz, t0.xyzw, s0 -mad r0.zw, r0.zzzw, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000) -mul r0.zw, r0.zzzw, cb0[30].xxxy -mul r2.yz, r2.xxxx, -r0.zzwz -add r2.xyz, r1.zxyz, -r2.xyzx -mov r3.y, cb0[20].x -mov r3.z, l(1.000000) -mad r0.zw, v1.xxxy, l(0.000000, 0.000000, 1.000000, -1.000000), r3.yyyz -sample_indexable(texture2d)(float,float,float,float) r3.x, r0.zwzz, t0.xyzw, s0 -mad r0.zw, r0.zzzw, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000) -mul r0.zw, r0.zzzw, cb0[30].xxxy -mul r3.yz, r3.xxxx, -r0.zzwz -add r3.xyz, -r1.zxyz, r3.xyzx -mov r4.z, l(0) -mov r4.x, cb0[20].y -add r0.zw, r0.yyyx, r4.xxxz -sample_indexable(texture2d)(float,float,float,float) r5.y, r0.wzww, t0.yxzw, s0 -mad r0.zw, r0.zzzw, l(0.000000, 0.000000, -2.000000, 2.000000), l(0.000000, 0.000000, 1.000000, -1.000000) -mul r0.zw, r0.zzzw, cb0[30].yyyx -mul r5.xz, r5.yyyy, -r0.zzwz -add r5.xyz, -r1.yzxy, r5.xyzx -add r0.zw, r0.yyyx, -r4.xxxz -sample_indexable(texture2d)(float,float,float,float) r4.y, r0.wzww, t0.yxzw, s0 -mad r0.zw, r0.zzzw, l(0.000000, 0.000000, -2.000000, 2.000000), l(0.000000, 0.000000, 1.000000, -1.000000) -mul r0.zw, r0.zzzw, cb0[30].yyyx -mul r4.xz, r4.yyyy, -r0.zzwz -add r4.xyz, r1.yzxy, -r4.xyzx -lt r0.z, |r3.x|, |r2.x| -movc r2.xyz, r0.zzzz, r3.xyzx, r2.xyzx -lt r0.z, |r4.y|, |r5.y| -movc r3.xyz, r0.zzzz, r4.xyzx, r5.xyzx -mul r4.xyz, r1.yyyy, cb0[13].xyzx -mad r4.xyz, cb0[12].xyzx, r1.xxxx, r4.xyzx -mad r4.xyz, cb0[14].xyzx, r1.zzzz, r4.xyzx -add r4.xyz, r4.xyzx, cb0[15].xyzx -mad r4.xzw, cb0[24].xxyz, l(0.150000, 0.000000, 0.150000, 0.150000), r4.xxyz -mul r5.xyzw, r4.zzzz, cb0[26].xyzw -mad r5.xyzw, cb0[25].xyzw, r4.xxxx, r5.xyzw -mad r5.xyzw, cb0[27].xyzw, r4.wwww, r5.xyzw -add r5.xyzw, r5.xyzw, cb0[28].xyzw -div r4.xzw, r5.xxyz, r5.wwww -mad r5.xyz, r4.xzwx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) -lt r0.z, r5.x, l(0.000000) -lt r0.w, l(1.000000), r5.x -or r0.z, r0.w, r0.z -if_z r0.z - lt r0.z, r5.y, l(0.000000) - lt r0.w, l(1.000000), r5.y - or r0.z, r0.w, r0.z - if_z r0.z - add r0.z, -cb0[32].y, l(1.000000) - mul r6.x, cb0[32].x, l(0.002000) - mul r6.y, r0.z, l(0.002000) - add r5.w, -r5.y, l(1.000000) - add r0.zw, r5.xxxw, r6.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t2.xxxx, s1, r5.z - add r0.w, -cb0[33].y, l(1.000000) - mul r6.x, cb0[33].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[34].y, l(1.000000) - mul r6.x, cb0[34].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[35].y, l(1.000000) - mul r6.x, cb0[35].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[36].y, l(1.000000) - mul r6.x, cb0[36].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[37].y, l(1.000000) - mul r6.x, cb0[37].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[38].y, l(1.000000) - mul r6.x, cb0[38].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[39].y, l(1.000000) - mul r6.x, cb0[39].x, l(0.002000) - mul r6.y, r0.w, l(0.002000) - add r4.xz, r5.xxwx, r6.xxyx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r4.xzxx, t2.xxxx, s1, r5.z - add r0.z, r0.w, r0.z - mul r0.z, r0.z, l(0.125000) - else - mov r0.z, l(1.000000) - endif -else - mov r0.z, l(1.000000) -endif -mul r4.xzw, cb0[5].xxyz, cb0[24].yyyy -mad r4.xzw, cb0[4].xxyz, cb0[24].xxxx, r4.xxzw -mad r4.xzw, cb0[6].xxyz, cb0[24].zzzz, r4.xxzw -dp3 r0.w, r1.xyzx, r1.xyzx -rsq r0.w, r0.w -mul r5.xyz, r0.wwww, r1.xyzx -mul r6.xyz, r2.xyzx, r3.xyzx -mad r2.xyz, r2.zxyz, r3.yzxy, -r6.xyzx -dp3 r1.w, r2.xyzx, r2.xyzx -rsq r1.w, r1.w -mul r2.xyz, r1.wwww, r2.xyzx -mad r1.xyw, -r1.xyxz, r0.wwww, r4.xzxw -dp3 r0.w, r1.xywx, r1.xywx -rsq r0.w, r0.w -mul r1.xyw, r0.wwww, r1.xyxw -dp3 r0.w, -r2.xyzx, -r5.xyzx -max r0.w, r0.w, l(0.000000) -add r0.w, -r0.w, l(1.000000) -mul r2.w, r0.w, r0.w -mul r0.w, r0.w, r2.w -mad r0.w, r0.w, l(0.900000), l(0.100000) -dp3 r2.w, r4.xzwx, -r2.xyzx -dp3 r3.x, r5.xyzx, -r2.xyzx -add r3.x, r3.x, r3.x -mad r3.xyz, r2.xyzx, r3.xxxx, r5.xyzx -mul r3.w, r3.y, cb0[13].y -mad r3.w, cb0[12].y, r3.x, r3.w -mad r3.z, cb0[14].y, r3.z, r3.w -mul r5.xy, cb0[31].zzzz, l(0.025000, 0.100000, 0.000000, 0.000000) -add r3.w, r4.y, l(-0.100000) -mul_sat r3.w, r3.w, l(3.333333) -mad r4.x, r3.w, l(-2.000000), l(3.000000) -mul r3.w, r3.w, r3.w -mul r3.w, r3.w, r4.x -mul r3.w, r3.w, r5.x -mul r4.xy, -r2.xyxx, r3.wwww -mad r4.xy, r4.xyxx, l(0.750000, 1.000000, 0.000000, 0.000000), r0.xyxx -add r6.xyzw, -cb0[29].xyzw, l(1.000000, 1.000000, 1.000000, 1.000000) -mad r6.xyz, -r6.xyzx, l(0.640000, 0.640000, 0.640000, 0.000000), l(1.000000, 1.000000, 1.000000, 0.000000) -mul r6.xyz, r6.xyzx, cb0[29].wwww -sample_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyxx, t1.xyzw, s0 -mul r7.xyz, r6.xyzx, r4.xyzx -mov r5.xz, l(0.750000,0,1.000000,0) -mul r3.xy, r3.xyxx, r5.yzyy -mul r5.y, cb0[31].z, l(0.100000) -mul r3.xy, r3.xyxx, r5.xyxx -div r3.xy, r3.xyxx, r1.zzzz -add r0.xy, r0.xyxx, -r3.xyxx -sample_indexable(texture2d)(float,float,float,float) r3.xyw, r0.xyxx, t1.xywz, s0 -add r0.x, r3.z, l(-0.150000) -mul_sat r0.x, r0.x, l(10.000001) -mad r0.y, r0.x, l(-2.000000), l(3.000000) -mul r0.x, r0.x, r0.x -mul r0.x, r0.x, r0.y -mul r0.x, r0.z, r0.x -mul r5.xyz, r0.xxxx, l(0.020000, 0.140000, 0.280000, 0.000000) -mad r3.xyz, r3.xywx, r0.zzzz, r5.xyzx -add r3.xyz, r3.xyzx, l(0.100000, 0.100000, 0.200000, 0.000000) -mad r0.x, r2.w, l(0.500000), l(0.500000) -max r0.y, r0.z, l(0.400000) -mul r0.x, r0.y, r0.x -mad r0.xyz, r0.xxxx, l(0.710000, 0.621000, 0.410000, 0.000000), l(0.290000, 0.379000, 0.590000, 0.000000) -mul r0.xyz, r0.xyzx, cb0[29].xyzx -dp3 r1.x, r1.xywx, -r2.xyzx -max r1.x, r1.x, l(0.000000) -log r1.x, r1.x -mul r1.x, r1.x, l(400.000000) -exp r1.x, r1.x -mad r2.xyz, -r4.xyzx, r6.xyzx, r3.xyzx -mad r2.xyz, r0.wwww, r2.xyzx, r7.xyzx -mad r1.xyw, r1.xxxx, l(1.200000, 1.200000, 0.000000, 1.200000), r2.xyxz -mul r1.xyw, r1.xyxw, cb0[29].wwww -mad o0.xyz, r0.xyzx, r6.wwww, r1.xywx -mad r0.xy, cb0[10].zwzz, r1.zzzz, cb0[11].zwzz -div oDepth, r0.x, r0.y -mov o0.w, l(1.000000) -ret -// Approximately 192 instruction slots used -#endif - -const BYTE g_compositePS[] = -{ - 68, 88, 66, 67, 223, 79, - 142, 103, 26, 30, 227, 152, - 95, 75, 188, 26, 149, 14, - 233, 77, 1, 0, 0, 0, - 232, 31, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 72, 5, 0, 0, 160, 5, - 0, 0, 244, 5, 0, 0, - 76, 31, 0, 0, 82, 68, - 69, 70, 12, 5, 0, 0, - 1, 0, 0, 0, 60, 1, - 0, 0, 6, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 216, 4, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 252, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 7, 1, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 21, 1, - 0, 0, 2, 0, 0, 0, - 5, 0, 0, 0, 4, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 30, 1, 0, 0, 2, 0, - 0, 0, 5, 0, 0, 0, - 4, 0, 0, 0, 255, 255, - 255, 255, 1, 0, 0, 0, - 1, 0, 0, 0, 9, 0, - 0, 0, 39, 1, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 2, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 49, 1, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 116, 101, 120, 83, 97, 109, - 112, 108, 101, 114, 0, 115, - 104, 97, 100, 111, 119, 83, - 97, 109, 112, 108, 101, 114, - 0, 100, 101, 112, 116, 104, - 84, 101, 120, 0, 115, 99, - 101, 110, 101, 84, 101, 120, - 0, 115, 104, 97, 100, 111, - 119, 84, 101, 120, 0, 99, - 111, 110, 115, 116, 66, 117, - 102, 0, 171, 171, 49, 1, - 0, 0, 1, 0, 0, 0, - 84, 1, 0, 0, 192, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 124, 1, - 0, 0, 0, 0, 0, 0, - 192, 2, 0, 0, 2, 0, - 0, 0, 180, 4, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 103, 80, 97, 114, - 97, 109, 115, 0, 70, 108, - 117, 105, 100, 83, 104, 97, - 100, 101, 114, 67, 111, 110, - 115, 116, 0, 109, 111, 100, - 101, 108, 118, 105, 101, 119, - 112, 114, 111, 106, 101, 99, - 116, 105, 111, 110, 0, 102, - 108, 111, 97, 116, 52, 120, - 52, 0, 171, 171, 3, 0, - 3, 0, 4, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 169, 1, 0, 0, 109, 111, - 100, 101, 108, 118, 105, 101, - 119, 0, 112, 114, 111, 106, - 101, 99, 116, 105, 111, 110, - 0, 109, 111, 100, 101, 108, - 118, 105, 101, 119, 95, 105, - 110, 118, 101, 114, 115, 101, - 0, 112, 114, 111, 106, 101, - 99, 116, 105, 111, 110, 95, - 105, 110, 118, 101, 114, 115, - 101, 0, 105, 110, 118, 84, - 101, 120, 83, 99, 97, 108, - 101, 0, 102, 108, 111, 97, - 116, 52, 0, 171, 171, 171, - 1, 0, 3, 0, 1, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 30, 2, 0, 0, - 105, 110, 118, 86, 105, 101, - 119, 112, 111, 114, 116, 0, - 102, 108, 111, 97, 116, 51, - 0, 171, 1, 0, 3, 0, - 1, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 88, 2, - 0, 0, 95, 112, 97, 100, - 48, 0, 102, 108, 111, 97, - 116, 0, 0, 0, 3, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 138, 2, - 0, 0, 98, 108, 117, 114, - 82, 97, 100, 105, 117, 115, - 87, 111, 114, 108, 100, 0, - 98, 108, 117, 114, 83, 99, - 97, 108, 101, 0, 98, 108, - 117, 114, 70, 97, 108, 108, - 111, 102, 102, 0, 100, 101, - 98, 117, 103, 0, 105, 110, - 116, 0, 0, 0, 2, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 224, 2, - 0, 0, 108, 105, 103, 104, - 116, 80, 111, 115, 0, 95, - 112, 97, 100, 49, 0, 108, - 105, 103, 104, 116, 68, 105, - 114, 0, 95, 112, 97, 100, - 50, 0, 108, 105, 103, 104, - 116, 84, 114, 97, 110, 115, - 102, 111, 114, 109, 0, 99, - 111, 108, 111, 114, 0, 99, - 108, 105, 112, 80, 111, 115, - 84, 111, 69, 121, 101, 0, - 115, 112, 111, 116, 77, 105, - 110, 0, 115, 112, 111, 116, - 77, 97, 120, 0, 105, 111, - 114, 0, 95, 112, 97, 100, - 51, 0, 115, 104, 97, 100, - 111, 119, 84, 97, 112, 115, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 30, 2, 0, 0, 149, 1, - 0, 0, 180, 1, 0, 0, - 0, 0, 0, 0, 216, 1, - 0, 0, 180, 1, 0, 0, - 64, 0, 0, 0, 226, 1, - 0, 0, 180, 1, 0, 0, - 128, 0, 0, 0, 237, 1, - 0, 0, 180, 1, 0, 0, - 192, 0, 0, 0, 255, 1, - 0, 0, 180, 1, 0, 0, - 0, 1, 0, 0, 18, 2, - 0, 0, 40, 2, 0, 0, - 64, 1, 0, 0, 76, 2, - 0, 0, 96, 2, 0, 0, - 80, 1, 0, 0, 132, 2, - 0, 0, 144, 2, 0, 0, - 92, 1, 0, 0, 180, 2, - 0, 0, 144, 2, 0, 0, - 96, 1, 0, 0, 196, 2, - 0, 0, 144, 2, 0, 0, - 100, 1, 0, 0, 206, 2, - 0, 0, 144, 2, 0, 0, - 104, 1, 0, 0, 218, 2, - 0, 0, 228, 2, 0, 0, - 108, 1, 0, 0, 8, 3, - 0, 0, 96, 2, 0, 0, - 112, 1, 0, 0, 17, 3, - 0, 0, 144, 2, 0, 0, - 124, 1, 0, 0, 23, 3, - 0, 0, 96, 2, 0, 0, - 128, 1, 0, 0, 32, 3, - 0, 0, 144, 2, 0, 0, - 140, 1, 0, 0, 38, 3, - 0, 0, 180, 1, 0, 0, - 144, 1, 0, 0, 53, 3, - 0, 0, 40, 2, 0, 0, - 208, 1, 0, 0, 59, 3, - 0, 0, 40, 2, 0, 0, - 224, 1, 0, 0, 72, 3, - 0, 0, 144, 2, 0, 0, - 240, 1, 0, 0, 80, 3, - 0, 0, 144, 2, 0, 0, - 244, 1, 0, 0, 88, 3, - 0, 0, 144, 2, 0, 0, - 248, 1, 0, 0, 92, 3, - 0, 0, 144, 2, 0, 0, - 252, 1, 0, 0, 98, 3, - 0, 0, 112, 3, 0, 0, - 0, 2, 0, 0, 5, 0, - 0, 0, 1, 0, 176, 0, - 0, 0, 24, 0, 148, 3, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 132, 1, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 80, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 3, 3, 0, 0, - 83, 86, 95, 80, 79, 83, - 73, 84, 73, 79, 78, 0, - 84, 69, 88, 67, 79, 79, - 82, 68, 0, 171, 171, 171, - 79, 83, 71, 78, 76, 0, - 0, 0, 2, 0, 0, 0, - 8, 0, 0, 0, 56, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 66, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 255, 255, 255, 255, - 1, 14, 0, 0, 83, 86, - 95, 84, 65, 82, 71, 69, - 84, 0, 83, 86, 95, 68, - 69, 80, 84, 72, 0, 171, - 83, 72, 69, 88, 80, 25, - 0, 0, 80, 0, 0, 0, - 84, 6, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 40, 0, 0, 0, - 90, 0, 0, 3, 0, 96, - 16, 0, 0, 0, 0, 0, - 90, 8, 0, 3, 0, 96, - 16, 0, 1, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 88, 24, - 0, 4, 0, 112, 16, 0, - 1, 0, 0, 0, 85, 85, - 0, 0, 88, 24, 0, 4, - 0, 112, 16, 0, 2, 0, - 0, 0, 85, 85, 0, 0, - 98, 16, 0, 3, 50, 16, - 16, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 0, 0, 0, 0, - 101, 0, 0, 2, 1, 192, - 0, 0, 104, 0, 0, 2, - 8, 0, 0, 0, 50, 0, - 0, 15, 50, 0, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 128, 63, 0, 0, 128, 191, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 63, 0, 0, 0, 0, - 0, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 66, 0, - 16, 0, 1, 0, 0, 0, - 70, 0, 16, 0, 0, 0, - 0, 0, 150, 124, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 24, 0, 0, 7, 66, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 13, 0, - 4, 3, 42, 0, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 15, 194, 0, 16, 0, - 0, 0, 0, 0, 6, 20, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 64, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 191, - 0, 0, 128, 191, 56, 0, - 0, 8, 194, 0, 16, 0, - 0, 0, 0, 0, 166, 14, - 16, 0, 0, 0, 0, 0, - 6, 132, 32, 0, 0, 0, - 0, 0, 30, 0, 0, 0, - 56, 0, 0, 8, 50, 0, - 16, 0, 1, 0, 0, 0, - 166, 10, 16, 0, 1, 0, - 0, 0, 230, 10, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 34, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 20, 0, - 0, 0, 54, 0, 0, 5, - 66, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 8, 194, 0, 16, 0, - 0, 0, 0, 0, 6, 4, - 16, 0, 0, 0, 0, 0, - 86, 9, 16, 128, 65, 0, - 0, 0, 2, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 18, 0, 16, 0, 2, 0, - 0, 0, 230, 10, 16, 0, - 0, 0, 0, 0, 70, 126, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 15, - 194, 0, 16, 0, 0, 0, - 0, 0, 166, 14, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 64, 0, 0, 0, 192, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 191, 0, 0, - 128, 63, 56, 0, 0, 8, - 194, 0, 16, 0, 0, 0, - 0, 0, 166, 14, 16, 0, - 0, 0, 0, 0, 6, 132, - 32, 0, 0, 0, 0, 0, - 30, 0, 0, 0, 56, 0, - 0, 8, 98, 0, 16, 0, - 2, 0, 0, 0, 6, 0, - 16, 0, 2, 0, 0, 0, - 166, 11, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 114, 0, - 16, 0, 2, 0, 0, 0, - 38, 9, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 128, - 65, 0, 0, 0, 2, 0, - 0, 0, 54, 0, 0, 6, - 34, 0, 16, 0, 3, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 20, 0, - 0, 0, 54, 0, 0, 5, - 66, 0, 16, 0, 3, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 50, 0, - 0, 12, 194, 0, 16, 0, - 0, 0, 0, 0, 6, 20, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 63, 0, 0, - 128, 191, 86, 9, 16, 0, - 3, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 18, 0, - 16, 0, 3, 0, 0, 0, - 230, 10, 16, 0, 0, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 15, 194, 0, - 16, 0, 0, 0, 0, 0, - 166, 14, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 64, - 0, 0, 0, 192, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 191, 0, 0, 128, 63, - 56, 0, 0, 8, 194, 0, - 16, 0, 0, 0, 0, 0, - 166, 14, 16, 0, 0, 0, - 0, 0, 6, 132, 32, 0, - 0, 0, 0, 0, 30, 0, - 0, 0, 56, 0, 0, 8, - 98, 0, 16, 0, 3, 0, - 0, 0, 6, 0, 16, 0, - 3, 0, 0, 0, 166, 11, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 8, 114, 0, 16, 0, - 3, 0, 0, 0, 38, 9, - 16, 128, 65, 0, 0, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 3, 0, 0, 0, - 54, 0, 0, 5, 66, 0, - 16, 0, 4, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 18, 0, 16, 0, 4, 0, - 0, 0, 26, 128, 32, 0, - 0, 0, 0, 0, 20, 0, - 0, 0, 0, 0, 0, 7, - 194, 0, 16, 0, 0, 0, - 0, 0, 86, 1, 16, 0, - 0, 0, 0, 0, 6, 8, - 16, 0, 4, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 34, 0, 16, 0, 5, 0, - 0, 0, 182, 15, 16, 0, - 0, 0, 0, 0, 22, 126, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 15, - 194, 0, 16, 0, 0, 0, - 0, 0, 166, 14, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 192, 0, 0, 0, 64, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 63, 0, 0, - 128, 191, 56, 0, 0, 8, - 194, 0, 16, 0, 0, 0, - 0, 0, 166, 14, 16, 0, - 0, 0, 0, 0, 86, 129, - 32, 0, 0, 0, 0, 0, - 30, 0, 0, 0, 56, 0, - 0, 8, 82, 0, 16, 0, - 5, 0, 0, 0, 86, 5, - 16, 0, 5, 0, 0, 0, - 166, 11, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 114, 0, - 16, 0, 5, 0, 0, 0, - 150, 4, 16, 128, 65, 0, - 0, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 8, - 194, 0, 16, 0, 0, 0, - 0, 0, 86, 1, 16, 0, - 0, 0, 0, 0, 6, 8, - 16, 128, 65, 0, 0, 0, - 4, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 34, 0, - 16, 0, 4, 0, 0, 0, - 182, 15, 16, 0, 0, 0, - 0, 0, 22, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 15, 194, 0, - 16, 0, 0, 0, 0, 0, - 166, 14, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 192, - 0, 0, 0, 64, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 63, 0, 0, 128, 191, - 56, 0, 0, 8, 194, 0, - 16, 0, 0, 0, 0, 0, - 166, 14, 16, 0, 0, 0, - 0, 0, 86, 129, 32, 0, - 0, 0, 0, 0, 30, 0, - 0, 0, 56, 0, 0, 8, - 82, 0, 16, 0, 4, 0, - 0, 0, 86, 5, 16, 0, - 4, 0, 0, 0, 166, 11, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 8, 114, 0, 16, 0, - 4, 0, 0, 0, 150, 4, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 128, 65, 0, - 0, 0, 4, 0, 0, 0, - 49, 0, 0, 9, 66, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 128, 129, 0, - 0, 0, 3, 0, 0, 0, - 10, 0, 16, 128, 129, 0, - 0, 0, 2, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 2, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 49, 0, 0, 9, 66, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 128, 129, 0, - 0, 0, 4, 0, 0, 0, - 26, 0, 16, 128, 129, 0, - 0, 0, 5, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 3, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 56, 0, 0, 8, 114, 0, - 16, 0, 4, 0, 0, 0, - 86, 5, 16, 0, 1, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 13, 0, - 0, 0, 50, 0, 0, 10, - 114, 0, 16, 0, 4, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 12, 0, - 0, 0, 6, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 4, 0, 0, 0, - 50, 0, 0, 10, 114, 0, - 16, 0, 4, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 14, 0, 0, 0, - 166, 10, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 4, 0, 0, 0, 0, 0, - 0, 8, 114, 0, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 0, 4, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 50, 0, 0, 13, 210, 0, - 16, 0, 4, 0, 0, 0, - 6, 137, 32, 0, 0, 0, - 0, 0, 24, 0, 0, 0, - 2, 64, 0, 0, 154, 153, - 25, 62, 0, 0, 0, 0, - 154, 153, 25, 62, 154, 153, - 25, 62, 6, 9, 16, 0, - 4, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 5, 0, 0, 0, 166, 10, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 26, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 5, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 25, 0, 0, 0, - 6, 0, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 5, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 5, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 27, 0, 0, 0, 246, 15, - 16, 0, 4, 0, 0, 0, - 70, 14, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 8, - 242, 0, 16, 0, 5, 0, - 0, 0, 70, 14, 16, 0, - 5, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 28, 0, 0, 0, 14, 0, - 0, 7, 210, 0, 16, 0, - 4, 0, 0, 0, 6, 9, - 16, 0, 5, 0, 0, 0, - 246, 15, 16, 0, 5, 0, - 0, 0, 50, 0, 0, 15, - 114, 0, 16, 0, 5, 0, - 0, 0, 134, 3, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 128, 63, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 49, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 5, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 49, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 10, 0, 16, 0, - 5, 0, 0, 0, 60, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 31, 0, 0, 3, - 42, 0, 16, 0, 0, 0, - 0, 0, 49, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 5, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 49, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 26, 0, 16, 0, - 5, 0, 0, 0, 60, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 31, 0, 0, 3, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 66, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 32, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 6, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 32, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 6, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 8, - 130, 0, 16, 0, 5, 0, - 0, 0, 26, 0, 16, 128, - 65, 0, 0, 0, 5, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 0, 0, - 0, 7, 194, 0, 16, 0, - 0, 0, 0, 0, 6, 12, - 16, 0, 5, 0, 0, 0, - 6, 4, 16, 0, 6, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 0, 0, 0, 0, 230, 10, - 16, 0, 0, 0, 0, 0, - 6, 112, 16, 0, 2, 0, - 0, 0, 0, 96, 16, 0, - 1, 0, 0, 0, 42, 0, - 16, 0, 5, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 33, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 34, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 35, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 35, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 36, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 36, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 37, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 37, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 38, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 38, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 39, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 6, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 39, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 6, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 7, 82, 0, - 16, 0, 4, 0, 0, 0, - 6, 3, 16, 0, 5, 0, - 0, 0, 6, 1, 16, 0, - 6, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 130, 0, - 16, 0, 0, 0, 0, 0, - 134, 0, 16, 0, 4, 0, - 0, 0, 6, 112, 16, 0, - 2, 0, 0, 0, 0, 96, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 66, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 62, 18, 0, - 0, 1, 54, 0, 0, 5, - 66, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 21, 0, - 0, 1, 18, 0, 0, 1, - 54, 0, 0, 5, 66, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 21, 0, 0, 1, - 56, 0, 0, 9, 210, 0, - 16, 0, 4, 0, 0, 0, - 6, 137, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 86, 133, 32, 0, 0, 0, - 0, 0, 24, 0, 0, 0, - 50, 0, 0, 11, 210, 0, - 16, 0, 4, 0, 0, 0, - 6, 137, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 6, 128, 32, 0, 0, 0, - 0, 0, 24, 0, 0, 0, - 6, 14, 16, 0, 4, 0, - 0, 0, 50, 0, 0, 11, - 210, 0, 16, 0, 4, 0, - 0, 0, 6, 137, 32, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 166, 138, 32, 0, - 0, 0, 0, 0, 24, 0, - 0, 0, 6, 14, 16, 0, - 4, 0, 0, 0, 16, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 68, 0, 0, 5, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 7, 114, 0, 16, 0, - 5, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 6, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 2, - 16, 0, 3, 0, 0, 0, - 50, 0, 0, 10, 114, 0, - 16, 0, 2, 0, 0, 0, - 38, 9, 16, 0, 2, 0, - 0, 0, 150, 4, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 6, 0, 0, 0, 16, 0, - 0, 7, 130, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 68, 0, 0, 5, - 130, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 7, 114, 0, 16, 0, - 2, 0, 0, 0, 246, 15, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 50, 0, 0, 10, - 178, 0, 16, 0, 1, 0, - 0, 0, 70, 8, 16, 128, - 65, 0, 0, 0, 1, 0, - 0, 0, 246, 15, 16, 0, - 0, 0, 0, 0, 134, 12, - 16, 0, 4, 0, 0, 0, - 16, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 70, 3, 16, 0, 1, 0, - 0, 0, 70, 3, 16, 0, - 1, 0, 0, 0, 68, 0, - 0, 5, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 178, 0, - 16, 0, 1, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 70, 12, 16, 0, - 1, 0, 0, 0, 16, 0, - 0, 9, 130, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 2, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 5, 0, 0, 0, 52, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 7, 130, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 102, 102, 102, 63, 1, 64, - 0, 0, 205, 204, 204, 61, - 16, 0, 0, 8, 130, 0, - 16, 0, 2, 0, 0, 0, - 134, 3, 16, 0, 4, 0, - 0, 0, 70, 2, 16, 128, - 65, 0, 0, 0, 2, 0, - 0, 0, 16, 0, 0, 8, - 18, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 5, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 7, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 0, - 16, 0, 3, 0, 0, 0, - 10, 0, 16, 0, 3, 0, - 0, 0, 50, 0, 0, 9, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 6, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 5, 0, - 0, 0, 56, 0, 0, 8, - 130, 0, 16, 0, 3, 0, - 0, 0, 26, 0, 16, 0, - 3, 0, 0, 0, 26, 128, - 32, 0, 0, 0, 0, 0, - 13, 0, 0, 0, 50, 0, - 0, 10, 130, 0, 16, 0, - 3, 0, 0, 0, 26, 128, - 32, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 10, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 3, 0, - 0, 0, 50, 0, 0, 10, - 66, 0, 16, 0, 3, 0, - 0, 0, 26, 128, 32, 0, - 0, 0, 0, 0, 14, 0, - 0, 0, 42, 0, 16, 0, - 3, 0, 0, 0, 58, 0, - 16, 0, 3, 0, 0, 0, - 56, 0, 0, 11, 50, 0, - 16, 0, 5, 0, 0, 0, - 166, 138, 32, 0, 0, 0, - 0, 0, 31, 0, 0, 0, - 2, 64, 0, 0, 205, 204, - 204, 60, 205, 204, 204, 61, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 7, - 130, 0, 16, 0, 3, 0, - 0, 0, 26, 0, 16, 0, - 4, 0, 0, 0, 1, 64, - 0, 0, 205, 204, 204, 189, - 56, 32, 0, 7, 130, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 3, 0, - 0, 0, 1, 64, 0, 0, - 85, 85, 85, 64, 50, 0, - 0, 9, 18, 0, 16, 0, - 4, 0, 0, 0, 58, 0, - 16, 0, 3, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 192, 1, 64, 0, 0, - 0, 0, 64, 64, 56, 0, - 0, 7, 130, 0, 16, 0, - 3, 0, 0, 0, 58, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 3, 0, - 0, 0, 56, 0, 0, 7, - 130, 0, 16, 0, 3, 0, - 0, 0, 58, 0, 16, 0, - 3, 0, 0, 0, 10, 0, - 16, 0, 4, 0, 0, 0, - 56, 0, 0, 7, 130, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 3, 0, - 0, 0, 10, 0, 16, 0, - 5, 0, 0, 0, 56, 0, - 0, 8, 50, 0, 16, 0, - 4, 0, 0, 0, 70, 0, - 16, 128, 65, 0, 0, 0, - 2, 0, 0, 0, 246, 15, - 16, 0, 3, 0, 0, 0, - 50, 0, 0, 12, 50, 0, - 16, 0, 4, 0, 0, 0, - 70, 0, 16, 0, 4, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 64, 63, 0, 0, - 128, 63, 0, 0, 0, 0, - 0, 0, 0, 0, 70, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 12, 242, 0, - 16, 0, 6, 0, 0, 0, - 70, 142, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 29, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 128, 63, - 50, 0, 0, 16, 114, 0, - 16, 0, 6, 0, 0, 0, - 70, 2, 16, 128, 65, 0, - 0, 0, 6, 0, 0, 0, - 2, 64, 0, 0, 11, 215, - 35, 63, 11, 215, 35, 63, - 11, 215, 35, 63, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 0, 0, 56, 0, - 0, 8, 114, 0, 16, 0, - 6, 0, 0, 0, 70, 2, - 16, 0, 6, 0, 0, 0, - 246, 143, 32, 0, 0, 0, - 0, 0, 29, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 114, 0, 16, 0, 4, 0, - 0, 0, 70, 0, 16, 0, - 4, 0, 0, 0, 70, 126, - 16, 0, 1, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 7, 0, - 0, 0, 70, 2, 16, 0, - 6, 0, 0, 0, 70, 2, - 16, 0, 4, 0, 0, 0, - 54, 0, 0, 8, 82, 0, - 16, 0, 5, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 64, 63, 0, 0, 0, 0, - 0, 0, 128, 63, 0, 0, - 0, 0, 56, 0, 0, 7, - 50, 0, 16, 0, 3, 0, - 0, 0, 70, 0, 16, 0, - 3, 0, 0, 0, 150, 5, - 16, 0, 5, 0, 0, 0, - 56, 0, 0, 8, 34, 0, - 16, 0, 5, 0, 0, 0, - 42, 128, 32, 0, 0, 0, - 0, 0, 31, 0, 0, 0, - 1, 64, 0, 0, 205, 204, - 204, 61, 56, 0, 0, 7, - 50, 0, 16, 0, 3, 0, - 0, 0, 70, 0, 16, 0, - 3, 0, 0, 0, 70, 0, - 16, 0, 5, 0, 0, 0, - 14, 0, 0, 7, 50, 0, - 16, 0, 3, 0, 0, 0, - 70, 0, 16, 0, 3, 0, - 0, 0, 166, 10, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 8, 50, 0, 16, 0, - 0, 0, 0, 0, 70, 0, - 16, 0, 0, 0, 0, 0, - 70, 0, 16, 128, 65, 0, - 0, 0, 3, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 178, 0, 16, 0, 3, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 70, 123, - 16, 0, 1, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 3, 0, 0, 0, 1, 64, - 0, 0, 154, 153, 25, 190, - 56, 32, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 1, 0, 32, 65, 50, 0, - 0, 9, 34, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 192, 1, 64, 0, 0, - 0, 0, 64, 64, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 10, 114, 0, 16, 0, - 5, 0, 0, 0, 6, 0, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 8, 215, - 163, 60, 40, 92, 15, 62, - 40, 92, 143, 62, 0, 0, - 0, 0, 50, 0, 0, 9, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 3, 16, 0, - 3, 0, 0, 0, 166, 10, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 205, 204, 204, 61, - 205, 204, 204, 61, 205, 204, - 76, 62, 0, 0, 0, 0, - 50, 0, 0, 9, 18, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 63, 1, 64, - 0, 0, 0, 0, 0, 63, - 52, 0, 0, 7, 34, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 205, 204, 204, 62, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 15, - 114, 0, 16, 0, 0, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 144, 194, 53, 63, - 219, 249, 30, 63, 134, 235, - 209, 62, 0, 0, 0, 0, - 2, 64, 0, 0, 225, 122, - 148, 62, 74, 12, 194, 62, - 61, 10, 23, 63, 0, 0, - 0, 0, 56, 0, 0, 8, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 29, 0, 0, 0, 16, 0, - 0, 8, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 3, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 128, 65, 0, - 0, 0, 2, 0, 0, 0, - 52, 0, 0, 7, 18, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 47, 0, - 0, 5, 18, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 7, 18, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 200, 67, 25, 0, - 0, 5, 18, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 128, 65, 0, - 0, 0, 4, 0, 0, 0, - 70, 2, 16, 0, 6, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 9, 114, 0, 16, 0, - 2, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 7, 0, 0, 0, 50, 0, - 0, 12, 178, 0, 16, 0, - 1, 0, 0, 0, 6, 0, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 154, 153, - 153, 63, 154, 153, 153, 63, - 0, 0, 0, 0, 154, 153, - 153, 63, 70, 8, 16, 0, - 2, 0, 0, 0, 56, 0, - 0, 8, 178, 0, 16, 0, - 1, 0, 0, 0, 70, 12, - 16, 0, 1, 0, 0, 0, - 246, 143, 32, 0, 0, 0, - 0, 0, 29, 0, 0, 0, - 50, 0, 0, 9, 114, 32, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 246, 15, 16, 0, - 6, 0, 0, 0, 70, 3, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 11, 50, 0, - 16, 0, 0, 0, 0, 0, - 230, 138, 32, 0, 0, 0, - 0, 0, 10, 0, 0, 0, - 166, 10, 16, 0, 1, 0, - 0, 0, 230, 138, 32, 0, - 0, 0, 0, 0, 11, 0, - 0, 0, 14, 0, 0, 6, - 1, 192, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 130, 32, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 192, 0, - 0, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 155, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 0, 0, - 0, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 10, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/debugLinePS.hlsl b/demo/d3d11/shaders/debugLinePS.hlsl deleted file mode 100644 index d01847b..0000000 --- a/demo/d3d11/shaders/debugLinePS.hlsl +++ /dev/null @@ -1,10 +0,0 @@ -struct Input -{ - float4 position : SV_POSITION; - float4 color : COLOR; -}; - -float4 debugLinePS(Input input) : SV_TARGET -{ - return input.color; -} diff --git a/demo/d3d11/shaders/debugLinePS.hlsl.h b/demo/d3d11/shaders/debugLinePS.hlsl.h deleted file mode 100644 index 6243104..0000000 --- a/demo/d3d11/shaders/debugLinePS.hlsl.h +++ /dev/null @@ -1,121 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// COLOR 0 xyzw 1 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_input_ps linear v1.xyzw -dcl_output o0.xyzw -mov o0.xyzw, v1.xyzw -ret -// Approximately 2 instruction slots used -#endif - -const BYTE g_debugLinePS[] = -{ - 68, 88, 66, 67, 51, 80, - 148, 24, 206, 189, 182, 148, - 220, 111, 88, 236, 138, 6, - 146, 179, 1, 0, 0, 0, - 20, 2, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 172, 0, 0, 0, 0, 1, - 0, 0, 52, 1, 0, 0, - 120, 1, 0, 0, 82, 68, - 69, 70, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 60, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 76, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 15, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 67, 79, 76, 79, - 82, 0, 171, 171, 79, 83, - 71, 78, 44, 0, 0, 0, - 1, 0, 0, 0, 8, 0, - 0, 0, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 84, - 65, 82, 71, 69, 84, 0, - 171, 171, 83, 72, 69, 88, - 60, 0, 0, 0, 80, 0, - 0, 0, 15, 0, 0, 0, - 106, 8, 0, 1, 98, 16, - 0, 3, 242, 16, 16, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 0, 0, 0, 0, 70, 30, - 16, 0, 1, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/debugLineVS.hlsl b/demo/d3d11/shaders/debugLineVS.hlsl deleted file mode 100644 index 1033b35..0000000 --- a/demo/d3d11/shaders/debugLineVS.hlsl +++ /dev/null @@ -1,26 +0,0 @@ - -cbuffer params : register(b0) -{ - float4x4 projectionViewWorld; -}; - -struct Input -{ - float3 position : POSITION; - float4 color : COLOR; -}; - -struct Output -{ - float4 position : SV_POSITION; - float4 color : COLOR; -}; - -Output debugLineVS(Input input) -{ - Output output; - output.position = mul(projectionViewWorld, float4(input.position, 1.0f)); - output.color = input.color; - - return output; -} diff --git a/demo/d3d11/shaders/debugLineVS.hlsl.h b/demo/d3d11/shaders/debugLineVS.hlsl.h deleted file mode 100644 index cdf7e4b..0000000 --- a/demo/d3d11/shaders/debugLineVS.hlsl.h +++ /dev/null @@ -1,213 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer params -// { -// -// float4x4 projectionViewWorld; // Offset: 0 Size: 64 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// params cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyz 0 NONE float xyz -// COLOR 0 xyzw 1 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// COLOR 0 xyzw 1 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[4], immediateIndexed -dcl_input v0.xyz -dcl_input v1.xyzw -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -dcl_temps 1 -mul r0.xyzw, v0.yyyy, cb0[1].xyzw -mad r0.xyzw, cb0[0].xyzw, v0.xxxx, r0.xyzw -mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw -add o0.xyzw, r0.xyzw, cb0[3].xyzw -mov o1.xyzw, v1.xyzw -ret -// Approximately 6 instruction slots used -#endif - -const BYTE g_debugLineVS[] = -{ - 68, 88, 66, 67, 240, 24, - 40, 204, 192, 159, 63, 125, - 158, 223, 41, 237, 85, 39, - 230, 54, 1, 0, 0, 0, - 160, 3, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 88, 1, 0, 0, 168, 1, - 0, 0, 252, 1, 0, 0, - 4, 3, 0, 0, 82, 68, - 69, 70, 28, 1, 0, 0, - 1, 0, 0, 0, 100, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 232, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 112, 97, 114, 97, - 109, 115, 0, 171, 92, 0, - 0, 0, 1, 0, 0, 0, - 124, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 164, 0, - 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 2, 0, - 0, 0, 196, 0, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 112, 114, 111, 106, - 101, 99, 116, 105, 111, 110, - 86, 105, 101, 119, 87, 111, - 114, 108, 100, 0, 102, 108, - 111, 97, 116, 52, 120, 52, - 0, 171, 171, 171, 3, 0, - 3, 0, 4, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 184, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 72, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 7, 7, 0, 0, - 65, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 15, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 67, 79, 76, - 79, 82, 0, 171, 79, 83, - 71, 78, 76, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 67, 79, 76, 79, - 82, 0, 171, 171, 83, 72, - 69, 88, 0, 1, 0, 0, - 80, 0, 1, 0, 64, 0, - 0, 0, 106, 8, 0, 1, - 89, 0, 0, 4, 70, 142, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 95, 0, - 0, 3, 114, 16, 16, 0, - 0, 0, 0, 0, 95, 0, - 0, 3, 242, 16, 16, 0, - 1, 0, 0, 0, 103, 0, - 0, 4, 242, 32, 16, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 1, 0, - 0, 0, 104, 0, 0, 2, - 1, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 0, 0, 0, 0, 86, 21, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 6, 16, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 166, 26, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 1, 0, 0, 0, 70, 30, - 16, 0, 1, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 6, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/diffuseGS.hlsl b/demo/d3d11/shaders/diffuseGS.hlsl deleted file mode 100644 index e7a92db..0000000 --- a/demo/d3d11/shaders/diffuseGS.hlsl +++ /dev/null @@ -1,176 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - DiffuseShaderConst gParams; -}; - -static const float2 corners[4] = -{ - float2(0.0, 1.0), - float2(0.0, 0.0), - float2(1.0, 1.0), - float2(1.0, 0.0) -}; - -[maxvertexcount(4)] -void diffuseGS(point DiffuseVertexOut input[1], inout TriangleStream triStream) -{ - float4 ndcPos = input[0].ndcPos; - - // frustrum culling - const float ndcBound = 1.0; - if (ndcPos.x < -ndcBound) return; - if (ndcPos.x > ndcBound) return; - if (ndcPos.y < -ndcBound) return; - if (ndcPos.y > ndcBound) return; - - float pointScale = gParams.diffuseScale; - float velocityScale = 1.0; - - float3 v = input[0].viewVel.xyz; - float3 p = input[0].viewPos.xyz; - - // billboard in eye space - float3 u = float3(0.0, pointScale, 0.0); - float3 l = float3(pointScale, 0.0, 0.0); - - // increase size based on life - float lifeTime = input[0].worldPos.w; - - float lifeFade = lerp(1.0f + gParams.diffusion, 1.0, min(1.0, lifeTime*0.25f)); - u *= lifeFade; - l *= lifeFade; - - float fade = 1.0/(lifeFade*lifeFade); - float vlen = length(v)*gParams.motionBlurScale; - - if (vlen > 0.5) - { - float len = max(pointScale, vlen*0.016); - fade = min(1.0, 2.0/(len/pointScale)); - - u = normalize(v)*max(pointScale, vlen*0.016); // assume 60hz - l = normalize(cross(u, float3(0.0, 0.0, -1.0)))*pointScale; - } - - - { - - DiffuseGeometryOut output; - - output.worldPos = input[0].worldPos; // vertex world pos (life in w) - output.viewPos = input[0].viewPos; // vertex eye pos - output.viewVel.xyz = input[0].viewVel.xyz; // vertex velocity in view space - output.viewVel.w = fade; - output.lightDir = mul(gParams.modelView, float4(gParams.lightDir, 0.0)); - output.color = input[0].color; - - output.uv = float4(0.0, 1.0, 0.0, 0.0); - output.clipPos = mul(gParams.projection, float4(p + u - l, 1.0)); - triStream.Append(output); - - output.uv = float4(0.0, 0.0, 0.0, 0.0); - output.clipPos = mul(gParams.projection, float4(p - u - l, 1.0)); - triStream.Append(output); - - output.uv = float4(1.0, 1.0, 0.0, 0.0); - output.clipPos = mul(gParams.projection, float4(p + u + l, 1.0)); - triStream.Append(output); - - output.uv = float4(1.0, 0.0, 0.0, 0.0); - output.clipPos = mul(gParams.projection, float4(p - u + l, 1.0)); - triStream.Append(output); - } - -} - -#if 0 - - -const char *geometryDiffuseShader = -"#version 120\n" -"#extension GL_EXT_geometry_shader4 : enable\n" -STRINGIFY( - -uniform float pointScale; // point size in world space -uniform float motionBlurScale; -uniform float diffusion; -uniform vec3 lightDir; - -void main() -{ - vec4 ndcPos = gl_TexCoordIn[0][5]; - - // frustrum culling - const float ndcBound = 1.0; - if (ndcPos.x < -ndcBound) return; - if (ndcPos.x > ndcBound) return; - if (ndcPos.y < -ndcBound) return; - if (ndcPos.y > ndcBound) return; - - float velocityScale = 1.0; - - vec3 v = gl_TexCoordIn[0][3].xyz*velocityScale; - vec3 p = gl_TexCoordIn[0][2].xyz; - - // billboard in eye space - vec3 u = vec3(0.0, pointScale, 0.0); - vec3 l = vec3(pointScale, 0.0, 0.0); - - // increase size based on life - float lifeFade = mix(1.0f+diffusion, 1.0, min(1.0, gl_TexCoordIn[0][1].w*0.25f)); - u *= lifeFade; - l *= lifeFade; - - //lifeFade = 1.0; - - float fade = 1.0/(lifeFade*lifeFade); - float vlen = length(v)*motionBlurScale; - - if (vlen > 0.5) - { - float len = max(pointScale, vlen*0.016); - fade = min(1.0, 2.0/(len/pointScale)); - - u = normalize(v)*max(pointScale, vlen*0.016); // assume 60hz - l = normalize(cross(u, vec3(0.0, 0.0, -1.0)))*pointScale; - } - - { - - gl_TexCoord[1] = gl_TexCoordIn[0][1]; // vertex world pos (life in w) - gl_TexCoord[2] = gl_TexCoordIn[0][2]; // vertex eye pos - gl_TexCoord[3] = gl_TexCoordIn[0][3]; // vertex velocity in view space - gl_TexCoord[3].w = fade; - gl_TexCoord[4] = gl_ModelViewMatrix*vec4(lightDir, 0.0); - gl_TexCoord[4].w = gl_TexCoordIn[0][3].w; // attenuation - gl_TexCoord[5].xyzw = gl_TexCoordIn[0][4].xyzw; // color - - float zbias = 0.0f;//0.00125*2.0; - - gl_TexCoord[0] = vec4(0.0, 1.0, 0.0, 0.0); - gl_Position = gl_ProjectionMatrix * vec4(p + u - l, 1.0); - gl_Position.z -= zbias; - EmitVertex(); - - gl_TexCoord[0] = vec4(0.0, 0.0, 0.0, 0.0); - gl_Position = gl_ProjectionMatrix * vec4(p - u - l, 1.0); - gl_Position.z -= zbias; - EmitVertex(); - - gl_TexCoord[0] = vec4(1.0, 1.0, 0.0, 0.0); - gl_Position = gl_ProjectionMatrix * vec4(p + u + l, 1.0); - gl_Position.z -= zbias; - EmitVertex(); - - gl_TexCoord[0] = vec4(1.0, 0.0, 0.0, 0.0); - gl_Position = gl_ProjectionMatrix * vec4(p - u + l, 1.0); - gl_Position.z -= zbias; - EmitVertex(); - } -} -); - - -#endif \ No newline at end of file diff --git a/demo/d3d11/shaders/diffuseGS.hlsl.h b/demo/d3d11/shaders/diffuseGS.hlsl.h deleted file mode 100644 index 1f71735..0000000 --- a/demo/d3d11/shaders/diffuseGS.hlsl.h +++ /dev/null @@ -1,973 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct DiffuseShaderConst -// { -// -// float3 lightPos; // Offset: 0 -// float pad0; // Offset: 12 -// float3 lightDir; // Offset: 16 -// float pad1; // Offset: 28 -// float4x4 lightTransform; // Offset: 32 -// float4 color; // Offset: 96 -// float4x4 modelView; // Offset: 112 -// float4x4 modelViewProjection; // Offset: 176 -// float4x4 projection; // Offset: 240 -// float4 shadowTaps[12]; // Offset: 304 -// float diffusion; // Offset: 496 -// float diffuseRadius; // Offset: 500 -// float diffuseScale; // Offset: 504 -// float spotMin; // Offset: 508 -// float spotMax; // Offset: 512 -// float motionBlurScale; // Offset: 516 -// float pad3; // Offset: 520 -// float pad4; // Offset: 524 -// -// } gParams; // Offset: 0 Size: 528 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// NCDPOS 0 xyzw 1 NONE float xy -// VIEWPOS 0 xyzw 2 NONE float xyzw -// VIEWVEL 0 xyzw 3 NONE float xyz -// COLOR 0 xyzw 4 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// POSITION 0 xyzw 1 NONE float xyzw -// VIEWPOS 0 xyzw 2 NONE float xyzw -// VIEWVEL 0 xyzw 3 NONE float xyzw -// LIGHTDIR 0 xyzw 4 NONE float xyzw -// COLOR 0 xyzw 5 NONE float xyzw -// UV 0 xyzw 6 NONE float xyzw -// -gs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[33], immediateIndexed -dcl_input v[1][0].xyzw -dcl_input v[1][1].xyzw -dcl_input v[1][2].xyzw -dcl_input v[1][3].xyzw -dcl_input v[1][4].xyzw -dcl_temps 6 -dcl_inputprimitive point -dcl_stream m0 -dcl_outputtopology trianglestrip -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -dcl_output o2.xyzw -dcl_output o3.xyzw -dcl_output o4.xyzw -dcl_output o5.xyzw -dcl_output o6.xyzw -dcl_maxout 4 -lt r0.x, v[0][1].x, l(-1.000000) -if_nz r0.x - ret -endif -lt r0.x, l(1.000000), v[0][1].x -if_nz r0.x - ret -endif -lt r0.x, v[0][1].y, l(-1.000000) -if_nz r0.x - ret -endif -lt r0.x, l(1.000000), v[0][1].y -if_nz r0.x - ret -endif -add r0.x, cb0[31].x, l(1.000000) -mul r0.y, l(0.250000), v[0][0].w -min r0.y, r0.y, l(1.000000) -add r0.z, -r0.x, l(1.000000) -mad r0.x, r0.y, r0.z, r0.x -mov r1.x, cb0[31].z -mov r1.yz, l(0,0,0,0) -mul r1.xyz, r0.xxxx, r1.xyzx -mul r0.x, r0.x, r0.x -div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x -dp3 r0.x, v[0][3].xyzx, v[0][3].xyzx -sqrt r0.y, r0.x -mul r0.y, r0.y, cb0[32].y -lt r0.z, l(0.500000), r0.y -mul r0.y, r0.y, l(0.016000) -max r0.y, r0.y, cb0[31].z -div r0.w, r0.y, cb0[31].z -div r0.w, l(2.000000), r0.w -min r2.w, r0.w, l(1.000000) -rsq r0.x, r0.x -mul r3.xyz, r0.xxxx, v[0][3].xyzx -mul r0.xyw, r0.yyyy, r3.xyxz -mul r3.xyz, r0.wxyw, l(0.000000, -1.000000, 0.000000, 0.000000) -mad r3.xyz, r0.ywxy, l(-1.000000, 0.000000, 0.000000, 0.000000), -r3.xyzx -dp2 r3.w, r3.xyxx, r3.xyxx -rsq r3.w, r3.w -mul r3.xyz, r3.wwww, r3.xyzx -mul r2.xyz, r3.xyzx, cb0[31].zzzz -movc r0.xyw, r0.zzzz, r0.xyxw, r1.zxzz -movc r1.xyzw, r0.zzzz, r2.xyzw, r1.xyzw -mul r2.xyzw, cb0[1].yyyy, cb0[8].xyzw -mad r2.xyzw, cb0[7].xyzw, cb0[1].xxxx, r2.xyzw -mad r2.xyzw, cb0[9].xyzw, cb0[1].zzzz, r2.xyzw -add r3.xyz, r0.xywx, v[0][2].xyzx -add r4.xyz, -r1.xyzx, r3.xyzx -mul r5.xyzw, r4.yyyy, cb0[16].xyzw -mad r5.xyzw, cb0[15].xyzw, r4.xxxx, r5.xyzw -mad r4.xyzw, cb0[17].xyzw, r4.zzzz, r5.xyzw -add r4.xyzw, r4.xyzw, cb0[18].xyzw -mov o0.xyzw, r4.xyzw -mov o1.xyzw, v[0][0].xyzw -mov o2.xyzw, v[0][2].xyzw -mov o3.xyz, v[0][3].xyzx -mov o3.w, r1.w -mov o4.xyzw, r2.xyzw -mov o5.xyzw, v[0][4].xyzw -mov o6.xyzw, l(0,1.000000,0,0) -emit_stream m0 -add r0.xyz, -r0.xywx, v[0][2].xyzx -add r4.xyz, -r1.xyzx, r0.xyzx -mul r5.xyzw, r4.yyyy, cb0[16].xyzw -mad r5.xyzw, cb0[15].xyzw, r4.xxxx, r5.xyzw -mad r4.xyzw, cb0[17].xyzw, r4.zzzz, r5.xyzw -add r4.xyzw, r4.xyzw, cb0[18].xyzw -mov o0.xyzw, r4.xyzw -mov o1.xyzw, v[0][0].xyzw -mov o2.xyzw, v[0][2].xyzw -mov o3.xyz, v[0][3].xyzx -mov o3.w, r1.w -mov o4.xyzw, r2.xyzw -mov o5.xyzw, v[0][4].xyzw -mov o6.xyzw, l(0,0,0,0) -emit_stream m0 -add r3.xyz, r1.xyzx, r3.xyzx -mul r4.xyzw, r3.yyyy, cb0[16].xyzw -mad r4.xyzw, cb0[15].xyzw, r3.xxxx, r4.xyzw -mad r3.xyzw, cb0[17].xyzw, r3.zzzz, r4.xyzw -add r3.xyzw, r3.xyzw, cb0[18].xyzw -mov o0.xyzw, r3.xyzw -mov o1.xyzw, v[0][0].xyzw -mov o2.xyzw, v[0][2].xyzw -mov o3.xyz, v[0][3].xyzx -mov o3.w, r1.w -mov o4.xyzw, r2.xyzw -mov o5.xyzw, v[0][4].xyzw -mov o6.xyzw, l(1.000000,1.000000,0,0) -emit_stream m0 -add r0.xyz, r1.xyzx, r0.xyzx -mul r3.xyzw, r0.yyyy, cb0[16].xyzw -mad r3.xyzw, cb0[15].xyzw, r0.xxxx, r3.xyzw -mad r0.xyzw, cb0[17].xyzw, r0.zzzz, r3.xyzw -add r0.xyzw, r0.xyzw, cb0[18].xyzw -mov o0.xyzw, r0.xyzw -mov o1.xyzw, v[0][0].xyzw -mov o2.xyzw, v[0][2].xyzw -mov o3.xyz, v[0][3].xyzx -mov o3.w, r1.w -mov o4.xyzw, r2.xyzw -mov o5.xyzw, v[0][4].xyzw -mov o6.xyzw, l(1.000000,0,0,0) -emit_stream m0 -ret -// Approximately 108 instruction slots used -#endif - -const BYTE g_diffuseGS[] = -{ - 68, 88, 66, 67, 206, 113, - 108, 237, 96, 228, 115, 111, - 205, 11, 177, 210, 155, 123, - 232, 125, 1, 0, 0, 0, - 16, 18, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 188, 3, 0, 0, 108, 4, - 0, 0, 120, 5, 0, 0, - 116, 17, 0, 0, 82, 68, - 69, 70, 128, 3, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 83, 71, 0, 1, 0, 0, - 76, 3, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 16, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 16, 2, - 0, 0, 2, 0, 0, 0, - 40, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 68, 105, 102, 102, - 117, 115, 101, 83, 104, 97, - 100, 101, 114, 67, 111, 110, - 115, 116, 0, 108, 105, 103, - 104, 116, 80, 111, 115, 0, - 102, 108, 111, 97, 116, 51, - 0, 171, 1, 0, 3, 0, - 1, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 204, 0, - 0, 0, 112, 97, 100, 48, - 0, 102, 108, 111, 97, 116, - 0, 171, 0, 0, 3, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 253, 0, - 0, 0, 108, 105, 103, 104, - 116, 68, 105, 114, 0, 112, - 97, 100, 49, 0, 108, 105, - 103, 104, 116, 84, 114, 97, - 110, 115, 102, 111, 114, 109, - 0, 102, 108, 111, 97, 116, - 52, 120, 52, 0, 171, 171, - 3, 0, 3, 0, 4, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 69, 1, 0, 0, - 99, 111, 108, 111, 114, 0, - 102, 108, 111, 97, 116, 52, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 122, 1, 0, 0, 109, 111, - 100, 101, 108, 86, 105, 101, - 119, 0, 109, 111, 100, 101, - 108, 86, 105, 101, 119, 80, - 114, 111, 106, 101, 99, 116, - 105, 111, 110, 0, 112, 114, - 111, 106, 101, 99, 116, 105, - 111, 110, 0, 115, 104, 97, - 100, 111, 119, 84, 97, 112, - 115, 0, 1, 0, 3, 0, - 1, 0, 4, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 122, 1, - 0, 0, 100, 105, 102, 102, - 117, 115, 105, 111, 110, 0, - 100, 105, 102, 102, 117, 115, - 101, 82, 97, 100, 105, 117, - 115, 0, 100, 105, 102, 102, - 117, 115, 101, 83, 99, 97, - 108, 101, 0, 115, 112, 111, - 116, 77, 105, 110, 0, 115, - 112, 111, 116, 77, 97, 120, - 0, 109, 111, 116, 105, 111, - 110, 66, 108, 117, 114, 83, - 99, 97, 108, 101, 0, 112, - 97, 100, 51, 0, 112, 97, - 100, 52, 0, 171, 195, 0, - 0, 0, 212, 0, 0, 0, - 0, 0, 0, 0, 248, 0, - 0, 0, 4, 1, 0, 0, - 12, 0, 0, 0, 40, 1, - 0, 0, 212, 0, 0, 0, - 16, 0, 0, 0, 49, 1, - 0, 0, 4, 1, 0, 0, - 28, 0, 0, 0, 54, 1, - 0, 0, 80, 1, 0, 0, - 32, 0, 0, 0, 116, 1, - 0, 0, 132, 1, 0, 0, - 96, 0, 0, 0, 168, 1, - 0, 0, 80, 1, 0, 0, - 112, 0, 0, 0, 178, 1, - 0, 0, 80, 1, 0, 0, - 176, 0, 0, 0, 198, 1, - 0, 0, 80, 1, 0, 0, - 240, 0, 0, 0, 209, 1, - 0, 0, 220, 1, 0, 0, - 48, 1, 0, 0, 0, 2, - 0, 0, 4, 1, 0, 0, - 240, 1, 0, 0, 10, 2, - 0, 0, 4, 1, 0, 0, - 244, 1, 0, 0, 24, 2, - 0, 0, 4, 1, 0, 0, - 248, 1, 0, 0, 37, 2, - 0, 0, 4, 1, 0, 0, - 252, 1, 0, 0, 45, 2, - 0, 0, 4, 1, 0, 0, - 0, 2, 0, 0, 53, 2, - 0, 0, 4, 1, 0, 0, - 4, 2, 0, 0, 69, 2, - 0, 0, 4, 1, 0, 0, - 8, 2, 0, 0, 74, 2, - 0, 0, 4, 1, 0, 0, - 12, 2, 0, 0, 5, 0, - 0, 0, 1, 0, 132, 0, - 0, 0, 18, 0, 80, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 176, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 168, 0, 0, 0, 5, 0, - 0, 0, 8, 0, 0, 0, - 128, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 137, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 3, 0, 0, - 144, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 15, 0, 0, - 152, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 7, 0, 0, - 160, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 4, 0, - 0, 0, 15, 15, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 78, 67, 68, - 80, 79, 83, 0, 86, 73, - 69, 87, 80, 79, 83, 0, - 86, 73, 69, 87, 86, 69, - 76, 0, 67, 79, 76, 79, - 82, 0, 171, 171, 79, 83, - 71, 53, 4, 1, 0, 0, - 7, 0, 0, 0, 8, 0, - 0, 0, 0, 0, 0, 0, - 204, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 216, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 0, 0, 0, 0, 0, - 0, 0, 225, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 0, - 0, 0, 0, 0, 0, 0, - 233, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 241, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 4, 0, 0, 0, - 15, 0, 0, 0, 0, 0, - 0, 0, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 5, 0, 0, 0, 15, 0, - 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 6, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 80, 79, 83, - 73, 84, 73, 79, 78, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 86, 73, 69, - 87, 80, 79, 83, 0, 86, - 73, 69, 87, 86, 69, 76, - 0, 76, 73, 71, 72, 84, - 68, 73, 82, 0, 67, 79, - 76, 79, 82, 0, 85, 86, - 0, 171, 83, 72, 69, 88, - 244, 11, 0, 0, 80, 0, - 2, 0, 253, 2, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 4, 70, 142, 32, 0, - 0, 0, 0, 0, 33, 0, - 0, 0, 95, 0, 0, 4, - 242, 16, 32, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 95, 0, 0, 4, 242, 16, - 32, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 95, 0, - 0, 4, 242, 16, 32, 0, - 1, 0, 0, 0, 2, 0, - 0, 0, 95, 0, 0, 4, - 242, 16, 32, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 95, 0, 0, 4, 242, 16, - 32, 0, 1, 0, 0, 0, - 4, 0, 0, 0, 104, 0, - 0, 2, 6, 0, 0, 0, - 93, 8, 0, 1, 143, 0, - 0, 3, 0, 0, 17, 0, - 0, 0, 0, 0, 92, 40, - 0, 1, 103, 0, 0, 4, - 242, 32, 16, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 2, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 3, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 4, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 5, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 6, 0, 0, 0, - 94, 0, 0, 2, 4, 0, - 0, 0, 49, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 10, 16, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 191, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 62, 0, - 0, 1, 21, 0, 0, 1, - 49, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 10, 16, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 31, 0, 4, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 21, 0, 0, 1, 49, 0, - 0, 8, 18, 0, 16, 0, - 0, 0, 0, 0, 26, 16, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 191, - 31, 0, 4, 3, 10, 0, - 16, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 21, 0, - 0, 1, 49, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 26, 16, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 62, 0, - 0, 1, 21, 0, 0, 1, - 0, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 31, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 34, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 62, 58, 16, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 51, 0, - 0, 7, 34, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 0, 0, 0, 8, - 66, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 50, 0, - 0, 9, 18, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 6, 18, 0, 16, 0, - 1, 0, 0, 0, 42, 128, - 32, 0, 0, 0, 0, 0, - 31, 0, 0, 0, 54, 0, - 0, 8, 98, 0, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 114, 0, - 16, 0, 1, 0, 0, 0, - 6, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 14, 0, 0, 10, - 130, 0, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 128, 63, 10, 0, - 16, 0, 0, 0, 0, 0, - 16, 0, 0, 9, 18, 0, - 16, 0, 0, 0, 0, 0, - 70, 18, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 70, 18, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 75, 0, 0, 5, 34, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 8, - 34, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 26, 128, - 32, 0, 0, 0, 0, 0, - 32, 0, 0, 0, 49, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 63, - 26, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 34, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 131, 60, - 52, 0, 0, 8, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 42, 128, 32, 0, - 0, 0, 0, 0, 31, 0, - 0, 0, 14, 0, 0, 8, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 42, 128, - 32, 0, 0, 0, 0, 0, - 31, 0, 0, 0, 14, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 64, - 58, 0, 16, 0, 0, 0, - 0, 0, 51, 0, 0, 7, - 130, 0, 16, 0, 2, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 68, 0, 0, 5, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 8, - 114, 0, 16, 0, 3, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 70, 18, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 56, 0, - 0, 7, 178, 0, 16, 0, - 0, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 70, 8, 16, 0, 3, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 54, 13, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 50, 0, 0, 13, 114, 0, - 16, 0, 3, 0, 0, 0, - 214, 4, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 128, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 3, 0, 0, 0, 15, 0, - 0, 7, 130, 0, 16, 0, - 3, 0, 0, 0, 70, 0, - 16, 0, 3, 0, 0, 0, - 70, 0, 16, 0, 3, 0, - 0, 0, 68, 0, 0, 5, - 130, 0, 16, 0, 3, 0, - 0, 0, 58, 0, 16, 0, - 3, 0, 0, 0, 56, 0, - 0, 7, 114, 0, 16, 0, - 3, 0, 0, 0, 246, 15, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 56, 0, 0, 8, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 166, 138, - 32, 0, 0, 0, 0, 0, - 31, 0, 0, 0, 55, 0, - 0, 9, 178, 0, 16, 0, - 0, 0, 0, 0, 166, 10, - 16, 0, 0, 0, 0, 0, - 70, 12, 16, 0, 0, 0, - 0, 0, 38, 10, 16, 0, - 1, 0, 0, 0, 55, 0, - 0, 9, 242, 0, 16, 0, - 1, 0, 0, 0, 166, 10, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 9, 242, 0, 16, 0, - 2, 0, 0, 0, 86, 133, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 50, 0, - 0, 11, 242, 0, 16, 0, - 2, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 6, 128, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 70, 14, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 11, 242, 0, - 16, 0, 2, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 9, 0, 0, 0, - 166, 138, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 3, 16, 0, - 0, 0, 0, 0, 70, 18, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 8, 114, 0, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 3, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 5, 0, 0, 0, - 86, 5, 16, 0, 4, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 16, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 5, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 6, 0, 16, 0, - 4, 0, 0, 0, 70, 14, - 16, 0, 5, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 17, 0, 0, 0, - 166, 10, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 5, 0, 0, 0, 0, 0, - 0, 8, 242, 0, 16, 0, - 4, 0, 0, 0, 70, 14, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 18, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 4, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 1, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 2, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 54, 0, 0, 6, - 114, 32, 16, 0, 3, 0, - 0, 0, 70, 18, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 54, 0, 0, 5, - 130, 32, 16, 0, 3, 0, - 0, 0, 58, 0, 16, 0, - 1, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 4, 0, 0, 0, 70, 14, - 16, 0, 2, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 5, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 54, 0, 0, 8, 242, 32, - 16, 0, 6, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 117, 0, 0, 3, - 0, 0, 17, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 3, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 70, 18, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 4, 0, - 0, 0, 70, 2, 16, 128, - 65, 0, 0, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 5, 0, 0, 0, 86, 5, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 16, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 5, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 6, 0, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 5, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 4, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 166, 10, - 16, 0, 4, 0, 0, 0, - 70, 14, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 8, - 242, 0, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 4, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 18, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 4, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 1, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 2, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 54, 0, 0, 6, 114, 32, - 16, 0, 3, 0, 0, 0, - 70, 18, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 5, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 54, 0, - 0, 8, 242, 32, 16, 0, - 6, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 117, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 4, 0, 0, 0, 86, 5, - 16, 0, 3, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 16, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 6, 0, 16, 0, 3, 0, - 0, 0, 70, 14, 16, 0, - 4, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 3, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 166, 10, - 16, 0, 3, 0, 0, 0, - 70, 14, 16, 0, 4, 0, - 0, 0, 0, 0, 0, 8, - 242, 0, 16, 0, 3, 0, - 0, 0, 70, 14, 16, 0, - 3, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 18, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 3, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 1, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 2, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 54, 0, 0, 6, 114, 32, - 16, 0, 3, 0, 0, 0, - 70, 18, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 5, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 54, 0, - 0, 8, 242, 32, 16, 0, - 6, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 117, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 3, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 16, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 3, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 6, 0, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 166, 10, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 3, 0, - 0, 0, 0, 0, 0, 8, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 18, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 1, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 2, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 54, 0, 0, 6, 114, 32, - 16, 0, 3, 0, 0, 0, - 70, 18, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 5, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 54, 0, - 0, 8, 242, 32, 16, 0, - 6, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 117, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 108, 0, 0, 0, 6, 0, - 0, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 55, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 5, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/diffusePS.hlsl b/demo/d3d11/shaders/diffusePS.hlsl deleted file mode 100644 index c6e474e..0000000 --- a/demo/d3d11/shaders/diffusePS.hlsl +++ /dev/null @@ -1,37 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - DiffuseShaderConst gParams; -}; - -float sqr(float x) { return x * x; } - - -float4 diffusePS(DiffuseGeometryOut input - //, out float gl_FragDepth : SV_DEPTH -) : SV_TARGET -{ - //return float4(1.0f, 0.0f, 0.0f, 1.0f); - - float attenuation = 1.0f; - float lifeTime = input.worldPos.w; - float lifeFade = min(1.0, lifeTime*0.125); - float velocityFade = input.viewVel.w; - - // calculate normal from texture coordinates - float3 normal; - normal.xy = input.uv.xy*float2(2.0, 2.0) + float2(-1.0, -1.0); - float mag = dot(normal.xy, normal.xy); - - // kill pixels outside circle - if (mag > 1.0) - discard; - - normal.z = 1.0-mag; - - float alpha = lifeFade*velocityFade*sqr(normal.z); - - return float4(alpha, alpha, alpha, alpha); - -} diff --git a/demo/d3d11/shaders/diffusePS.hlsl.h b/demo/d3d11/shaders/diffusePS.hlsl.h deleted file mode 100644 index b77dc1c..0000000 --- a/demo/d3d11/shaders/diffusePS.hlsl.h +++ /dev/null @@ -1,216 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// POSITION 0 xyzw 1 NONE float w -// VIEWPOS 0 xyzw 2 NONE float -// VIEWVEL 0 xyzw 3 NONE float w -// LIGHTDIR 0 xyzw 4 NONE float -// COLOR 0 xyzw 5 NONE float -// UV 0 xyzw 6 NONE float xy -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_input_ps linear v1.w -dcl_input_ps linear v3.w -dcl_input_ps linear v6.xy -dcl_output o0.xyzw -dcl_temps 1 -mad r0.xy, v6.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000) -dp2 r0.x, r0.xyxx, r0.xyxx -lt r0.y, l(1.000000), r0.x -discard_nz r0.y -mul r0.y, v1.w, l(0.125000) -min r0.y, r0.y, l(1.000000) -add r0.x, -r0.x, l(1.000000) -mul r0.y, r0.y, v3.w -mul r0.x, r0.x, r0.x -mul o0.xyzw, r0.xxxx, r0.yyyy -ret -// Approximately 11 instruction slots used -#endif - -const BYTE g_diffusePS[] = -{ - 68, 88, 66, 67, 142, 84, - 94, 27, 80, 231, 240, 136, - 237, 253, 148, 77, 42, 64, - 90, 183, 1, 0, 0, 0, - 232, 3, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 172, 0, 0, 0, 156, 1, - 0, 0, 208, 1, 0, 0, - 76, 3, 0, 0, 82, 68, - 69, 70, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 60, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 232, 0, 0, 0, - 7, 0, 0, 0, 8, 0, - 0, 0, 176, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 188, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 8, - 0, 0, 197, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 0, - 0, 0, 205, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 15, 8, - 0, 0, 213, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 0, - 0, 0, 222, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 5, 0, 0, 0, 15, 0, - 0, 0, 228, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 6, 0, 0, 0, 15, 3, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 80, 79, 83, 73, - 84, 73, 79, 78, 0, 86, - 73, 69, 87, 80, 79, 83, - 0, 86, 73, 69, 87, 86, - 69, 76, 0, 76, 73, 71, - 72, 84, 68, 73, 82, 0, - 67, 79, 76, 79, 82, 0, - 85, 86, 0, 171, 79, 83, - 71, 78, 44, 0, 0, 0, - 1, 0, 0, 0, 8, 0, - 0, 0, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 84, - 65, 82, 71, 69, 84, 0, - 171, 171, 83, 72, 69, 88, - 116, 1, 0, 0, 80, 0, - 0, 0, 93, 0, 0, 0, - 106, 8, 0, 1, 98, 16, - 0, 3, 130, 16, 16, 0, - 1, 0, 0, 0, 98, 16, - 0, 3, 130, 16, 16, 0, - 3, 0, 0, 0, 98, 16, - 0, 3, 50, 16, 16, 0, - 6, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 0, 0, 0, 0, 104, 0, - 0, 2, 1, 0, 0, 0, - 50, 0, 0, 15, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 6, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 191, - 0, 0, 128, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 49, 0, - 0, 7, 34, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 10, 0, 16, 0, 0, 0, - 0, 0, 13, 0, 4, 3, - 26, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 34, 0, 16, 0, 0, 0, - 0, 0, 58, 16, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 62, - 51, 0, 0, 7, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 0, 0, - 0, 8, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 7, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 58, 16, 16, 0, - 3, 0, 0, 0, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 242, 32, 16, 0, 0, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 11, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 9, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/diffuseVS.hlsl b/demo/d3d11/shaders/diffuseVS.hlsl deleted file mode 100644 index afca738..0000000 --- a/demo/d3d11/shaders/diffuseVS.hlsl +++ /dev/null @@ -1,26 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - DiffuseShaderConst gParams; -}; - -DiffuseVertexOut diffuseVS(DiffuseVertexIn input) -{ - float3 worldPos = input.position.xyz; - float4 eyePos = mul(gParams.modelView, float4(worldPos, 1.0)); - - DiffuseVertexOut output; - - output.worldPos = input.position; // lifetime in w - output.viewPos = eyePos; - output.viewVel = mul(gParams.modelView, float4(input.velocity.xyz, 0.0)); - output.color = gParams.color; - - // compute ndc pos for frustrum culling in GS - float4 ndcPos = mul(gParams.modelViewProjection, float4(worldPos.xyz, 1.0)); - output.ndcPos = ndcPos / ndcPos.w; - - return output; - -} diff --git a/demo/d3d11/shaders/diffuseVS.hlsl.h b/demo/d3d11/shaders/diffuseVS.hlsl.h deleted file mode 100644 index 7db0a8c..0000000 --- a/demo/d3d11/shaders/diffuseVS.hlsl.h +++ /dev/null @@ -1,425 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct DiffuseShaderConst -// { -// -// float3 lightPos; // Offset: 0 -// float pad0; // Offset: 12 -// float3 lightDir; // Offset: 16 -// float pad1; // Offset: 28 -// float4x4 lightTransform; // Offset: 32 -// float4 color; // Offset: 96 -// float4x4 modelView; // Offset: 112 -// float4x4 modelViewProjection; // Offset: 176 -// float4x4 projection; // Offset: 240 -// float4 shadowTaps[12]; // Offset: 304 -// float diffusion; // Offset: 496 -// float diffuseRadius; // Offset: 500 -// float diffuseScale; // Offset: 504 -// float spotMin; // Offset: 508 -// float spotMax; // Offset: 512 -// float motionBlurScale; // Offset: 516 -// float pad3; // Offset: 520 -// float pad4; // Offset: 524 -// -// } gParams; // Offset: 0 Size: 528 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// VELOCITY 0 xyzw 1 NONE float xyz -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// NCDPOS 0 xyzw 1 NONE float xyzw -// VIEWPOS 0 xyzw 2 NONE float xyzw -// VIEWVEL 0 xyzw 3 NONE float xyzw -// COLOR 0 xyzw 4 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[15], immediateIndexed -dcl_input v0.xyzw -dcl_input v1.xyz -dcl_output o0.xyzw -dcl_output o1.xyzw -dcl_output o2.xyzw -dcl_output o3.xyzw -dcl_output o4.xyzw -dcl_temps 1 -mov o0.xyzw, v0.xyzw -mul r0.xyzw, v0.yyyy, cb0[12].xyzw -mad r0.xyzw, cb0[11].xyzw, v0.xxxx, r0.xyzw -mad r0.xyzw, cb0[13].xyzw, v0.zzzz, r0.xyzw -add r0.xyzw, r0.xyzw, cb0[14].xyzw -div o1.xyzw, r0.xyzw, r0.wwww -mul r0.xyzw, v0.yyyy, cb0[8].xyzw -mad r0.xyzw, cb0[7].xyzw, v0.xxxx, r0.xyzw -mad r0.xyzw, cb0[9].xyzw, v0.zzzz, r0.xyzw -add o2.xyzw, r0.xyzw, cb0[10].xyzw -mul r0.xyzw, v1.yyyy, cb0[8].xyzw -mad r0.xyzw, cb0[7].xyzw, v1.xxxx, r0.xyzw -mad o3.xyzw, cb0[9].xyzw, v1.zzzz, r0.xyzw -mov o4.xyzw, cb0[6].xyzw -ret -// Approximately 15 instruction slots used -#endif - -const BYTE g_diffuseVS[] = -{ - 68, 88, 66, 67, 169, 46, - 39, 192, 132, 15, 181, 233, - 181, 235, 144, 49, 232, 212, - 251, 135, 1, 0, 0, 0, - 184, 7, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 188, 3, 0, 0, 16, 4, - 0, 0, 192, 4, 0, 0, - 28, 7, 0, 0, 82, 68, - 69, 70, 128, 3, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 76, 3, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 16, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 16, 2, - 0, 0, 2, 0, 0, 0, - 40, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 68, 105, 102, 102, - 117, 115, 101, 83, 104, 97, - 100, 101, 114, 67, 111, 110, - 115, 116, 0, 108, 105, 103, - 104, 116, 80, 111, 115, 0, - 102, 108, 111, 97, 116, 51, - 0, 171, 1, 0, 3, 0, - 1, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 204, 0, - 0, 0, 112, 97, 100, 48, - 0, 102, 108, 111, 97, 116, - 0, 171, 0, 0, 3, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 253, 0, - 0, 0, 108, 105, 103, 104, - 116, 68, 105, 114, 0, 112, - 97, 100, 49, 0, 108, 105, - 103, 104, 116, 84, 114, 97, - 110, 115, 102, 111, 114, 109, - 0, 102, 108, 111, 97, 116, - 52, 120, 52, 0, 171, 171, - 3, 0, 3, 0, 4, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 69, 1, 0, 0, - 99, 111, 108, 111, 114, 0, - 102, 108, 111, 97, 116, 52, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 122, 1, 0, 0, 109, 111, - 100, 101, 108, 86, 105, 101, - 119, 0, 109, 111, 100, 101, - 108, 86, 105, 101, 119, 80, - 114, 111, 106, 101, 99, 116, - 105, 111, 110, 0, 112, 114, - 111, 106, 101, 99, 116, 105, - 111, 110, 0, 115, 104, 97, - 100, 111, 119, 84, 97, 112, - 115, 0, 1, 0, 3, 0, - 1, 0, 4, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 122, 1, - 0, 0, 100, 105, 102, 102, - 117, 115, 105, 111, 110, 0, - 100, 105, 102, 102, 117, 115, - 101, 82, 97, 100, 105, 117, - 115, 0, 100, 105, 102, 102, - 117, 115, 101, 83, 99, 97, - 108, 101, 0, 115, 112, 111, - 116, 77, 105, 110, 0, 115, - 112, 111, 116, 77, 97, 120, - 0, 109, 111, 116, 105, 111, - 110, 66, 108, 117, 114, 83, - 99, 97, 108, 101, 0, 112, - 97, 100, 51, 0, 112, 97, - 100, 52, 0, 171, 195, 0, - 0, 0, 212, 0, 0, 0, - 0, 0, 0, 0, 248, 0, - 0, 0, 4, 1, 0, 0, - 12, 0, 0, 0, 40, 1, - 0, 0, 212, 0, 0, 0, - 16, 0, 0, 0, 49, 1, - 0, 0, 4, 1, 0, 0, - 28, 0, 0, 0, 54, 1, - 0, 0, 80, 1, 0, 0, - 32, 0, 0, 0, 116, 1, - 0, 0, 132, 1, 0, 0, - 96, 0, 0, 0, 168, 1, - 0, 0, 80, 1, 0, 0, - 112, 0, 0, 0, 178, 1, - 0, 0, 80, 1, 0, 0, - 176, 0, 0, 0, 198, 1, - 0, 0, 80, 1, 0, 0, - 240, 0, 0, 0, 209, 1, - 0, 0, 220, 1, 0, 0, - 48, 1, 0, 0, 0, 2, - 0, 0, 4, 1, 0, 0, - 240, 1, 0, 0, 10, 2, - 0, 0, 4, 1, 0, 0, - 244, 1, 0, 0, 24, 2, - 0, 0, 4, 1, 0, 0, - 248, 1, 0, 0, 37, 2, - 0, 0, 4, 1, 0, 0, - 252, 1, 0, 0, 45, 2, - 0, 0, 4, 1, 0, 0, - 0, 2, 0, 0, 53, 2, - 0, 0, 4, 1, 0, 0, - 4, 2, 0, 0, 69, 2, - 0, 0, 4, 1, 0, 0, - 8, 2, 0, 0, 74, 2, - 0, 0, 4, 1, 0, 0, - 12, 2, 0, 0, 5, 0, - 0, 0, 1, 0, 132, 0, - 0, 0, 18, 0, 80, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 176, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 76, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 65, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 7, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 86, 69, 76, - 79, 67, 73, 84, 89, 0, - 171, 171, 79, 83, 71, 78, - 168, 0, 0, 0, 5, 0, - 0, 0, 8, 0, 0, 0, - 128, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 137, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 0, 0, 0, - 144, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 0, 0, 0, - 152, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 0, 0, 0, - 160, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 4, 0, - 0, 0, 15, 0, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 78, 67, 68, - 80, 79, 83, 0, 86, 73, - 69, 87, 80, 79, 83, 0, - 86, 73, 69, 87, 86, 69, - 76, 0, 67, 79, 76, 79, - 82, 0, 171, 171, 83, 72, - 69, 88, 84, 2, 0, 0, - 80, 0, 1, 0, 149, 0, - 0, 0, 106, 8, 0, 1, - 89, 0, 0, 4, 70, 142, - 32, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 95, 0, - 0, 3, 242, 16, 16, 0, - 0, 0, 0, 0, 95, 0, - 0, 3, 114, 16, 16, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 0, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 2, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 3, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 4, 0, 0, 0, 104, 0, - 0, 2, 1, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 0, 0, 0, 0, - 70, 30, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 8, - 242, 0, 16, 0, 0, 0, - 0, 0, 86, 21, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 11, 0, 0, 0, 6, 16, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 13, 0, - 0, 0, 166, 26, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 14, 0, - 0, 0, 14, 0, 0, 7, - 242, 32, 16, 0, 1, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 0, 0, 0, 0, - 86, 21, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 7, 0, - 0, 0, 6, 16, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 9, 0, 0, 0, - 166, 26, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 0, 0, - 0, 8, 242, 32, 16, 0, - 2, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 10, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 0, 0, 0, 0, - 86, 21, 16, 0, 1, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 7, 0, - 0, 0, 6, 16, 16, 0, - 1, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 10, 242, 32, - 16, 0, 3, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 9, 0, 0, 0, - 166, 26, 16, 0, 1, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 4, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 15, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 7, 0, - 0, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/ellipsoidDepthGS.hlsl b/demo/d3d11/shaders/ellipsoidDepthGS.hlsl deleted file mode 100644 index 8c892e4..0000000 --- a/demo/d3d11/shaders/ellipsoidDepthGS.hlsl +++ /dev/null @@ -1,127 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - FluidShaderConst gParams; -}; - -static const float2 corners[4] = -{ - float2(0.0, 1.0), float2(0.0, 0.0), float2(1.0, 1.0), float2(1.0, 0.0) -}; - -[maxvertexcount(4)] -void ellipsoidDepthGS(point FluidVertexOut input[1], inout TriangleStream triStream) -{ - float4 gl_Position; - float4 gl_TexCoord[6]; - - float4 gl_PositionIn[1]; - float4 gl_TexCoordIn[1][6]; - - gl_PositionIn[0] = input[0].position; - { - [unroll] - for (int i = 0; i < 6; i++) - gl_TexCoordIn[0][i] = input[0].texCoord[i]; - } - - float3 pos = gl_PositionIn[0].xyz; - float4 bounds = gl_TexCoordIn[0][0]; - float4 ndcPos = gl_TexCoordIn[0][5]; - - if (ndcPos.w < 0.0) - return; - - // frustrum culling - const float ndcBound = 1.0; - if (ndcPos.x < -ndcBound) return; - if (ndcPos.x > ndcBound) return; - if (ndcPos.y < -ndcBound) return; - if (ndcPos.y > ndcBound) return; - - float xmin = bounds.x; - float xmax = bounds.y; - float ymin = bounds.z; - float ymax = bounds.w; - - - // inv quadric transform - gl_TexCoord[0] = gl_TexCoordIn[0][1]; - gl_TexCoord[1] = gl_TexCoordIn[0][2]; - gl_TexCoord[2] = gl_TexCoordIn[0][3]; - gl_TexCoord[3] = gl_TexCoordIn[0][4]; - - FluidGeoOut output; - - gl_Position = float4(xmin, ymax, 0.5, 1.0); - output.position = gl_Position; - output.texCoord[0] = gl_TexCoord[0]; - output.texCoord[1] = gl_TexCoord[1]; - output.texCoord[2] = gl_TexCoord[2]; - output.texCoord[3] = gl_TexCoord[3]; - triStream.Append(output); - - gl_Position = float4(xmin, ymin, 0.5, 1.0); - output.position = gl_Position; - output.texCoord[0] = gl_TexCoord[0]; - output.texCoord[1] = gl_TexCoord[1]; - output.texCoord[2] = gl_TexCoord[2]; - output.texCoord[3] = gl_TexCoord[3]; - triStream.Append(output); - - gl_Position = float4(xmax, ymax, 0.5, 1.0); - output.position = gl_Position; - output.texCoord[0] = gl_TexCoord[0]; - output.texCoord[1] = gl_TexCoord[1]; - output.texCoord[2] = gl_TexCoord[2]; - output.texCoord[3] = gl_TexCoord[3]; - triStream.Append(output); - - gl_Position = float4(xmax, ymin, 0.5, 1.0); - output.position = gl_Position; - output.texCoord[0] = gl_TexCoord[0]; - output.texCoord[1] = gl_TexCoord[1]; - output.texCoord[2] = gl_TexCoord[2]; - output.texCoord[3] = gl_TexCoord[3]; - triStream.Append(output); - - /* - void main() - { - vec3 pos = gl_PositionIn[0].xyz; - vec4 bounds = gl_TexCoordIn[0][0]; - vec4 ndcPos = gl_TexCoordIn[0][5]; - - // frustrum culling - const float ndcBound = 1.0; - if (ndcPos.x < -ndcBound) return; - if (ndcPos.x > ndcBound) return; - if (ndcPos.y < -ndcBound) return; - if (ndcPos.y > ndcBound) return; - - float xmin = bounds.x; - float xmax = bounds.y; - float ymin = bounds.z; - float ymax = bounds.w; - - // inv quadric transform - gl_TexCoord[0] = gl_TexCoordIn[0][1]; - gl_TexCoord[1] = gl_TexCoordIn[0][2]; - gl_TexCoord[2] = gl_TexCoordIn[0][3]; - gl_TexCoord[3] = gl_TexCoordIn[0][4]; - - gl_Position = vec4(xmin, ymax, 0.0, 1.0); - EmitVertex(); - - gl_Position = vec4(xmin, ymin, 0.0, 1.0); - EmitVertex(); - - gl_Position = vec4(xmax, ymax, 0.0, 1.0); - EmitVertex(); - - gl_Position = vec4(xmax, ymin, 0.0, 1.0); - EmitVertex(); - } - */ -} diff --git a/demo/d3d11/shaders/ellipsoidDepthGS.hlsl.h b/demo/d3d11/shaders/ellipsoidDepthGS.hlsl.h deleted file mode 100644 index c82cc89..0000000 --- a/demo/d3d11/shaders/ellipsoidDepthGS.hlsl.h +++ /dev/null @@ -1,414 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float -// TEXCOORD 0 xyzw 1 NONE float xyzw -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyzw -// TEXCOORD 3 xyzw 4 NONE float xyzw -// TEXCOORD 4 xyzw 5 NONE float xyzw -// TEXCOORD 5 xyzw 6 NONE float xy w -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// TEXCOORD 0 xyzw 1 NONE float xyzw -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyzw -// TEXCOORD 3 xyzw 4 NONE float xyzw -// -gs_5_0 -dcl_globalFlags refactoringAllowed -dcl_input v[1][0].xyzw -dcl_input v[1][1].xyzw -dcl_input v[1][2].xyzw -dcl_input v[1][3].xyzw -dcl_input v[1][4].xyzw -dcl_input v[1][5].xyzw -dcl_input v[1][6].xyzw -dcl_temps 1 -dcl_inputprimitive point -dcl_stream m0 -dcl_outputtopology trianglestrip -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -dcl_output o2.xyzw -dcl_output o3.xyzw -dcl_output o4.xyzw -dcl_maxout 4 -lt r0.x, v[0][6].w, l(0.000000) -if_nz r0.x - ret -endif -lt r0.x, v[0][6].x, l(-1.000000) -if_nz r0.x - ret -endif -lt r0.x, l(1.000000), v[0][6].x -if_nz r0.x - ret -endif -lt r0.x, v[0][6].y, l(-1.000000) -if_nz r0.x - ret -endif -lt r0.x, l(1.000000), v[0][6].y -if_nz r0.x - ret -endif -mov o0.xy, v[0][1].xwxx -mov o0.zw, l(0,0,0.500000,1.000000) -mov o1.xyzw, v[0][2].xyzw -mov o2.xyzw, v[0][3].xyzw -mov o3.xyzw, v[0][4].xyzw -mov o4.xyzw, v[0][5].xyzw -emit_stream m0 -mov o0.xy, v[0][1].xzxx -mov o0.zw, l(0,0,0.500000,1.000000) -mov o1.xyzw, v[0][2].xyzw -mov o2.xyzw, v[0][3].xyzw -mov o3.xyzw, v[0][4].xyzw -mov o4.xyzw, v[0][5].xyzw -emit_stream m0 -mov o0.xy, v[0][1].ywyy -mov o0.zw, l(0,0,0.500000,1.000000) -mov o1.xyzw, v[0][2].xyzw -mov o2.xyzw, v[0][3].xyzw -mov o3.xyzw, v[0][4].xyzw -mov o4.xyzw, v[0][5].xyzw -emit_stream m0 -mov o0.xy, v[0][1].yzyy -mov o0.zw, l(0,0,0.500000,1.000000) -mov o1.xyzw, v[0][2].xyzw -mov o2.xyzw, v[0][3].xyzw -mov o3.xyzw, v[0][4].xyzw -mov o4.xyzw, v[0][5].xyzw -emit_stream m0 -ret -// Approximately 49 instruction slots used -#endif - -const BYTE g_ellipsoidDepthGS[] = -{ - 68, 88, 66, 67, 121, 233, - 112, 246, 66, 190, 203, 227, - 242, 237, 242, 197, 75, 158, - 125, 123, 1, 0, 0, 0, - 72, 7, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 172, 0, 0, 0, 120, 1, - 0, 0, 44, 2, 0, 0, - 172, 6, 0, 0, 82, 68, - 69, 70, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 83, 71, 0, 1, 0, 0, - 60, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 196, 0, 0, 0, - 7, 0, 0, 0, 8, 0, - 0, 0, 176, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 185, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 15, - 0, 0, 185, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 15, - 0, 0, 185, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 15, 15, - 0, 0, 185, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 15, - 0, 0, 185, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 5, 0, 0, 0, 15, 15, - 0, 0, 185, 0, 0, 0, - 5, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 6, 0, 0, 0, 15, 11, - 0, 0, 80, 79, 83, 73, - 84, 73, 79, 78, 0, 84, - 69, 88, 67, 79, 79, 82, - 68, 0, 171, 171, 79, 83, - 71, 53, 172, 0, 0, 0, - 5, 0, 0, 0, 8, 0, - 0, 0, 0, 0, 0, 0, - 148, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 160, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 0, 0, 0, 0, 0, - 0, 0, 160, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 0, - 0, 0, 0, 0, 0, 0, - 160, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 160, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 4, 0, 0, 0, - 15, 0, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 171, 171, 171, 83, 72, - 69, 88, 120, 4, 0, 0, - 80, 0, 2, 0, 30, 1, - 0, 0, 106, 8, 0, 1, - 95, 0, 0, 4, 242, 16, - 32, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 95, 0, - 0, 4, 242, 16, 32, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 95, 0, 0, 4, - 242, 16, 32, 0, 1, 0, - 0, 0, 2, 0, 0, 0, - 95, 0, 0, 4, 242, 16, - 32, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 95, 0, - 0, 4, 242, 16, 32, 0, - 1, 0, 0, 0, 4, 0, - 0, 0, 95, 0, 0, 4, - 242, 16, 32, 0, 1, 0, - 0, 0, 5, 0, 0, 0, - 95, 0, 0, 4, 242, 16, - 32, 0, 1, 0, 0, 0, - 6, 0, 0, 0, 104, 0, - 0, 2, 1, 0, 0, 0, - 93, 8, 0, 1, 143, 0, - 0, 3, 0, 0, 17, 0, - 0, 0, 0, 0, 92, 40, - 0, 1, 103, 0, 0, 4, - 242, 32, 16, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 2, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 3, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 4, 0, 0, 0, - 94, 0, 0, 2, 4, 0, - 0, 0, 49, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 58, 16, 32, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 62, 0, - 0, 1, 21, 0, 0, 1, - 49, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 16, 32, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 191, 31, 0, 4, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 21, 0, 0, 1, 49, 0, - 0, 8, 18, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 10, 16, 32, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 31, 0, 4, 3, 10, 0, - 16, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 21, 0, - 0, 1, 49, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 26, 16, 32, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 191, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 62, 0, - 0, 1, 21, 0, 0, 1, - 49, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 26, 16, 32, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 31, 0, 4, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 21, 0, 0, 1, 54, 0, - 0, 6, 50, 32, 16, 0, - 0, 0, 0, 0, 198, 16, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 54, 0, - 0, 8, 194, 32, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 128, 63, - 54, 0, 0, 6, 242, 32, - 16, 0, 1, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 2, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 3, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 4, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 117, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 54, 0, 0, 6, 50, 32, - 16, 0, 0, 0, 0, 0, - 134, 16, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 54, 0, 0, 8, 194, 32, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 63, 0, 0, - 128, 63, 54, 0, 0, 6, - 242, 32, 16, 0, 1, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 2, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 3, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 4, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 117, 0, 0, 3, - 0, 0, 17, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 50, 32, 16, 0, 0, 0, - 0, 0, 214, 21, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 54, 0, 0, 8, - 194, 32, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 63, - 0, 0, 128, 63, 54, 0, - 0, 6, 242, 32, 16, 0, - 1, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 2, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 3, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 4, 0, 0, 0, 70, 30, - 32, 0, 0, 0, 0, 0, - 5, 0, 0, 0, 117, 0, - 0, 3, 0, 0, 17, 0, - 0, 0, 0, 0, 54, 0, - 0, 6, 50, 32, 16, 0, - 0, 0, 0, 0, 150, 21, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 54, 0, - 0, 8, 194, 32, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 128, 63, - 54, 0, 0, 6, 242, 32, - 16, 0, 1, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 2, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 3, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 54, 0, 0, 6, 242, 32, - 16, 0, 4, 0, 0, 0, - 70, 30, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 117, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 49, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 5, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/ellipsoidDepthPS.hlsl b/demo/d3d11/shaders/ellipsoidDepthPS.hlsl deleted file mode 100644 index b9a8287..0000000 --- a/demo/d3d11/shaders/ellipsoidDepthPS.hlsl +++ /dev/null @@ -1,108 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - FluidShaderConst gParams; -}; - -float Sign(float x) { return x < 0.0 ? -1.0 : 1.0; } - -bool solveQuadratic(float a, float b, float c, out float minT, out float maxT) -{ -#if 0 - minT = 0.0f; - maxT = 0.0f; -#endif - - if (a == 0.0 && b == 0.0) - { - minT = maxT = 0.0; - return true; - } - - float discriminant = b*b - 4.0*a*c; - - if (discriminant < 0.0) - { - return false; - } - - float t = -0.5*(b + Sign(b)*sqrt(discriminant)); - minT = t / a; - maxT = c / t; - - if (minT > maxT) - { - float tmp = minT; - minT = maxT; - maxT = tmp; - } - - return true; -} - -float sqr(float x) { return x * x; } - - -float4 ellipsoidDepthPS(FluidGeoOut input - , out float gl_FragDepth : SV_DEPTH -) : SV_TARGET -{ - const float4x4 gl_ProjectionMatrix = gParams.projection; - const float4x4 gl_ProjectionMatrixInverse = gParams.projection_inverse; - const float3 invViewport = gParams.invViewport; - - float4 gl_FragColor; - float4 gl_FragCoord; - float4 gl_TexCoord[6]; - - gl_FragCoord = input.position; - [unroll] - for (int i = 0; i < 4; i++) - gl_TexCoord[i] = input.texCoord[i]; - - // transform from view space to parameter space - //column_major - float4x4 invQuadric; - invQuadric._m00_m10_m20_m30 = gl_TexCoord[0]; - invQuadric._m01_m11_m21_m31 = gl_TexCoord[1]; - invQuadric._m02_m12_m22_m32 = gl_TexCoord[2]; - invQuadric._m03_m13_m23_m33 = gl_TexCoord[3]; - - //float4 ndcPos = float4(gl_FragCoord.xy * invViewport.xy * float2(2.0, 2.0) - float2(1.0, 1.0), -1.0, 1.0); - float4 ndcPos = float4(gl_FragCoord.x*invViewport.x*2.0f-1.0f, (1.0f-gl_FragCoord.y*invViewport.y)*2.0 - 1.0, 0.0f, 1.0); - float4 viewDir = mul(gl_ProjectionMatrixInverse, ndcPos); - - // ray to parameter space - float4 dir = mul(invQuadric, float4(viewDir.xyz, 0.0)); - float4 origin = invQuadric._m03_m13_m23_m33; - - // set up quadratric equation - float a = sqr(dir.x) + sqr(dir.y) + sqr(dir.z); - float b = dir.x*origin.x + dir.y*origin.y + dir.z*origin.z - dir.w*origin.w; - float c = sqr(origin.x) + sqr(origin.y) + sqr(origin.z) - sqr(origin.w); - - float minT; - float maxT; - - if (solveQuadratic(a, 2.0 * b, c, minT, maxT)) - { - float3 eyePos = viewDir.xyz*minT; - float4 ndcPos = mul(gl_ProjectionMatrix, float4(eyePos, 1.0)); - ndcPos.z /= ndcPos.w; - - gl_FragColor = float4(eyePos.z, 1.0, 1.0, 1.0); - gl_FragDepth = ndcPos.z; - - return gl_FragColor; - } - - // kill pixels outside of ellipsoid - discard; - - - gl_FragColor = 0.0f; - gl_FragDepth = 1.0f; - - return gl_FragColor; -} diff --git a/demo/d3d11/shaders/ellipsoidDepthPS.hlsl.h b/demo/d3d11/shaders/ellipsoidDepthPS.hlsl.h deleted file mode 100644 index d21d446..0000000 --- a/demo/d3d11/shaders/ellipsoidDepthPS.hlsl.h +++ /dev/null @@ -1,662 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct FluidShaderConst -// { -// -// float4x4 modelviewprojection; // Offset: 0 -// float4x4 modelview; // Offset: 64 -// float4x4 projection; // Offset: 128 -// float4x4 modelview_inverse; // Offset: 192 -// float4x4 projection_inverse; // Offset: 256 -// float4 invTexScale; // Offset: 320 -// float3 invViewport; // Offset: 336 -// float _pad0; // Offset: 348 -// float blurRadiusWorld; // Offset: 352 -// float blurScale; // Offset: 356 -// float blurFalloff; // Offset: 360 -// int debug; // Offset: 364 -// float3 lightPos; // Offset: 368 -// float _pad1; // Offset: 380 -// float3 lightDir; // Offset: 384 -// float _pad2; // Offset: 396 -// float4x4 lightTransform; // Offset: 400 -// float4 color; // Offset: 464 -// float4 clipPosToEye; // Offset: 480 -// float spotMin; // Offset: 496 -// float spotMax; // Offset: 500 -// float ior; // Offset: 504 -// float _pad3; // Offset: 508 -// float4 shadowTaps[12]; // Offset: 512 -// -// } gParams; // Offset: 0 Size: 704 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xy -// TEXCOORD 0 xyzw 1 NONE float xyzw -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyzw -// TEXCOORD 3 xyzw 4 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// SV_DEPTH 0 N/A oDepth DEPTH float YES -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[22], immediateIndexed -dcl_input_ps_siv linear noperspective v0.xy, position -dcl_input_ps linear v1.xyzw -dcl_input_ps linear v2.xyzw -dcl_input_ps linear v3.xyzw -dcl_input_ps linear v4.xyzw -dcl_output o0.xyzw -dcl_output oDepth -dcl_temps 4 -dp2 r0.x, v0.xxxx, cb0[21].xxxx -add r0.x, r0.x, l(-1.000000) -mad r0.y, -v0.y, cb0[21].y, l(1.000000) -mad r0.y, r0.y, l(2.000000), l(-1.000000) -mul r0.yzw, r0.yyyy, cb0[17].xxyz -mad r0.xyz, cb0[16].xyzx, r0.xxxx, r0.yzwy -add r0.xyz, r0.xyzx, cb0[19].xyzx -mul r1.xyzw, r0.yyyy, v2.xyzw -mad r1.xyzw, v1.xyzw, r0.xxxx, r1.xyzw -mad r1.xyzw, v3.xyzw, r0.zzzz, r1.xyzw -dp3 r0.w, r1.xyzx, r1.xyzx -dp3 r1.x, r1.xyzx, v4.xyzx -mad r1.x, -r1.w, v4.w, r1.x -dp3 r1.y, v4.xyzx, v4.xyzx -mad r1.y, -v4.w, v4.w, r1.y -add r1.z, r1.x, r1.x -eq r1.w, r0.w, l(0.000000) -eq r2.x, r1.x, l(0.000000) -and r1.w, r1.w, r2.x -mul r2.x, r0.w, r1.y -mul r2.x, r2.x, l(4.000000) -mad r2.x, r1.z, r1.z, -r2.x -lt r2.y, r2.x, l(0.000000) -not r3.y, r2.y -lt r1.x, r1.x, l(0.000000) -movc r1.x, r1.x, l(-1.000000), l(1.000000) -sqrt r2.x, r2.x -mad r1.x, r1.x, r2.x, r1.z -mul r1.x, r1.x, l(-0.500000) -div r0.w, r1.x, r0.w -div r1.x, r1.y, r1.x -lt r1.y, r1.x, r0.w -movc r3.z, r1.y, r1.x, r0.w -mov r3.xw, l(0,0,0,-1) -movc r1.xy, r2.yyyy, r3.xyxx, r3.zwzz -movc r1.xy, r1.wwww, l(0,-1,0,0), r1.xyxx -if_nz r1.y - mul r0.xyz, r0.xyzx, r1.xxxx - mul r0.yw, r0.yyyy, cb0[9].zzzw - mad r0.xy, cb0[8].zwzz, r0.xxxx, r0.ywyy - mad r0.xy, cb0[10].zwzz, r0.zzzz, r0.xyxx - add r0.xy, r0.xyxx, cb0[11].zwzz - div oDepth, r0.x, r0.y - mov o0.x, r0.z - mov o0.yzw, l(0,1.000000,1.000000,1.000000) - ret -endif -discard_nz l(-1) -mov o0.xyzw, l(0,0,0,0) -mov oDepth, l(1.000000) -ret -// Approximately 51 instruction slots used -#endif - -const BYTE g_ellipsoidDepthPS[] = -{ - 68, 88, 66, 67, 67, 187, - 249, 247, 27, 80, 204, 105, - 148, 238, 87, 239, 162, 120, - 35, 255, 1, 0, 0, 0, - 76, 12, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 116, 4, 0, 0, 20, 5, - 0, 0, 104, 5, 0, 0, - 176, 11, 0, 0, 82, 68, - 69, 70, 56, 4, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 4, 4, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 192, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 192, 2, - 0, 0, 2, 0, 0, 0, - 224, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 70, 108, 117, 105, - 100, 83, 104, 97, 100, 101, - 114, 67, 111, 110, 115, 116, - 0, 109, 111, 100, 101, 108, - 118, 105, 101, 119, 112, 114, - 111, 106, 101, 99, 116, 105, - 111, 110, 0, 102, 108, 111, - 97, 116, 52, 120, 52, 0, - 171, 171, 3, 0, 3, 0, - 4, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 213, 0, - 0, 0, 109, 111, 100, 101, - 108, 118, 105, 101, 119, 0, - 112, 114, 111, 106, 101, 99, - 116, 105, 111, 110, 0, 109, - 111, 100, 101, 108, 118, 105, - 101, 119, 95, 105, 110, 118, - 101, 114, 115, 101, 0, 112, - 114, 111, 106, 101, 99, 116, - 105, 111, 110, 95, 105, 110, - 118, 101, 114, 115, 101, 0, - 105, 110, 118, 84, 101, 120, - 83, 99, 97, 108, 101, 0, - 102, 108, 111, 97, 116, 52, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 74, 1, 0, 0, 105, 110, - 118, 86, 105, 101, 119, 112, - 111, 114, 116, 0, 102, 108, - 111, 97, 116, 51, 0, 171, - 1, 0, 3, 0, 1, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 132, 1, 0, 0, - 95, 112, 97, 100, 48, 0, - 102, 108, 111, 97, 116, 0, - 0, 0, 3, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 182, 1, 0, 0, - 98, 108, 117, 114, 82, 97, - 100, 105, 117, 115, 87, 111, - 114, 108, 100, 0, 98, 108, - 117, 114, 83, 99, 97, 108, - 101, 0, 98, 108, 117, 114, - 70, 97, 108, 108, 111, 102, - 102, 0, 100, 101, 98, 117, - 103, 0, 105, 110, 116, 0, - 0, 0, 2, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 12, 2, 0, 0, - 108, 105, 103, 104, 116, 80, - 111, 115, 0, 95, 112, 97, - 100, 49, 0, 108, 105, 103, - 104, 116, 68, 105, 114, 0, - 95, 112, 97, 100, 50, 0, - 108, 105, 103, 104, 116, 84, - 114, 97, 110, 115, 102, 111, - 114, 109, 0, 99, 111, 108, - 111, 114, 0, 99, 108, 105, - 112, 80, 111, 115, 84, 111, - 69, 121, 101, 0, 115, 112, - 111, 116, 77, 105, 110, 0, - 115, 112, 111, 116, 77, 97, - 120, 0, 105, 111, 114, 0, - 95, 112, 97, 100, 51, 0, - 115, 104, 97, 100, 111, 119, - 84, 97, 112, 115, 0, 171, - 171, 171, 1, 0, 3, 0, - 1, 0, 4, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 74, 1, - 0, 0, 193, 0, 0, 0, - 224, 0, 0, 0, 0, 0, - 0, 0, 4, 1, 0, 0, - 224, 0, 0, 0, 64, 0, - 0, 0, 14, 1, 0, 0, - 224, 0, 0, 0, 128, 0, - 0, 0, 25, 1, 0, 0, - 224, 0, 0, 0, 192, 0, - 0, 0, 43, 1, 0, 0, - 224, 0, 0, 0, 0, 1, - 0, 0, 62, 1, 0, 0, - 84, 1, 0, 0, 64, 1, - 0, 0, 120, 1, 0, 0, - 140, 1, 0, 0, 80, 1, - 0, 0, 176, 1, 0, 0, - 188, 1, 0, 0, 92, 1, - 0, 0, 224, 1, 0, 0, - 188, 1, 0, 0, 96, 1, - 0, 0, 240, 1, 0, 0, - 188, 1, 0, 0, 100, 1, - 0, 0, 250, 1, 0, 0, - 188, 1, 0, 0, 104, 1, - 0, 0, 6, 2, 0, 0, - 16, 2, 0, 0, 108, 1, - 0, 0, 52, 2, 0, 0, - 140, 1, 0, 0, 112, 1, - 0, 0, 61, 2, 0, 0, - 188, 1, 0, 0, 124, 1, - 0, 0, 67, 2, 0, 0, - 140, 1, 0, 0, 128, 1, - 0, 0, 76, 2, 0, 0, - 188, 1, 0, 0, 140, 1, - 0, 0, 82, 2, 0, 0, - 224, 0, 0, 0, 144, 1, - 0, 0, 97, 2, 0, 0, - 84, 1, 0, 0, 208, 1, - 0, 0, 103, 2, 0, 0, - 84, 1, 0, 0, 224, 1, - 0, 0, 116, 2, 0, 0, - 188, 1, 0, 0, 240, 1, - 0, 0, 124, 2, 0, 0, - 188, 1, 0, 0, 244, 1, - 0, 0, 132, 2, 0, 0, - 188, 1, 0, 0, 248, 1, - 0, 0, 136, 2, 0, 0, - 188, 1, 0, 0, 252, 1, - 0, 0, 142, 2, 0, 0, - 156, 2, 0, 0, 0, 2, - 0, 0, 5, 0, 0, 0, - 1, 0, 176, 0, 0, 0, - 24, 0, 192, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 176, 0, - 0, 0, 77, 105, 99, 114, - 111, 115, 111, 102, 116, 32, - 40, 82, 41, 32, 72, 76, - 83, 76, 32, 83, 104, 97, - 100, 101, 114, 32, 67, 111, - 109, 112, 105, 108, 101, 114, - 32, 54, 46, 51, 46, 57, - 54, 48, 48, 46, 49, 54, - 51, 56, 52, 0, 171, 171, - 73, 83, 71, 78, 152, 0, - 0, 0, 5, 0, 0, 0, - 8, 0, 0, 0, 128, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 3, 0, 0, 140, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 15, 0, 0, 140, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 15, 15, 0, 0, 140, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 15, 15, 0, 0, 140, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 4, 0, 0, 0, - 15, 15, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 171, 171, 171, 79, 83, - 71, 78, 76, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 66, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 255, 255, 255, 255, 1, 14, - 0, 0, 83, 86, 95, 84, - 65, 82, 71, 69, 84, 0, - 83, 86, 95, 68, 69, 80, - 84, 72, 0, 171, 83, 72, - 69, 88, 64, 6, 0, 0, - 80, 0, 0, 0, 144, 1, - 0, 0, 106, 8, 0, 1, - 89, 0, 0, 4, 70, 142, - 32, 0, 0, 0, 0, 0, - 22, 0, 0, 0, 100, 32, - 0, 4, 50, 16, 16, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 1, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 3, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 4, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 101, 0, 0, 2, - 1, 192, 0, 0, 104, 0, - 0, 2, 4, 0, 0, 0, - 15, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 6, 16, 16, 0, 0, 0, - 0, 0, 6, 128, 32, 0, - 0, 0, 0, 0, 21, 0, - 0, 0, 0, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 191, - 50, 0, 0, 11, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 16, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 26, 128, 32, 0, 0, 0, - 0, 0, 21, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 50, 0, 0, 9, - 34, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 64, - 1, 64, 0, 0, 0, 0, - 128, 191, 56, 0, 0, 8, - 226, 0, 16, 0, 0, 0, - 0, 0, 86, 5, 16, 0, - 0, 0, 0, 0, 6, 137, - 32, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 50, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 16, 0, 0, 0, 6, 0, - 16, 0, 0, 0, 0, 0, - 150, 7, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 19, 0, 0, 0, 56, 0, - 0, 7, 242, 0, 16, 0, - 1, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 70, 30, 16, 0, 2, 0, - 0, 0, 50, 0, 0, 9, - 242, 0, 16, 0, 1, 0, - 0, 0, 70, 30, 16, 0, - 1, 0, 0, 0, 6, 0, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 1, 0, - 0, 0, 50, 0, 0, 9, - 242, 0, 16, 0, 1, 0, - 0, 0, 70, 30, 16, 0, - 3, 0, 0, 0, 166, 10, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 1, 0, - 0, 0, 16, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 16, 0, 0, 7, 18, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 70, 18, 16, 0, - 4, 0, 0, 0, 50, 0, - 0, 10, 18, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 128, 65, 0, 0, 0, - 1, 0, 0, 0, 58, 16, - 16, 0, 4, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 16, 0, 0, 7, - 34, 0, 16, 0, 1, 0, - 0, 0, 70, 18, 16, 0, - 4, 0, 0, 0, 70, 18, - 16, 0, 4, 0, 0, 0, - 50, 0, 0, 10, 34, 0, - 16, 0, 1, 0, 0, 0, - 58, 16, 16, 128, 65, 0, - 0, 0, 4, 0, 0, 0, - 58, 16, 16, 0, 4, 0, - 0, 0, 26, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 24, 0, 0, 7, - 130, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 24, 0, 0, 7, 18, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 7, 130, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 56, 0, 0, 7, - 18, 0, 16, 0, 2, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 7, 18, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 64, 50, 0, - 0, 10, 18, 0, 16, 0, - 2, 0, 0, 0, 42, 0, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 128, - 65, 0, 0, 0, 2, 0, - 0, 0, 49, 0, 0, 7, - 34, 0, 16, 0, 2, 0, - 0, 0, 10, 0, 16, 0, - 2, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 59, 0, 0, 5, 34, 0, - 16, 0, 3, 0, 0, 0, - 26, 0, 16, 0, 2, 0, - 0, 0, 49, 0, 0, 7, - 18, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 55, 0, 0, 9, 18, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 191, 1, 64, - 0, 0, 0, 0, 128, 63, - 75, 0, 0, 5, 18, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 50, 0, 0, 9, - 18, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 2, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 7, - 18, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 191, - 14, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 14, 0, - 0, 7, 18, 0, 16, 0, - 1, 0, 0, 0, 26, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 49, 0, 0, 7, - 34, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 55, 0, 0, 9, 66, 0, - 16, 0, 3, 0, 0, 0, - 26, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 8, 146, 0, - 16, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 55, 0, 0, 9, - 50, 0, 16, 0, 1, 0, - 0, 0, 86, 5, 16, 0, - 2, 0, 0, 0, 70, 0, - 16, 0, 3, 0, 0, 0, - 230, 10, 16, 0, 3, 0, - 0, 0, 55, 0, 0, 12, - 50, 0, 16, 0, 1, 0, - 0, 0, 246, 15, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 1, 0, - 0, 0, 31, 0, 4, 3, - 26, 0, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 6, 0, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 8, 162, 0, - 16, 0, 0, 0, 0, 0, - 86, 5, 16, 0, 0, 0, - 0, 0, 166, 142, 32, 0, - 0, 0, 0, 0, 9, 0, - 0, 0, 50, 0, 0, 10, - 50, 0, 16, 0, 0, 0, - 0, 0, 230, 138, 32, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 214, 5, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 10, 50, 0, - 16, 0, 0, 0, 0, 0, - 230, 138, 32, 0, 0, 0, - 0, 0, 10, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 0, 0, - 0, 8, 50, 0, 16, 0, - 0, 0, 0, 0, 70, 0, - 16, 0, 0, 0, 0, 0, - 230, 138, 32, 0, 0, 0, - 0, 0, 11, 0, 0, 0, - 14, 0, 0, 6, 1, 192, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 18, 32, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 8, - 226, 32, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 128, 63, 62, 0, - 0, 1, 21, 0, 0, 1, - 13, 0, 4, 3, 1, 64, - 0, 0, 255, 255, 255, 255, - 54, 0, 0, 8, 242, 32, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 4, - 1, 192, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 62, 0, 0, 1, 83, 84, - 65, 84, 148, 0, 0, 0, - 51, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 35, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 2, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/ellipsoidDepthVS.hlsl b/demo/d3d11/shaders/ellipsoidDepthVS.hlsl deleted file mode 100644 index 03ef001..0000000 --- a/demo/d3d11/shaders/ellipsoidDepthVS.hlsl +++ /dev/null @@ -1,195 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - FluidShaderConst gParams; -}; - -// returns 1.0 for x==0.0 (unlike glsl) -float Sign(float x) { return x < 0.0 ? -1.0 : 1.0; } - -bool solveQuadratic(float a, float b, float c, out float minT, out float maxT) -{ -#if 0 - // for debugging - minT = -0.5; - maxT = 0.5; - return true; -#else - //minT = 0.0f; - //maxT = 0.0f; -#endif - - if (a == 0.0 && b == 0.0) - { - minT = maxT = 0.0; - return false; - } - - float discriminant = b*b - 4.0*a*c; - - if (discriminant < 0.0) - { - return false; - } - - float t = -0.5*(b + Sign(b)*sqrt(discriminant)); - minT = t / a; - maxT = c / t; - - if (minT > maxT) - { - float tmp = minT; - minT = maxT; - maxT = tmp; - } - - return true; -} - -float DotInvW(float4 a, float4 b) { return a.x*b.x + a.y*b.y + a.z*b.z - a.w*b.w; } - -FluidVertexOut ellipsoidDepthVS(FluidVertexIn input, uint instance : SV_VertexID) -{ - float4 gl_Position; - float4 gl_TexCoord[6]; - - const float4 gl_Vertex = input.position; - const float4 q1 = input.q1; - const float4 q2 = input.q2; - const float4 q3 = input.q3; - - const float4x4 gl_ModelViewProjectionMatrix = gParams.modelviewprojection; - const float4x4 gl_ModelViewMatrixInverse = gParams.modelview_inverse; - - float3 worldPos = gl_Vertex.xyz; - - // construct quadric matrix - float4x4 q; - q._m00_m10_m20_m30 = float4(q1.xyz*q1.w, 0.0); - q._m01_m11_m21_m31 = float4(q2.xyz*q2.w, 0.0); - q._m02_m12_m22_m32 = float4(q3.xyz*q3.w, 0.0); - q._m03_m13_m23_m33 = float4(worldPos, 1.0); - - // transforms a normal to parameter space (inverse transpose of (q*modelview)^-T) - float4x4 invClip = /*transpose*/(mul(gl_ModelViewProjectionMatrix, q)); - - // solve for the right hand bounds in homogenous clip space - float a1 = DotInvW(invClip[3], invClip[3]); - float b1 = -2.0f*DotInvW(invClip[0], invClip[3]); - float c1 = DotInvW(invClip[0], invClip[0]); - - float xmin; - float xmax; - solveQuadratic(a1, b1, c1, xmin, xmax); - - // solve for the right hand bounds in homogenous clip space - float a2 = DotInvW(invClip[3], invClip[3]); - float b2 = -2.0f*DotInvW(invClip[1], invClip[3]); - float c2 = DotInvW(invClip[1], invClip[1]); - - float ymin; - float ymax; - solveQuadratic(a2, b2, c2, ymin, ymax); - - gl_Position = float4(worldPos.xyz, 1.0); - gl_TexCoord[0] = float4(xmin, xmax, ymin, ymax); - - // construct inverse quadric matrix (used for ray-casting in parameter space) - float4x4 invq; - invq._m00_m10_m20_m30 = float4(q1.xyz / q1.w, 0.0); - invq._m01_m11_m21_m31 = float4(q2.xyz / q2.w, 0.0); - invq._m02_m12_m22_m32 = float4(q3.xyz / q3.w, 0.0); - invq._m03_m13_m23_m33 = float4(0.0, 0.0, 0.0, 1.0); - - invq = transpose(invq); - invq._m03_m13_m23_m33 = -(mul(invq, gl_Position)); - - // transform a point from view space to parameter space - invq = mul(invq, gl_ModelViewMatrixInverse); - - // pass down - gl_TexCoord[1] = invq._m00_m10_m20_m30; - gl_TexCoord[2] = invq._m01_m11_m21_m31; - gl_TexCoord[3] = invq._m02_m12_m22_m32; - gl_TexCoord[4] = invq._m03_m13_m23_m33; - - // compute ndc pos for frustrum culling in GS - float4 ndcPos = mul(gl_ModelViewProjectionMatrix, float4(worldPos.xyz, 1.0)); - gl_TexCoord[5].xyz = ndcPos.xyz / ndcPos.w; - gl_TexCoord[5].w = ndcPos.w; - - FluidVertexOut output; - output.position = gl_Position; - [unroll] - for (int j = 0; j < 6; j++) - output.texCoord[j] = gl_TexCoord[j]; - - return output; - - /* - // rotation matrix in xyz, scale in w - attribute vec4 q1; - attribute vec4 q2; - attribute vec4 q3; - - void main() - { - vec3 worldPos = gl_Vertex.xyz;// - vec3(0.0, 0.1*0.25, 0.0); // hack move towards ground to account for anisotropy - - // construct quadric matrix - mat4 q; - q[0] = vec4(q1.xyz*q1.w, 0.0); - q[1] = vec4(q2.xyz*q2.w, 0.0); - q[2] = vec4(q3.xyz*q3.w, 0.0); - q[3] = vec4(worldPos, 1.0); - - // transforms a normal to parameter space (inverse transpose of (q*modelview)^-T) - mat4 invClip = transpose(gl_ModelViewProjectionMatrix*q); - - // solve for the right hand bounds in homogenous clip space - float a1 = DotInvW(invClip[3], invClip[3]); - float b1 = -2.0f*DotInvW(invClip[0], invClip[3]); - float c1 = DotInvW(invClip[0], invClip[0]); - - float xmin; - float xmax; - solveQuadratic(a1, b1, c1, xmin, xmax); - - // solve for the right hand bounds in homogenous clip space - float a2 = DotInvW(invClip[3], invClip[3]); - float b2 = -2.0f*DotInvW(invClip[1], invClip[3]); - float c2 = DotInvW(invClip[1], invClip[1]); - - float ymin; - float ymax; - solveQuadratic(a2, b2, c2, ymin, ymax); - - gl_Position = vec4(worldPos.xyz, 1.0); - gl_TexCoord[0] = vec4(xmin, xmax, ymin, ymax); - - // construct inverse quadric matrix (used for ray-casting in parameter space) - mat4 invq; - invq[0] = vec4(q1.xyz / q1.w, 0.0); - invq[1] = vec4(q2.xyz / q2.w, 0.0); - invq[2] = vec4(q3.xyz / q3.w, 0.0); - invq[3] = vec4(0.0, 0.0, 0.0, 1.0); - - invq = transpose(invq); - invq[3] = -(invq*gl_Position); - - // transform a point from view space to parameter space - invq = invq*gl_ModelViewMatrixInverse; - - // pass down - gl_TexCoord[1] = invq[0]; - gl_TexCoord[2] = invq[1]; - gl_TexCoord[3] = invq[2]; - gl_TexCoord[4] = invq[3]; - - // compute ndc pos for frustrum culling in GS - vec4 ndcPos = gl_ModelViewProjectionMatrix * vec4(worldPos.xyz, 1.0); - gl_TexCoord[5] = ndcPos / ndcPos.w; - } - */ -} diff --git a/demo/d3d11/shaders/ellipsoidDepthVS.hlsl.h b/demo/d3d11/shaders/ellipsoidDepthVS.hlsl.h deleted file mode 100644 index d1dd741..0000000 --- a/demo/d3d11/shaders/ellipsoidDepthVS.hlsl.h +++ /dev/null @@ -1,940 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct FluidShaderConst -// { -// -// float4x4 modelviewprojection; // Offset: 0 -// float4x4 modelview; // Offset: 64 -// float4x4 projection; // Offset: 128 -// float4x4 modelview_inverse; // Offset: 192 -// float4x4 projection_inverse; // Offset: 256 -// float4 invTexScale; // Offset: 320 -// float3 invViewport; // Offset: 336 -// float _pad0; // Offset: 348 -// float blurRadiusWorld; // Offset: 352 -// float blurScale; // Offset: 356 -// float blurFalloff; // Offset: 360 -// int debug; // Offset: 364 -// float3 lightPos; // Offset: 368 -// float _pad1; // Offset: 380 -// float3 lightDir; // Offset: 384 -// float _pad2; // Offset: 396 -// float4x4 lightTransform; // Offset: 400 -// float4 color; // Offset: 464 -// float4 clipPosToEye; // Offset: 480 -// float spotMin; // Offset: 496 -// float spotMax; // Offset: 500 -// float ior; // Offset: 504 -// float _pad3; // Offset: 508 -// float4 shadowTaps[12]; // Offset: 512 -// -// } gParams; // Offset: 0 Size: 704 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyz -// U 0 xyzw 1 NONE float xyzw -// V 0 xyzw 2 NONE float xyzw -// W 0 xyzw 3 NONE float xyzw -// SV_VertexID 0 x 4 VERTID uint -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// TEXCOORD 0 xyzw 1 NONE float xyzw -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyzw -// TEXCOORD 3 xyzw 4 NONE float xyzw -// TEXCOORD 4 xyzw 5 NONE float xyzw -// TEXCOORD 5 xyzw 6 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[16], immediateIndexed -dcl_input v0.xyz -dcl_input v1.xyzw -dcl_input v2.xyzw -dcl_input v3.xyzw -dcl_output o0.xyzw -dcl_output o1.xyzw -dcl_output o2.xyzw -dcl_output o3.xyzw -dcl_output o4.xyzw -dcl_output o5.xyzw -dcl_output o6.xyzw -dcl_temps 4 -mov o0.xyz, v0.xyzx -mov o0.w, l(1.000000) -mul r0.xyz, v2.wwww, v2.xyzx -mul r1.xyzw, r0.yyyy, cb0[1].wxxy -mad r1.xyzw, cb0[0].wxxy, r0.xxxx, r1.xyzw -mad r0.xyzw, cb0[2].wxxy, r0.zzzz, r1.xyzw -mul r1.x, r0.w, r0.w -mul r0.xyzw, r0.xxzx, r0.xyzw -mul r1.yzw, v1.wwww, v1.xxyz -mul r2.xyzw, r1.zzzz, cb0[1].wxxy -mad r2.xyzw, cb0[0].wxxy, r1.yyyy, r2.xyzw -mad r2.xyzw, cb0[2].wxxy, r1.wwww, r2.xyzw -mad r1.x, r2.w, r2.w, r1.x -mad r0.xyzw, r2.xyzw, r2.xxzx, r0.xyzw -mul r1.yzw, v3.wwww, v3.xxyz -mul r2.xyzw, r1.zzzz, cb0[1].wxxy -mad r2.xyzw, cb0[0].wxxy, r1.yyyy, r2.xyzw -mad r2.xyzw, cb0[2].wxxy, r1.wwww, r2.xyzw -mad r1.x, r2.w, r2.w, r1.x -mad r0.xyzw, r2.xyzw, r2.xxzx, r0.xyzw -mul r2.xyzw, v0.yyyy, cb0[1].wxxy -mad r2.xyzw, cb0[0].wxxy, v0.xxxx, r2.xyzw -mad r2.xyzw, cb0[2].wxxy, v0.zzzz, r2.xyzw -add r2.xyzw, r2.xyzw, cb0[3].wxxy -mad r1.x, -r2.w, r2.w, r1.x -mad r0.xyzw, -r2.xyzw, r2.xxzx, r0.xyzw -mul r1.yzw, r0.yyxw, l(0.000000, -2.000000, 4.000000, -2.000000) -mul r2.xy, r1.ywyy, r1.ywyy -mad r2.y, -r1.z, r1.x, r2.y -mad r1.z, -r1.z, r0.z, r2.x -sqrt r2.x, r2.y -ge r2.y, r2.y, l(0.000000) -lt r2.zw, l(0.000000, 0.000000, -0.000000, -0.000000), r0.yyyw -movc r2.zw, r2.zzzw, l(0,0,-1.000000,-1.000000), l(0,0,1.000000,1.000000) -mad r1.w, r2.w, r2.x, r1.w -mul r1.w, r1.w, l(-0.500000) -div r3.w, r1.w, r0.x -div r3.z, r1.x, r1.w -lt r1.x, r3.z, r3.w -movc r1.xw, r1.xxxx, r3.zzzw, r3.wwwz -and r1.xw, r1.xxxw, r2.yyyy -eq r2.xyw, r0.xyxw, l(0.000000, -0.000000, 0.000000, -0.000000) -and r0.yw, r2.yyyw, r2.xxxx -movc o1.zw, r0.wwww, l(0,0,0,0), r1.xxxw -sqrt r0.w, r1.z -ge r1.x, r1.z, l(0.000000) -mad r0.w, r2.z, r0.w, r1.y -mul r0.w, r0.w, l(-0.500000) -div r2.xy, r0.zwzz, r0.wxww -lt r0.x, r2.x, r2.y -movc r0.xz, r0.xxxx, r2.xxyx, r2.yyxy -and r0.xz, r0.xxzx, r1.xxxx -movc o1.xy, r0.yyyy, l(0,0,0,0), r0.xzxx -mov o2.w, -cb0[12].w -div r0.xyz, v1.xyzx, v1.wwww -dp3 r0.w, r0.xyzx, v0.xyzx -mov r0.w, -r0.w -dp4 o2.x, r0.xyzw, cb0[12].xyzw -div r1.xyz, v2.xyzx, v2.wwww -dp3 r1.w, r1.xyzx, v0.xyzx -mov r1.w, -r1.w -dp4 o2.y, r1.xyzw, cb0[12].xyzw -div r2.xyz, v3.xyzx, v3.wwww -dp3 r2.w, r2.xyzx, v0.xyzx -mov r2.w, -r2.w -dp4 o2.z, r2.xyzw, cb0[12].xyzw -mov o3.w, -cb0[13].w -dp4 o3.x, r0.xyzw, cb0[13].xyzw -dp4 o3.y, r1.xyzw, cb0[13].xyzw -dp4 o3.z, r2.xyzw, cb0[13].xyzw -dp4 o4.x, r0.xyzw, cb0[14].xyzw -dp4 o5.x, r0.xyzw, cb0[15].xyzw -dp4 o4.y, r1.xyzw, cb0[14].xyzw -dp4 o5.y, r1.xyzw, cb0[15].xyzw -dp4 o4.z, r2.xyzw, cb0[14].xyzw -dp4 o5.z, r2.xyzw, cb0[15].xyzw -mov o4.w, -cb0[14].w -mov o5.w, -cb0[15].w -mul r0.xyzw, v0.yyyy, cb0[1].xyzw -mad r0.xyzw, cb0[0].xyzw, v0.xxxx, r0.xyzw -mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw -add r0.xyzw, r0.xyzw, cb0[3].xyzw -div o6.xyz, r0.xyzx, r0.wwww -mov o6.w, r0.w -ret -// Approximately 85 instruction slots used -#endif - -const BYTE g_ellipsoidDepthVS[] = -{ - 68, 88, 66, 67, 1, 86, - 214, 204, 57, 184, 18, 6, - 20, 42, 129, 16, 226, 241, - 71, 198, 1, 0, 0, 0, - 208, 17, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 116, 4, 0, 0, 24, 5, - 0, 0, 228, 5, 0, 0, - 52, 17, 0, 0, 82, 68, - 69, 70, 56, 4, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 4, 4, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 192, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 192, 2, - 0, 0, 2, 0, 0, 0, - 224, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 70, 108, 117, 105, - 100, 83, 104, 97, 100, 101, - 114, 67, 111, 110, 115, 116, - 0, 109, 111, 100, 101, 108, - 118, 105, 101, 119, 112, 114, - 111, 106, 101, 99, 116, 105, - 111, 110, 0, 102, 108, 111, - 97, 116, 52, 120, 52, 0, - 171, 171, 3, 0, 3, 0, - 4, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 213, 0, - 0, 0, 109, 111, 100, 101, - 108, 118, 105, 101, 119, 0, - 112, 114, 111, 106, 101, 99, - 116, 105, 111, 110, 0, 109, - 111, 100, 101, 108, 118, 105, - 101, 119, 95, 105, 110, 118, - 101, 114, 115, 101, 0, 112, - 114, 111, 106, 101, 99, 116, - 105, 111, 110, 95, 105, 110, - 118, 101, 114, 115, 101, 0, - 105, 110, 118, 84, 101, 120, - 83, 99, 97, 108, 101, 0, - 102, 108, 111, 97, 116, 52, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 74, 1, 0, 0, 105, 110, - 118, 86, 105, 101, 119, 112, - 111, 114, 116, 0, 102, 108, - 111, 97, 116, 51, 0, 171, - 1, 0, 3, 0, 1, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 132, 1, 0, 0, - 95, 112, 97, 100, 48, 0, - 102, 108, 111, 97, 116, 0, - 0, 0, 3, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 182, 1, 0, 0, - 98, 108, 117, 114, 82, 97, - 100, 105, 117, 115, 87, 111, - 114, 108, 100, 0, 98, 108, - 117, 114, 83, 99, 97, 108, - 101, 0, 98, 108, 117, 114, - 70, 97, 108, 108, 111, 102, - 102, 0, 100, 101, 98, 117, - 103, 0, 105, 110, 116, 0, - 0, 0, 2, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 12, 2, 0, 0, - 108, 105, 103, 104, 116, 80, - 111, 115, 0, 95, 112, 97, - 100, 49, 0, 108, 105, 103, - 104, 116, 68, 105, 114, 0, - 95, 112, 97, 100, 50, 0, - 108, 105, 103, 104, 116, 84, - 114, 97, 110, 115, 102, 111, - 114, 109, 0, 99, 111, 108, - 111, 114, 0, 99, 108, 105, - 112, 80, 111, 115, 84, 111, - 69, 121, 101, 0, 115, 112, - 111, 116, 77, 105, 110, 0, - 115, 112, 111, 116, 77, 97, - 120, 0, 105, 111, 114, 0, - 95, 112, 97, 100, 51, 0, - 115, 104, 97, 100, 111, 119, - 84, 97, 112, 115, 0, 171, - 171, 171, 1, 0, 3, 0, - 1, 0, 4, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 74, 1, - 0, 0, 193, 0, 0, 0, - 224, 0, 0, 0, 0, 0, - 0, 0, 4, 1, 0, 0, - 224, 0, 0, 0, 64, 0, - 0, 0, 14, 1, 0, 0, - 224, 0, 0, 0, 128, 0, - 0, 0, 25, 1, 0, 0, - 224, 0, 0, 0, 192, 0, - 0, 0, 43, 1, 0, 0, - 224, 0, 0, 0, 0, 1, - 0, 0, 62, 1, 0, 0, - 84, 1, 0, 0, 64, 1, - 0, 0, 120, 1, 0, 0, - 140, 1, 0, 0, 80, 1, - 0, 0, 176, 1, 0, 0, - 188, 1, 0, 0, 92, 1, - 0, 0, 224, 1, 0, 0, - 188, 1, 0, 0, 96, 1, - 0, 0, 240, 1, 0, 0, - 188, 1, 0, 0, 100, 1, - 0, 0, 250, 1, 0, 0, - 188, 1, 0, 0, 104, 1, - 0, 0, 6, 2, 0, 0, - 16, 2, 0, 0, 108, 1, - 0, 0, 52, 2, 0, 0, - 140, 1, 0, 0, 112, 1, - 0, 0, 61, 2, 0, 0, - 188, 1, 0, 0, 124, 1, - 0, 0, 67, 2, 0, 0, - 140, 1, 0, 0, 128, 1, - 0, 0, 76, 2, 0, 0, - 188, 1, 0, 0, 140, 1, - 0, 0, 82, 2, 0, 0, - 224, 0, 0, 0, 144, 1, - 0, 0, 97, 2, 0, 0, - 84, 1, 0, 0, 208, 1, - 0, 0, 103, 2, 0, 0, - 84, 1, 0, 0, 224, 1, - 0, 0, 116, 2, 0, 0, - 188, 1, 0, 0, 240, 1, - 0, 0, 124, 2, 0, 0, - 188, 1, 0, 0, 244, 1, - 0, 0, 132, 2, 0, 0, - 188, 1, 0, 0, 248, 1, - 0, 0, 136, 2, 0, 0, - 188, 1, 0, 0, 252, 1, - 0, 0, 142, 2, 0, 0, - 156, 2, 0, 0, 0, 2, - 0, 0, 5, 0, 0, 0, - 1, 0, 176, 0, 0, 0, - 24, 0, 192, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 176, 0, - 0, 0, 77, 105, 99, 114, - 111, 115, 111, 102, 116, 32, - 40, 82, 41, 32, 72, 76, - 83, 76, 32, 83, 104, 97, - 100, 101, 114, 32, 67, 111, - 109, 112, 105, 108, 101, 114, - 32, 54, 46, 51, 46, 57, - 54, 48, 48, 46, 49, 54, - 51, 56, 52, 0, 171, 171, - 73, 83, 71, 78, 156, 0, - 0, 0, 5, 0, 0, 0, - 8, 0, 0, 0, 128, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 7, 0, 0, 137, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 15, 0, 0, 139, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 15, 15, 0, 0, 141, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 15, 15, 0, 0, 143, 0, - 0, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 1, 0, - 0, 0, 4, 0, 0, 0, - 1, 0, 0, 0, 80, 79, - 83, 73, 84, 73, 79, 78, - 0, 85, 0, 86, 0, 87, - 0, 83, 86, 95, 86, 101, - 114, 116, 101, 120, 73, 68, - 0, 171, 79, 83, 71, 78, - 196, 0, 0, 0, 7, 0, - 0, 0, 8, 0, 0, 0, - 176, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 185, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 0, 0, 0, - 185, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 0, 0, 0, - 185, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 0, 0, 0, - 185, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 4, 0, - 0, 0, 15, 0, 0, 0, - 185, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 5, 0, - 0, 0, 15, 0, 0, 0, - 185, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 6, 0, - 0, 0, 15, 0, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 84, 69, 88, - 67, 79, 79, 82, 68, 0, - 171, 171, 83, 72, 69, 88, - 72, 11, 0, 0, 80, 0, - 1, 0, 210, 2, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 4, 70, 142, 32, 0, - 0, 0, 0, 0, 16, 0, - 0, 0, 95, 0, 0, 3, - 114, 16, 16, 0, 0, 0, - 0, 0, 95, 0, 0, 3, - 242, 16, 16, 0, 1, 0, - 0, 0, 95, 0, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 95, 0, 0, 3, - 242, 16, 16, 0, 3, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 3, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 4, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 5, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 6, 0, - 0, 0, 104, 0, 0, 2, - 4, 0, 0, 0, 54, 0, - 0, 5, 114, 32, 16, 0, - 0, 0, 0, 0, 70, 18, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 246, 31, 16, 0, - 2, 0, 0, 0, 70, 18, - 16, 0, 2, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 1, 0, 0, 0, - 86, 5, 16, 0, 0, 0, - 0, 0, 54, 132, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 1, 0, - 0, 0, 54, 132, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 0, 0, 0, 0, - 54, 132, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 7, 18, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 242, 0, 16, 0, 0, 0, - 0, 0, 6, 2, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 226, 0, - 16, 0, 1, 0, 0, 0, - 246, 31, 16, 0, 1, 0, - 0, 0, 6, 25, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 2, 0, 0, 0, 166, 10, - 16, 0, 1, 0, 0, 0, - 54, 132, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 2, 0, 0, 0, - 54, 132, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 86, 5, 16, 0, 1, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 2, 0, 0, 0, 54, 132, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 246, 15, - 16, 0, 1, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 50, 0, 0, 9, - 18, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 50, 0, 0, 9, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 6, 2, - 16, 0, 2, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 226, 0, 16, 0, 1, 0, - 0, 0, 246, 31, 16, 0, - 3, 0, 0, 0, 6, 25, - 16, 0, 3, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 2, 0, 0, 0, - 166, 10, 16, 0, 1, 0, - 0, 0, 54, 132, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 2, 0, - 0, 0, 54, 132, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 86, 5, 16, 0, - 1, 0, 0, 0, 70, 14, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 2, 0, 0, 0, - 54, 132, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 246, 15, 16, 0, 1, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 50, 0, - 0, 9, 18, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 0, 2, 0, 0, 0, - 58, 0, 16, 0, 2, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 50, 0, - 0, 9, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 2, 0, 0, 0, - 6, 2, 16, 0, 2, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 2, 0, 0, 0, 86, 21, - 16, 0, 0, 0, 0, 0, - 54, 132, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 2, 0, 0, 0, - 54, 132, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 6, 16, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 2, 0, 0, 0, 54, 132, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 166, 26, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 0, 0, 0, 8, - 242, 0, 16, 0, 2, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 54, 132, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 50, 0, - 0, 10, 18, 0, 16, 0, - 1, 0, 0, 0, 58, 0, - 16, 128, 65, 0, 0, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 128, - 65, 0, 0, 0, 2, 0, - 0, 0, 6, 2, 16, 0, - 2, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 10, 226, 0, - 16, 0, 1, 0, 0, 0, - 86, 12, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 192, 0, 0, 128, 64, - 0, 0, 0, 192, 56, 0, - 0, 7, 50, 0, 16, 0, - 2, 0, 0, 0, 214, 5, - 16, 0, 1, 0, 0, 0, - 214, 5, 16, 0, 1, 0, - 0, 0, 50, 0, 0, 10, - 34, 0, 16, 0, 2, 0, - 0, 0, 42, 0, 16, 128, - 65, 0, 0, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 26, 0, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 10, 66, 0, - 16, 0, 1, 0, 0, 0, - 42, 0, 16, 128, 65, 0, - 0, 0, 1, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 2, 0, 0, 0, 75, 0, - 0, 5, 18, 0, 16, 0, - 2, 0, 0, 0, 26, 0, - 16, 0, 2, 0, 0, 0, - 29, 0, 0, 7, 34, 0, - 16, 0, 2, 0, 0, 0, - 26, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 49, 0, - 0, 10, 194, 0, 16, 0, - 2, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 128, 0, 0, 0, 128, - 86, 13, 16, 0, 0, 0, - 0, 0, 55, 0, 0, 15, - 194, 0, 16, 0, 2, 0, - 0, 0, 166, 14, 16, 0, - 2, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 191, 0, 0, 128, 191, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 63, 0, 0, - 128, 63, 50, 0, 0, 9, - 130, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 2, 0, 0, 0, 10, 0, - 16, 0, 2, 0, 0, 0, - 58, 0, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 7, - 130, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 191, - 14, 0, 0, 7, 130, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 14, 0, - 0, 7, 66, 0, 16, 0, - 3, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 58, 0, 16, 0, 1, 0, - 0, 0, 49, 0, 0, 7, - 18, 0, 16, 0, 1, 0, - 0, 0, 42, 0, 16, 0, - 3, 0, 0, 0, 58, 0, - 16, 0, 3, 0, 0, 0, - 55, 0, 0, 9, 146, 0, - 16, 0, 1, 0, 0, 0, - 6, 0, 16, 0, 1, 0, - 0, 0, 166, 14, 16, 0, - 3, 0, 0, 0, 246, 11, - 16, 0, 3, 0, 0, 0, - 1, 0, 0, 7, 146, 0, - 16, 0, 1, 0, 0, 0, - 6, 12, 16, 0, 1, 0, - 0, 0, 86, 5, 16, 0, - 2, 0, 0, 0, 24, 0, - 0, 10, 178, 0, 16, 0, - 2, 0, 0, 0, 70, 12, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 128, - 0, 0, 0, 0, 0, 0, - 0, 128, 1, 0, 0, 7, - 162, 0, 16, 0, 0, 0, - 0, 0, 86, 13, 16, 0, - 2, 0, 0, 0, 6, 0, - 16, 0, 2, 0, 0, 0, - 55, 0, 0, 12, 194, 32, - 16, 0, 1, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 12, - 16, 0, 1, 0, 0, 0, - 75, 0, 0, 5, 130, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 29, 0, 0, 7, - 18, 0, 16, 0, 1, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 50, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 2, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 191, 14, 0, - 0, 7, 50, 0, 16, 0, - 2, 0, 0, 0, 230, 10, - 16, 0, 0, 0, 0, 0, - 54, 15, 16, 0, 0, 0, - 0, 0, 49, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 2, 0, 0, 0, 26, 0, - 16, 0, 2, 0, 0, 0, - 55, 0, 0, 9, 82, 0, - 16, 0, 0, 0, 0, 0, - 6, 0, 16, 0, 0, 0, - 0, 0, 6, 1, 16, 0, - 2, 0, 0, 0, 86, 4, - 16, 0, 2, 0, 0, 0, - 1, 0, 0, 7, 82, 0, - 16, 0, 0, 0, 0, 0, - 6, 2, 16, 0, 0, 0, - 0, 0, 6, 0, 16, 0, - 1, 0, 0, 0, 55, 0, - 0, 12, 50, 32, 16, 0, - 1, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 134, 0, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 7, 130, 32, 16, 0, - 2, 0, 0, 0, 58, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 12, 0, - 0, 0, 14, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 18, 16, 0, - 1, 0, 0, 0, 246, 31, - 16, 0, 1, 0, 0, 0, - 16, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 18, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 6, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 17, 0, - 0, 8, 18, 32, 16, 0, - 2, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 12, 0, 0, 0, - 14, 0, 0, 7, 114, 0, - 16, 0, 1, 0, 0, 0, - 70, 18, 16, 0, 2, 0, - 0, 0, 246, 31, 16, 0, - 2, 0, 0, 0, 16, 0, - 0, 7, 130, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 70, 18, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 130, 0, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 128, - 65, 0, 0, 0, 1, 0, - 0, 0, 17, 0, 0, 8, - 34, 32, 16, 0, 2, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 14, 0, - 0, 7, 114, 0, 16, 0, - 2, 0, 0, 0, 70, 18, - 16, 0, 3, 0, 0, 0, - 246, 31, 16, 0, 3, 0, - 0, 0, 16, 0, 0, 7, - 130, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 18, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 6, 130, 0, - 16, 0, 2, 0, 0, 0, - 58, 0, 16, 128, 65, 0, - 0, 0, 2, 0, 0, 0, - 17, 0, 0, 8, 66, 32, - 16, 0, 2, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 12, 0, - 0, 0, 54, 0, 0, 7, - 130, 32, 16, 0, 3, 0, - 0, 0, 58, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 13, 0, 0, 0, - 17, 0, 0, 8, 18, 32, - 16, 0, 3, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 13, 0, - 0, 0, 17, 0, 0, 8, - 34, 32, 16, 0, 3, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 13, 0, 0, 0, 17, 0, - 0, 8, 66, 32, 16, 0, - 3, 0, 0, 0, 70, 14, - 16, 0, 2, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 13, 0, 0, 0, - 17, 0, 0, 8, 18, 32, - 16, 0, 4, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 14, 0, - 0, 0, 17, 0, 0, 8, - 18, 32, 16, 0, 5, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 17, 0, - 0, 8, 34, 32, 16, 0, - 4, 0, 0, 0, 70, 14, - 16, 0, 1, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 14, 0, 0, 0, - 17, 0, 0, 8, 34, 32, - 16, 0, 5, 0, 0, 0, - 70, 14, 16, 0, 1, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 17, 0, 0, 8, - 66, 32, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 14, 0, 0, 0, 17, 0, - 0, 8, 66, 32, 16, 0, - 5, 0, 0, 0, 70, 14, - 16, 0, 2, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 54, 0, 0, 7, 130, 32, - 16, 0, 4, 0, 0, 0, - 58, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 14, 0, 0, 0, 54, 0, - 0, 7, 130, 32, 16, 0, - 5, 0, 0, 0, 58, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 56, 0, 0, 8, - 242, 0, 16, 0, 0, 0, - 0, 0, 86, 21, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 16, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 166, 26, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 14, 0, 0, 7, - 114, 32, 16, 0, 6, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 6, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 83, 84, 65, 84, 148, 0, - 0, 0, 85, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 11, 0, 0, 0, - 70, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/imguiPS.hlsl b/demo/d3d11/shaders/imguiPS.hlsl deleted file mode 100644 index f51a21b..0000000 --- a/demo/d3d11/shaders/imguiPS.hlsl +++ /dev/null @@ -1,22 +0,0 @@ - -struct Input -{ - float4 position : SV_POSITION; - float2 texCoord : TEXCOORD; - float4 color : COLOR; -}; - -Texture2D tex : register(t0); -SamplerState texSampler : register(s0); - -float4 imguiPS(Input input) : SV_TARGET -{ - float4 color = input.color; - - if (input.texCoord.x >= 0.f) - { - color.a *= tex.SampleLevel(texSampler, input.texCoord, 0.f); - } - - return color; -} \ No newline at end of file diff --git a/demo/d3d11/shaders/imguiPS.hlsl.h b/demo/d3d11/shaders/imguiPS.hlsl.h deleted file mode 100644 index 92aa84a..0000000 --- a/demo/d3d11/shaders/imguiPS.hlsl.h +++ /dev/null @@ -1,197 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// texSampler sampler NA NA 0 1 -// tex texture float 2d 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_sampler s0, mode_default -dcl_resource_texture2d (float,float,float,float) t0 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xyzw -dcl_output o0.xyzw -dcl_temps 1 -ge r0.x, v1.x, l(0.000000) -if_nz r0.x - sample_l_indexable(texture2d)(float,float,float,float) r0.x, v1.xyxx, t0.xyzw, s0, l(0.000000) - mul r0.x, r0.x, v2.w -else - mov r0.x, v2.w -endif -mov r0.yzw, v2.xxyz -mov o0.xyzw, r0.yzwx -ret -// Approximately 10 instruction slots used -#endif - -const BYTE g_imguiPS[] = -{ - 68, 88, 66, 67, 214, 230, - 179, 60, 250, 108, 227, 78, - 125, 188, 145, 68, 25, 248, - 141, 62, 1, 0, 0, 0, - 92, 3, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 252, 0, 0, 0, 112, 1, - 0, 0, 164, 1, 0, 0, - 192, 2, 0, 0, 82, 68, - 69, 70, 192, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 139, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 124, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 135, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 116, 101, - 120, 83, 97, 109, 112, 108, - 101, 114, 0, 116, 101, 120, - 0, 77, 105, 99, 114, 111, - 115, 111, 102, 116, 32, 40, - 82, 41, 32, 72, 76, 83, - 76, 32, 83, 104, 97, 100, - 101, 114, 32, 67, 111, 109, - 112, 105, 108, 101, 114, 32, - 54, 46, 51, 46, 57, 54, - 48, 48, 46, 49, 54, 51, - 56, 52, 0, 171, 171, 171, - 73, 83, 71, 78, 108, 0, - 0, 0, 3, 0, 0, 0, - 8, 0, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 92, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 3, 3, 0, 0, 101, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 15, 15, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 67, 79, 76, 79, 82, - 0, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 20, 1, - 0, 0, 80, 0, 0, 0, - 69, 0, 0, 0, 106, 8, - 0, 1, 90, 0, 0, 3, - 0, 96, 16, 0, 0, 0, - 0, 0, 88, 24, 0, 4, - 0, 112, 16, 0, 0, 0, - 0, 0, 85, 85, 0, 0, - 98, 16, 0, 3, 50, 16, - 16, 0, 1, 0, 0, 0, - 98, 16, 0, 3, 242, 16, - 16, 0, 2, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 0, 0, 0, 0, - 104, 0, 0, 2, 1, 0, - 0, 0, 29, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 10, 16, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 31, 0, 4, 3, 10, 0, - 16, 0, 0, 0, 0, 0, - 72, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 18, 0, 16, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 70, 126, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 58, 16, 16, 0, 2, 0, - 0, 0, 18, 0, 0, 1, - 54, 0, 0, 5, 18, 0, - 16, 0, 0, 0, 0, 0, - 58, 16, 16, 0, 2, 0, - 0, 0, 21, 0, 0, 1, - 54, 0, 0, 5, 226, 0, - 16, 0, 0, 0, 0, 0, - 6, 25, 16, 0, 2, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 0, 0, - 0, 0, 150, 3, 16, 0, - 0, 0, 0, 0, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 10, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/imguiVS.hlsl b/demo/d3d11/shaders/imguiVS.hlsl deleted file mode 100644 index 6116ee1..0000000 --- a/demo/d3d11/shaders/imguiVS.hlsl +++ /dev/null @@ -1,31 +0,0 @@ - -cbuffer params : register(b0) -{ - float4x4 transform; -}; - -struct Input -{ - float2 position : POSITION; - float2 texCoord : TEXCOORD; - float4 color : COLOR; -}; - -struct Output -{ - float4 position : SV_POSITION; - float2 texCoord : TEXCOORD; - float4 color : COLOR; -}; - -Output imguiVS(Input input, uint instance : SV_InstanceID) -{ - Output output; - - output.position = mul(float4(input.position, 0.f, 1.f), transform); - - output.texCoord = input.texCoord.xy; // float2(input.texCoord.x, 1.f - input.texCoord.y); - output.color = input.color; - - return output; -} \ No newline at end of file diff --git a/demo/d3d11/shaders/imguiVS.hlsl.h b/demo/d3d11/shaders/imguiVS.hlsl.h deleted file mode 100644 index 7249cec..0000000 --- a/demo/d3d11/shaders/imguiVS.hlsl.h +++ /dev/null @@ -1,248 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer params -// { -// -// float4x4 transform; // Offset: 0 Size: 64 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// params cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xy 0 NONE float xy -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// SV_InstanceID 0 x 3 INSTID uint -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[4], immediateIndexed -dcl_input v0.xy -dcl_input v1.xy -dcl_input v2.xyzw -dcl_output_siv o0.xyzw, position -dcl_output o1.xy -dcl_output o2.xyzw -dcl_temps 1 -mov r0.xy, v0.xyxx -mov r0.z, l(1.000000) -dp3 o0.x, r0.xyzx, cb0[0].xywx -dp3 o0.y, r0.xyzx, cb0[1].xywx -dp3 o0.z, r0.xyzx, cb0[2].xywx -dp3 o0.w, r0.xyzx, cb0[3].xywx -mov o1.xy, v1.xyxx -mov o2.xyzw, v2.xyzw -ret -// Approximately 9 instruction slots used -#endif - -const BYTE g_imguiVS[] = -{ - 68, 88, 66, 67, 11, 92, - 70, 30, 32, 80, 66, 187, - 246, 56, 106, 189, 128, 201, - 215, 197, 1, 0, 0, 0, - 64, 4, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 76, 1, 0, 0, 228, 1, - 0, 0, 88, 2, 0, 0, - 164, 3, 0, 0, 82, 68, - 69, 70, 16, 1, 0, 0, - 1, 0, 0, 0, 100, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 220, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 112, 97, 114, 97, - 109, 115, 0, 171, 92, 0, - 0, 0, 1, 0, 0, 0, - 124, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 164, 0, - 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 2, 0, - 0, 0, 184, 0, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 116, 114, 97, 110, - 115, 102, 111, 114, 109, 0, - 102, 108, 111, 97, 116, 52, - 120, 52, 0, 171, 3, 0, - 3, 0, 4, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 174, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 144, 0, 0, 0, 4, 0, - 0, 0, 8, 0, 0, 0, - 104, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 0, 0, - 113, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 3, 3, 0, 0, - 122, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 15, 0, 0, - 128, 0, 0, 0, 0, 0, - 0, 0, 8, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 84, 69, 88, - 67, 79, 79, 82, 68, 0, - 67, 79, 76, 79, 82, 0, - 83, 86, 95, 73, 110, 115, - 116, 97, 110, 99, 101, 73, - 68, 0, 171, 171, 79, 83, - 71, 78, 108, 0, 0, 0, - 3, 0, 0, 0, 8, 0, - 0, 0, 80, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 92, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 3, 12, - 0, 0, 101, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 67, - 79, 76, 79, 82, 0, 171, - 83, 72, 69, 88, 68, 1, - 0, 0, 80, 0, 1, 0, - 81, 0, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 95, 0, 0, 3, 50, 16, - 16, 0, 0, 0, 0, 0, - 95, 0, 0, 3, 50, 16, - 16, 0, 1, 0, 0, 0, - 95, 0, 0, 3, 242, 16, - 16, 0, 2, 0, 0, 0, - 103, 0, 0, 4, 242, 32, - 16, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 50, 32, 16, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 2, 0, 0, 0, 104, 0, - 0, 2, 1, 0, 0, 0, - 54, 0, 0, 5, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 66, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 16, 0, - 0, 8, 18, 32, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 131, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 16, 0, 0, 8, 34, 32, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 131, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 16, 0, 0, 8, - 66, 32, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 131, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 16, 0, - 0, 8, 130, 32, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 131, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 5, 50, 32, - 16, 0, 1, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 2, 0, - 0, 0, 70, 30, 16, 0, - 2, 0, 0, 0, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 9, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/meshPS.hlsl b/demo/d3d11/shaders/meshPS.hlsl deleted file mode 100644 index db28d60..0000000 --- a/demo/d3d11/shaders/meshPS.hlsl +++ /dev/null @@ -1,130 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - MeshShaderConst gParams; -}; - -Texture2D shadowTexture : register(t0); // shadow map - -SamplerComparisonState shadowSampler : register(s0); // texture sample used to sample depth from shadow texture in this sample - -// sample shadow map -float shadowSample(float4 gl_TexCoord[8]) -{ - float3 pos = float3(gl_TexCoord[1].xyz / gl_TexCoord[1].w); - float3 uvw = (pos.xyz * float3(0.5, 0.5, 1.0)) + float3(0.5, 0.5, 0.0); - - // user clip - if (uvw.x < 0.0 || uvw.x > 1.0) - return 1.0; - if (uvw.y < 0.0 || uvw.y > 1.0) - return 1.0; - - float s = 0.0; - float radius = 0.002; - - const int numTaps = 12; - - // flip uv y-coordinate - uvw.y = 1.0f - uvw.y; - - [unroll] - for (int i = 0; i < numTaps; i++) - { - float2 shadowTaps = gParams.shadowTaps[i].xy; - shadowTaps.y = 1.0f - shadowTaps.y; - s += shadowTexture.SampleCmpLevelZero(shadowSampler, uvw.xy + shadowTaps * radius, uvw.z); - } - s /= numTaps; - - return s; -} - -float filterwidth(float2 v) -{ - float2 fw = max(abs(ddx(v)), abs(ddy(v))); - return max(fw.x, fw.y); -} - -float2 bump(float2 x) -{ - return (floor((x) / 2) + 2.f * max(((x) / 2) - floor((x) / 2) - .5f, 0.f)); -} - -float checker(float2 uv) -{ - float width = filterwidth(uv); - float2 p0 = uv - 0.5 * width; - float2 p1 = uv + 0.5 * width; - - float2 i = (bump(p1) - bump(p0)) / width; - return i.x * i.y + (1 - i.x) * (1 - i.y); -} - -float4 meshPS(MeshVertexOut input, bool isFrontFace : SV_IsFrontFace) : SV_TARGET -{ - float4 gl_FragColor; - float4 gl_TexCoord[8]; - - [unroll] - for (int i = 0; i < 8; i++) - gl_TexCoord[i] = input.texCoord[i]; - - const float4 fogColor = gParams.fogColor; - const float3 lightDir = gParams.lightDir; - const float3 lightPos = gParams.lightPos; - const float spotMin = gParams.spotMin; - const float spotMax = gParams.spotMax; - const int grid = gParams.grid; - const int tex = gParams.tex; - - // calculate lighting - float shadow = max(shadowSample(gl_TexCoord), 0.5); - - float3 lVec = normalize(gl_TexCoord[3].xyz - (lightPos)); - float3 lPos = float3(gl_TexCoord[1].xyz / gl_TexCoord[1].w); - float attenuation = max(smoothstep(spotMax, spotMin, dot(lPos.xy, lPos.xy)), 0.05); - - float3 n = gl_TexCoord[0].xyz; - float3 color = gl_TexCoord[4].xyz; - - if (!isFrontFace) - { - color = gl_TexCoord[6].xyz; - n *= -1.0f; - } - - if (grid && (n.y > 0.995)) - { - color *= 1.0 - 0.25 * checker(float2(gl_TexCoord[3].x, gl_TexCoord[3].z)); - } - else if (grid && abs(n.z) > 0.995) - { - color *= 1.0 - 0.25 * checker(float2(gl_TexCoord[3].y, gl_TexCoord[3].x)); - } - - if (tex) - { - //color = texture2D(tex, gl_TexCoord[5].xy).xyz; - } - - // direct light term - float wrap = 0.0; - float3 diffuse = color * float3(1.0, 1.0, 1.0) * max(0.0, (-dot(lightDir, n) + wrap) / (1.0 + wrap) * shadow) * attenuation; - - // wrap ambient term aligned with light dir - float3 light = float3(0.03, 0.025, 0.025) * 1.5; - float3 dark = float3(0.025, 0.025, 0.03); - //float3 ambient = 4.0 * color * lerp(dark, light, -dot(lightDir, n) * 0.5 + 0.5) * attenuation; - float3 ambient = 4.0 * color * lerp(dark, light, -dot(lightDir, n) * float3(0.5, 0.5, 1.0) + float3(0.5, 0.5, 0.0)) * attenuation; - - float3 fog = lerp(fogColor.xyz, diffuse + ambient, exp(gl_TexCoord[7].z * fogColor.w)); - - //gl_FragColor = float4(pow(fog, float3(1.0 / 2.2)), 1.0); - const float tmp = 1.0 / 2.2; - gl_FragColor = float4(pow(abs(fog), float3(tmp, tmp, tmp)), 1.0); - - return gl_FragColor; - -} diff --git a/demo/d3d11/shaders/meshPS.hlsl.h b/demo/d3d11/shaders/meshPS.hlsl.h deleted file mode 100644 index 9bbb118..0000000 --- a/demo/d3d11/shaders/meshPS.hlsl.h +++ /dev/null @@ -1,1553 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct MeshShaderConst -// { -// -// float4x4 modelviewprojection; // Offset: 0 -// float4x4 modelview; // Offset: 64 -// float4x4 objectTransform; // Offset: 128 -// float4x4 lightTransform; // Offset: 192 -// float4 clipPlane; // Offset: 256 -// float4 fogColor; // Offset: 272 -// float4 color; // Offset: 288 -// float4 secondaryColor; // Offset: 304 -// float4 shadowTaps[12]; // Offset: 320 -// float3 lightPos; // Offset: 512 -// float _pad0; // Offset: 524 -// float3 lightDir; // Offset: 528 -// float _pad1; // Offset: 540 -// float bias; // Offset: 544 -// float expand; // Offset: 548 -// float spotMin; // Offset: 552 -// float spotMax; // Offset: 556 -// int grid; // Offset: 560 -// int tex; // Offset: 564 -// int colorArray; // Offset: 568 -// int _pad2; // Offset: 572 -// -// } gParams; // Offset: 0 Size: 576 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// shadowSampler sampler_c NA NA 0 1 -// shadowTexture texture float 2d 0 1 -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xyzw 1 NONE float xyz -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float -// TEXCOORD 3 xyzw 4 NONE float xyz -// TEXCOORD 4 xyzw 5 NONE float xyz -// TEXCOORD 5 xyzw 6 NONE float -// TEXCOORD 6 xyzw 7 NONE float xyz -// TEXCOORD 7 xyzw 8 NONE float z -// SV_IsFrontFace 0 x 9 FFACE uint x -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[36], immediateIndexed -dcl_sampler s0, mode_comparison -dcl_resource_texture2d (float,float,float,float) t0 -dcl_input_ps linear v1.xyz -dcl_input_ps linear v2.xyzw -dcl_input_ps linear v4.xyz -dcl_input_ps linear v5.xyz -dcl_input_ps linear v7.xyz -dcl_input_ps linear v8.z -dcl_input_ps_sgv v9.x, is_front_face -dcl_output o0.xyzw -dcl_temps 6 -div r0.xyz, v2.xyzx, v2.wwww -mad r1.xyz, r0.xyzx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) -lt r0.z, r1.x, l(0.000000) -lt r0.w, l(1.000000), r1.x -or r0.z, r0.w, r0.z -if_z r0.z - lt r0.z, r1.y, l(0.000000) - lt r0.w, l(1.000000), r1.y - or r0.z, r0.w, r0.z - if_z r0.z - add r0.z, -cb0[20].y, l(1.000000) - mul r2.x, cb0[20].x, l(0.002000) - mul r2.y, r0.z, l(0.002000) - add r1.w, -r1.y, l(1.000000) - add r0.zw, r1.xxxw, r2.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t0.xxxx, s0, r1.z - add r0.w, -cb0[21].y, l(1.000000) - mul r2.x, cb0[21].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[22].y, l(1.000000) - mul r2.x, cb0[22].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[23].y, l(1.000000) - mul r2.x, cb0[23].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[24].y, l(1.000000) - mul r2.x, cb0[24].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[25].y, l(1.000000) - mul r2.x, cb0[25].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[26].y, l(1.000000) - mul r2.x, cb0[26].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[27].y, l(1.000000) - mul r2.x, cb0[27].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[28].y, l(1.000000) - mul r2.x, cb0[28].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[29].y, l(1.000000) - mul r2.x, cb0[29].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[30].y, l(1.000000) - mul r2.x, cb0[30].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r2.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r2.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - add r0.w, -cb0[31].y, l(1.000000) - mul r2.x, cb0[31].x, l(0.002000) - mul r2.y, r0.w, l(0.002000) - add r1.xy, r1.xwxx, r2.xyxx - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r1.xyxx, t0.xxxx, s0, r1.z - add r0.z, r0.w, r0.z - mul r0.z, r0.z, l(0.083333) - else - mov r0.z, l(1.000000) - endif -else - mov r0.z, l(1.000000) -endif -dp2 r0.x, r0.xyxx, r0.xyxx -add r0.y, -cb0[34].w, cb0[34].z -add r0.x, r0.x, -cb0[34].w -div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y -mul_sat r0.x, r0.y, r0.x -mad r0.y, r0.x, l(-2.000000), l(3.000000) -mul r0.x, r0.x, r0.x -mul r0.x, r0.x, r0.y -max r0.xz, r0.xxzx, l(0.050000, 0.000000, 0.500000, 0.000000) -movc r1.xyz, v9.xxxx, v1.xyzx, -v1.xyzx -movc r2.xyz, v9.xxxx, v5.xyzx, v7.xyzx -ine r0.y, cb0[35].x, l(0) -lt r0.w, l(0.995000), r1.y -and r0.w, r0.w, r0.y -if_nz r0.w - deriv_rtx_coarse r3.xy, v4.xzxx - deriv_rty_coarse r3.zw, v4.xxxz - max r3.xy, |r3.zwzz|, |r3.xyxx| - max r0.w, r3.y, r3.x - mad r3.xy, -r0.wwww, l(0.500000, 0.500000, 0.000000, 0.000000), v4.xzxx - mad r3.zw, r0.wwww, l(0.000000, 0.000000, 0.500000, 0.500000), v4.xxxz - mul r4.xy, r3.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) - round_ni r4.xy, r4.xyxx - mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), -r4.xxxy - add r3.zw, r3.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000) - max r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000) - mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), r4.xxxy - mul r4.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) - round_ni r4.xy, r4.xyxx - mad r3.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), -r4.xyxx - add r3.xy, r3.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) - max r3.xy, r3.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) - mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r4.xyxx - add r3.xy, -r3.xyxx, r3.zwzz - div r3.xy, r3.xyxx, r0.wwww - add r3.zw, -r3.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) - mul r0.w, r3.w, r3.z - mad r0.w, r3.x, r3.y, r0.w - mad r0.w, -r0.w, l(0.250000), l(1.000000) - mul r3.xyz, r0.wwww, r2.xyzx -else - lt r0.w, l(0.995000), |r1.z| - and r0.y, r0.w, r0.y - deriv_rtx_coarse r4.xy, v4.yxyy - deriv_rty_coarse r4.zw, v4.yyyx - max r4.xy, |r4.zwzz|, |r4.xyxx| - max r0.w, r4.y, r4.x - mad r4.xy, -r0.wwww, l(0.500000, 0.500000, 0.000000, 0.000000), v4.yxyy - mad r4.zw, r0.wwww, l(0.000000, 0.000000, 0.500000, 0.500000), v4.yyyx - mul r5.xy, r4.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) - round_ni r5.xy, r5.xyxx - mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), -r5.xxxy - add r4.zw, r4.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000) - max r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000) - mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), r5.xxxy - mul r5.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) - round_ni r5.xy, r5.xyxx - mad r4.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), -r5.xyxx - add r4.xy, r4.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000) - max r4.xy, r4.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000) - mad r4.xy, r4.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r5.xyxx - add r4.xy, -r4.xyxx, r4.zwzz - div r4.xy, r4.xyxx, r0.wwww - add r4.zw, -r4.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) - mul r0.w, r4.w, r4.z - mad r0.w, r4.x, r4.y, r0.w - mad r0.w, -r0.w, l(0.250000), l(1.000000) - mul r4.xyz, r0.wwww, r2.xyzx - movc r3.xyz, r0.yyyy, r4.xyzx, r2.xyzx -endif -dp3 r0.y, cb0[33].xyzx, r1.xyzx -mul r0.z, r0.z, -r0.y -max r0.z, r0.z, l(0.000000) -mul r1.xyz, r0.zzzz, r3.xyzx -mul r2.xyz, r3.xyzx, l(4.000000, 4.000000, 4.000000, 0.000000) -mad r0.yzw, r0.yyyy, l(0.000000, -0.500000, -0.500000, -1.000000), l(0.000000, 0.500000, 0.500000, 0.000000) -mad r0.yzw, r0.yyzw, l(0.000000, 0.020000, 0.012500, 0.007500), l(0.000000, 0.025000, 0.025000, 0.030000) -mul r0.yzw, r0.yyzw, r2.xxyz -mul r0.yzw, r0.xxxx, r0.yyzw -mad r0.xyz, r1.xyzx, r0.xxxx, r0.yzwy -mul r0.w, v8.z, cb0[17].w -mul r0.w, r0.w, l(1.442695) -exp r0.w, r0.w -add r0.xyz, r0.xyzx, -cb0[17].xyzx -mad r0.xyz, r0.wwww, r0.xyzx, cb0[17].xyzx -log r0.xyz, |r0.xyzx| -mul r0.xyz, r0.xyzx, l(0.454545, 0.454545, 0.454545, 0.000000) -exp o0.xyz, r0.xyzx -mov o0.w, l(1.000000) -ret -// Approximately 179 instruction slots used -#endif - -const BYTE g_meshPS[] = -{ - 68, 88, 66, 67, 162, 143, - 63, 83, 112, 221, 166, 253, - 12, 109, 97, 84, 15, 129, - 226, 222, 1, 0, 0, 0, - 8, 30, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 116, 4, 0, 0, 152, 5, - 0, 0, 204, 5, 0, 0, - 108, 29, 0, 0, 82, 68, - 69, 70, 56, 4, 0, 0, - 1, 0, 0, 0, 196, 0, - 0, 0, 3, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 4, 4, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 156, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 170, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 184, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 115, 104, 97, 100, 111, 119, - 83, 97, 109, 112, 108, 101, - 114, 0, 115, 104, 97, 100, - 111, 119, 84, 101, 120, 116, - 117, 114, 101, 0, 99, 111, - 110, 115, 116, 66, 117, 102, - 0, 171, 171, 171, 184, 0, - 0, 0, 1, 0, 0, 0, - 220, 0, 0, 0, 64, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 1, - 0, 0, 0, 0, 0, 0, - 64, 2, 0, 0, 2, 0, - 0, 0, 224, 3, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 103, 80, 97, 114, - 97, 109, 115, 0, 77, 101, - 115, 104, 83, 104, 97, 100, - 101, 114, 67, 111, 110, 115, - 116, 0, 109, 111, 100, 101, - 108, 118, 105, 101, 119, 112, - 114, 111, 106, 101, 99, 116, - 105, 111, 110, 0, 102, 108, - 111, 97, 116, 52, 120, 52, - 0, 171, 171, 171, 3, 0, - 3, 0, 4, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 48, 1, 0, 0, 109, 111, - 100, 101, 108, 118, 105, 101, - 119, 0, 111, 98, 106, 101, - 99, 116, 84, 114, 97, 110, - 115, 102, 111, 114, 109, 0, - 108, 105, 103, 104, 116, 84, - 114, 97, 110, 115, 102, 111, - 114, 109, 0, 99, 108, 105, - 112, 80, 108, 97, 110, 101, - 0, 102, 108, 111, 97, 116, - 52, 0, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 147, 1, 0, 0, 102, 111, - 103, 67, 111, 108, 111, 114, - 0, 99, 111, 108, 111, 114, - 0, 115, 101, 99, 111, 110, - 100, 97, 114, 121, 67, 111, - 108, 111, 114, 0, 115, 104, - 97, 100, 111, 119, 84, 97, - 112, 115, 0, 171, 171, 171, - 1, 0, 3, 0, 1, 0, - 4, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 147, 1, 0, 0, - 108, 105, 103, 104, 116, 80, - 111, 115, 0, 102, 108, 111, - 97, 116, 51, 0, 1, 0, - 3, 0, 1, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 25, 2, 0, 0, 95, 112, - 97, 100, 48, 0, 102, 108, - 111, 97, 116, 0, 0, 0, - 3, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 74, 2, 0, 0, 108, 105, - 103, 104, 116, 68, 105, 114, - 0, 95, 112, 97, 100, 49, - 0, 98, 105, 97, 115, 0, - 101, 120, 112, 97, 110, 100, - 0, 115, 112, 111, 116, 77, - 105, 110, 0, 115, 112, 111, - 116, 77, 97, 120, 0, 103, - 114, 105, 100, 0, 105, 110, - 116, 0, 0, 0, 2, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 164, 2, - 0, 0, 116, 101, 120, 0, - 99, 111, 108, 111, 114, 65, - 114, 114, 97, 121, 0, 95, - 112, 97, 100, 50, 0, 171, - 171, 171, 28, 1, 0, 0, - 60, 1, 0, 0, 0, 0, - 0, 0, 96, 1, 0, 0, - 60, 1, 0, 0, 64, 0, - 0, 0, 106, 1, 0, 0, - 60, 1, 0, 0, 128, 0, - 0, 0, 122, 1, 0, 0, - 60, 1, 0, 0, 192, 0, - 0, 0, 137, 1, 0, 0, - 156, 1, 0, 0, 0, 1, - 0, 0, 192, 1, 0, 0, - 156, 1, 0, 0, 16, 1, - 0, 0, 201, 1, 0, 0, - 156, 1, 0, 0, 32, 1, - 0, 0, 207, 1, 0, 0, - 156, 1, 0, 0, 48, 1, - 0, 0, 222, 1, 0, 0, - 236, 1, 0, 0, 64, 1, - 0, 0, 16, 2, 0, 0, - 32, 2, 0, 0, 0, 2, - 0, 0, 68, 2, 0, 0, - 80, 2, 0, 0, 12, 2, - 0, 0, 116, 2, 0, 0, - 32, 2, 0, 0, 16, 2, - 0, 0, 125, 2, 0, 0, - 80, 2, 0, 0, 28, 2, - 0, 0, 131, 2, 0, 0, - 80, 2, 0, 0, 32, 2, - 0, 0, 136, 2, 0, 0, - 80, 2, 0, 0, 36, 2, - 0, 0, 143, 2, 0, 0, - 80, 2, 0, 0, 40, 2, - 0, 0, 151, 2, 0, 0, - 80, 2, 0, 0, 44, 2, - 0, 0, 159, 2, 0, 0, - 168, 2, 0, 0, 48, 2, - 0, 0, 204, 2, 0, 0, - 168, 2, 0, 0, 52, 2, - 0, 0, 208, 2, 0, 0, - 168, 2, 0, 0, 56, 2, - 0, 0, 219, 2, 0, 0, - 168, 2, 0, 0, 60, 2, - 0, 0, 5, 0, 0, 0, - 1, 0, 144, 0, 0, 0, - 21, 0, 228, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 12, 1, - 0, 0, 77, 105, 99, 114, - 111, 115, 111, 102, 116, 32, - 40, 82, 41, 32, 72, 76, - 83, 76, 32, 83, 104, 97, - 100, 101, 114, 32, 67, 111, - 109, 112, 105, 108, 101, 114, - 32, 54, 46, 51, 46, 57, - 54, 48, 48, 46, 49, 54, - 51, 56, 52, 0, 171, 171, - 73, 83, 71, 78, 28, 1, - 0, 0, 10, 0, 0, 0, - 8, 0, 0, 0, 248, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 4, 1, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 7, 0, 0, 4, 1, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 15, 15, 0, 0, 4, 1, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 15, 0, 0, 0, 4, 1, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 4, 0, 0, 0, - 15, 7, 0, 0, 4, 1, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 5, 0, 0, 0, - 15, 7, 0, 0, 4, 1, - 0, 0, 5, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 6, 0, 0, 0, - 15, 0, 0, 0, 4, 1, - 0, 0, 6, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 7, 0, 0, 0, - 15, 7, 0, 0, 4, 1, - 0, 0, 7, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 8, 0, 0, 0, - 15, 4, 0, 0, 13, 1, - 0, 0, 0, 0, 0, 0, - 9, 0, 0, 0, 1, 0, - 0, 0, 9, 0, 0, 0, - 1, 1, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 83, 86, 95, 73, 115, - 70, 114, 111, 110, 116, 70, - 97, 99, 101, 0, 79, 83, - 71, 78, 44, 0, 0, 0, - 1, 0, 0, 0, 8, 0, - 0, 0, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 84, - 65, 82, 71, 69, 84, 0, - 171, 171, 83, 72, 69, 88, - 152, 23, 0, 0, 80, 0, - 0, 0, 230, 5, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 4, 70, 142, 32, 0, - 0, 0, 0, 0, 36, 0, - 0, 0, 90, 8, 0, 3, - 0, 96, 16, 0, 0, 0, - 0, 0, 88, 24, 0, 4, - 0, 112, 16, 0, 0, 0, - 0, 0, 85, 85, 0, 0, - 98, 16, 0, 3, 114, 16, - 16, 0, 1, 0, 0, 0, - 98, 16, 0, 3, 242, 16, - 16, 0, 2, 0, 0, 0, - 98, 16, 0, 3, 114, 16, - 16, 0, 4, 0, 0, 0, - 98, 16, 0, 3, 114, 16, - 16, 0, 5, 0, 0, 0, - 98, 16, 0, 3, 114, 16, - 16, 0, 7, 0, 0, 0, - 98, 16, 0, 3, 66, 16, - 16, 0, 8, 0, 0, 0, - 99, 8, 0, 4, 18, 16, - 16, 0, 9, 0, 0, 0, - 9, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 0, 0, 0, 0, 104, 0, - 0, 2, 6, 0, 0, 0, - 14, 0, 0, 7, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 18, 16, 0, 2, 0, - 0, 0, 246, 31, 16, 0, - 2, 0, 0, 0, 50, 0, - 0, 15, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 0, 0, 128, 63, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 63, 0, 0, - 0, 63, 0, 0, 0, 0, - 0, 0, 0, 0, 49, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 0, 49, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 10, 0, - 16, 0, 1, 0, 0, 0, - 60, 0, 0, 7, 66, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 0, 0, 0, 0, 31, 0, - 0, 3, 42, 0, 16, 0, - 0, 0, 0, 0, 49, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 26, 0, - 16, 0, 1, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 0, 49, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 26, 0, - 16, 0, 1, 0, 0, 0, - 60, 0, 0, 7, 66, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 0, 0, 0, 0, 31, 0, - 0, 3, 42, 0, 16, 0, - 0, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 0, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 20, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 2, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 20, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 2, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 8, 130, 0, 16, 0, - 1, 0, 0, 0, 26, 0, - 16, 128, 65, 0, 0, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 0, 7, 194, 0, - 16, 0, 0, 0, 0, 0, - 6, 12, 16, 0, 1, 0, - 0, 0, 6, 4, 16, 0, - 2, 0, 0, 0, 71, 0, - 0, 141, 194, 0, 0, 128, - 67, 85, 21, 0, 66, 0, - 16, 0, 0, 0, 0, 0, - 230, 10, 16, 0, 0, 0, - 0, 0, 6, 112, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 21, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 21, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 22, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 22, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 23, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 23, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 24, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 24, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 25, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 25, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 26, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 26, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 27, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 27, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 28, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 28, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 29, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 29, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 30, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 30, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 2, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 2, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 31, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 56, 0, 0, 8, - 18, 0, 16, 0, 2, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 31, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 56, 0, - 0, 7, 34, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 0, 0, 0, 7, - 50, 0, 16, 0, 1, 0, - 0, 0, 198, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 2, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 1, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 7, 66, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 171, 170, 170, 61, - 18, 0, 0, 1, 54, 0, - 0, 5, 66, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 21, 0, 0, 1, 18, 0, - 0, 1, 54, 0, 0, 5, - 66, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 21, 0, - 0, 1, 15, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 70, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 34, 0, - 16, 0, 0, 0, 0, 0, - 58, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 42, 128, - 32, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 0, 0, - 0, 9, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 58, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 14, 0, - 0, 10, 34, 0, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 128, 63, - 26, 0, 16, 0, 0, 0, - 0, 0, 56, 32, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 26, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 9, 34, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 192, 1, 64, - 0, 0, 0, 0, 64, 64, - 56, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 52, 0, 0, 10, - 82, 0, 16, 0, 0, 0, - 0, 0, 6, 2, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 205, 204, 76, 61, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 0, - 55, 0, 0, 10, 114, 0, - 16, 0, 1, 0, 0, 0, - 6, 16, 16, 0, 9, 0, - 0, 0, 70, 18, 16, 0, - 1, 0, 0, 0, 70, 18, - 16, 128, 65, 0, 0, 0, - 1, 0, 0, 0, 55, 0, - 0, 9, 114, 0, 16, 0, - 2, 0, 0, 0, 6, 16, - 16, 0, 9, 0, 0, 0, - 70, 18, 16, 0, 5, 0, - 0, 0, 70, 18, 16, 0, - 7, 0, 0, 0, 39, 0, - 0, 8, 34, 0, 16, 0, - 0, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 35, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 49, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 82, 184, - 126, 63, 26, 0, 16, 0, - 1, 0, 0, 0, 1, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 31, 0, 4, 3, - 58, 0, 16, 0, 0, 0, - 0, 0, 122, 0, 0, 5, - 50, 0, 16, 0, 3, 0, - 0, 0, 134, 16, 16, 0, - 4, 0, 0, 0, 124, 0, - 0, 5, 194, 0, 16, 0, - 3, 0, 0, 0, 6, 24, - 16, 0, 4, 0, 0, 0, - 52, 0, 0, 9, 50, 0, - 16, 0, 3, 0, 0, 0, - 230, 10, 16, 128, 129, 0, - 0, 0, 3, 0, 0, 0, - 70, 0, 16, 128, 129, 0, - 0, 0, 3, 0, 0, 0, - 52, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 3, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 13, 50, 0, 16, 0, - 3, 0, 0, 0, 246, 15, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 134, 16, 16, 0, 4, 0, - 0, 0, 50, 0, 0, 12, - 194, 0, 16, 0, 3, 0, - 0, 0, 246, 15, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 6, 24, 16, 0, 4, 0, - 0, 0, 56, 0, 0, 10, - 50, 0, 16, 0, 4, 0, - 0, 0, 230, 10, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 65, 0, 0, 5, 50, 0, - 16, 0, 4, 0, 0, 0, - 70, 0, 16, 0, 4, 0, - 0, 0, 50, 0, 0, 13, - 194, 0, 16, 0, 3, 0, - 0, 0, 166, 14, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 6, 4, 16, 128, 65, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 10, 194, 0, - 16, 0, 3, 0, 0, 0, - 166, 14, 16, 0, 3, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 191, - 0, 0, 0, 191, 52, 0, - 0, 10, 194, 0, 16, 0, - 3, 0, 0, 0, 166, 14, - 16, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 50, 0, 0, 12, - 194, 0, 16, 0, 3, 0, - 0, 0, 166, 14, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 64, 0, 0, 0, 64, - 6, 4, 16, 0, 4, 0, - 0, 0, 56, 0, 0, 10, - 50, 0, 16, 0, 4, 0, - 0, 0, 70, 0, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 65, 0, 0, 5, 50, 0, - 16, 0, 4, 0, 0, 0, - 70, 0, 16, 0, 4, 0, - 0, 0, 50, 0, 0, 13, - 50, 0, 16, 0, 3, 0, - 0, 0, 70, 0, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 0, 16, 128, 65, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 10, 50, 0, - 16, 0, 3, 0, 0, 0, - 70, 0, 16, 0, 3, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 191, 0, 0, - 0, 191, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 0, - 0, 10, 50, 0, 16, 0, - 3, 0, 0, 0, 70, 0, - 16, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 50, 0, 0, 12, - 50, 0, 16, 0, 3, 0, - 0, 0, 70, 0, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 64, - 0, 0, 0, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 4, 0, - 0, 0, 0, 0, 0, 8, - 50, 0, 16, 0, 3, 0, - 0, 0, 70, 0, 16, 128, - 65, 0, 0, 0, 3, 0, - 0, 0, 230, 10, 16, 0, - 3, 0, 0, 0, 14, 0, - 0, 7, 50, 0, 16, 0, - 3, 0, 0, 0, 70, 0, - 16, 0, 3, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 11, - 194, 0, 16, 0, 3, 0, - 0, 0, 6, 4, 16, 128, - 65, 0, 0, 0, 3, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 56, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 3, 0, - 0, 0, 50, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 3, 0, 0, 0, 26, 0, - 16, 0, 3, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 62, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 7, 114, 0, - 16, 0, 3, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 18, 0, - 0, 1, 49, 0, 0, 8, - 130, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 82, 184, 126, 63, 42, 0, - 16, 128, 129, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 7, 34, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 122, 0, 0, 5, - 50, 0, 16, 0, 4, 0, - 0, 0, 22, 21, 16, 0, - 4, 0, 0, 0, 124, 0, - 0, 5, 194, 0, 16, 0, - 4, 0, 0, 0, 86, 17, - 16, 0, 4, 0, 0, 0, - 52, 0, 0, 9, 50, 0, - 16, 0, 4, 0, 0, 0, - 230, 10, 16, 128, 129, 0, - 0, 0, 4, 0, 0, 0, - 70, 0, 16, 128, 129, 0, - 0, 0, 4, 0, 0, 0, - 52, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 4, 0, - 0, 0, 10, 0, 16, 0, - 4, 0, 0, 0, 50, 0, - 0, 13, 50, 0, 16, 0, - 4, 0, 0, 0, 246, 15, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 22, 21, 16, 0, 4, 0, - 0, 0, 50, 0, 0, 12, - 194, 0, 16, 0, 4, 0, - 0, 0, 246, 15, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 86, 17, 16, 0, 4, 0, - 0, 0, 56, 0, 0, 10, - 50, 0, 16, 0, 5, 0, - 0, 0, 230, 10, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 65, 0, 0, 5, 50, 0, - 16, 0, 5, 0, 0, 0, - 70, 0, 16, 0, 5, 0, - 0, 0, 50, 0, 0, 13, - 194, 0, 16, 0, 4, 0, - 0, 0, 166, 14, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 6, 4, 16, 128, 65, 0, - 0, 0, 5, 0, 0, 0, - 0, 0, 0, 10, 194, 0, - 16, 0, 4, 0, 0, 0, - 166, 14, 16, 0, 4, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 191, - 0, 0, 0, 191, 52, 0, - 0, 10, 194, 0, 16, 0, - 4, 0, 0, 0, 166, 14, - 16, 0, 4, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 50, 0, 0, 12, - 194, 0, 16, 0, 4, 0, - 0, 0, 166, 14, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 64, 0, 0, 0, 64, - 6, 4, 16, 0, 5, 0, - 0, 0, 56, 0, 0, 10, - 50, 0, 16, 0, 5, 0, - 0, 0, 70, 0, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 65, 0, 0, 5, 50, 0, - 16, 0, 5, 0, 0, 0, - 70, 0, 16, 0, 5, 0, - 0, 0, 50, 0, 0, 13, - 50, 0, 16, 0, 4, 0, - 0, 0, 70, 0, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 0, 16, 128, 65, 0, - 0, 0, 5, 0, 0, 0, - 0, 0, 0, 10, 50, 0, - 16, 0, 4, 0, 0, 0, - 70, 0, 16, 0, 4, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 191, 0, 0, - 0, 191, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 0, - 0, 10, 50, 0, 16, 0, - 4, 0, 0, 0, 70, 0, - 16, 0, 4, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 50, 0, 0, 12, - 50, 0, 16, 0, 4, 0, - 0, 0, 70, 0, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 64, - 0, 0, 0, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 5, 0, - 0, 0, 0, 0, 0, 8, - 50, 0, 16, 0, 4, 0, - 0, 0, 70, 0, 16, 128, - 65, 0, 0, 0, 4, 0, - 0, 0, 230, 10, 16, 0, - 4, 0, 0, 0, 14, 0, - 0, 7, 50, 0, 16, 0, - 4, 0, 0, 0, 70, 0, - 16, 0, 4, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 11, - 194, 0, 16, 0, 4, 0, - 0, 0, 6, 4, 16, 128, - 65, 0, 0, 0, 4, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 56, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 4, 0, 0, 0, - 42, 0, 16, 0, 4, 0, - 0, 0, 50, 0, 0, 9, - 130, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 4, 0, 0, 0, 26, 0, - 16, 0, 4, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 62, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 7, 114, 0, - 16, 0, 4, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 55, 0, - 0, 9, 114, 0, 16, 0, - 3, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 4, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 21, 0, - 0, 1, 16, 0, 0, 8, - 34, 0, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 33, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 8, 66, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 52, 0, 0, 7, 66, 0, - 16, 0, 0, 0, 0, 0, - 42, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 56, 0, - 0, 7, 114, 0, 16, 0, - 1, 0, 0, 0, 166, 10, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 64, - 0, 0, 128, 64, 0, 0, - 128, 64, 0, 0, 0, 0, - 50, 0, 0, 15, 226, 0, - 16, 0, 0, 0, 0, 0, - 86, 5, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 191, 0, 0, 0, 191, - 0, 0, 128, 191, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 63, 0, 0, - 0, 63, 0, 0, 0, 0, - 50, 0, 0, 15, 226, 0, - 16, 0, 0, 0, 0, 0, - 86, 14, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 11, 215, - 163, 60, 206, 204, 76, 60, - 148, 194, 245, 59, 2, 64, - 0, 0, 0, 0, 0, 0, - 205, 204, 204, 60, 205, 204, - 204, 60, 143, 194, 245, 60, - 56, 0, 0, 7, 226, 0, - 16, 0, 0, 0, 0, 0, - 86, 14, 16, 0, 0, 0, - 0, 0, 6, 9, 16, 0, - 2, 0, 0, 0, 56, 0, - 0, 7, 226, 0, 16, 0, - 0, 0, 0, 0, 6, 0, - 16, 0, 0, 0, 0, 0, - 86, 14, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 9, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 6, 0, - 16, 0, 0, 0, 0, 0, - 150, 7, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 8, - 130, 0, 16, 0, 0, 0, - 0, 0, 42, 16, 16, 0, - 8, 0, 0, 0, 58, 128, - 32, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 56, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 59, 170, - 184, 63, 25, 0, 0, 5, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 0, 0, - 0, 9, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 130, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 50, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 17, 0, - 0, 0, 47, 0, 0, 6, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 128, - 129, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 47, 186, 232, 62, - 47, 186, 232, 62, 47, 186, - 232, 62, 0, 0, 0, 0, - 25, 0, 0, 5, 114, 32, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 130, 32, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 179, 0, - 0, 0, 6, 0, 0, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 146, 0, 0, 0, - 1, 0, 0, 0, 4, 0, - 0, 0, 4, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/meshShadowPS.hlsl b/demo/d3d11/shaders/meshShadowPS.hlsl deleted file mode 100644 index cb60c22..0000000 --- a/demo/d3d11/shaders/meshShadowPS.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - MeshShaderConst gParams; -}; - -float4 meshPS_Shadow(MeshVertexOut input) : SV_TARGET -{ - return float4(0.0, 0.0, 0.0, 1.0); -} diff --git a/demo/d3d11/shaders/meshShadowPS.hlsl.h b/demo/d3d11/shaders/meshShadowPS.hlsl.h deleted file mode 100644 index 3794f61..0000000 --- a/demo/d3d11/shaders/meshShadowPS.hlsl.h +++ /dev/null @@ -1,156 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xyzw 1 NONE float -// TEXCOORD 1 xyzw 2 NONE float -// TEXCOORD 2 xyzw 3 NONE float -// TEXCOORD 3 xyzw 4 NONE float -// TEXCOORD 4 xyzw 5 NONE float -// TEXCOORD 5 xyzw 6 NONE float -// TEXCOORD 6 xyzw 7 NONE float -// TEXCOORD 7 xyzw 8 NONE float -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_output o0.xyzw -mov o0.xyzw, l(0,0,0,1.000000) -ret -// Approximately 2 instruction slots used -#endif - -const BYTE g_meshPS_Shadow[] = -{ - 68, 88, 66, 67, 106, 78, - 82, 142, 162, 137, 138, 82, - 3, 68, 165, 116, 56, 116, - 165, 11, 1, 0, 0, 0, - 192, 2, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 172, 0, 0, 0, 172, 1, - 0, 0, 224, 1, 0, 0, - 36, 2, 0, 0, 82, 68, - 69, 70, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 60, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 248, 0, 0, 0, - 9, 0, 0, 0, 8, 0, - 0, 0, 224, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 5, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 5, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 6, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 6, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 7, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 7, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 8, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 171, - 171, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 60, 0, - 0, 0, 80, 0, 0, 0, - 15, 0, 0, 0, 106, 8, - 0, 1, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 8, - 242, 32, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 63, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/meshVS.hlsl b/demo/d3d11/shaders/meshVS.hlsl deleted file mode 100644 index 09f78ec..0000000 --- a/demo/d3d11/shaders/meshVS.hlsl +++ /dev/null @@ -1,91 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - MeshShaderConst gParams; -}; - -MeshVertexOut meshVS(MeshVertexIn input) -{ - float4 gl_Position; - float4 gl_TexCoord[8]; - - { - [unroll] - for (int i = 0; i < 8; i++) - gl_TexCoord[i] = float4(0.0f, 0.0f, 0.0f, 0.0f); - } - - const float4x4 gl_ModelViewProjectionMatrix = gParams.modelviewprojection; - const float4x4 gl_ModelViewMatrix = gParams.modelview; - const float4x4 objectTransform = gParams.objectTransform; - const float4x4 lightTransform = gParams.lightTransform; - const float3 lightDir = gParams.lightDir; - const float bias = gParams.bias; - const float4 clipPlane = gParams.clipPlane; - const float expand = gParams.expand; - const float4 gl_Color = gParams.color; - const float4 gl_SecondaryColor = gParams.secondaryColor; - - const float3 gl_Vertex = input.position; - const float3 gl_Normal = input.normal; - const float2 gl_MultiTexCoord0 = input.texCoord; - - float3 n = normalize(mul(objectTransform, float4(gl_Normal, 0.0)).xyz); - float3 p = mul(objectTransform, float4(gl_Vertex.xyz, 1.0)).xyz; - - // calculate window-space point size - gl_Position = mul(gl_ModelViewProjectionMatrix, float4(p + expand * n, 1.0)); - - gl_TexCoord[0].xyz = n; - gl_TexCoord[1] = mul(lightTransform, float4(p + n * bias, 1.0)); - gl_TexCoord[2] = mul(gl_ModelViewMatrix, float4(lightDir, 0.0)); - gl_TexCoord[3].xyz = p; - if (gParams.colorArray) - gl_TexCoord[4] = input.color; - else - gl_TexCoord[4] = gl_Color; - gl_TexCoord[5].xy = gl_MultiTexCoord0; - gl_TexCoord[5].y = 1.0f - gl_TexCoord[5].y; // flip the y component of uv (glsl to hlsl conversion) - gl_TexCoord[6] = gl_SecondaryColor; - gl_TexCoord[7] = mul(gl_ModelViewMatrix, float4(gl_Vertex.xyz, 1.0)); - - MeshVertexOut output; - output.position = gl_Position; - { - [unroll] - for (int i = 0; i < 8; i++) - output.texCoord[i] = gl_TexCoord[i]; - } - - return output; - - /* - uniform mat4 lightTransform; - uniform vec3 lightDir; - uniform float bias; - uniform vec4 clipPlane; - uniform float expand; - - uniform mat4 objectTransform; - - void main() - { - vec3 n = normalize((objectTransform*vec4(gl_Normal, 0.0)).xyz); - vec3 p = (objectTransform*vec4(gl_Vertex.xyz, 1.0)).xyz; - - // calculate window-space point size - gl_Position = gl_ModelViewProjectionMatrix * vec4(p + expand*n, 1.0); - - gl_TexCoord[0].xyz = n; - gl_TexCoord[1] = lightTransform*vec4(p + n*bias, 1.0); - gl_TexCoord[2] = gl_ModelViewMatrix*vec4(lightDir, 0.0); - gl_TexCoord[3].xyz = p; - gl_TexCoord[4] = gl_Color; - gl_TexCoord[5] = gl_MultiTexCoord0; - gl_TexCoord[6] = gl_SecondaryColor; - gl_TexCoord[7] = gl_ModelViewMatrix*vec4(gl_Vertex.xyz, 1.0); - - gl_ClipDistance[0] = dot(clipPlane, vec4(gl_Vertex.xyz, 1.0)); - */ -} diff --git a/demo/d3d11/shaders/meshVS.hlsl.h b/demo/d3d11/shaders/meshVS.hlsl.h deleted file mode 100644 index cc314af..0000000 --- a/demo/d3d11/shaders/meshVS.hlsl.h +++ /dev/null @@ -1,635 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct MeshShaderConst -// { -// -// float4x4 modelviewprojection; // Offset: 0 -// float4x4 modelview; // Offset: 64 -// float4x4 objectTransform; // Offset: 128 -// float4x4 lightTransform; // Offset: 192 -// float4 clipPlane; // Offset: 256 -// float4 fogColor; // Offset: 272 -// float4 color; // Offset: 288 -// float4 secondaryColor; // Offset: 304 -// float4 shadowTaps[12]; // Offset: 320 -// float3 lightPos; // Offset: 512 -// float _pad0; // Offset: 524 -// float3 lightDir; // Offset: 528 -// float _pad1; // Offset: 540 -// float bias; // Offset: 544 -// float expand; // Offset: 548 -// float spotMin; // Offset: 552 -// float spotMax; // Offset: 556 -// int grid; // Offset: 560 -// int tex; // Offset: 564 -// int colorArray; // Offset: 568 -// int _pad2; // Offset: 572 -// -// } gParams; // Offset: 0 Size: 576 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyz 0 NONE float xyz -// NORMAL 0 xyz 1 NONE float xyz -// TEXCOORD 0 xy 2 NONE float xy -// COLOR 0 xyzw 3 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// TEXCOORD 0 xyzw 1 NONE float xyzw -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyzw -// TEXCOORD 3 xyzw 4 NONE float xyzw -// TEXCOORD 4 xyzw 5 NONE float xyzw -// TEXCOORD 5 xyzw 6 NONE float xyzw -// TEXCOORD 6 xyzw 7 NONE float xyzw -// TEXCOORD 7 xyzw 8 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[36], immediateIndexed -dcl_input v0.xyz -dcl_input v1.xyz -dcl_input v2.xy -dcl_input v3.xyzw -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -dcl_output o2.xyzw -dcl_output o3.xyzw -dcl_output o4.xyzw -dcl_output o5.xyzw -dcl_output o6.xyzw -dcl_output o7.xyzw -dcl_output o8.xyzw -dcl_temps 4 -mul r0.xyz, v1.yyyy, cb0[9].xyzx -mad r0.xyz, cb0[8].xyzx, v1.xxxx, r0.xyzx -mad r0.xyz, cb0[10].xyzx, v1.zzzz, r0.xyzx -dp3 r0.w, r0.xyzx, r0.xyzx -rsq r0.w, r0.w -mul r0.xyz, r0.wwww, r0.xyzx -mul r1.xyz, v0.yyyy, cb0[9].xyzx -mad r1.xyz, cb0[8].xyzx, v0.xxxx, r1.xyzx -mad r1.xyz, cb0[10].xyzx, v0.zzzz, r1.xyzx -add r1.xyz, r1.xyzx, cb0[11].xyzx -mad r2.xyz, cb0[34].yyyy, r0.xyzx, r1.xyzx -mul r3.xyzw, r2.yyyy, cb0[1].xyzw -mad r3.xyzw, cb0[0].xyzw, r2.xxxx, r3.xyzw -mad r2.xyzw, cb0[2].xyzw, r2.zzzz, r3.xyzw -add o0.xyzw, r2.xyzw, cb0[3].xyzw -mov o1.xyz, r0.xyzx -mad r0.xyz, r0.xyzx, cb0[34].xxxx, r1.xyzx -mov o4.xyz, r1.xyzx -mov o1.w, l(0) -mul r1.xyzw, r0.yyyy, cb0[13].xyzw -mad r1.xyzw, cb0[12].xyzw, r0.xxxx, r1.xyzw -mad r0.xyzw, cb0[14].xyzw, r0.zzzz, r1.xyzw -add o2.xyzw, r0.xyzw, cb0[15].xyzw -mul r0.xyzw, cb0[5].xyzw, cb0[33].yyyy -mad r0.xyzw, cb0[4].xyzw, cb0[33].xxxx, r0.xyzw -mad o3.xyzw, cb0[6].xyzw, cb0[33].zzzz, r0.xyzw -mov o4.w, l(0) -movc o5.xyzw, cb0[35].zzzz, v3.xyzw, cb0[18].xyzw -mad o6.xy, v2.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(0.000000, 1.000000, 0.000000, 0.000000) -mov o6.zw, l(0,0,0,0) -mov o7.xyzw, cb0[19].xyzw -mul r0.xyzw, v0.yyyy, cb0[5].xyzw -mad r0.xyzw, cb0[4].xyzw, v0.xxxx, r0.xyzw -mad r0.xyzw, cb0[6].xyzw, v0.zzzz, r0.xyzw -add o8.xyzw, r0.xyzw, cb0[7].xyzw -ret -// Approximately 36 instruction slots used -#endif - -const BYTE g_meshVS[] = -{ - 68, 88, 66, 67, 128, 165, - 34, 49, 122, 47, 91, 168, - 78, 217, 246, 213, 221, 36, - 22, 221, 1, 0, 0, 0, - 204, 11, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 24, 4, 0, 0, 168, 4, - 0, 0, 168, 5, 0, 0, - 48, 11, 0, 0, 82, 68, - 69, 70, 220, 3, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 168, 3, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 64, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 64, 2, - 0, 0, 2, 0, 0, 0, - 132, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 77, 101, 115, 104, - 83, 104, 97, 100, 101, 114, - 67, 111, 110, 115, 116, 0, - 109, 111, 100, 101, 108, 118, - 105, 101, 119, 112, 114, 111, - 106, 101, 99, 116, 105, 111, - 110, 0, 102, 108, 111, 97, - 116, 52, 120, 52, 0, 171, - 171, 171, 3, 0, 3, 0, - 4, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 212, 0, - 0, 0, 109, 111, 100, 101, - 108, 118, 105, 101, 119, 0, - 111, 98, 106, 101, 99, 116, - 84, 114, 97, 110, 115, 102, - 111, 114, 109, 0, 108, 105, - 103, 104, 116, 84, 114, 97, - 110, 115, 102, 111, 114, 109, - 0, 99, 108, 105, 112, 80, - 108, 97, 110, 101, 0, 102, - 108, 111, 97, 116, 52, 0, - 171, 171, 1, 0, 3, 0, - 1, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 1, - 0, 0, 102, 111, 103, 67, - 111, 108, 111, 114, 0, 99, - 111, 108, 111, 114, 0, 115, - 101, 99, 111, 110, 100, 97, - 114, 121, 67, 111, 108, 111, - 114, 0, 115, 104, 97, 100, - 111, 119, 84, 97, 112, 115, - 0, 171, 171, 171, 1, 0, - 3, 0, 1, 0, 4, 0, - 12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 55, 1, 0, 0, 108, 105, - 103, 104, 116, 80, 111, 115, - 0, 102, 108, 111, 97, 116, - 51, 0, 1, 0, 3, 0, - 1, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 189, 1, - 0, 0, 95, 112, 97, 100, - 48, 0, 102, 108, 111, 97, - 116, 0, 0, 0, 3, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 238, 1, - 0, 0, 108, 105, 103, 104, - 116, 68, 105, 114, 0, 95, - 112, 97, 100, 49, 0, 98, - 105, 97, 115, 0, 101, 120, - 112, 97, 110, 100, 0, 115, - 112, 111, 116, 77, 105, 110, - 0, 115, 112, 111, 116, 77, - 97, 120, 0, 103, 114, 105, - 100, 0, 105, 110, 116, 0, - 0, 0, 2, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 72, 2, 0, 0, - 116, 101, 120, 0, 99, 111, - 108, 111, 114, 65, 114, 114, - 97, 121, 0, 95, 112, 97, - 100, 50, 0, 171, 171, 171, - 192, 0, 0, 0, 224, 0, - 0, 0, 0, 0, 0, 0, - 4, 1, 0, 0, 224, 0, - 0, 0, 64, 0, 0, 0, - 14, 1, 0, 0, 224, 0, - 0, 0, 128, 0, 0, 0, - 30, 1, 0, 0, 224, 0, - 0, 0, 192, 0, 0, 0, - 45, 1, 0, 0, 64, 1, - 0, 0, 0, 1, 0, 0, - 100, 1, 0, 0, 64, 1, - 0, 0, 16, 1, 0, 0, - 109, 1, 0, 0, 64, 1, - 0, 0, 32, 1, 0, 0, - 115, 1, 0, 0, 64, 1, - 0, 0, 48, 1, 0, 0, - 130, 1, 0, 0, 144, 1, - 0, 0, 64, 1, 0, 0, - 180, 1, 0, 0, 196, 1, - 0, 0, 0, 2, 0, 0, - 232, 1, 0, 0, 244, 1, - 0, 0, 12, 2, 0, 0, - 24, 2, 0, 0, 196, 1, - 0, 0, 16, 2, 0, 0, - 33, 2, 0, 0, 244, 1, - 0, 0, 28, 2, 0, 0, - 39, 2, 0, 0, 244, 1, - 0, 0, 32, 2, 0, 0, - 44, 2, 0, 0, 244, 1, - 0, 0, 36, 2, 0, 0, - 51, 2, 0, 0, 244, 1, - 0, 0, 40, 2, 0, 0, - 59, 2, 0, 0, 244, 1, - 0, 0, 44, 2, 0, 0, - 67, 2, 0, 0, 76, 2, - 0, 0, 48, 2, 0, 0, - 112, 2, 0, 0, 76, 2, - 0, 0, 52, 2, 0, 0, - 116, 2, 0, 0, 76, 2, - 0, 0, 56, 2, 0, 0, - 127, 2, 0, 0, 76, 2, - 0, 0, 60, 2, 0, 0, - 5, 0, 0, 0, 1, 0, - 144, 0, 0, 0, 21, 0, - 136, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 176, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 136, 0, 0, 0, - 4, 0, 0, 0, 8, 0, - 0, 0, 104, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 7, 7, - 0, 0, 113, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 7, 7, - 0, 0, 120, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 3, 3, - 0, 0, 129, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 15, 15, - 0, 0, 80, 79, 83, 73, - 84, 73, 79, 78, 0, 78, - 79, 82, 77, 65, 76, 0, - 84, 69, 88, 67, 79, 79, - 82, 68, 0, 67, 79, 76, - 79, 82, 0, 171, 79, 83, - 71, 78, 248, 0, 0, 0, - 9, 0, 0, 0, 8, 0, - 0, 0, 224, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 5, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 5, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 6, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 6, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 7, 0, 0, 0, 15, 0, - 0, 0, 236, 0, 0, 0, - 7, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 8, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 171, - 171, 171, 83, 72, 69, 88, - 128, 5, 0, 0, 80, 0, - 1, 0, 96, 1, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 4, 70, 142, 32, 0, - 0, 0, 0, 0, 36, 0, - 0, 0, 95, 0, 0, 3, - 114, 16, 16, 0, 0, 0, - 0, 0, 95, 0, 0, 3, - 114, 16, 16, 0, 1, 0, - 0, 0, 95, 0, 0, 3, - 50, 16, 16, 0, 2, 0, - 0, 0, 95, 0, 0, 3, - 242, 16, 16, 0, 3, 0, - 0, 0, 103, 0, 0, 4, - 242, 32, 16, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 2, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 3, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 4, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 5, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 6, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 7, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 8, 0, 0, 0, - 104, 0, 0, 2, 4, 0, - 0, 0, 56, 0, 0, 8, - 114, 0, 16, 0, 0, 0, - 0, 0, 86, 21, 16, 0, - 1, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 9, 0, 0, 0, 50, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 6, 16, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 10, 0, - 0, 0, 166, 26, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 16, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 68, 0, - 0, 5, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 114, 0, - 16, 0, 0, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 8, 114, 0, 16, 0, - 1, 0, 0, 0, 86, 21, - 16, 0, 0, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 9, 0, 0, 0, - 50, 0, 0, 10, 114, 0, - 16, 0, 1, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 8, 0, 0, 0, - 6, 16, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 50, 0, - 0, 10, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 10, 0, 0, 0, 166, 26, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 11, 0, 0, 0, 50, 0, - 0, 10, 114, 0, 16, 0, - 2, 0, 0, 0, 86, 133, - 32, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 8, - 242, 0, 16, 0, 3, 0, - 0, 0, 86, 5, 16, 0, - 2, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 3, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 0, - 16, 0, 2, 0, 0, 0, - 70, 14, 16, 0, 3, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 2, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 166, 10, 16, 0, - 2, 0, 0, 0, 70, 14, - 16, 0, 3, 0, 0, 0, - 0, 0, 0, 8, 242, 32, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 54, 0, 0, 5, - 114, 32, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 6, 128, 32, 0, 0, 0, - 0, 0, 34, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 114, 32, 16, 0, 4, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 54, 0, - 0, 5, 130, 32, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 1, 0, 0, 0, - 86, 5, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 13, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 1, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 12, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 14, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 8, 242, 32, 16, 0, - 2, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 56, 0, 0, 9, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 86, 133, 32, 0, 0, 0, - 0, 0, 33, 0, 0, 0, - 50, 0, 0, 11, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 6, 128, 32, 0, 0, 0, - 0, 0, 33, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 11, - 242, 32, 16, 0, 3, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 6, 0, - 0, 0, 166, 138, 32, 0, - 0, 0, 0, 0, 33, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 130, 32, 16, 0, - 4, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 55, 0, 0, 11, 242, 32, - 16, 0, 5, 0, 0, 0, - 166, 138, 32, 0, 0, 0, - 0, 0, 35, 0, 0, 0, - 70, 30, 16, 0, 3, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 18, 0, - 0, 0, 50, 0, 0, 15, - 50, 32, 16, 0, 6, 0, - 0, 0, 70, 16, 16, 0, - 2, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 8, - 194, 32, 16, 0, 6, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 54, 0, - 0, 6, 242, 32, 16, 0, - 7, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 19, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 0, 0, 0, 0, 86, 21, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 6, 16, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 166, 26, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 242, 32, 16, 0, 8, 0, - 0, 0, 70, 14, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 62, 0, - 0, 1, 83, 84, 65, 84, - 148, 0, 0, 0, 36, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 13, 0, - 0, 0, 28, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 -}; diff --git a/demo/d3d11/shaders/passThroughVS.hlsl b/demo/d3d11/shaders/passThroughVS.hlsl deleted file mode 100644 index 9b16afa..0000000 --- a/demo/d3d11/shaders/passThroughVS.hlsl +++ /dev/null @@ -1,26 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - FluidShaderConst gParams; -}; - -PassthroughVertexOut passThroughVS(PassthroughVertexIn input) -{ - float4 gl_Vertex = float4(input.position, 0.0f, 1.0f); - float2 gl_MultiTexCoord0 = input.texCoord; - - PassthroughVertexOut output; - output.position = gl_Vertex; - output.texCoord[0] = gl_MultiTexCoord0; - - return output; - - /* - void main() - { - gl_Position = vec4(gl_Vertex.xyz, 1.0); - gl_TexCoord[0] = gl_MultiTexCoord0; - } - */ -} diff --git a/demo/d3d11/shaders/passThroughVS.hlsl.h b/demo/d3d11/shaders/passThroughVS.hlsl.h deleted file mode 100644 index 4b1b2cf..0000000 --- a/demo/d3d11/shaders/passThroughVS.hlsl.h +++ /dev/null @@ -1,145 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xy 0 NONE float xy -// TEXCOORD 0 xy 1 NONE float xy -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// TEXCOORD 0 xy 1 NONE float xy -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_input v0.xy -dcl_input v1.xy -dcl_output_siv o0.xyzw, position -dcl_output o1.xy -mov o0.xy, v0.xyxx -mov o0.zw, l(0,0,0,1.000000) -mov o1.xy, v1.xyxx -ret -// Approximately 4 instruction slots used -#endif - -const BYTE g_passThroughVS[] = -{ - 68, 88, 66, 67, 187, 133, - 114, 171, 205, 36, 113, 9, - 245, 108, 33, 122, 172, 89, - 138, 214, 1, 0, 0, 0, - 136, 2, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 172, 0, 0, 0, 0, 1, - 0, 0, 88, 1, 0, 0, - 236, 1, 0, 0, 82, 68, - 69, 70, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 60, 0, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 76, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 3, 3, - 0, 0, 65, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 3, 3, - 0, 0, 80, 79, 83, 73, - 84, 73, 79, 78, 0, 84, - 69, 88, 67, 79, 79, 82, - 68, 0, 171, 171, 79, 83, - 71, 78, 80, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 3, 12, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 171, - 171, 171, 83, 72, 69, 88, - 140, 0, 0, 0, 80, 0, - 1, 0, 35, 0, 0, 0, - 106, 8, 0, 1, 95, 0, - 0, 3, 50, 16, 16, 0, - 0, 0, 0, 0, 95, 0, - 0, 3, 50, 16, 16, 0, - 1, 0, 0, 0, 103, 0, - 0, 4, 242, 32, 16, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 50, 32, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 50, 32, 16, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 8, 194, 32, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 54, 0, 0, 5, 50, 32, - 16, 0, 1, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 62, 0, 0, 1, - 83, 84, 65, 84, 148, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/pointGS.hlsl b/demo/d3d11/shaders/pointGS.hlsl deleted file mode 100644 index 2d8126e..0000000 --- a/demo/d3d11/shaders/pointGS.hlsl +++ /dev/null @@ -1,84 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - PointShaderConst gParams; -}; - -static const float2 corners[4] = -{ - float2(0.0, 1.0), float2(0.0, 0.0), float2(1.0, 1.0), float2(1.0, 0.0) -}; - -[maxvertexcount(4)] -void pointGS(point PointVertexOut input[1], inout TriangleStream triStream) -{ - float4 gl_Position; - float4 gl_TexCoord[6]; - - { - [unroll] - for (int i = 0; i < 6; i++) - gl_TexCoord[i] = float4(0.0f, 0.0f, 0.0f, 0.0f); - } - - const float4x4 gl_ModelViewMatrix = gParams.modelview; - const float pointRadius = gParams.pointRadius; - const float pointScale = gParams.pointScale; - const float4x4 lightTransform = gParams.lightTransform; - const float3 lightDir = gParams.lightDir.xyz; - const int mode = gParams.mode; - - float4 viewPos = input[0].position; - float density = input[0].density; - unsigned int phase = input[0].phase; - float4 gl_Vertex = input[0].vertex; - - //float gl_PointSize = -pointScale * (pointRadius / viewPos.z); - //float spriteSize = (pointRadius / viewPos.z); - float spriteSize = pointRadius * 2; - - PointGeoOut output; - - for (int i = 0; i < 4; ++i) - { - - float4 eyePos = viewPos; // start with point position - eyePos.xy += spriteSize * (corners[i] - float2(0.5, 0.5)); // add corner position - gl_Position = mul(gParams.projection, eyePos); // complete transformation - - gl_TexCoord[0].xy = corners[i].xy; // use corner as texCoord - gl_TexCoord[0].y = 1.0f - gl_TexCoord[0].y; // flip the y component of uv (glsl to hlsl conversion) - gl_TexCoord[1] = mul(lightTransform, float4(gl_Vertex.xyz - lightDir * pointRadius * 2.0, 1.0)); - gl_TexCoord[2] = mul(gl_ModelViewMatrix, float4(lightDir, 0.0)); - - if (mode == 1) - { - // density visualization - if (density < 0.0f) - gl_TexCoord[3].xyz = lerp(float3(0.1, 0.1, 1.0), float3(0.1, 1.0, 1.0), -density); - else - gl_TexCoord[3].xyz = lerp(float3(1.0, 1.0, 1.0), float3(0.1, 0.2, 1.0), density); - } - else if (mode == 2) - { - //gl_PointSize *= clamp(gl_Vertex.w * 0.25, 0.0f, 1.0); - float tmp = clamp(gl_Vertex.w * 0.05, 0.0f, 1.0); - gl_TexCoord[3].xyzw = float4(tmp, tmp, tmp, tmp); - } - else - { - gl_TexCoord[3].xyz = lerp(gParams.colors[phase % 8].xyz * 2.0, float3(1.0, 1.0, 1.0), 0.1); - } - - gl_TexCoord[4].xyz = gl_Vertex.xyz; - gl_TexCoord[5].xyz = viewPos.xyz; - - output.position = gl_Position; - [unroll] - for (int j = 0; j < 6; j++) - output.texCoord[j] = gl_TexCoord[j]; - - triStream.Append(output); - } -} diff --git a/demo/d3d11/shaders/pointGS.hlsl.h b/demo/d3d11/shaders/pointGS.hlsl.h deleted file mode 100644 index afc1b76..0000000 --- a/demo/d3d11/shaders/pointGS.hlsl.h +++ /dev/null @@ -1,740 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct PointShaderConst -// { -// -// float4x4 modelview; // Offset: 0 -// float4x4 projection; // Offset: 64 -// float4x4 lightTransform; // Offset: 128 -// float4 colors[8]; // Offset: 192 -// float4 shadowTaps[12]; // Offset: 320 -// float3 lightPos; // Offset: 512 -// float _pad0; // Offset: 524 -// float3 lightDir; // Offset: 528 -// float _pad1; // Offset: 540 -// float pointRadius; // Offset: 544 -// float pointScale; // Offset: 548 -// float spotMin; // Offset: 552 -// float spotMax; // Offset: 556 -// int mode; // Offset: 560 -// int _pad2[3]; // Offset: 576 -// -// } gParams; // Offset: 0 Size: 612 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// DENSITY 0 x 1 NONE float x -// PHASE 0 x 2 NONE int x -// VERTEX 0 xyzw 3 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// TEXCOORD 0 xyzw 1 NONE float xyzw -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyzw -// TEXCOORD 3 xyzw 4 NONE float xyzw -// TEXCOORD 4 xyzw 5 NONE float xyzw -// TEXCOORD 5 xyzw 6 NONE float xyzw -// -gs_5_0 -dcl_globalFlags refactoringAllowed -dcl_immediateConstantBuffer { { 0, 1.000000, 0, 0}, - { 0, 0, 0, 0}, - { 1.000000, 1.000000, 0, 0}, - { 1.000000, 0, 0, 0} } -dcl_constantbuffer cb0[36], dynamicIndexed -dcl_input v[1][0].xyzw -dcl_input v[1][1].x -dcl_input v[1][2].x -dcl_input v[1][3].xyzw -dcl_temps 8 -dcl_indexableTemp x0[6], 4 -dcl_inputprimitive point -dcl_stream m0 -dcl_outputtopology trianglestrip -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -dcl_output o2.xyzw -dcl_output o3.xyzw -dcl_output o4.xyzw -dcl_output o5.xyzw -dcl_output o6.xyzw -dcl_maxout 4 -mov x0[3].w, l(0) -add r0.x, cb0[34].x, cb0[34].x -mul r0.yzw, cb0[33].xxyz, cb0[34].xxxx -mad r0.yzw, -r0.yyzw, l(0.000000, 2.000000, 2.000000, 2.000000), v[0][3].xxyz -mul r1.xyzw, r0.zzzz, cb0[9].xyzw -mad r1.xyzw, cb0[8].xyzw, r0.yyyy, r1.xyzw -mad r1.xyzw, cb0[10].xyzw, r0.wwww, r1.xyzw -add r1.xyzw, r1.xyzw, cb0[11].xyzw -mul r2.xyzw, cb0[1].xyzw, cb0[33].yyyy -mad r2.xyzw, cb0[0].xyzw, cb0[33].xxxx, r2.xyzw -mad r2.xyzw, cb0[2].xyzw, cb0[33].zzzz, r2.xyzw -lt r0.y, v[0][1].x, l(0.000000) -mad r3.xyz, v[0][1].xxxx, l(0.000000, -0.900000, 0.000000, 0.000000), l(0.100000, 0.100000, 1.000000, 0.000000) -mad r4.xyz, v[0][1].xxxx, l(-0.900000, -0.800000, 0.000000, 0.000000), l(1.000000, 1.000000, 1.000000, 0.000000) -ieq r0.zw, l(0, 0, 1, 2), cb0[35].xxxx -mul r3.w, l(0.050000), v[0][3].w -mov_sat r5.xyz, r3.wwww -and r3.w, l(7), v[0][2].x -add r6.xyz, cb0[r3.w + 12].xyzx, cb0[r3.w + 12].xyzx -mad r7.xyz, -cb0[r3.w + 12].xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(1.000000, 1.000000, 1.000000, 0.000000) -mad r6.xyz, r7.xyzx, l(0.100000, 0.100000, 0.100000, 0.000000), r6.xyzx -movc r3.xyz, r0.yyyy, r3.xyzx, r4.xyzx -mov r0.y, l(0) -loop - ige r3.w, r0.y, l(4) - breakc_nz r3.w - add r4.xy, l(-0.500000, -0.500000, 0.000000, 0.000000), icb[r0.y + 0].xyxx - mad r4.xy, r0.xxxx, r4.xyxx, v[0][0].xyxx - mul r7.xyzw, r4.yyyy, cb0[5].xyzw - mad r4.xyzw, cb0[4].xyzw, r4.xxxx, r7.xyzw - mad r4.xyzw, cb0[6].xyzw, v[0][0].zzzz, r4.xyzw - mad r4.xyzw, cb0[7].xyzw, v[0][0].wwww, r4.xyzw - add r3.w, l(1.000000), -icb[r0.y + 0].y - if_nz r0.z - mov r7.xyz, r3.xyzx - else - if_nz r0.w - mov x0[3].w, r5.z - mov r7.xyz, r5.xyzx - else - mov r7.xyz, r6.xyzx - endif - endif - mov r5.w, x0[3].w - mov o0.xyzw, r4.xyzw - mov o1.x, icb[r0.y + 0].x - mov o1.y, r3.w - mov o1.zw, l(0,0,0,0) - mov o2.xyzw, r1.xyzw - mov o3.xyzw, r2.xyzw - mov o4.xyz, r7.xyzx - mov o4.w, r5.w - mov o5.xyz, v[0][3].xyzx - mov o5.w, l(0) - mov o6.xyz, v[0][0].xyzx - mov o6.w, l(0) - emit_stream m0 - iadd r0.y, r0.y, l(1) -endloop -ret -// Approximately 60 instruction slots used -#endif - -const BYTE g_pointGS[] = -{ - 68, 88, 66, 67, 83, 238, - 66, 156, 86, 118, 105, 62, - 85, 224, 176, 224, 229, 4, - 226, 151, 1, 0, 0, 0, - 188, 13, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 176, 3, 0, 0, 64, 4, - 0, 0, 44, 5, 0, 0, - 32, 13, 0, 0, 82, 68, - 69, 70, 116, 3, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 83, 71, 0, 1, 0, 0, - 64, 3, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 112, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 100, 2, - 0, 0, 2, 0, 0, 0, - 28, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 80, 111, 105, 110, - 116, 83, 104, 97, 100, 101, - 114, 67, 111, 110, 115, 116, - 0, 109, 111, 100, 101, 108, - 118, 105, 101, 119, 0, 102, - 108, 111, 97, 116, 52, 120, - 52, 0, 3, 0, 3, 0, - 4, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 203, 0, - 0, 0, 112, 114, 111, 106, - 101, 99, 116, 105, 111, 110, - 0, 108, 105, 103, 104, 116, - 84, 114, 97, 110, 115, 102, - 111, 114, 109, 0, 99, 111, - 108, 111, 114, 115, 0, 102, - 108, 111, 97, 116, 52, 0, - 1, 0, 3, 0, 1, 0, - 4, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 25, 1, 0, 0, - 115, 104, 97, 100, 111, 119, - 84, 97, 112, 115, 0, 171, - 1, 0, 3, 0, 1, 0, - 4, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 25, 1, 0, 0, - 108, 105, 103, 104, 116, 80, - 111, 115, 0, 102, 108, 111, - 97, 116, 51, 0, 1, 0, - 3, 0, 1, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 125, 1, 0, 0, 95, 112, - 97, 100, 48, 0, 102, 108, - 111, 97, 116, 0, 0, 0, - 3, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 174, 1, 0, 0, 108, 105, - 103, 104, 116, 68, 105, 114, - 0, 95, 112, 97, 100, 49, - 0, 112, 111, 105, 110, 116, - 82, 97, 100, 105, 117, 115, - 0, 112, 111, 105, 110, 116, - 83, 99, 97, 108, 101, 0, - 115, 112, 111, 116, 77, 105, - 110, 0, 115, 112, 111, 116, - 77, 97, 120, 0, 109, 111, - 100, 101, 0, 105, 110, 116, - 0, 171, 0, 0, 2, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 2, - 0, 0, 95, 112, 97, 100, - 50, 0, 171, 171, 0, 0, - 2, 0, 1, 0, 1, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 19, 2, 0, 0, 193, 0, - 0, 0, 212, 0, 0, 0, - 0, 0, 0, 0, 248, 0, - 0, 0, 212, 0, 0, 0, - 64, 0, 0, 0, 3, 1, - 0, 0, 212, 0, 0, 0, - 128, 0, 0, 0, 18, 1, - 0, 0, 32, 1, 0, 0, - 192, 0, 0, 0, 68, 1, - 0, 0, 80, 1, 0, 0, - 64, 1, 0, 0, 116, 1, - 0, 0, 132, 1, 0, 0, - 0, 2, 0, 0, 168, 1, - 0, 0, 180, 1, 0, 0, - 12, 2, 0, 0, 216, 1, - 0, 0, 132, 1, 0, 0, - 16, 2, 0, 0, 225, 1, - 0, 0, 180, 1, 0, 0, - 28, 2, 0, 0, 231, 1, - 0, 0, 180, 1, 0, 0, - 32, 2, 0, 0, 243, 1, - 0, 0, 180, 1, 0, 0, - 36, 2, 0, 0, 254, 1, - 0, 0, 180, 1, 0, 0, - 40, 2, 0, 0, 6, 2, - 0, 0, 180, 1, 0, 0, - 44, 2, 0, 0, 14, 2, - 0, 0, 24, 2, 0, 0, - 48, 2, 0, 0, 60, 2, - 0, 0, 68, 2, 0, 0, - 64, 2, 0, 0, 5, 0, - 0, 0, 1, 0, 144, 0, - 0, 0, 15, 0, 104, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 176, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 136, 0, 0, 0, 4, 0, - 0, 0, 8, 0, 0, 0, - 104, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 113, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 1, 1, 0, 0, - 121, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 2, 0, - 0, 0, 1, 1, 0, 0, - 127, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 15, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 68, 69, 78, - 83, 73, 84, 89, 0, 80, - 72, 65, 83, 69, 0, 86, - 69, 82, 84, 69, 88, 0, - 171, 171, 79, 83, 71, 53, - 228, 0, 0, 0, 7, 0, - 0, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 204, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 0, 0, - 0, 0, 216, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 0, - 0, 0, 0, 0, 0, 0, - 216, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 216, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 15, 0, 0, 0, 0, 0, - 0, 0, 216, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 0, - 0, 0, 0, 0, 0, 0, - 216, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 5, 0, - 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 216, 0, - 0, 0, 5, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 6, 0, 0, 0, - 15, 0, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 171, 171, 171, 83, 72, - 69, 88, 236, 7, 0, 0, - 80, 0, 2, 0, 251, 1, - 0, 0, 106, 8, 0, 1, - 53, 24, 0, 0, 18, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 128, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 89, 8, 0, 4, 70, 142, - 32, 0, 0, 0, 0, 0, - 36, 0, 0, 0, 95, 0, - 0, 4, 242, 16, 32, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 95, 0, 0, 4, - 18, 16, 32, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 95, 0, 0, 4, 18, 16, - 32, 0, 1, 0, 0, 0, - 2, 0, 0, 0, 95, 0, - 0, 4, 242, 16, 32, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 104, 0, 0, 2, - 8, 0, 0, 0, 105, 0, - 0, 4, 0, 0, 0, 0, - 6, 0, 0, 0, 4, 0, - 0, 0, 93, 8, 0, 1, - 143, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 92, 40, 0, 1, 103, 0, - 0, 4, 242, 32, 16, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 3, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 4, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 5, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 6, 0, - 0, 0, 94, 0, 0, 2, - 4, 0, 0, 0, 54, 0, - 0, 6, 130, 48, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 9, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 56, 0, - 0, 9, 226, 0, 16, 0, - 0, 0, 0, 0, 6, 137, - 32, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 6, 128, - 32, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 50, 0, - 0, 14, 226, 0, 16, 0, - 0, 0, 0, 0, 86, 14, - 16, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 64, 0, 0, 0, 64, - 6, 25, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 56, 0, 0, 8, 242, 0, - 16, 0, 1, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 9, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 1, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 86, 5, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 1, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 10, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 8, 242, 0, 16, 0, - 1, 0, 0, 0, 70, 14, - 16, 0, 1, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 11, 0, 0, 0, - 56, 0, 0, 9, 242, 0, - 16, 0, 2, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 86, 133, 32, 0, 0, 0, - 0, 0, 33, 0, 0, 0, - 50, 0, 0, 11, 242, 0, - 16, 0, 2, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 6, 128, 32, 0, 0, 0, - 0, 0, 33, 0, 0, 0, - 70, 14, 16, 0, 2, 0, - 0, 0, 50, 0, 0, 11, - 242, 0, 16, 0, 2, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 166, 138, 32, 0, - 0, 0, 0, 0, 33, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 49, 0, - 0, 8, 34, 0, 16, 0, - 0, 0, 0, 0, 10, 16, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 50, 0, 0, 16, 114, 0, - 16, 0, 3, 0, 0, 0, - 6, 16, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 102, 102, 102, 191, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 205, 204, 204, 61, 205, 204, - 204, 61, 0, 0, 128, 63, - 0, 0, 0, 0, 50, 0, - 0, 16, 114, 0, 16, 0, - 4, 0, 0, 0, 6, 16, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 102, 102, 102, 191, - 205, 204, 76, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 0, 0, 32, 0, 0, 11, - 194, 0, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 2, 0, 0, 0, 6, 128, - 32, 0, 0, 0, 0, 0, - 35, 0, 0, 0, 56, 0, - 0, 8, 130, 0, 16, 0, - 3, 0, 0, 0, 1, 64, - 0, 0, 205, 204, 76, 61, - 58, 16, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 32, 0, 5, 114, 0, - 16, 0, 5, 0, 0, 0, - 246, 15, 16, 0, 3, 0, - 0, 0, 1, 0, 0, 8, - 130, 0, 16, 0, 3, 0, - 0, 0, 1, 64, 0, 0, - 7, 0, 0, 0, 10, 16, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 13, 114, 0, 16, 0, - 6, 0, 0, 0, 70, 130, - 32, 6, 0, 0, 0, 0, - 12, 0, 0, 0, 58, 0, - 16, 0, 3, 0, 0, 0, - 70, 130, 32, 6, 0, 0, - 0, 0, 12, 0, 0, 0, - 58, 0, 16, 0, 3, 0, - 0, 0, 50, 0, 0, 19, - 114, 0, 16, 0, 7, 0, - 0, 0, 70, 130, 32, 134, - 65, 0, 0, 0, 0, 0, - 0, 0, 12, 0, 0, 0, - 58, 0, 16, 0, 3, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 64, 0, 0, 0, 64, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 0, 0, - 50, 0, 0, 12, 114, 0, - 16, 0, 6, 0, 0, 0, - 70, 2, 16, 0, 7, 0, - 0, 0, 2, 64, 0, 0, - 205, 204, 204, 61, 205, 204, - 204, 61, 205, 204, 204, 61, - 0, 0, 0, 0, 70, 2, - 16, 0, 6, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 3, 0, 0, 0, - 86, 5, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 4, 0, 0, 0, - 54, 0, 0, 5, 34, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 0, 48, 0, 0, 1, - 33, 0, 0, 7, 130, 0, - 16, 0, 3, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 4, 0, 0, 0, 3, 0, - 4, 3, 58, 0, 16, 0, - 3, 0, 0, 0, 0, 0, - 0, 11, 50, 0, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 191, - 0, 0, 0, 191, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 144, 144, 0, 26, 0, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 10, 50, 0, - 16, 0, 4, 0, 0, 0, - 6, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 4, 0, 0, 0, 70, 16, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 7, 0, 0, 0, 86, 5, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 6, 0, 16, 0, 4, 0, - 0, 0, 70, 14, 16, 0, - 7, 0, 0, 0, 50, 0, - 0, 11, 242, 0, 16, 0, - 4, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 166, 26, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 4, 0, 0, 0, - 50, 0, 0, 11, 242, 0, - 16, 0, 4, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 7, 0, 0, 0, - 246, 31, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 4, 0, - 0, 0, 0, 0, 0, 9, - 130, 0, 16, 0, 3, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 26, 144, - 144, 128, 65, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 31, 0, 4, 3, - 42, 0, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 114, 0, 16, 0, 7, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 18, 0, - 0, 1, 31, 0, 4, 3, - 58, 0, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 130, 48, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 54, 0, 0, 5, - 114, 0, 16, 0, 7, 0, - 0, 0, 70, 2, 16, 0, - 5, 0, 0, 0, 18, 0, - 0, 1, 54, 0, 0, 5, - 114, 0, 16, 0, 7, 0, - 0, 0, 70, 2, 16, 0, - 6, 0, 0, 0, 21, 0, - 0, 1, 21, 0, 0, 1, - 54, 0, 0, 6, 130, 0, - 16, 0, 5, 0, 0, 0, - 58, 48, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 4, 0, - 0, 0, 54, 0, 0, 6, - 18, 32, 16, 0, 1, 0, - 0, 0, 10, 144, 144, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 34, 32, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 0, - 3, 0, 0, 0, 54, 0, - 0, 8, 194, 32, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 2, 0, 0, 0, - 70, 14, 16, 0, 1, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 3, 0, - 0, 0, 70, 14, 16, 0, - 2, 0, 0, 0, 54, 0, - 0, 5, 114, 32, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 0, 7, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 4, 0, 0, 0, - 58, 0, 16, 0, 5, 0, - 0, 0, 54, 0, 0, 6, - 114, 32, 16, 0, 5, 0, - 0, 0, 70, 18, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 54, 0, 0, 5, - 130, 32, 16, 0, 5, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 54, 0, - 0, 6, 114, 32, 16, 0, - 6, 0, 0, 0, 70, 18, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 130, 32, 16, 0, - 6, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 0, - 117, 0, 0, 3, 0, 0, - 17, 0, 0, 0, 0, 0, - 30, 0, 0, 7, 34, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 1, 0, 0, 0, 22, 0, - 0, 1, 62, 0, 0, 1, - 83, 84, 65, 84, 148, 0, - 0, 0, 60, 0, 0, 0, - 8, 0, 0, 0, 4, 0, - 0, 0, 11, 0, 0, 0, - 24, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 5, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 5, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/pointPS.hlsl b/demo/d3d11/shaders/pointPS.hlsl deleted file mode 100644 index e8bcaf4..0000000 --- a/demo/d3d11/shaders/pointPS.hlsl +++ /dev/null @@ -1,103 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - PointShaderConst gParams; -}; - -Texture2D shadowTexture : register(t0); // shadow map - -SamplerComparisonState shadowSampler : register(s0); // texture sample used to sample depth from shadow texture in this sample - -float sqr(float x) { return x * x; } - -float shadowSample(float4 gl_TexCoord[6]) -{ - float3 pos = float3(gl_TexCoord[1].xyz / gl_TexCoord[1].w); - //float3 uvw = (pos.xyz * 0.5) + vec3(0.5); - float3 uvw = (pos.xyz * float3(0.5, 0.5, 1.0)) + float3(0.5, 0.5, 0.0); - - // user clip - if (uvw.x < 0.0 || uvw.x > 1.0) - return 1.0; - if (uvw.y < 0.0 || uvw.y > 1.0) - return 1.0; - - float s = 0.0; - float radius = 0.002; - - // flip uv y-coordinate - uvw.y = 1.0f - uvw.y; - - [unroll] - for (int i = 0; i < 8; i++) - { - float2 shadowTaps = gParams.shadowTaps[i].xy; - shadowTaps.y = 1.0f - shadowTaps.y; - - //s += shadow2D(shadowTex, vec3(uvw.xy + shadowTaps[i] * radius, uvw.z)).r; - s += shadowTexture.SampleCmpLevelZero(shadowSampler, uvw.xy + shadowTaps * radius, uvw.z); - } - s /= 8.0; - - return s; -} - -float4 pointPS(PointGeoOut input - //, out float gl_FragDepth : SV_DEPTH -) : SV_TARGET -{ - //gl_FragDepth = 0.0f; - - const float spotMin = gParams.spotMin; - const float spotMax = gParams.spotMax; - - float4 gl_FragColor; - float4 gl_TexCoord[6]; - - [unroll] - for (int i = 0; i < 6; i++) - gl_TexCoord[i] = input.texCoord[i]; - - // calculate normal from texture coordinates - float3 normal; - normal.xy = gl_TexCoord[0].xy * float2(2.0, -2.0) + float2(-1.0, 1.0); - float mag = dot(normal.xy, normal.xy); - if (mag > 1.0) discard; // kill pixels outside circle - normal.z = sqrt(1.0 - mag); - - if (gParams.mode == 2) - { - float alpha = normal.z * gl_TexCoord[3].w; - gl_FragColor.xyz = gl_TexCoord[3].xyz * alpha; - gl_FragColor.w = alpha; - - return gl_FragColor; - } - - // calculate lighting - float shadow = shadowSample(gl_TexCoord); - - float3 lPos = float3(gl_TexCoord[1].xyz / gl_TexCoord[1].w); - float attenuation = max(smoothstep(spotMax, spotMin, dot(lPos.xy, lPos.xy)), 0.05); - - float3 diffuse = float3(0.9, 0.9, 0.9); - float3 reflectance = gl_TexCoord[3].xyz; - - float3 Lo = diffuse * reflectance * max(0.0, sqr(-dot(gl_TexCoord[2].xyz, normal) * 0.5 + 0.5)) * max(0.2, shadow) * attenuation; - - const float tmp = 1.0 / 2.2; - gl_FragColor = float4(pow(abs(Lo), float3(tmp, tmp, tmp)), 1.0); - - /* - const float pointRadius = gParams.pointRadius; - const float4x4 gl_ProjectionMatrix = gParams.projection; - - float3 eyePos = gl_TexCoord[5].xyz + normal * pointRadius; - float4 ndcPos = mul(gl_ProjectionMatrix, float4(eyePos, 1.0)); - ndcPos.z /= ndcPos.w; - gl_FragDepth = ndcPos.z; - */ - - return gl_FragColor; -} diff --git a/demo/d3d11/shaders/pointPS.hlsl.h b/demo/d3d11/shaders/pointPS.hlsl.h deleted file mode 100644 index 843b166..0000000 --- a/demo/d3d11/shaders/pointPS.hlsl.h +++ /dev/null @@ -1,947 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct PointShaderConst -// { -// -// float4x4 modelview; // Offset: 0 -// float4x4 projection; // Offset: 64 -// float4x4 lightTransform; // Offset: 128 -// float4 colors[8]; // Offset: 192 -// float4 shadowTaps[12]; // Offset: 320 -// float3 lightPos; // Offset: 512 -// float _pad0; // Offset: 524 -// float3 lightDir; // Offset: 528 -// float _pad1; // Offset: 540 -// float pointRadius; // Offset: 544 -// float pointScale; // Offset: 548 -// float spotMin; // Offset: 552 -// float spotMax; // Offset: 556 -// int mode; // Offset: 560 -// int _pad2[3]; // Offset: 576 -// -// } gParams; // Offset: 0 Size: 612 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// shadowSampler sampler_c NA NA 0 1 -// shadowTexture texture float 2d 0 1 -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xyzw 1 NONE float xy -// TEXCOORD 1 xyzw 2 NONE float xyzw -// TEXCOORD 2 xyzw 3 NONE float xyz -// TEXCOORD 3 xyzw 4 NONE float xyzw -// TEXCOORD 4 xyzw 5 NONE float -// TEXCOORD 5 xyzw 6 NONE float -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[36], immediateIndexed -dcl_sampler s0, mode_comparison -dcl_resource_texture2d (float,float,float,float) t0 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xyzw -dcl_input_ps linear v3.xyz -dcl_input_ps linear v4.xyzw -dcl_output o0.xyzw -dcl_temps 4 -mad r0.xy, v1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000) -dp2 r0.x, r0.xyxx, r0.xyxx -lt r0.y, l(1.000000), r0.x -discard_nz r0.y -add r0.x, -r0.x, l(1.000000) -sqrt r0.z, r0.x -ieq r0.w, cb0[35].x, l(2) -if_nz r0.w - mul r0.w, r0.z, v4.w - mul o0.xyz, r0.wwww, v4.xyzx - mov o0.w, r0.w - ret -endif -div r1.xyz, v2.xyzx, v2.wwww -mad r2.xyz, r1.xyzx, l(0.500000, 0.500000, 1.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000) -lt r0.w, r2.x, l(0.000000) -lt r1.z, l(1.000000), r2.x -or r0.w, r0.w, r1.z -if_z r0.w - lt r0.w, r2.y, l(0.000000) - lt r1.z, l(1.000000), r2.y - or r0.w, r0.w, r1.z - if_z r0.w - add r0.w, -cb0[20].y, l(1.000000) - mul r3.x, cb0[20].x, l(0.002000) - mul r3.y, r0.w, l(0.002000) - add r2.w, -r2.y, l(1.000000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r0.w, r1.zwzz, t0.xxxx, s0, r2.z - add r1.z, -cb0[21].y, l(1.000000) - mul r3.x, cb0[21].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - add r1.z, -cb0[22].y, l(1.000000) - mul r3.x, cb0[22].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - add r1.z, -cb0[23].y, l(1.000000) - mul r3.x, cb0[23].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - add r1.z, -cb0[24].y, l(1.000000) - mul r3.x, cb0[24].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - add r1.z, -cb0[25].y, l(1.000000) - mul r3.x, cb0[25].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - add r1.z, -cb0[26].y, l(1.000000) - mul r3.x, cb0[26].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - add r1.z, -cb0[27].y, l(1.000000) - mul r3.x, cb0[27].x, l(0.002000) - mul r3.y, r1.z, l(0.002000) - add r1.zw, r2.xxxw, r3.xxxy - sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r1.zwzz, t0.xxxx, s0, r2.z - add r0.w, r0.w, r1.z - mul r0.w, r0.w, l(0.125000) - else - mov r0.w, l(1.000000) - endif -else - mov r0.w, l(1.000000) -endif -dp2 r1.x, r1.xyxx, r1.xyxx -add r1.y, -cb0[34].w, cb0[34].z -add r1.x, r1.x, -cb0[34].w -div r1.y, l(1.000000, 1.000000, 1.000000, 1.000000), r1.y -mul_sat r1.x, r1.y, r1.x -mad r1.y, r1.x, l(-2.000000), l(3.000000) -mul r1.x, r1.x, r1.x -mul r1.x, r1.x, r1.y -max r1.x, r1.x, l(0.050000) -mul r1.yzw, v4.xxyz, l(0.000000, 0.900000, 0.900000, 0.900000) -mad r0.xy, v1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000) -dp3 r0.x, v3.xyzx, r0.xyzx -mad r0.x, r0.x, l(-0.500000), l(0.500000) -mul r0.x, r0.x, r0.x -mul r0.xyz, r0.xxxx, r1.yzwy -max r0.w, r0.w, l(0.200000) -mul r0.xyz, r0.wwww, r0.xyzx -mul r0.xyz, r1.xxxx, r0.xyzx -log r0.xyz, |r0.xyzx| -mul r0.xyz, r0.xyzx, l(0.454545, 0.454545, 0.454545, 0.000000) -exp o0.xyz, r0.xyzx -mov o0.w, l(1.000000) -ret -// Approximately 101 instruction slots used -#endif - -const BYTE g_pointPS[] = -{ - 68, 88, 66, 67, 43, 46, - 192, 8, 211, 105, 212, 151, - 103, 8, 148, 62, 30, 192, - 144, 175, 1, 0, 0, 0, - 244, 17, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 12, 4, 0, 0, 220, 4, - 0, 0, 16, 5, 0, 0, - 88, 17, 0, 0, 82, 68, - 69, 70, 208, 3, 0, 0, - 1, 0, 0, 0, 196, 0, - 0, 0, 3, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 156, 3, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 156, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 170, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 184, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 115, 104, 97, 100, 111, 119, - 83, 97, 109, 112, 108, 101, - 114, 0, 115, 104, 97, 100, - 111, 119, 84, 101, 120, 116, - 117, 114, 101, 0, 99, 111, - 110, 115, 116, 66, 117, 102, - 0, 171, 171, 171, 184, 0, - 0, 0, 1, 0, 0, 0, - 220, 0, 0, 0, 112, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 1, - 0, 0, 0, 0, 0, 0, - 100, 2, 0, 0, 2, 0, - 0, 0, 120, 3, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 103, 80, 97, 114, - 97, 109, 115, 0, 80, 111, - 105, 110, 116, 83, 104, 97, - 100, 101, 114, 67, 111, 110, - 115, 116, 0, 109, 111, 100, - 101, 108, 118, 105, 101, 119, - 0, 102, 108, 111, 97, 116, - 52, 120, 52, 0, 3, 0, - 3, 0, 4, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 39, 1, 0, 0, 112, 114, - 111, 106, 101, 99, 116, 105, - 111, 110, 0, 108, 105, 103, - 104, 116, 84, 114, 97, 110, - 115, 102, 111, 114, 109, 0, - 99, 111, 108, 111, 114, 115, - 0, 102, 108, 111, 97, 116, - 52, 0, 1, 0, 3, 0, - 1, 0, 4, 0, 8, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 117, 1, - 0, 0, 115, 104, 97, 100, - 111, 119, 84, 97, 112, 115, - 0, 171, 1, 0, 3, 0, - 1, 0, 4, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 117, 1, - 0, 0, 108, 105, 103, 104, - 116, 80, 111, 115, 0, 102, - 108, 111, 97, 116, 51, 0, - 1, 0, 3, 0, 1, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 217, 1, 0, 0, - 95, 112, 97, 100, 48, 0, - 102, 108, 111, 97, 116, 0, - 0, 0, 3, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 10, 2, 0, 0, - 108, 105, 103, 104, 116, 68, - 105, 114, 0, 95, 112, 97, - 100, 49, 0, 112, 111, 105, - 110, 116, 82, 97, 100, 105, - 117, 115, 0, 112, 111, 105, - 110, 116, 83, 99, 97, 108, - 101, 0, 115, 112, 111, 116, - 77, 105, 110, 0, 115, 112, - 111, 116, 77, 97, 120, 0, - 109, 111, 100, 101, 0, 105, - 110, 116, 0, 171, 0, 0, - 2, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 111, 2, 0, 0, 95, 112, - 97, 100, 50, 0, 171, 171, - 0, 0, 2, 0, 1, 0, - 1, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 111, 2, 0, 0, - 29, 1, 0, 0, 48, 1, - 0, 0, 0, 0, 0, 0, - 84, 1, 0, 0, 48, 1, - 0, 0, 64, 0, 0, 0, - 95, 1, 0, 0, 48, 1, - 0, 0, 128, 0, 0, 0, - 110, 1, 0, 0, 124, 1, - 0, 0, 192, 0, 0, 0, - 160, 1, 0, 0, 172, 1, - 0, 0, 64, 1, 0, 0, - 208, 1, 0, 0, 224, 1, - 0, 0, 0, 2, 0, 0, - 4, 2, 0, 0, 16, 2, - 0, 0, 12, 2, 0, 0, - 52, 2, 0, 0, 224, 1, - 0, 0, 16, 2, 0, 0, - 61, 2, 0, 0, 16, 2, - 0, 0, 28, 2, 0, 0, - 67, 2, 0, 0, 16, 2, - 0, 0, 32, 2, 0, 0, - 79, 2, 0, 0, 16, 2, - 0, 0, 36, 2, 0, 0, - 90, 2, 0, 0, 16, 2, - 0, 0, 40, 2, 0, 0, - 98, 2, 0, 0, 16, 2, - 0, 0, 44, 2, 0, 0, - 106, 2, 0, 0, 116, 2, - 0, 0, 48, 2, 0, 0, - 152, 2, 0, 0, 160, 2, - 0, 0, 64, 2, 0, 0, - 5, 0, 0, 0, 1, 0, - 144, 0, 0, 0, 15, 0, - 196, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 12, 1, 0, 0, - 77, 105, 99, 114, 111, 115, - 111, 102, 116, 32, 40, 82, - 41, 32, 72, 76, 83, 76, - 32, 83, 104, 97, 100, 101, - 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 54, - 46, 51, 46, 57, 54, 48, - 48, 46, 49, 54, 51, 56, - 52, 0, 171, 171, 73, 83, - 71, 78, 200, 0, 0, 0, - 7, 0, 0, 0, 8, 0, - 0, 0, 176, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 188, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 3, - 0, 0, 188, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 15, - 0, 0, 188, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 15, 7, - 0, 0, 188, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 15, - 0, 0, 188, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 5, 0, 0, 0, 15, 0, - 0, 0, 188, 0, 0, 0, - 5, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 6, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 171, - 171, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 64, 12, - 0, 0, 80, 0, 0, 0, - 16, 3, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 36, 0, 0, 0, - 90, 8, 0, 3, 0, 96, - 16, 0, 0, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 98, 16, - 0, 3, 50, 16, 16, 0, - 1, 0, 0, 0, 98, 16, - 0, 3, 242, 16, 16, 0, - 2, 0, 0, 0, 98, 16, - 0, 3, 114, 16, 16, 0, - 3, 0, 0, 0, 98, 16, - 0, 3, 242, 16, 16, 0, - 4, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 0, 0, 0, 0, 104, 0, - 0, 2, 4, 0, 0, 0, - 50, 0, 0, 15, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 192, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 191, - 0, 0, 128, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 49, 0, - 0, 7, 34, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 10, 0, 16, 0, 0, 0, - 0, 0, 13, 0, 4, 3, - 26, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 75, 0, - 0, 5, 66, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 32, 0, 0, 8, 130, 0, - 16, 0, 0, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 35, 0, 0, 0, - 1, 64, 0, 0, 2, 0, - 0, 0, 31, 0, 4, 3, - 58, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 0, 0, 0, 0, 58, 16, - 16, 0, 4, 0, 0, 0, - 56, 0, 0, 7, 114, 32, - 16, 0, 0, 0, 0, 0, - 246, 15, 16, 0, 0, 0, - 0, 0, 70, 18, 16, 0, - 4, 0, 0, 0, 54, 0, - 0, 5, 130, 32, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 62, 0, 0, 1, 21, 0, - 0, 1, 14, 0, 0, 7, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 18, 16, 0, - 2, 0, 0, 0, 246, 31, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 15, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 63, 0, 0, - 0, 63, 0, 0, 128, 63, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 49, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 49, 0, - 0, 7, 66, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 10, 0, 16, 0, 2, 0, - 0, 0, 60, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 1, 0, 0, 0, - 31, 0, 0, 3, 58, 0, - 16, 0, 0, 0, 0, 0, - 49, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 49, 0, - 0, 7, 66, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 26, 0, 16, 0, 2, 0, - 0, 0, 60, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 1, 0, 0, 0, - 31, 0, 0, 3, 58, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 20, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 56, 0, 0, 8, 18, 0, - 16, 0, 3, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 20, 0, 0, 0, - 1, 64, 0, 0, 111, 18, - 3, 59, 56, 0, 0, 7, - 34, 0, 16, 0, 3, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 0, 0, 0, 8, 130, 0, - 16, 0, 2, 0, 0, 0, - 26, 0, 16, 128, 65, 0, - 0, 0, 2, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 0, 0, 0, 7, - 194, 0, 16, 0, 1, 0, - 0, 0, 6, 12, 16, 0, - 2, 0, 0, 0, 6, 4, - 16, 0, 3, 0, 0, 0, - 71, 0, 0, 141, 194, 0, - 0, 128, 67, 85, 21, 0, - 130, 0, 16, 0, 0, 0, - 0, 0, 230, 10, 16, 0, - 1, 0, 0, 0, 6, 112, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 2, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 21, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 21, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 22, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 22, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 23, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 23, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 24, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 24, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 25, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 25, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 26, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 26, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 0, 0, - 0, 9, 66, 0, 16, 0, - 1, 0, 0, 0, 26, 128, - 32, 128, 65, 0, 0, 0, - 0, 0, 0, 0, 27, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 8, 18, 0, 16, 0, - 3, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 27, 0, 0, 0, 1, 64, - 0, 0, 111, 18, 3, 59, - 56, 0, 0, 7, 34, 0, - 16, 0, 3, 0, 0, 0, - 42, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 111, 18, 3, 59, 0, 0, - 0, 7, 194, 0, 16, 0, - 1, 0, 0, 0, 6, 12, - 16, 0, 2, 0, 0, 0, - 6, 4, 16, 0, 3, 0, - 0, 0, 71, 0, 0, 141, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, - 1, 0, 0, 0, 230, 10, - 16, 0, 1, 0, 0, 0, - 6, 112, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 2, 0, 0, 0, - 0, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 62, 18, 0, 0, 1, - 54, 0, 0, 5, 130, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 21, 0, 0, 1, - 18, 0, 0, 1, 54, 0, - 0, 5, 130, 0, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 21, 0, 0, 1, 15, 0, - 0, 7, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 1, 0, 0, 0, - 70, 0, 16, 0, 1, 0, - 0, 0, 0, 0, 0, 10, - 34, 0, 16, 0, 1, 0, - 0, 0, 58, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 34, 0, 0, 0, - 42, 128, 32, 0, 0, 0, - 0, 0, 34, 0, 0, 0, - 0, 0, 0, 9, 18, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 58, 128, 32, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 34, 0, 0, 0, - 14, 0, 0, 10, 34, 0, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 128, 63, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 128, 63, 26, 0, 16, 0, - 1, 0, 0, 0, 56, 32, - 0, 7, 18, 0, 16, 0, - 1, 0, 0, 0, 26, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 50, 0, 0, 9, - 34, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 0, 192, - 1, 64, 0, 0, 0, 0, - 64, 64, 56, 0, 0, 7, - 18, 0, 16, 0, 1, 0, - 0, 0, 10, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 7, 18, 0, - 16, 0, 1, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 26, 0, 16, 0, - 1, 0, 0, 0, 52, 0, - 0, 7, 18, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 1, 0, 0, 0, - 1, 64, 0, 0, 205, 204, - 76, 61, 56, 0, 0, 10, - 226, 0, 16, 0, 1, 0, - 0, 0, 6, 25, 16, 0, - 4, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 102, 102, 102, 63, 102, 102, - 102, 63, 102, 102, 102, 63, - 50, 0, 0, 15, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 64, 0, 0, - 0, 192, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 191, - 0, 0, 128, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 16, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 70, 18, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 9, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 191, 1, 64, 0, 0, - 0, 0, 0, 63, 56, 0, - 0, 7, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 6, 0, 16, 0, - 0, 0, 0, 0, 150, 7, - 16, 0, 1, 0, 0, 0, - 52, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 205, 204, 76, 62, 56, 0, - 0, 7, 114, 0, 16, 0, - 0, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 6, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 47, 0, 0, 6, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 128, 129, 0, - 0, 0, 0, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 47, 186, 232, 62, 47, 186, - 232, 62, 47, 186, 232, 62, - 0, 0, 0, 0, 25, 0, - 0, 5, 114, 32, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 130, 32, - 16, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 62, 0, 0, 1, - 83, 84, 65, 84, 148, 0, - 0, 0, 101, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 75, 0, 0, 0, 1, 0, - 0, 0, 2, 0, 0, 0, - 4, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/pointVS.hlsl b/demo/d3d11/shaders/pointVS.hlsl deleted file mode 100644 index 6ab4b6c..0000000 --- a/demo/d3d11/shaders/pointVS.hlsl +++ /dev/null @@ -1,26 +0,0 @@ -#include "shaderCommon.h" - -cbuffer constBuf : register(b0) -{ - PointShaderConst gParams; -}; - -PointVertexOut pointVS(PointVertexIn input, uint instance : SV_VertexID) -{ - const float4 gl_Vertex = input.position; - const float4x4 gl_ModelViewMatrix = gParams.modelview; - - float density = input.density; - int phase = input.phase; - - // calculate window-space point size - float4 viewPos = mul(gl_ModelViewMatrix, float4(gl_Vertex.xyz, 1.0)); - - PointVertexOut output; - output.position = viewPos; - output.density = density; - output.phase = phase; - output.vertex = gl_Vertex; - - return output; -} diff --git a/demo/d3d11/shaders/pointVS.hlsl.h b/demo/d3d11/shaders/pointVS.hlsl.h deleted file mode 100644 index b78b3f1..0000000 --- a/demo/d3d11/shaders/pointVS.hlsl.h +++ /dev/null @@ -1,374 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 -// -// -// Buffer Definitions: -// -// cbuffer constBuf -// { -// -// struct PointShaderConst -// { -// -// float4x4 modelview; // Offset: 0 -// float4x4 projection; // Offset: 64 -// float4x4 lightTransform; // Offset: 128 -// float4 colors[8]; // Offset: 192 -// float4 shadowTaps[12]; // Offset: 320 -// float3 lightPos; // Offset: 512 -// float _pad0; // Offset: 524 -// float3 lightDir; // Offset: 528 -// float _pad1; // Offset: 540 -// float pointRadius; // Offset: 544 -// float pointScale; // Offset: 548 -// float spotMin; // Offset: 552 -// float spotMax; // Offset: 556 -// int mode; // Offset: 560 -// int _pad2[3]; // Offset: 576 -// -// } gParams; // Offset: 0 Size: 612 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// constBuf cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// DENSITY 0 x 1 NONE float x -// PHASE 0 x 2 NONE int x -// SV_VertexID 0 x 3 VERTID uint -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// DENSITY 0 x 1 NONE float x -// PHASE 0 x 2 NONE int x -// VERTEX 0 xyzw 3 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer cb0[4], immediateIndexed -dcl_input v0.xyzw -dcl_input v1.x -dcl_input v2.x -dcl_output o0.xyzw -dcl_output o1.x -dcl_output o2.x -dcl_output o3.xyzw -dcl_temps 1 -mul r0.xyzw, v0.yyyy, cb0[1].xyzw -mad r0.xyzw, cb0[0].xyzw, v0.xxxx, r0.xyzw -mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw -add o0.xyzw, r0.xyzw, cb0[3].xyzw -mov o1.x, v1.x -mov o2.x, v2.x -mov o3.xyzw, v0.xyzw -ret -// Approximately 8 instruction slots used -#endif - -const BYTE g_pointVS[] = -{ - 68, 88, 66, 67, 195, 164, - 148, 248, 252, 197, 222, 222, - 84, 139, 94, 6, 43, 78, - 110, 120, 1, 0, 0, 0, - 192, 6, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 176, 3, 0, 0, 68, 4, - 0, 0, 212, 4, 0, 0, - 36, 6, 0, 0, 82, 68, - 69, 70, 116, 3, 0, 0, - 1, 0, 0, 0, 104, 0, - 0, 0, 1, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 254, 255, 0, 1, 0, 0, - 64, 3, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 99, 111, 110, 115, - 116, 66, 117, 102, 0, 171, - 171, 171, 92, 0, 0, 0, - 1, 0, 0, 0, 128, 0, - 0, 0, 112, 2, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 168, 0, 0, 0, - 0, 0, 0, 0, 100, 2, - 0, 0, 2, 0, 0, 0, - 28, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 103, 80, 97, 114, 97, 109, - 115, 0, 80, 111, 105, 110, - 116, 83, 104, 97, 100, 101, - 114, 67, 111, 110, 115, 116, - 0, 109, 111, 100, 101, 108, - 118, 105, 101, 119, 0, 102, - 108, 111, 97, 116, 52, 120, - 52, 0, 3, 0, 3, 0, - 4, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 203, 0, - 0, 0, 112, 114, 111, 106, - 101, 99, 116, 105, 111, 110, - 0, 108, 105, 103, 104, 116, - 84, 114, 97, 110, 115, 102, - 111, 114, 109, 0, 99, 111, - 108, 111, 114, 115, 0, 102, - 108, 111, 97, 116, 52, 0, - 1, 0, 3, 0, 1, 0, - 4, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 25, 1, 0, 0, - 115, 104, 97, 100, 111, 119, - 84, 97, 112, 115, 0, 171, - 1, 0, 3, 0, 1, 0, - 4, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 25, 1, 0, 0, - 108, 105, 103, 104, 116, 80, - 111, 115, 0, 102, 108, 111, - 97, 116, 51, 0, 1, 0, - 3, 0, 1, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 125, 1, 0, 0, 95, 112, - 97, 100, 48, 0, 102, 108, - 111, 97, 116, 0, 0, 0, - 3, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 174, 1, 0, 0, 108, 105, - 103, 104, 116, 68, 105, 114, - 0, 95, 112, 97, 100, 49, - 0, 112, 111, 105, 110, 116, - 82, 97, 100, 105, 117, 115, - 0, 112, 111, 105, 110, 116, - 83, 99, 97, 108, 101, 0, - 115, 112, 111, 116, 77, 105, - 110, 0, 115, 112, 111, 116, - 77, 97, 120, 0, 109, 111, - 100, 101, 0, 105, 110, 116, - 0, 171, 0, 0, 2, 0, - 1, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 2, - 0, 0, 95, 112, 97, 100, - 50, 0, 171, 171, 0, 0, - 2, 0, 1, 0, 1, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 19, 2, 0, 0, 193, 0, - 0, 0, 212, 0, 0, 0, - 0, 0, 0, 0, 248, 0, - 0, 0, 212, 0, 0, 0, - 64, 0, 0, 0, 3, 1, - 0, 0, 212, 0, 0, 0, - 128, 0, 0, 0, 18, 1, - 0, 0, 32, 1, 0, 0, - 192, 0, 0, 0, 68, 1, - 0, 0, 80, 1, 0, 0, - 64, 1, 0, 0, 116, 1, - 0, 0, 132, 1, 0, 0, - 0, 2, 0, 0, 168, 1, - 0, 0, 180, 1, 0, 0, - 12, 2, 0, 0, 216, 1, - 0, 0, 132, 1, 0, 0, - 16, 2, 0, 0, 225, 1, - 0, 0, 180, 1, 0, 0, - 28, 2, 0, 0, 231, 1, - 0, 0, 180, 1, 0, 0, - 32, 2, 0, 0, 243, 1, - 0, 0, 180, 1, 0, 0, - 36, 2, 0, 0, 254, 1, - 0, 0, 180, 1, 0, 0, - 40, 2, 0, 0, 6, 2, - 0, 0, 180, 1, 0, 0, - 44, 2, 0, 0, 14, 2, - 0, 0, 24, 2, 0, 0, - 48, 2, 0, 0, 60, 2, - 0, 0, 68, 2, 0, 0, - 64, 2, 0, 0, 5, 0, - 0, 0, 1, 0, 144, 0, - 0, 0, 15, 0, 104, 2, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 176, 0, 0, 0, 77, 105, - 99, 114, 111, 115, 111, 102, - 116, 32, 40, 82, 41, 32, - 72, 76, 83, 76, 32, 83, - 104, 97, 100, 101, 114, 32, - 67, 111, 109, 112, 105, 108, - 101, 114, 32, 54, 46, 51, - 46, 57, 54, 48, 48, 46, - 49, 54, 51, 56, 52, 0, - 171, 171, 73, 83, 71, 78, - 140, 0, 0, 0, 4, 0, - 0, 0, 8, 0, 0, 0, - 104, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 113, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 1, 1, 0, 0, - 121, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 2, 0, - 0, 0, 1, 1, 0, 0, - 127, 0, 0, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 68, 69, 78, - 83, 73, 84, 89, 0, 80, - 72, 65, 83, 69, 0, 83, - 86, 95, 86, 101, 114, 116, - 101, 120, 73, 68, 0, 171, - 79, 83, 71, 78, 136, 0, - 0, 0, 4, 0, 0, 0, - 8, 0, 0, 0, 104, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 113, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 1, 14, 0, 0, 121, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 2, 0, 0, 0, - 1, 14, 0, 0, 127, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 15, 0, 0, 0, 80, 79, - 83, 73, 84, 73, 79, 78, - 0, 68, 69, 78, 83, 73, - 84, 89, 0, 80, 72, 65, - 83, 69, 0, 86, 69, 82, - 84, 69, 88, 0, 171, 171, - 83, 72, 69, 88, 72, 1, - 0, 0, 80, 0, 1, 0, - 82, 0, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 95, 0, 0, 3, 242, 16, - 16, 0, 0, 0, 0, 0, - 95, 0, 0, 3, 18, 16, - 16, 0, 1, 0, 0, 0, - 95, 0, 0, 3, 18, 16, - 16, 0, 2, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 0, 0, 0, 0, - 101, 0, 0, 3, 18, 32, - 16, 0, 1, 0, 0, 0, - 101, 0, 0, 3, 18, 32, - 16, 0, 2, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 3, 0, 0, 0, - 104, 0, 0, 2, 1, 0, - 0, 0, 56, 0, 0, 8, - 242, 0, 16, 0, 0, 0, - 0, 0, 86, 21, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 16, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 166, 26, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 242, 32, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 54, 0, 0, 5, - 18, 32, 16, 0, 1, 0, - 0, 0, 10, 16, 16, 0, - 1, 0, 0, 0, 54, 0, - 0, 5, 18, 32, 16, 0, - 2, 0, 0, 0, 10, 16, - 16, 0, 2, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 3, 0, 0, 0, - 70, 30, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 83, 84, 65, 84, 148, 0, - 0, 0, 8, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 7, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/demo/d3d11/shaders/shaderCommon.h b/demo/d3d11/shaders/shaderCommon.h deleted file mode 100644 index 176c97d..0000000 --- a/demo/d3d11/shaders/shaderCommon.h +++ /dev/null @@ -1,237 +0,0 @@ -struct MeshShaderConst -{ - float4x4 modelviewprojection; - float4x4 modelview; - float4x4 objectTransform; - float4x4 lightTransform; - - float4 clipPlane; - float4 fogColor; - float4 color; - float4 secondaryColor; - - float4 shadowTaps[12]; - - float3 lightPos; - float _pad0; - float3 lightDir; - float _pad1; - - float bias; - float expand; - float spotMin; - float spotMax; - - int grid; - int tex; - int colorArray; - int _pad2; -}; - -struct DebugRenderConst -{ - float4x4 modelview; - float4x4 projection; -}; - - -#ifndef EXCLUDE_SHADER_STRUCTS -struct MeshVertexIn -{ - float3 position : POSITION; - float3 normal : NORMAL; - float2 texCoord : TEXCOORD; - float4 color : COLOR; -}; - -struct MeshVertexOut -{ - float4 position : SV_POSITION; - //float3 normal : NORMAL; - //float4 color : COLOR; - float4 texCoord[8] : TEXCOORD; - //float clipDistance[1] : CLIP_DISTANCE; -}; -#endif - -struct PointShaderConst -{ - float4x4 modelview; - float4x4 projection; - float4x4 lightTransform; - - float4 colors[8]; - float4 shadowTaps[12]; - - float3 lightPos; - float _pad0; - float3 lightDir; - float _pad1; - - float pointRadius; // point size in world space - float pointScale; // scale to calculate size in pixels - float spotMin; - float spotMax; - - int mode; - int _pad2[3]; -}; - -#ifndef EXCLUDE_SHADER_STRUCTS -struct PointVertexIn -{ - float4 position : POSITION; - float density : DENSITY; - int phase : PHASE; -}; - -struct PointVertexOut -{ - float4 position : POSITION; - float density : DENSITY; - int phase : PHASE; - float4 vertex : VERTEX; -}; - -struct PointGeoOut -{ - float4 position : SV_POSITION; - float4 texCoord[6] : TEXCOORD; -}; -#endif - -struct FluidShaderConst -{ - float4x4 modelviewprojection; - float4x4 modelview; - float4x4 projection; // ogl projection - float4x4 modelview_inverse; - float4x4 projection_inverse; // ogl inverse projection - - float4 invTexScale; - - float3 invViewport; - float _pad0; - //float3 invProjection; - //float _pad1; - - float blurRadiusWorld; - float blurScale; - float blurFalloff; - int debug; - - float3 lightPos; - float _pad1; - float3 lightDir; - float _pad2; - float4x4 lightTransform; - - float4 color; - float4 clipPosToEye; - - float spotMin; - float spotMax; - float ior; - float _pad3; - - float4 shadowTaps[12]; -}; - -#ifndef EXCLUDE_SHADER_STRUCTS -struct FluidVertexIn -{ - float4 position : POSITION; - float4 q1 : U; - float4 q2 : V; - float4 q3 : W; -}; - -struct FluidVertexOut -{ - float4 position : POSITION; - float4 texCoord[6] : TEXCOORD; -}; - -struct FluidGeoOut -{ - float4 position : SV_POSITION; - float4 texCoord[4] : TEXCOORD; -}; - -struct PassthroughVertexIn -{ - float2 position : POSITION; - float2 texCoord : TEXCOORD; -}; - -struct PassthroughVertexOut -{ - float4 position : SV_POSITION; - float2 texCoord[1] : TEXCOORD; -}; -#endif - - -struct DiffuseShaderConst -{ - float3 lightPos; float pad0; - float3 lightDir; float pad1; - float4x4 lightTransform; - float4 color; - - float4x4 modelView; - float4x4 modelViewProjection; - float4x4 projection; - - float4 shadowTaps[12]; - - float diffusion; - float diffuseRadius; // point size in world space - float diffuseScale; // scale to calculate size in pixels - - float spotMin; - float spotMax; - - float motionBlurScale; - - float pad3; - float pad4; - -}; - -#ifndef EXCLUDE_SHADER_STRUCTS - -struct DiffuseVertexIn -{ - float4 position : POSITION; // lifetime in w - float4 velocity : VELOCITY; -}; - -struct DiffuseVertexOut -{ - float4 worldPos : POSITION; // lifetime in w - float4 ndcPos : NCDPOS; - float4 viewPos : VIEWPOS; - float4 viewVel : VIEWVEL; - - float4 color : COLOR; -}; - -struct DiffuseGeometryOut -{ - float4 clipPos : SV_POSITION; - - float4 worldPos : POSITION; - - float4 viewPos : VIEWPOS; - float4 viewVel : VIEWVEL; - - float4 lightDir : LIGHTDIR; - float4 color : COLOR; - - float4 uv : UV; - -}; - -#endif - diff --git a/demo/d3d11/shadersD3D11.cpp b/demo/d3d11/shadersD3D11.cpp deleted file mode 100644 index 9e1d278..0000000 --- a/demo/d3d11/shadersD3D11.cpp +++ /dev/null @@ -1,1041 +0,0 @@ -#include "core/maths.h" -#include "core/extrude.h" - -#include "shaders.h" - -#include "meshRender.h" -#include "pointRender.h" -#include "fluidRender.h" -#include "diffuseRender.h" -#include "debugLineRender.h" - -#include "shadowMap.h" -#include "renderTarget.h" - -#include "imguiGraph.h" -#include "imguiGraphD3D11.h" - -#include "appD3D11Ctx.h" - -#include -#include - -#include - -DebugLineRender gDebugLineRender; -MeshRenderer gMeshRenderer; -PointRenderer gPointRenderer; -DiffuseRenderer gDiffuseRenderer; - -AppGraphCtx* gAppGraphCtx; - -static float gSpotMin = 0.5f; -static float gSpotMax = 1.0f; -float gShadowBias = 0.075f; - -struct RenderContext -{ - RenderContext() - { - memset(&mMeshDrawParams, 0, sizeof(MeshDrawParams)); - } - - MeshDrawParams mMeshDrawParams; - - Matrix44 view; - Matrix44 proj; - - ShadowMap* shadowMap; - GpuMesh* immediateMesh; - - SDL_Window* window; - - int msaaSamples; -}; - -RenderContext gContext; - - -// convert an OpenGL style projection matrix to D3D (clip z range [0, 1]) -Matrix44 ConvertToD3DProjection(const Matrix44& proj) -{ - Matrix44 scale = Matrix44::kIdentity; - scale.columns[2][2] = 0.5f; - - Matrix44 bias = Matrix44::kIdentity; - bias.columns[3][2] = 1.0f; - - return scale*bias*proj; -} - -#define checkDxErrors(err) __checkDxErrors (err, __FILE__, __LINE__) - -inline void __checkDxErrors(HRESULT err, const char *file, const int line) -{ - if (FAILED(err)) - { - char* lpMsgBuf; - - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, - 0, NULL); - - fprintf(stdout, "DX Error = %04d \"%s\" from file <%s>, line %i.\n", - err, lpMsgBuf, file, line); - - exit(EXIT_FAILURE); - } -} - -void InitRender(SDL_Window* window, bool fullscreen, int msaaSamples) -{ - // must always have at least one sample - msaaSamples = Max(1, msaaSamples); - - // create app graph context - gAppGraphCtx = AppGraphCtxCreate(0); - - AppGraphCtxInitRenderTarget(gAppGraphCtx, window, fullscreen, msaaSamples); - //gScene = getScene(0); - - float clearVal[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; - AppGraphCtxFrameStart(gAppGraphCtx, clearVal); - - // create imgui, connect to app graph context - - ImguiGraphDesc desc; - desc.device = gAppGraphCtx->m_device; - desc.deviceContext = gAppGraphCtx->m_deviceContext; - desc.winW = gAppGraphCtx->m_winW; - desc.winH = gAppGraphCtx->m_winH; - - imguiGraphInit("../../data/DroidSans.ttf", &desc); - - AppGraphCtxFramePresent(gAppGraphCtx, true); - - gPointRenderer.Init(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext); - gMeshRenderer.Init(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext); - gDebugLineRender.Init(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext); - gDiffuseRenderer.Init(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext); - - // create a mesh for immediate mode rendering - gContext.immediateMesh = new GpuMesh(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext); - - gContext.window = window; - gContext.msaaSamples = msaaSamples; -} - -void GetRenderDevice(ID3D11Device** device, ID3D11DeviceContext** context) -{ - *device = gAppGraphCtx->m_device; - *context = gAppGraphCtx->m_deviceContext; -} - -void ReshapeRender(SDL_Window* window) -{ - AppGraphCtxReleaseRenderTarget(gAppGraphCtx); - AppGraphCtxInitRenderTarget(gAppGraphCtx, window, false, gContext.msaaSamples); -} - -void DestroyRender() -{ - gDebugLineRender.Destroy(); - gMeshRenderer.Destroy(); - gPointRenderer.Destroy(); - gDiffuseRenderer.Destroy(); - - imguiGraphDestroy(); - - delete gContext.immediateMesh; - - // do this first, since it flushes all GPU work - AppGraphCtxReleaseRenderTarget(gAppGraphCtx); - AppGraphCtxRelease(gAppGraphCtx); - - gAppGraphCtx = nullptr; -} - -void StartFrame(Vec4 clear) -{ - AppGraphCtxFrameStart(gAppGraphCtx, clear); - - MeshDrawParams meshDrawParams; - memset(&meshDrawParams, 0, sizeof(MeshDrawParams)); - meshDrawParams.renderStage = MESH_DRAW_LIGHT; - meshDrawParams.renderMode = MESH_RENDER_SOLID; - meshDrawParams.cullMode = MESH_CULL_BACK; - meshDrawParams.projection = (XMMATRIX)Matrix44::kIdentity; - meshDrawParams.view = (XMMATRIX)Matrix44::kIdentity; - meshDrawParams.model = DirectX::XMMatrixMultiply( - DirectX::XMMatrixScaling(1.0f, 1.0f, 1.0f), - DirectX::XMMatrixTranslation(0.0f, 0.0f, 0.0f) - ); - - gContext.mMeshDrawParams = meshDrawParams; -} - -void FlushFrame() -{ - gAppGraphCtx->m_deviceContext->Flush(); - -} - -void EndFrame() -{ - FlushFrame(); - - ImguiGraphDesc desc; - desc.device = gAppGraphCtx->m_device; - desc.deviceContext = gAppGraphCtx->m_deviceContext; - desc.winW = gAppGraphCtx->m_winW; - desc.winH = gAppGraphCtx->m_winH; - - imguiGraphUpdate(&desc); -} - -void PresentFrame(bool fullsync) -{ - AppGraphCtxFramePresent(gAppGraphCtx, fullsync); - -} - -void ReadFrame(int* backbuffer, int width, int height) -{ - assert(0); -} - -void GetViewRay(int x, int y, Vec3& origin, Vec3& dir) -{ - using namespace DirectX; - - XMVECTOR nearVector = XMVector3Unproject(XMVectorSet(float(x), float(gAppGraphCtx->m_winH-y), 0.0f, 0.0f), 0.0f, 0.0f, (float)gAppGraphCtx->m_winW, (float)gAppGraphCtx->m_winH, 0.0f, 1.0f, (XMMATRIX)gContext.proj, XMMatrixIdentity(), (XMMATRIX)gContext.view); - XMVECTOR farVector = XMVector3Unproject(XMVectorSet(float(x), float(gAppGraphCtx->m_winH-y), 1.0f, 0.0f), 0.0f, 0.0f, (float)gAppGraphCtx->m_winW, (float)gAppGraphCtx->m_winH, 0.0f, 1.0f, (XMMATRIX)gContext.proj, XMMatrixIdentity(), (XMMATRIX)gContext.view); - - origin = Vec3(XMVectorGetX(nearVector), XMVectorGetY(nearVector), XMVectorGetZ(nearVector)); - XMVECTOR tmp = farVector - nearVector; - dir = Normalize(Vec3(XMVectorGetX(tmp), XMVectorGetY(tmp), XMVectorGetZ(tmp))); - -} - -Colour gColors[] = -{ - Colour(0.0f, 0.5f, 1.0f), - Colour(0.797f, 0.354f, 0.000f), - Colour(0.092f, 0.465f, 0.820f), - Colour(0.000f, 0.349f, 0.173f), - Colour(0.875f, 0.782f, 0.051f), - Colour(0.000f, 0.170f, 0.453f), - Colour(0.673f, 0.111f, 0.000f), - Colour(0.612f, 0.194f, 0.394f) -}; - - -void SetFillMode(bool wire) -{ - gContext.mMeshDrawParams.renderMode = wire?MESH_RENDER_WIREFRAME:MESH_RENDER_SOLID; -} - -void SetCullMode(bool enabled) -{ - gContext.mMeshDrawParams.cullMode = enabled?MESH_CULL_BACK:MESH_CULL_NONE; -} - -void SetView(Matrix44 view, Matrix44 projection) -{ - Matrix44 vp = projection*view; - - gContext.mMeshDrawParams.model = (XMMATRIX)Matrix44::kIdentity; - gContext.mMeshDrawParams.view = (XMMATRIX)view; - gContext.mMeshDrawParams.projection = (XMMATRIX)(ConvertToD3DProjection(projection)); - - gContext.view = view; - gContext.proj = ConvertToD3DProjection(projection); -} - - - -FluidRenderer* CreateFluidRenderer(uint32_t width, uint32_t height) -{ - FluidRenderer* renderer = new(_aligned_malloc(sizeof(FluidRenderer), 16)) FluidRenderer(); - renderer->Init(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext, width, height); - - return renderer; -} - -void DestroyFluidRenderer(FluidRenderer* renderer) -{ - renderer->Destroy(); - renderer->~FluidRenderer(); - - _aligned_free(renderer); -} - -FluidRenderBuffers CreateFluidRenderBuffers(int numParticles, bool enableInterop) -{ - FluidRenderBuffers buffers = {}; - buffers.mNumFluidParticles = numParticles; - - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = numParticles*sizeof(Vec4); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - bufDesc.StructureByteStride = 0; - - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mPositionVBO); - - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mAnisotropyVBO[0]); - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mAnisotropyVBO[1]); - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mAnisotropyVBO[2]); - - bufDesc.ByteWidth = numParticles*sizeof(float); - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mDensityVBO); - } - - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = numParticles * sizeof(int); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - bufDesc.StructureByteStride = 0; - - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mIndices); - } - - if (enableInterop) - { - extern NvFlexLibrary* g_flexLib; - - buffers.mPositionBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mPositionVBO, numParticles, sizeof(Vec4)); - buffers.mDensitiesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mDensityVBO, numParticles, sizeof(float)); - buffers.mIndicesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mIndices, numParticles, sizeof(int)); - - buffers.mAnisotropyBuf[0] = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mAnisotropyVBO[0], numParticles, sizeof(Vec4)); - buffers.mAnisotropyBuf[1] = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mAnisotropyVBO[1], numParticles, sizeof(Vec4)); - buffers.mAnisotropyBuf[2] = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mAnisotropyVBO[2], numParticles, sizeof(Vec4)); - } - - return buffers; -} - -void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, NvFlexSolver* solver, bool anisotropy, bool density) -{ - if (!anisotropy) - { - // regular particles - NvFlexGetParticles(solver, buffers.mPositionBuf, buffers.mNumFluidParticles); - } - else - { - // fluid buffers - NvFlexGetSmoothParticles(solver, buffers.mPositionBuf, buffers.mNumFluidParticles); - NvFlexGetAnisotropy(solver, buffers.mAnisotropyBuf[0], buffers.mAnisotropyBuf[1], buffers.mAnisotropyBuf[2]); - } - - if (density) - { - NvFlexGetDensities(solver, buffers.mDensitiesBuf, buffers.mNumFluidParticles); - } - else - { - NvFlexGetPhases(solver, buffers.mDensitiesBuf, buffers.mNumFluidParticles); - } - - NvFlexGetActive(solver, buffers.mIndicesBuf); -} - -void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) -{ - D3D11_MAPPED_SUBRESOURCE res; - - // vertices - if (particles) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mPositionVBO, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, particles, sizeof(Vec4)*numParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mPositionVBO, 0); - } - - if (anisotropy1) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mAnisotropyVBO[0], 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, anisotropy1, sizeof(Vec4)*numParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mAnisotropyVBO[0], 0); - } - - if (anisotropy2) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mAnisotropyVBO[1], 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, anisotropy2, sizeof(Vec4)*numParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mAnisotropyVBO[1], 0); - } - - if (anisotropy3) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mAnisotropyVBO[2], 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, anisotropy3, sizeof(Vec4)*numParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mAnisotropyVBO[2], 0); - } - - if (densities) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mDensityVBO, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, densities, sizeof(float)*numParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mDensityVBO, 0); - } - - // indices - if (indices) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mIndices, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, indices, sizeof(int)*numIndices); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mIndices, 0); - } - -} - -void DestroyFluidRenderBuffers(FluidRenderBuffers buffers) -{ - COMRelease(buffers.mPositionVBO); - COMRelease(buffers.mAnisotropyVBO[0]); - COMRelease(buffers.mAnisotropyVBO[1]); - COMRelease(buffers.mAnisotropyVBO[2]); - COMRelease(buffers.mDensityVBO); - COMRelease(buffers.mIndices); - - NvFlexUnregisterD3DBuffer(buffers.mPositionBuf); - NvFlexUnregisterD3DBuffer(buffers.mDensitiesBuf); - NvFlexUnregisterD3DBuffer(buffers.mIndicesBuf); - - NvFlexUnregisterD3DBuffer(buffers.mAnisotropyBuf[0]); - NvFlexUnregisterD3DBuffer(buffers.mAnisotropyBuf[1]); - NvFlexUnregisterD3DBuffer(buffers.mAnisotropyBuf[2]); -} - - -static const int kShadowResolution = 2048; - - -ShadowMap* ShadowCreate() -{ - ShadowMap* shadowMap = new(_aligned_malloc(sizeof(ShadowMap), 16)) ShadowMap(); - shadowMap->init(gAppGraphCtx->m_device, kShadowResolution); - - return shadowMap; -} - -void ShadowDestroy(ShadowMap* map) -{ - map->~ShadowMap(); - _aligned_free(map); -} - -void ShadowBegin(ShadowMap* map) -{ - ShadowMap* shadowMap = map; - shadowMap->bindAndClear(gAppGraphCtx->m_deviceContext); - - gContext.mMeshDrawParams.renderStage = MESH_DRAW_SHADOW; -} - -void ShadowEnd() -{ - AppGraphCtx* context = gAppGraphCtx; - - // reset to main frame buffer - context->m_deviceContext->RSSetViewports(1, &context->m_viewport); - context->m_deviceContext->OMSetRenderTargets(1, &context->m_rtv, context->m_dsv); - context->m_deviceContext->OMSetDepthStencilState(context->m_depthState, 0u); - context->m_deviceContext->ClearDepthStencilView(context->m_dsv, D3D11_CLEAR_DEPTH, 1.0, 0); - - gContext.mMeshDrawParams.renderStage = MESH_DRAW_NULL; - -} - - -struct ShadowParams -{ - DirectX::XMMATRIX lightTransform; - float3 lightPos; - float3 lightDir; - float bias; - float4 shadowTaps[12]; -}; - -void ShadowApply(ShadowParams* params, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, void* shadowTex) -{ - params->lightTransform = (DirectX::XMMATRIX&)(ConvertToD3DProjection(lightTransform)); - params->lightPos = (float3&)lightPos; - params->lightDir = (float3&)Normalize(lightTarget - lightPos); - params->bias = gShadowBias; - - const Vec4 taps[] = - { - Vec2(-0.326212f,-0.40581f), Vec2(-0.840144f,-0.07358f), - Vec2(-0.695914f,0.457137f), Vec2(-0.203345f,0.620716f), - Vec2(0.96234f,-0.194983f), Vec2(0.473434f,-0.480026f), - Vec2(0.519456f,0.767022f), Vec2(0.185461f,-0.893124f), - Vec2(0.507431f,0.064425f), Vec2(0.89642f,0.412458f), - Vec2(-0.32194f,-0.932615f), Vec2(-0.791559f,-0.59771f) - }; - memcpy(params->shadowTaps, taps, sizeof(taps)); - -} - -void BindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float bias, Vec4 fogColor) -{ - gContext.mMeshDrawParams.renderStage = MESH_DRAW_LIGHT; - - gContext.mMeshDrawParams.grid = 0; - gContext.mMeshDrawParams.spotMin = gSpotMin; - gContext.mMeshDrawParams.spotMax = gSpotMax; - gContext.mMeshDrawParams.fogColor = (float4&)fogColor; - - gContext.mMeshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; - - ShadowParams shadow; - ShadowApply(&shadow, lightPos, lightTarget, lightTransform, shadowMap); - gContext.mMeshDrawParams.lightTransform = shadow.lightTransform; - gContext.mMeshDrawParams.lightDir = shadow.lightDir; - gContext.mMeshDrawParams.lightPos = shadow.lightPos; - gContext.mMeshDrawParams.bias = shadow.bias; - memcpy(gContext.mMeshDrawParams.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); - - gContext.shadowMap = shadowMap; - -} - -void UnbindSolidShader() -{ - gContext.mMeshDrawParams.renderStage = MESH_DRAW_NULL; -} - -void DrawMesh(const Mesh* m, Vec3 color) -{ - if (m) - { - if (m->m_colours.size()) - { - gContext.mMeshDrawParams.colorArray = 1; - gContext.immediateMesh->UpdateData((Vec3*)&m->m_positions[0], &m->m_normals[0], NULL, (Vec4*)&m->m_colours[0], (int*)&m->m_indices[0], m->GetNumVertices(), int(m->GetNumFaces())); - } - else - { - gContext.mMeshDrawParams.colorArray = 0; - gContext.immediateMesh->UpdateData((Vec3*)&m->m_positions[0], &m->m_normals[0], NULL, NULL, (int*)&m->m_indices[0], m->GetNumVertices(), int(m->GetNumFaces())); - } - - gContext.mMeshDrawParams.color = (float4&)color; - gContext.mMeshDrawParams.secondaryColor = (float4&)color; - gContext.mMeshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; - gContext.mMeshDrawParams.shadowMap = gContext.shadowMap; - - gMeshRenderer.Draw(gContext.immediateMesh, &gContext.mMeshDrawParams); - - if (m->m_colours.size()) - gContext.mMeshDrawParams.colorArray = 0; - - } -} - -void DrawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth) -{ - if (!numTris) - return; - - gContext.immediateMesh->UpdateData(positions, normals, NULL, NULL, indices, numPositions, numTris); - - if (twosided) - SetCullMode(false); - - gContext.mMeshDrawParams.bias = 0.0f; - gContext.mMeshDrawParams.expand = expand; - - gContext.mMeshDrawParams.color = (float4&)(gColors[colorIndex + 1] * 1.5f); - gContext.mMeshDrawParams.secondaryColor = (float4&)(gColors[colorIndex] * 1.5f); - gContext.mMeshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; - gContext.mMeshDrawParams.shadowMap = gContext.shadowMap; - - gMeshRenderer.Draw(gContext.immediateMesh, &gContext.mMeshDrawParams); - - if (twosided) - SetCullMode(true); - - gContext.mMeshDrawParams.bias = gShadowBias; - gContext.mMeshDrawParams.expand = 0.0f; - -} - -void DrawRope(Vec4* positions, int* indices, int numIndices, float radius, int color) -{ - if (numIndices < 2) - return; - - std::vector vertices; - std::vector normals; - std::vector triangles; - - // flatten curve - std::vector curve(numIndices); - for (int i = 0; i < numIndices; ++i) - curve[i] = Vec3(positions[indices[i]]); - - const int resolution = 8; - const int smoothing = 3; - - vertices.reserve(resolution*numIndices*smoothing); - normals.reserve(resolution*numIndices*smoothing); - triangles.reserve(numIndices*resolution * 6 * smoothing); - - Extrude(&curve[0], int(curve.size()), vertices, normals, triangles, radius, resolution, smoothing); - - gContext.immediateMesh->UpdateData(&vertices[0], &normals[0], NULL, NULL, &triangles[0], int(vertices.size()), int(triangles.size())/3); - - SetCullMode(false); - - gContext.mMeshDrawParams.color = (float4&)(gColors[color % 8] * 1.5f); - gContext.mMeshDrawParams.secondaryColor = (float4&)(gColors[color % 8] * 1.5f); - gContext.mMeshDrawParams.objectTransform = (float4x4&)Matrix44::kIdentity; - gContext.mMeshDrawParams.shadowMap = gContext.shadowMap; - - gMeshRenderer.Draw(gContext.immediateMesh, &gContext.mMeshDrawParams); - - SetCullMode(true); -} - -void DrawPlane(const Vec4& p, bool color) -{ - std::vector vertices; - std::vector normals; - std::vector indices; - - Vec3 u, v; - BasisFromVector(Vec3(p.x, p.y, p.z), &u, &v); - - Vec3 c = Vec3(p.x, p.y, p.z)*-p.w; - - gContext.mMeshDrawParams.shadowMap = gContext.shadowMap; - - if (color) - gContext.mMeshDrawParams.color = (float4&)(p * 0.5f + Vec4(0.5f, 0.5f, 0.5f, 0.5f)); - - const float kSize = 200.0f; - const int kGrid = 3; - - // draw a grid of quads, otherwise z precision suffers - for (int x = -kGrid; x <= kGrid; ++x) - { - for (int y = -kGrid; y <= kGrid; ++y) - { - Vec3 coff = c + u*float(x)*kSize*2.0f + v*float(y)*kSize*2.0f; - - int indexStart = int(vertices.size()); - - vertices.push_back(Vec3(coff + u*kSize + v*kSize)); - vertices.push_back(Vec3(coff - u*kSize + v*kSize)); - vertices.push_back(Vec3(coff - u*kSize - v*kSize)); - vertices.push_back(Vec3(coff + u*kSize - v*kSize)); - - normals.push_back(Vec3(p.x, p.y, p.z)); - normals.push_back(Vec3(p.x, p.y, p.z)); - normals.push_back(Vec3(p.x, p.y, p.z)); - normals.push_back(Vec3(p.x, p.y, p.z)); - - - indices.push_back(indexStart+0); - indices.push_back(indexStart+1); - indices.push_back(indexStart+2); - - indices.push_back(indexStart+2); - indices.push_back(indexStart+3); - indices.push_back(indexStart+0); - } - } - - gContext.immediateMesh->UpdateData(&vertices[0], &normals[0], NULL, NULL, &indices[0], int(vertices.size()), int(indices.size())/3); - gMeshRenderer.Draw(gContext.immediateMesh, &gContext.mMeshDrawParams); -} - -void DrawPlanes(Vec4* planes, int n, float bias) -{ - gContext.mMeshDrawParams.color = (float4&)Vec4(0.9f, 0.9f, 0.9f, 1.0f); - - gContext.mMeshDrawParams.bias = 0.0f; - gContext.mMeshDrawParams.grid = 1; - gContext.mMeshDrawParams.expand = 0; - - for (int i = 0; i < n; ++i) - { - Vec4 p = planes[i]; - p.w -= bias; - - DrawPlane(p, false); - } - - gContext.mMeshDrawParams.grid = 0; - gContext.mMeshDrawParams.bias = gShadowBias; - -} - -GpuMesh* CreateGpuMesh(const Mesh* m) -{ - GpuMesh* mesh = new GpuMesh(gAppGraphCtx->m_device, gAppGraphCtx->m_deviceContext); - - mesh->UpdateData((Vec3*)&m->m_positions[0], &m->m_normals[0], NULL, NULL, (int*)&m->m_indices[0], m->GetNumVertices(), int(m->GetNumFaces())); - - return mesh; -} - -void DestroyGpuMesh(GpuMesh* m) -{ - delete m; -} - -void DrawGpuMesh(GpuMesh* m, const Matrix44& xform, const Vec3& color) -{ - if (m) - { - MeshDrawParams params = gContext.mMeshDrawParams; - - params.color = (float4&)color; - params.secondaryColor = (float4&)color; - params.objectTransform = (float4x4&)xform; - params.shadowMap = gContext.shadowMap; - - gMeshRenderer.Draw(m, ¶ms); - } -} - -void DrawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const Vec3& color) -{ - if (m) - { - gContext.mMeshDrawParams.color = (float4&)color; - gContext.mMeshDrawParams.secondaryColor = (float4&)color; - gContext.mMeshDrawParams.shadowMap = gContext.shadowMap; - - // copy params - MeshDrawParams params = gContext.mMeshDrawParams; - - for (int i = 0; i < n; ++i) - { - params.objectTransform = (float4x4&)xforms[i]; - - gMeshRenderer.Draw(m, ¶ms); - } - } -} - -void DrawPoints(VertexBuffer positions, VertexBuffer colors, IndexBuffer indices, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, bool showDensity) -{ - if (n == 0) - return; - - PointDrawParams params; - - params.renderMode = POINT_RENDER_SOLID; - params.cullMode = POINT_CULL_BACK; - params.model = (XMMATRIX&)Matrix44::kIdentity; - params.view = (XMMATRIX&)gContext.view; - params.projection = (XMMATRIX&)gContext.proj; - - params.pointRadius = radius; - params.pointScale = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); - params.spotMin = gSpotMin; - params.spotMax = gSpotMax; - - int mode = 0; - if (showDensity) - mode = 1; - if (shadowTex == 0) - mode = 2; - params.mode = mode; - - for (int i = 0; i < 8; i++) - params.colors[i] = *((float4*)&gColors[i].r); - - // set shadow parameters - ShadowParams shadow; - ShadowApply(&shadow, lightPos, lightTarget, lightTransform, shadowTex); - params.lightTransform = shadow.lightTransform; - params.lightDir = shadow.lightDir; - params.lightPos = shadow.lightPos; - memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); - - if (gContext.mMeshDrawParams.renderStage == MESH_DRAW_SHADOW) - { - params.renderStage = POINT_DRAW_SHADOW; - params.mode = 2; - } - else - params.renderStage = POINT_DRAW_LIGHT; - - params.shadowMap = gContext.shadowMap; - - gPointRenderer.Draw(¶ms, positions, colors, indices, n, offset); - -} - -void RenderEllipsoids(FluidRenderer* renderer, FluidRenderBuffers buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) -{ - if (n == 0) - return; - - FluidDrawParams params; - - params.renderMode = FLUID_RENDER_SOLID; - params.cullMode = FLUID_CULL_BACK; - params.model = (XMMATRIX&)Matrix44::kIdentity; - params.view = (XMMATRIX&)gContext.view; - params.projection = (XMMATRIX&)gContext.proj; - - params.offset = offset; - params.n = n; - params.renderStage = FLUID_DRAW_LIGHT; - - const float viewHeight = tanf(fov / 2.0f); - params.invViewport = float3(1.0f / screenWidth, screenAspect / screenWidth, 1.0f); - params.invProjection = float3(screenAspect * viewHeight, viewHeight, 1.0f); - - params.shadowMap = gContext.shadowMap; - - renderer->mDepthTex.BindAndClear(gAppGraphCtx->m_deviceContext); - - // draw static shapes into depth buffer - //DrawShapes(); - - renderer->DrawEllipsoids(¶ms, &buffers); - - - //--------------------------------------------------------------- - // build smooth depth - - renderer->mDepthSmoothTex.BindAndClear(gAppGraphCtx->m_deviceContext); - - params.blurRadiusWorld = radius * 0.5f; - params.blurScale = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); - params.invTexScale = float4(1.0f / screenAspect, 1.0f, 0.0f, 0.0f); - params.blurFalloff = blur; - params.debug = debug; - - renderer->DrawBlurDepth(¶ms); - - //--------------------------------------------------------------- - // composite - - AppGraphCtx* context = gAppGraphCtx; - - { - context->m_deviceContext->RSSetViewports(1, &context->m_viewport); - context->m_deviceContext->RSSetScissorRects(0, nullptr); - - context->m_deviceContext->OMSetRenderTargets(1, &context->m_rtv, context->m_dsv); - context->m_deviceContext->OMSetDepthStencilState(context->m_depthState, 0u); - - float blendFactor[4] = { 1.0, 1.0, 1.0, 1.0 }; - context->m_deviceContext->OMSetBlendState(context->m_blendState, blendFactor, 0xffff); - } - - params.invTexScale = (float4&)Vec2(1.0f / screenWidth, screenAspect / screenWidth); - params.clipPosToEye = (float4&)Vec2(tanf(fov*0.5f)*screenAspect, tanf(fov*0.5f)); - params.color = (float4&)color; - params.ior = ior; - params.spotMin = gSpotMin; - params.spotMax = gSpotMax; - params.debug = debug; - - params.lightPos = (float3&)lightPos; - params.lightDir = (float3&)-Normalize(lightTarget - lightPos); - params.lightTransform = (XMMATRIX&)(ConvertToD3DProjection(lightTransform)); - - - AppGraphCtxResolveFrame(context); - - - renderer->DrawComposite(¶ms, context->m_resolvedTargetSRV); - - { - AppGraphCtx* context = gAppGraphCtx; - context->m_deviceContext->OMSetBlendState(nullptr, 0, 0xffff); - } -} - -DiffuseRenderBuffers CreateDiffuseRenderBuffers(int numParticles, bool& enableInterop) -{ - DiffuseRenderBuffers buffers = {}; - buffers.mNumDiffuseParticles = numParticles; - if (numParticles > 0) - { - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = numParticles * sizeof(Vec4); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - if (enableInterop) - { - bufDesc.CPUAccessFlags = 0; - bufDesc.Usage = D3D11_USAGE_DEFAULT; - bufDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; - } - - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mDiffusePositionVBO); - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mDiffuseVelocityVBO); - } - - { - D3D11_BUFFER_DESC bufDesc; - bufDesc.ByteWidth = numParticles * sizeof(int); - bufDesc.Usage = D3D11_USAGE_DYNAMIC; - bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; - bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufDesc.MiscFlags = 0; - if (enableInterop) - { - bufDesc.CPUAccessFlags = 0; - bufDesc.Usage = D3D11_USAGE_DEFAULT; - bufDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; - } - - gAppGraphCtx->m_device->CreateBuffer(&bufDesc, NULL, &buffers.mDiffuseIndicesIBO); - } - - if (enableInterop) - { - extern NvFlexLibrary* g_flexLib; - - buffers.mDiffuseIndicesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mDiffuseIndicesIBO, numParticles, sizeof(int)); - buffers.mDiffusePositionsBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mDiffusePositionVBO, numParticles, sizeof(Vec4)); - buffers.mDiffuseVelocitiesBuf = NvFlexRegisterD3DBuffer(g_flexLib, buffers.mDiffuseVelocityVBO, numParticles, sizeof(Vec4)); - - if (buffers.mDiffuseIndicesBuf == nullptr || - buffers.mDiffusePositionsBuf == nullptr || - buffers.mDiffuseVelocitiesBuf == nullptr) - enableInterop = false; - } - } - - return buffers; -} - -void DestroyDiffuseRenderBuffers(DiffuseRenderBuffers buffers) -{ - if (buffers.mNumDiffuseParticles > 0) - { - COMRelease(buffers.mDiffusePositionVBO); - COMRelease(buffers.mDiffuseVelocityVBO); - COMRelease(buffers.mDiffuseIndicesIBO); - - NvFlexUnregisterD3DBuffer(buffers.mDiffuseIndicesBuf); - NvFlexUnregisterD3DBuffer(buffers.mDiffusePositionsBuf); - NvFlexUnregisterD3DBuffer(buffers.mDiffuseVelocitiesBuf); - } -} - -void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers buffers, NvFlexSolver* solver) -{ - // diffuse particles - if (buffers.mNumDiffuseParticles) - { - NvFlexGetDiffuseParticles(solver, buffers.mDiffusePositionsBuf, buffers.mDiffuseVelocitiesBuf, buffers.mDiffuseIndicesBuf); - } -} - -void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, int* diffuseIndices, int numDiffuseParticles) -{ - D3D11_MAPPED_SUBRESOURCE res; - - // vertices - if (diffusePositions) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mDiffusePositionVBO, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, diffusePositions, sizeof(Vec4)*numDiffuseParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mDiffusePositionVBO, 0); - } - - if (diffuseVelocities) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mDiffuseVelocityVBO, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, diffuseVelocities, sizeof(Vec4)*numDiffuseParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mDiffuseVelocityVBO, 0); - } - - if (diffuseIndices) - { - gAppGraphCtx->m_deviceContext->Map(buffers.mDiffuseIndicesIBO, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); - memcpy(res.pData, diffuseIndices, sizeof(int)*numDiffuseParticles); - gAppGraphCtx->m_deviceContext->Unmap(buffers.mDiffuseIndicesIBO, 0); - } - -} - -void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers buffers, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front) -{ - if (n == 0) - return; - - DiffuseDrawParams params; - - params.model = (const XMMATRIX&)Matrix44::kIdentity; - params.view = (const XMMATRIX&)gContext.view; - params.projection = (const XMMATRIX&)gContext.proj; - params.diffuseRadius = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); - params.diffuseScale = radius; - params.spotMin = gSpotMin; - params.spotMax = gSpotMax; - params.color = float4(1.0f, 1.0f, 1.0f, 1.0f); - params.motionScale = motionBlur; - - // set shadow parameters - ShadowParams shadow; - ShadowApply(&shadow, lightPos, lightTarget, lightTransform, shadowMap); - params.lightTransform = shadow.lightTransform; - params.lightDir = shadow.lightDir; - params.lightPos = shadow.lightPos; - params.shadowMap = gContext.shadowMap; - - memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); - - - gDiffuseRenderer.Draw(¶ms, buffers.mDiffusePositionVBO, buffers.mDiffuseVelocityVBO, buffers.mDiffuseIndicesIBO, n); - - // reset depth stencil state - gAppGraphCtx->m_deviceContext->OMSetDepthStencilState(gAppGraphCtx->m_depthState, 0u); - - -} - - -void BeginLines() -{ - -} - -void DrawLine(const Vec3& p, const Vec3& q, const Vec4& color) -{ - gDebugLineRender.AddLine(p, q, color); -} - -void EndLines() -{ - // draw - Matrix44 projectionViewWorld = ((Matrix44&)(gContext.mMeshDrawParams.projection))*((Matrix44&)(gContext.mMeshDrawParams.view)); - - gDebugLineRender.FlushLines(projectionViewWorld); -} - -void BeginPoints(float size) {} -void DrawPoint(const Vec3& p, const Vec4& color) {} -void EndPoints() {} - diff --git a/demo/d3d11/shadowMap.cpp b/demo/d3d11/shadowMap.cpp deleted file mode 100644 index 403ec59..0000000 --- a/demo/d3d11/shadowMap.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2008-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 "shadowMap.h" - -ShadowMap::ShadowMap() -{ -} - -static D3D11_TEXTURE2D_DESC _getTextureDesc(DXGI_FORMAT format, UINT width, UINT height, - UINT bindFlags, UINT sampleCount = 1, D3D11_USAGE usage = D3D11_USAGE_DEFAULT, UINT cpuAccessFlags = 0, - UINT miscFlags = 0, UINT arraySize = 1, UINT mipLevels = 1) -{ - D3D11_TEXTURE2D_DESC desc; - desc.Format = format; - desc.Width = width; - desc.Height = height; - - desc.ArraySize = arraySize; - desc.MiscFlags = miscFlags; - desc.MipLevels = mipLevels; - - desc.SampleDesc.Count = sampleCount; - desc.SampleDesc.Quality = 0; - desc.BindFlags = bindFlags; - desc.Usage = usage; - desc.CPUAccessFlags = cpuAccessFlags; - return desc; -} - -static D3D11_DEPTH_STENCIL_VIEW_DESC _getDsvDesc(DXGI_FORMAT format, D3D11_DSV_DIMENSION viewDimension, UINT flags = 0, UINT mipSlice = 0) -{ - D3D11_DEPTH_STENCIL_VIEW_DESC desc; - desc.Format = format; - desc.ViewDimension = viewDimension; - desc.Flags = flags; - desc.Texture2D.MipSlice = mipSlice; - return desc; -} - -static D3D11_SHADER_RESOURCE_VIEW_DESC _getSrvDesc(DXGI_FORMAT format) -{ - D3D11_SHADER_RESOURCE_VIEW_DESC desc; - desc.Format = format; - desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - desc.Texture2D.MostDetailedMip = 0; - desc.Texture2D.MipLevels = -1; - - return desc; -} - -HRESULT ShadowMap::init(ID3D11Device* device, int resolution) -{ - // set viewport - { - m_viewport.Width = float(resolution); - m_viewport.Height = float(resolution); - m_viewport.MinDepth = 0; - m_viewport.MaxDepth = 1; - m_viewport.TopLeftX = 0; - m_viewport.TopLeftY = 0; - } - - // create shadow render target - { - D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_FLOAT, UINT(resolution), UINT(resolution), - D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); - - NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_backTexture.ReleaseAndGetAddressOf())); - NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_backTexture.Get(), NV_NULL, m_backSrv.ReleaseAndGetAddressOf())); - NV_RETURN_ON_FAIL(device->CreateRenderTargetView(m_backTexture.Get(), NV_NULL, m_backRtv.ReleaseAndGetAddressOf())); - } - - // create shadow depth stencil - { - D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_TYPELESS, UINT(resolution), UINT(resolution), - D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE); - NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_depthTexture.ReleaseAndGetAddressOf())); - - D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = _getDsvDesc(DXGI_FORMAT_D32_FLOAT, D3D11_DSV_DIMENSION_TEXTURE2D); - NV_RETURN_ON_FAIL(device->CreateDepthStencilView(m_depthTexture.Get(), &dsvDesc, m_depthDsv.ReleaseAndGetAddressOf())); - - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = _getSrvDesc(DXGI_FORMAT_R32_FLOAT); - NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_depthTexture.Get(), &srvDesc, m_depthSrv.ReleaseAndGetAddressOf())); - } - - { - // example texture sampler (use any texture sampler of your own choice) - D3D11_SAMPLER_DESC samplerDesc = - { - D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - 0.0, 0, D3D11_COMPARISON_LESS_EQUAL, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, D3D11_FLOAT32_MAX, - }; - NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_linearSampler.ReleaseAndGetAddressOf())); - } - { - D3D11_SAMPLER_DESC samplerDesc = - { - D3D11_FILTER_MIN_MAG_MIP_POINT, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - D3D11_TEXTURE_ADDRESS_CLAMP, - 0.0, 0, D3D11_COMPARISON_NEVER, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, D3D11_FLOAT32_MAX, - }; - NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_pointSampler.ReleaseAndGetAddressOf())); - } - - return S_OK; -} - -void ShadowMap::bindAndClear(ID3D11DeviceContext* context) -{ - ID3D11RenderTargetView* ppRtv[1] = { m_backRtv.Get() }; - context->OMSetRenderTargets(1, ppRtv, m_depthDsv.Get()); - - context->RSSetViewports(1, &m_viewport); - - float clearDepth = FLT_MAX; - float clearColor[4] = { clearDepth, clearDepth, clearDepth, clearDepth }; - - context->ClearRenderTargetView(m_backRtv.Get(), clearColor); - context->ClearDepthStencilView(m_depthDsv.Get(), D3D11_CLEAR_DEPTH, 1.0, 0); -} - -void ShadowMap::setDefaultLight(FXMVECTOR eye, FXMVECTOR at, FXMVECTOR up) -{ - float sizeX = 50.0f; - float sizeY = 50.0f; - float znear = -200.0f; - float zfar = 200.0f; - - setLightMatrices(eye, at, up, sizeX, sizeY, znear, zfar); -} - -void ShadowMap::setLightMatrices(FXMVECTOR eye, FXMVECTOR lookAt, FXMVECTOR up, float sizeX, float sizeY, float zNear, float zFar) -{ - m_lightView = XMMatrixLookAtLH(eye, lookAt, up); - - m_lightProjection = XMMatrixOrthographicLH(sizeX, sizeY, zNear, zFar); - - DirectX::XMMATRIX clip2Tex(0.5, 0, 0, 0, - 0, -0.5, 0, 0, - 0, 0, 1, 0, - 0.5, 0.5, 0, 1); - - DirectX::XMMATRIX viewProjection = m_lightView * m_lightProjection; - m_lightWorldToTex = viewProjection * clip2Tex; -} diff --git a/demo/d3d11/shadowMap.h b/demo/d3d11/shadowMap.h deleted file mode 100644 index 2ed15ca..0000000 --- a/demo/d3d11/shadowMap.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. - * - * NVIDIA CORPORATION and its licensors retain all intellectual property - * and proprietary rights in and to this software, related documentation - * and any modifications thereto. Any use, reproduction, disclosure or - * distribution of this software and related documentation without an express - * license agreement from NVIDIA CORPORATION is strictly prohibited. - */ - -#pragma once - -#include -#include -#include - -using namespace DirectX; -using namespace Microsoft::WRL; - -#define NV_NULL nullptr -#define NV_RETURN_ON_FAIL(x) { HRESULT _res = (x); if (FAILED(_res)) { return _res; } } - -struct ShadowMap -{ - - ShadowMap(); - - HRESULT init(ID3D11Device* device, int resolution); - - void setDefaultLight(FXMVECTOR eye, FXMVECTOR at, FXMVECTOR up); - void setLightMatrices(FXMVECTOR eye, FXMVECTOR lookAt, FXMVECTOR up, float sizeX, float sizeY, float zNear, float zFar); - - void bindAndClear(ID3D11DeviceContext* context); - - XMMATRIX m_lightView; - XMMATRIX m_lightProjection; - XMMATRIX m_lightWorldToTex; - - ComPtr m_backTexture; - ComPtr m_backRtv; - ComPtr m_backSrv; - - ComPtr m_depthTexture; - ComPtr m_depthDsv; - ComPtr m_depthSrv; - - ComPtr m_linearSampler; - ComPtr m_pointSampler; - - D3D11_VIEWPORT m_viewport; -}; diff --git a/demo/d3d11/shadowMapD3D11.cpp b/demo/d3d11/shadowMapD3D11.cpp new file mode 100644 index 0000000..a824929 --- /dev/null +++ b/demo/d3d11/shadowMapD3D11.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2008-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 "shadowMapD3D11.h" + +ShadowMapD3D11::ShadowMapD3D11() +{ +} + +static D3D11_TEXTURE2D_DESC _getTextureDesc(DXGI_FORMAT format, UINT width, UINT height, + UINT bindFlags, UINT sampleCount = 1, D3D11_USAGE usage = D3D11_USAGE_DEFAULT, UINT cpuAccessFlags = 0, + UINT miscFlags = 0, UINT arraySize = 1, UINT mipLevels = 1) +{ + D3D11_TEXTURE2D_DESC desc; + desc.Format = format; + desc.Width = width; + desc.Height = height; + + desc.ArraySize = arraySize; + desc.MiscFlags = miscFlags; + desc.MipLevels = mipLevels; + + desc.SampleDesc.Count = sampleCount; + desc.SampleDesc.Quality = 0; + desc.BindFlags = bindFlags; + desc.Usage = usage; + desc.CPUAccessFlags = cpuAccessFlags; + return desc; +} + +static D3D11_DEPTH_STENCIL_VIEW_DESC _getDsvDesc(DXGI_FORMAT format, D3D11_DSV_DIMENSION viewDimension, UINT flags = 0, UINT mipSlice = 0) +{ + D3D11_DEPTH_STENCIL_VIEW_DESC desc; + desc.Format = format; + desc.ViewDimension = viewDimension; + desc.Flags = flags; + desc.Texture2D.MipSlice = mipSlice; + return desc; +} + +static D3D11_SHADER_RESOURCE_VIEW_DESC _getSrvDesc(DXGI_FORMAT format) +{ + D3D11_SHADER_RESOURCE_VIEW_DESC desc; + desc.Format = format; + desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + desc.Texture2D.MostDetailedMip = 0; + desc.Texture2D.MipLevels = -1; + + return desc; +} + +HRESULT ShadowMapD3D11::init(ID3D11Device* device, int resolution) +{ + // set viewport + { + m_viewport.Width = float(resolution); + m_viewport.Height = float(resolution); + m_viewport.MinDepth = 0; + m_viewport.MaxDepth = 1; + m_viewport.TopLeftX = 0; + m_viewport.TopLeftY = 0; + } + + // create shadow render target + { + D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_FLOAT, UINT(resolution), UINT(resolution), + D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); + + NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_backTexture.ReleaseAndGetAddressOf())); + NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_backTexture.Get(), NV_NULL, m_backSrv.ReleaseAndGetAddressOf())); + NV_RETURN_ON_FAIL(device->CreateRenderTargetView(m_backTexture.Get(), NV_NULL, m_backRtv.ReleaseAndGetAddressOf())); + } + + // create shadow depth stencil + { + D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_TYPELESS, UINT(resolution), UINT(resolution), + D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE); + NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_depthTexture.ReleaseAndGetAddressOf())); + + D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = _getDsvDesc(DXGI_FORMAT_D32_FLOAT, D3D11_DSV_DIMENSION_TEXTURE2D); + NV_RETURN_ON_FAIL(device->CreateDepthStencilView(m_depthTexture.Get(), &dsvDesc, m_depthDsv.ReleaseAndGetAddressOf())); + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = _getSrvDesc(DXGI_FORMAT_R32_FLOAT); + NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_depthTexture.Get(), &srvDesc, m_depthSrv.ReleaseAndGetAddressOf())); + } + + { + // example texture sampler (use any texture sampler of your own choice) + D3D11_SAMPLER_DESC samplerDesc = + { + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + 0.0, 0, D3D11_COMPARISON_LESS_EQUAL, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, D3D11_FLOAT32_MAX, + }; + NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_linearSampler.ReleaseAndGetAddressOf())); + } + { + D3D11_SAMPLER_DESC samplerDesc = + { + D3D11_FILTER_MIN_MAG_MIP_POINT, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + D3D11_TEXTURE_ADDRESS_CLAMP, + 0.0, 0, D3D11_COMPARISON_NEVER, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, D3D11_FLOAT32_MAX, + }; + NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_pointSampler.ReleaseAndGetAddressOf())); + } + + return S_OK; +} + +void ShadowMapD3D11::bindAndClear(ID3D11DeviceContext* context) +{ + ID3D11RenderTargetView* ppRtv[1] = { m_backRtv.Get() }; + context->OMSetRenderTargets(1, ppRtv, m_depthDsv.Get()); + + context->RSSetViewports(1, &m_viewport); + + float clearDepth = FLT_MAX; + float clearColor[4] = { clearDepth, clearDepth, clearDepth, clearDepth }; + + context->ClearRenderTargetView(m_backRtv.Get(), clearColor); + context->ClearDepthStencilView(m_depthDsv.Get(), D3D11_CLEAR_DEPTH, 1.0, 0); +} + +void ShadowMapD3D11::setDefaultLight(FXMVECTOR eye, FXMVECTOR at, FXMVECTOR up) +{ + float sizeX = 50.0f; + float sizeY = 50.0f; + float znear = -200.0f; + float zfar = 200.0f; + + setLightMatrices(eye, at, up, sizeX, sizeY, znear, zfar); +} + +void ShadowMapD3D11::setLightMatrices(FXMVECTOR eye, FXMVECTOR lookAt, FXMVECTOR up, float sizeX, float sizeY, float zNear, float zFar) +{ + m_lightView = XMMatrixLookAtLH(eye, lookAt, up); + + m_lightProjection = XMMatrixOrthographicLH(sizeX, sizeY, zNear, zFar); + + DirectX::XMMATRIX clip2Tex(0.5, 0, 0, 0, + 0, -0.5, 0, 0, + 0, 0, 1, 0, + 0.5, 0.5, 0, 1); + + DirectX::XMMATRIX viewProjection = m_lightView * m_lightProjection; + m_lightWorldToTex = viewProjection * clip2Tex; +} diff --git a/demo/d3d11/shadowMapD3D11.h b/demo/d3d11/shadowMapD3D11.h new file mode 100644 index 0000000..1fa79ec --- /dev/null +++ b/demo/d3d11/shadowMapD3D11.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#pragma once + +#include +#include +#include + +using namespace DirectX; +using namespace Microsoft::WRL; + +#define NV_NULL nullptr +#define NV_RETURN_ON_FAIL(x) { HRESULT _res = (x); if (FAILED(_res)) { return _res; } } + +struct ShadowMapD3D11 +{ + ShadowMapD3D11(); + + HRESULT init(ID3D11Device* device, int resolution); + + void setDefaultLight(FXMVECTOR eye, FXMVECTOR at, FXMVECTOR up); + void setLightMatrices(FXMVECTOR eye, FXMVECTOR lookAt, FXMVECTOR up, float sizeX, float sizeY, float zNear, float zFar); + + void bindAndClear(ID3D11DeviceContext* context); + + XMMATRIX m_lightView; + XMMATRIX m_lightProjection; + XMMATRIX m_lightWorldToTex; + + ComPtr m_backTexture; + ComPtr m_backRtv; + ComPtr m_backSrv; + + ComPtr m_depthTexture; + ComPtr m_depthDsv; + ComPtr m_depthSrv; + + ComPtr m_linearSampler; + ComPtr m_pointSampler; + + D3D11_VIEWPORT m_viewport; +}; diff --git a/demo/d3d12/NvCoDx12CircularResourceHeap.cpp b/demo/d3d12/NvCoDx12CircularResourceHeap.cpp new file mode 100644 index 0000000..040b159 --- /dev/null +++ b/demo/d3d12/NvCoDx12CircularResourceHeap.cpp @@ -0,0 +1,204 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDx12CircularResourceHeap.h" + +namespace nvidia { +namespace Common { + +Dx12CircularResourceHeap::Dx12CircularResourceHeap(): + m_fence(nullptr), + m_device(nullptr), + m_blockFreeList(sizeof(Block), __alignof(Block), 16), + m_blocks(nullptr) +{ + m_back.m_block = nullptr; + m_back.m_position = nullptr; + m_front.m_block = nullptr; + m_front.m_position = nullptr; +} + +Dx12CircularResourceHeap::~Dx12CircularResourceHeap() +{ + _freeBlockListResources(m_blocks); +} + +void Dx12CircularResourceHeap::_freeBlockListResources(const Block* start) +{ + if (start) + { + { + ID3D12Resource* resource = start->m_resource; + resource->Unmap(0, nullptr); + resource->Release(); + } + for (Block* block = start->m_next; block != start; block = block->m_next) + { + ID3D12Resource* resource = block->m_resource; + resource->Unmap(0, nullptr); + resource->Release(); + } + } +} + +int Dx12CircularResourceHeap::init(ID3D12Device* device, const Desc& desc, Dx12CounterFence* fence) +{ + assert(m_blocks == nullptr); + assert(desc.m_blockSize > 0); + + m_fence = fence; + m_desc = desc; + m_device = device; + + return NV_OK; +} + +void Dx12CircularResourceHeap::addSync(uint64_t signalValue) +{ + assert(signalValue == m_fence->getCurrentValue()); + PendingEntry entry; + entry.m_completedValue = signalValue; + entry.m_cursor = m_front; + m_pendingQueue.push_back(entry); +} + +void Dx12CircularResourceHeap::updateCompleted() +{ + const uint64_t completedValue = m_fence->getCompletedValue(); + while (!m_pendingQueue.empty()) + { + const PendingEntry& entry = m_pendingQueue.front(); + if (entry.m_completedValue <= completedValue) + { + m_back = entry.m_cursor; + m_pendingQueue.pop_front(); + } + else + { + break; + } + } +} + +Dx12CircularResourceHeap::Block* Dx12CircularResourceHeap::_newBlock() +{ + D3D12_RESOURCE_DESC desc; + + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Alignment = 0; + desc.Width = m_desc.m_blockSize; + desc.Height = 1; + desc.DepthOrArraySize = 1; + desc.MipLevels = 1; + desc.Format = DXGI_FORMAT_UNKNOWN; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Flags = D3D12_RESOURCE_FLAG_NONE; + + ComPtr resource; + int res = m_device->CreateCommittedResource(&m_desc.m_heapProperties, m_desc.m_heapFlags, &desc, m_desc.m_initialState, nullptr, IID_PPV_ARGS(&resource)); + if (NV_FAILED(res)) + { + printf("Resource allocation failed"); + return nullptr; + } + + uint8_t* data = nullptr; + if (m_desc.m_heapProperties.Type == D3D12_HEAP_TYPE_READBACK) + { + } + else + { + // Map it, and keep it mapped + resource->Map(0, nullptr, (void**)&data); + } + + // We have no blocks -> so lets allocate the first + Block* block = (Block*)m_blockFreeList.allocate(); + block->m_next = nullptr; + + block->m_resource = resource.Detach(); + block->m_start = data; + return block; +} + +Dx12CircularResourceHeap::Cursor Dx12CircularResourceHeap::allocate(size_t size, size_t alignment) +{ + const size_t blockSize = getBlockSize(); + + assert(size <= blockSize); + + // If nothing is allocated add the first block + if (m_blocks == nullptr) + { + Block* block = _newBlock(); + if (!block) + { + Cursor cursor = {}; + return cursor; + } + m_blocks = block; + // Make circular + block->m_next = block; + + // Point front and back to same position, as currently it is all free + m_back = { block, block->m_start }; + m_front = m_back; + } + + // If front and back are in the same block then front MUST be ahead of back (as that defined as + // an invariant and is required for block insertion to be possible + Block* block = m_front.m_block; + + // Check the invariant + assert(block != m_back.m_block || m_front.m_position >= m_back.m_position); + + { + uint8_t* cur = (uint8_t*)((size_t(m_front.m_position) + alignment - 1) & ~(alignment - 1)); + // Does the the allocation fit? + if (cur + size <= block->m_start + blockSize) + { + // It fits + // Move the front forward + m_front.m_position = cur + size; + Cursor cursor = { block, cur }; + return cursor; + } + } + + // Okay I can't fit into current block... + + // If the next block contains front, we need to add a block, else we can use that block + if (block->m_next == m_back.m_block) + { + Block* newBlock = _newBlock(); + // Insert into the list + newBlock->m_next = block->m_next; + block->m_next = newBlock; + } + + // Use the block we are going to add to + block = block->m_next; + uint8_t* cur = (uint8_t*)((size_t(block->m_start) + alignment - 1) & ~(alignment - 1)); + // Does the the allocation fit? + if (cur + size > block->m_start + blockSize) + { + printf("Couldn't fit into a free block(!) Alignment breaks it?"); + Cursor cursor = {}; + return cursor; + } + // It fits + // Move the front forward + m_front.m_block = block; + m_front.m_position = cur + size; + Cursor cursor = { block, cur }; + return cursor; +} + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDx12CircularResourceHeap.h b/demo/d3d12/NvCoDx12CircularResourceHeap.h new file mode 100644 index 0000000..c88db06 --- /dev/null +++ b/demo/d3d12/NvCoDx12CircularResourceHeap.h @@ -0,0 +1,234 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX12_CIRCULAR_RESOURCE_HEAP_H +#define NV_CO_DX12_CIRCULAR_RESOURCE_HEAP_H + +#include +#include +#include "NvCoDx12CounterFence.h" + +#define NOMINMAX +#include +#include +#include + +using namespace Microsoft::WRL; + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +/*! \brief The Dx12CircularResourceHeap is a heap that is suited for size constrained real-time resources allocation that +is transitory in nature. It is designed to allocate resources which are used and discarded, often used where in +previous versions of DirectX the 'DISCARD' flag was used. + +The idea is to have a heap which chunks of resource can be allocated, and used for GPU execution, +and that the heap is able through the addSync/updateCompleted idiom is able to track when the usage of the resources is +completed allowing them to be reused. The heap is arranged as circularly, with new allocations made from the front, and the back +being updated as the GPU updating the back when it is informed anything using prior parts of the heap have completed. In this +arrangement all the heap between the back and the front can be thought of as in use or potentially in use by the GPU. All the heap +from the front back around to the back, is free and can be allocated from. It is the responsibility of the user of the Heap to make +sure the invariant holds, but in most normal usage it does so simply. + +Another feature of the heap is that it does not require upfront knowledge of how big a heap is needed. The backing resources will be expanded +dynamically with requests as needed. The only requirement is that know single request can be larger than m_blockSize specified in the Desc +used to initialize the heap. This is because all the backing resources are allocated to a single size. This limitation means the Dx12CircularResourceHeap +may not be the best use for example for uploading a texture - because it's design is really around transitory uploads or write backs, and so more suited +to constant buffers, vertex buffer, index buffers and the like. + +To upload a texture at program startup it is most likely better to use a Dx12ResourceScopeManager. + +### The addSync/updateCompleted Idiom + +Lots of classes in Nv/Common/Platform/Dx12 use the addSync/update idiom. The idiom enables a class to track GPU progress fairly simply. The +two methods are generally called at a fairly low frequency - say once a frame. The addSync method is given a signalValue that should be the +value generated from nextSignal on the Dx12Fence that is passed on construction of the type. Calling addSync means when this value is hit +ALL previous heap allocations will no longer be used. Thus in practice usage looks something like + +\code{.cpp} + +typedef Dx12CircularResourceHeap Heap; + +Heap::Cursor cursor = heap.allocateVertexBuffer(sizeof(Vertex) * numVerts); +Memory:copy(cursor.m_position, verts, sizeof(Vertex) * numVerts); + +// Do a command using the GPU handle +m_commandList->... +// Do another command using the GPU handle + +m_commandList->... + +// Execute the command list on the command queue +{ + ID3D12CommandList* lists[] = { m_commandList }; + m_commandQueue->ExecuteCommandLists(_countof(lists), lists); +} + +// Add a sync point +const uint64_t signalValue = m_fence.nextSignal(m_commandQueue); +heap.addSync(signalValue) + +// The cursors cannot be used anymore + +// At some later point call updateCompleted. This will see where the GPU is at, and make resources available that the GPU no longer accesses. +heap.updateCompleted(); + +\endcode + +### Implementation + +Front and back can be in the same block, but ONLY if back is behind front, because we have to always be able to insert +new blocks in front of front. So it must be possible to do an block insertion between the two of them. + +|--B---F-----| |----------| + +When B and F are on top of one another it means there is nothing in the list. NOTE this also means that a move of front can never place it +top of the back. + +https://msdn.microsoft.com/en-us/library/windows/desktop/dn899125%28v=vs.85%29.aspx +https://msdn.microsoft.com/en-us/library/windows/desktop/mt426646%28v=vs.85%29.aspx +*/ +class Dx12CircularResourceHeap +{ + protected: + struct Block; + + //NV_CO_DECLARE_CLASS_BASE(Dx12CircularResourceHeap); +public: + /// The alignment used for VERTEX_BUFFER allocations + /// Strictly speaking it seems the hardware can handle 4 byte alignment, but since often in use + /// data will be copied from CPU memory to the allocation, using 16 byte alignment is superior as allows + /// significantly faster memcpy. + /// The sample that shows sizeof(float) - 4 bytes is appropriate is at the link below. + /// https://msdn.microsoft.com/en-us/library/windows/desktop/mt426646%28v=vs.85%29.aspx + enum + { + VERTEX_BUFFER_ALIGNMENT = 16, + }; + + struct Desc + { + void init() + { + { + D3D12_HEAP_PROPERTIES& props = m_heapProperties; + + props.Type = D3D12_HEAP_TYPE_UPLOAD; + props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + props.CreationNodeMask = 1; + props.VisibleNodeMask = 1; + } + m_heapFlags = D3D12_HEAP_FLAG_NONE; + m_initialState = D3D12_RESOURCE_STATE_GENERIC_READ; + m_blockSize = 0; + } + + D3D12_HEAP_PROPERTIES m_heapProperties; + D3D12_HEAP_FLAGS m_heapFlags; + D3D12_RESOURCE_STATES m_initialState; + size_t m_blockSize; + }; + + /// Cursor position + struct Cursor + { + /// Get GpuHandle + inline D3D12_GPU_VIRTUAL_ADDRESS getGpuHandle() const { return m_block->m_resource->GetGPUVirtualAddress() + size_t(m_position - m_block->m_start); } + /// Must have a block and position + inline bool isValid() const { return m_block != nullptr; } + /// Calculate the offset into the underlying resource + inline size_t getOffset() const { return size_t(m_position - m_block->m_start); } + /// Get the underlying resource + inline ID3D12Resource* getResource() const { return m_block->m_resource; } + + Block* m_block; ///< The block index + uint8_t* m_position; ///< The current position + }; + + /// Get the desc used to initialize the heap + inline const Desc& getDesc() const { return m_desc; } + + /// Must be called before used + /// Block size must be at least as large as the _largest_ thing allocated + /// Also note depending on alignment of a resource allocation, the block size might also need to take into account the + /// maximum alignment use. It is a REQUIREMENT that a newly allocated resource block is large enough to hold any + /// allocation taking into account the alignment used. + int init(ID3D12Device* device, const Desc& desc, Dx12CounterFence* fence); + + /// Get the block size + inline size_t getBlockSize() const { return m_desc.m_blockSize; } + + /// Allocate constant buffer of specified size + Cursor allocate(size_t size, size_t alignment); + + /// Allocate a constant buffer + inline Cursor allocateConstantBuffer(size_t size) { return allocate(size, D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); } + /// Allocate a vertex buffer + inline Cursor allocateVertexBuffer(size_t size) { return allocate(size, VERTEX_BUFFER_ALIGNMENT); } + + /// Create filled in constant buffer + inline Cursor newConstantBuffer(const void* data, size_t size) { Cursor cursor = allocateConstantBuffer(size); memcpy(cursor.m_position, data, size); return cursor; } + /// Create in filled in constant buffer + template + inline Cursor newConstantBuffer(const T& in) { return newConstantBuffer(&in, sizeof(T)); } + + /// Look where the GPU has got to and release anything not currently used + void updateCompleted(); + /// Add a sync point - meaning that when this point is hit in the queue + /// all of the resources up to this point will no longer be used. + void addSync(uint64_t signalValue); + + /// Get the gpu address of this cursor + D3D12_GPU_VIRTUAL_ADDRESS getGpuHandle(const Cursor& cursor) const { return cursor.m_block->m_resource->GetGPUVirtualAddress() + size_t(cursor.m_position - cursor.m_block->m_start); } + + /// Ctor + Dx12CircularResourceHeap(); + /// Dtor + ~Dx12CircularResourceHeap(); + + protected: + + struct Block + { + ID3D12Resource* m_resource; ///< The mapped resource + uint8_t* m_start; ///< Once created the resource is mapped to here + Block* m_next; ///< Points to next block in the list + }; + struct PendingEntry + { + uint64_t m_completedValue; ///< The value when this is completed + Cursor m_cursor; ///< the cursor at that point + }; + void _freeBlockListResources(const Block* block); + /// Create a new block (with associated resource), do not add the block list + Block* _newBlock(); + + Block* m_blocks; ///< Circular singly linked list of block. nullptr initially + FreeList m_blockFreeList; ///< Free list of actual allocations of blocks + std::deque m_pendingQueue; ///< Holds the list of pending positions. When the fence value is greater than the value on the queue entry, the entry is done. + + // Allocation is made from the front, and freed from the back. + Cursor m_back; ///< Current back position. + Cursor m_front; ///< Current front position. + + Desc m_desc; ///< Describes the heap + + Dx12CounterFence* m_fence; ///< The fence to use + ID3D12Device* m_device; ///< The device that resources will be constructed on +}; + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_DX12_CIRCULAR_RESOURCE_HEAP_H diff --git a/demo/d3d12/NvCoDx12CounterFence.cpp b/demo/d3d12/NvCoDx12CounterFence.cpp new file mode 100644 index 0000000..bca181a --- /dev/null +++ b/demo/d3d12/NvCoDx12CounterFence.cpp @@ -0,0 +1,71 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDx12CounterFence.h" + +namespace nvidia { +namespace Common { + +Dx12CounterFence::~Dx12CounterFence() +{ + if (m_event) + { + CloseHandle(m_event); + } +} + +int Dx12CounterFence::init(ID3D12Device* device, uint64_t initialValue) +{ + m_currentValue = initialValue; + + NV_RETURN_ON_FAIL(device->CreateFence(m_currentValue, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_fence))); + // Create an event handle to use for frame synchronization. + m_event = CreateEvent(nullptr, FALSE, FALSE, nullptr); + if (m_event == nullptr) + { + int res = HRESULT_FROM_WIN32(GetLastError()); + return NV_FAILED(res) ? res : NV_FAIL; + } + return NV_OK; +} + +uint64_t Dx12CounterFence::nextSignal(ID3D12CommandQueue* commandQueue) +{ + // Increment the fence value. Save on the frame - we'll know that frame is done when the fence value >= + m_currentValue++; + // Schedule a Signal command in the queue. + int res = commandQueue->Signal(m_fence.Get(), m_currentValue); + if (NV_FAILED(res)) + { + printf("Signal failed"); + } + return m_currentValue; +} + +void Dx12CounterFence::waitUntilCompleted(uint64_t completedValue) +{ + // You can only wait for a value that is less than or equal to the current value + assert(completedValue <= m_currentValue); + + // Wait until the previous frame is finished. + while (m_fence->GetCompletedValue() < completedValue) + { + // Make it signal with the current value + HRESULT res = m_fence->SetEventOnCompletion(completedValue, m_event); + if (FAILED(res)) { assert(0); return; } + + WaitForSingleObject(m_event, INFINITE); + } +} + +void Dx12CounterFence::nextSignalAndWait(ID3D12CommandQueue* commandQueue) +{ + waitUntilCompleted(nextSignal(commandQueue)); +} + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDx12CounterFence.h b/demo/d3d12/NvCoDx12CounterFence.h new file mode 100644 index 0000000..9add39b --- /dev/null +++ b/demo/d3d12/NvCoDx12CounterFence.h @@ -0,0 +1,82 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX12_COUNTER_FENCE_H +#define NV_CO_DX12_COUNTER_FENCE_H + +#include + +#define NOMINMAX +#include +#include +#include +#include +#include + +using namespace Microsoft::WRL; + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +/*! \brief A class to simplify using Dx12 fences. + +A fence is a mechanism to track GPU work. This is achieved by having a counter that the CPU holds +called the current value. Calling nextSignal will increase the CPU counter, and add a fence +with that value to the commandQueue. When the GPU has completed all the work before the fence it will +update the completed value. This is typically used when +the CPU needs to know the GPU has finished some piece of work has completed. To do this the CPU +can check the completed value, and when it is greater or equal to the value returned by nextSignal the +CPU will know that all the work prior to when the nextSignal was added to the queue will have completed. + +NOTE! This cannot be used across threads, as for amongst other reasons SetEventOnCompletion +only works with a single value. + +Signal on the CommandQueue updates the fence on the GPU side. Signal on the fence object changes +the value on the CPU side (not used here). + +Useful article describing how Dx12 synchronization works: +https://msdn.microsoft.com/en-us/library/windows/desktop/dn899217%28v=vs.85%29.aspx +*/ +class Dx12CounterFence +{ + //NV_CO_DECLARE_CLASS_BASE(Dx12CounterFence); +public: + /// Must be called before used + int init(ID3D12Device* device, uint64_t initialValue = 0); + /// Increases the counter, signals the queue and waits for the signal to be hit + void nextSignalAndWait(ID3D12CommandQueue* queue); + /// Signals with next counter value. Returns the value the signal was called on + uint64_t nextSignal(ID3D12CommandQueue* commandQueue); + /// Get the current value + inline uint64_t getCurrentValue() const { return m_currentValue; } + /// Get the completed value + inline uint64_t getCompletedValue() const { return m_fence->GetCompletedValue(); } + + /// Waits for the the specified value + void waitUntilCompleted(uint64_t completedValue); + + /// Ctor + Dx12CounterFence():m_event(nullptr), m_currentValue(0) {} + /// Dtor + ~Dx12CounterFence(); + + protected: + HANDLE m_event; + ComPtr m_fence; + uint64_t m_currentValue; +}; + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_DX12_COUNTER_FENCE_H diff --git a/demo/d3d12/NvCoDx12DescriptorHeap.cpp b/demo/d3d12/NvCoDx12DescriptorHeap.cpp new file mode 100644 index 0000000..acda590 --- /dev/null +++ b/demo/d3d12/NvCoDx12DescriptorHeap.cpp @@ -0,0 +1,54 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDx12DescriptorHeap.h" + +namespace nvidia { +namespace Common { + +Dx12DescriptorHeap::Dx12DescriptorHeap(): + m_size(0), + m_currentIndex(0), + m_descriptorSize(0) +{ +} + +int Dx12DescriptorHeap::init(ID3D12Device* device, int size, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags) +{ + D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {}; + srvHeapDesc.NumDescriptors = size; + srvHeapDesc.Flags = flags; + srvHeapDesc.Type = type; + NV_RETURN_ON_FAIL(device->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&m_heap))); + + m_descriptorSize = device->GetDescriptorHandleIncrementSize(type); + m_size = size; + + return NV_OK; +} + +int Dx12DescriptorHeap::init(ID3D12Device* device, const D3D12_CPU_DESCRIPTOR_HANDLE* handles, int numHandles, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags) +{ + NV_RETURN_ON_FAIL(init(device, numHandles, type, flags)); + D3D12_CPU_DESCRIPTOR_HANDLE dst = m_heap->GetCPUDescriptorHandleForHeapStart(); + + // Copy them all + for (int i = 0; i < numHandles; i++, dst.ptr += m_descriptorSize) + { + D3D12_CPU_DESCRIPTOR_HANDLE src = handles[i]; + if (src.ptr != 0) + { + device->CopyDescriptorsSimple(1, dst, src, type); + } + } + + return NV_OK; +} + +} // namespace Common +} // namespace nvidia + diff --git a/demo/d3d12/NvCoDx12DescriptorHeap.h b/demo/d3d12/NvCoDx12DescriptorHeap.h new file mode 100644 index 0000000..d323ce6 --- /dev/null +++ b/demo/d3d12/NvCoDx12DescriptorHeap.h @@ -0,0 +1,116 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX12_DESCRIPTOR_HEAP_H +#define NV_CO_DX12_DESCRIPTOR_HEAP_H + +#include + +#define NOMINMAX +#include +#include +#include +#include + +using namespace Microsoft::WRL; + +namespace nvidia { +namespace Common { + +/*! \brief A simple class to manage an underlying Dx12 Descriptor Heap. Allocations are made linearly in order. It is not possible to free +individual allocations, but all allocations can be deallocated with 'deallocateAll'. */ +class Dx12DescriptorHeap +{ + //NV_CO_DECLARE_CLASS_BASE(Dx12DescriptorHeap); +public: + /// Initialize + int init(ID3D12Device* device, int size, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags); + /// Initialize with an array of handles copying over the representation + int init(ID3D12Device* device, const D3D12_CPU_DESCRIPTOR_HANDLE* handles, int numHandles, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags); + + /// Get the total amount of descriptors possible on the heap + inline int getSize() const { return m_size; } + /// Allocate a descriptor. Returns the index, or -1 if none left. + inline int allocate(); + /// Allocate a number of descriptors. Returns the start index (or -1 if not possible) + inline int allocate(int numDescriptors); + + /// Deallocates all allocations, and starts allocation from the start of the underlying heap again + inline void deallocateAll() { m_currentIndex = 0; } + + /// Get the size of each + inline int getDescriptorSize() const { return m_descriptorSize; } + + /// Get the GPU heap start + inline D3D12_GPU_DESCRIPTOR_HANDLE getGpuStart() const { return m_heap->GetGPUDescriptorHandleForHeapStart(); } + /// Get the CPU heap start + inline D3D12_CPU_DESCRIPTOR_HANDLE getCpuStart() const { return m_heap->GetCPUDescriptorHandleForHeapStart(); } + + /// Get the GPU handle at the specified index + inline D3D12_GPU_DESCRIPTOR_HANDLE getGpuHandle(int index) const; + /// Get the CPU handle at the specified index + inline D3D12_CPU_DESCRIPTOR_HANDLE getCpuHandle(int index) const; + + /// Get the underlying heap + inline ID3D12DescriptorHeap* getHeap() const { return m_heap.Get(); } + + /// Ctor + Dx12DescriptorHeap(); + +protected: + ComPtr m_heap; ///< The underlying heap being allocated from + int m_size; ///< Total amount of allocations available on the heap + int m_currentIndex; ///< The current descriptor + int m_descriptorSize; ///< The size of each descriptor +}; + +// --------------------------------------------------------------------------- +int Dx12DescriptorHeap::allocate() +{ + assert(m_currentIndex < m_size); + if (m_currentIndex < m_size) + { + return m_currentIndex++; + } + return -1; +} +// --------------------------------------------------------------------------- +int Dx12DescriptorHeap::allocate(int numDescriptors) +{ + assert(m_currentIndex + numDescriptors <= m_size); + if (m_currentIndex + numDescriptors <= m_size) + { + const int index = m_currentIndex; + m_currentIndex += numDescriptors; + return index; + } + return -1; +} +// --------------------------------------------------------------------------- +inline D3D12_CPU_DESCRIPTOR_HANDLE Dx12DescriptorHeap::getCpuHandle(int index) const +{ + assert(index >= 0 && index < m_size); + D3D12_CPU_DESCRIPTOR_HANDLE start = m_heap->GetCPUDescriptorHandleForHeapStart(); + D3D12_CPU_DESCRIPTOR_HANDLE dst; + dst.ptr = start.ptr + m_descriptorSize * index; + return dst; +} +// --------------------------------------------------------------------------- +inline D3D12_GPU_DESCRIPTOR_HANDLE Dx12DescriptorHeap::getGpuHandle(int index) const +{ + assert(index >= 0 && index < m_size); + D3D12_GPU_DESCRIPTOR_HANDLE start = m_heap->GetGPUDescriptorHandleForHeapStart(); + D3D12_GPU_DESCRIPTOR_HANDLE dst; + dst.ptr = start.ptr + m_descriptorSize * index; + return dst; +} + +} // namespace Common +} // namespace nvidia + + +#endif // NV_CO_DX12_DESCRIPTOR_HEAP_H diff --git a/demo/d3d12/NvCoDx12Handle.h b/demo/d3d12/NvCoDx12Handle.h new file mode 100644 index 0000000..bbe8372 --- /dev/null +++ b/demo/d3d12/NvCoDx12Handle.h @@ -0,0 +1,162 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX12_HANDLE_H +#define NV_CO_DX12_HANDLE_H + +// Dx12 types +#define NOMINMAX +#include +#include + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +/*! +\brief Description of how the intended rendering target is arranged. +*/ +struct Dx12TargetInfo +{ + void init() + { + m_numRenderTargets = 1; + m_renderTargetFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; + m_depthStencilFormat = DXGI_FORMAT_D24_UNORM_S8_UINT; + m_numSamples = 1; + m_sampleQuality = 0; + m_sampleMask = ~uint32_t(0); + } + + int m_numRenderTargets; + DXGI_FORMAT m_renderTargetFormats[8]; ///< Format used for render target view access (the actual resource could be different!) + DXGI_FORMAT m_depthStencilFormat; ///< Format to use for depth stencil view access (the actual resource could be different!) + int m_numSamples; ///< The number of multi sample samples + int m_sampleQuality; ///< The multi sample quality + uint32_t m_sampleMask; ///< The sample mask +}; + +#if 0 +/*! +\brief Specifies the kinds of types that can be wrapped in ApiHandle/ApiPtr/ConstPtr types */ +class Dx12SubType { Dx12SubType(); public: +/*! SubTypes for Dx12 */ +enum Enum +{ + UNKNOWN, ///< Unknown + CONTEXT, + DEVICE, + BUFFER, + FLOAT32, + CPU_DESCRIPTOR_HANDLE, + COMMAND_QUEUE, + TARGET_INFO, + COUNT_OF, +}; +}; + +// Handle types +#define NV_DX12_HANDLE_TYPES(x) \ + x(ID3D12Device, DEVICE, DEVICE) \ + x(ID3D12GraphicsCommandList, CONTEXT, CONTEXT) \ + x(ID3D12Resource, BUFFER, BUFFER) \ + x(ID3D12CommandQueue, COMMAND_QUEUE, UNKNOWN ) + +// The 'value' types - ie ones that can be passed as pointers, in addition to the handle types +#define NV_DX12_VALUE_TYPES(x) \ + x(Float32, FLOAT32, UNKNOWN) \ + x(D3D12_CPU_DESCRIPTOR_HANDLE, CPU_DESCRIPTOR_HANDLE, CPU_DESCRIPTOR_HANDLE) \ + x(Dx12TargetInfo, TARGET_INFO, UNKNOWN) + +/*! +\brief A helper class to wrap Dx12 related types to ApiHandle, ApiPtr types, or extract via a cast the Dx12 types back out again. + +Some examples of how to wrap and cast handles and pointers + +\code{.cpp} +ID3D12Device* device = ...; + +\\ To wrap as a handle +ApiHandle handle = Dx12Type::wrap(device); + +\\ To wrap an array or pointer you can use + +Dx12TargetInfo target; +ApiPtr ptr = Dx12Type::wrapPtr(&target); + +\\ If you want to convert a wrapped handle back you can use +ID3D12Device* device = Dx12Type::cast(handle); + +\\ Similarly to get a pointer +Dx12TargetInfo* target = Dx12Type::castPtr(ptr); +\endcode + +*/ +struct Dx12Type +{ + // Used by the macros. NOTE! Should be wrapping type (ie not the actual type - typically with E prefix) + typedef Dx12SubType ScopeSubType; + + /// Get the full type for the subtype + inline static int getType(Dx12SubType::Enum subType) { return (int(ApiType::DX12) << 8) | int(subType); } + /// Get the type via template, needed for arrays + template + inline static int getType() { return getType((T*)NV_NULL); } + + /// Implement getType + NV_DX12_HANDLE_TYPES(NV_CO_API_GET_TYPE) + /// Implement getHandle, which will return a TypedApiHandle + NV_DX12_HANDLE_TYPES(NV_CO_API_WRAP) + /// Implement getType for 'value types' (ie structs and others that shouldn't be in a handle) + NV_DX12_VALUE_TYPES(NV_CO_API_GET_VALUE_TYPE) + + /// A template to work around warnings from dereferencing NV_NULL + template + inline static int getPtrType() { void* data = NV_NULL; return getType(*(const T*)&data); } + + /// Get a pointer + template + inline static ConstApiPtr wrapPtr(const T* in) { return ConstApiPtr(getPtrType(), in); } + template + inline static ApiPtr wrapPtr(T* in) { return ApiPtr(getPtrType(), in); } + + /// Get from a handle + template + inline static T* cast(const ApiHandle& in) { const int type = getType((T*)NV_NULL); return reinterpret_cast((type == in.m_type) ? in.m_handle : NV_NULL); } + /// Get from + template + inline static const T* cast(const ConstApiPtr& ptr) { const int type = getPtrType(); return reinterpret_cast((ptr.m_type == type) ? ptr.getData() : NV_NULL); } + // Get from + template + inline static T* cast(const ApiPtr& ptr) { const int type = getPtrType(); return reinterpret_cast((ptr.m_type == type) ? ptr.getData() : NV_NULL); } + + /// Get the sub type as text + static const Char* getSubTypeText(Dx12SubType::Enum subType); + + /// If the match fails - implement casting. Writes impossible casts to Logger and returns NV_NULL. + static void* handlePtrCast(int fromType, int toType); + static void* handleCast(int fromType, int toType); + /// Called when a cast isn't possible. Will output warnings to log and return NV_NULL + static void castFailure(int fromType, int toType); + /// Log failure + static void logCastFailure(int fromType, int toType); +}; + +/* For generic handles you can use Dx11Handle. If you want the typed handle type use Dx11Type::wrap(texture) */ +typedef WrapApiHandle Dx12Handle; + +#endif + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_DX12_HANDLE_H diff --git a/demo/d3d12/NvCoDx12HelperUtil.cpp b/demo/d3d12/NvCoDx12HelperUtil.cpp new file mode 100644 index 0000000..46e2265 --- /dev/null +++ b/demo/d3d12/NvCoDx12HelperUtil.cpp @@ -0,0 +1,89 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +// Make the DXGI_DEBUG_D3D12 symbol defined in this compilation unit, to avoid link problems +#define INITGUID + +#include "NvCoDx12HelperUtil.h" + +namespace nvidia { +namespace Common { + +void Dx12HelperUtil::calcSrvDesc(ID3D12Resource* resource, DXGI_FORMAT pixelFormat, D3D12_SHADER_RESOURCE_VIEW_DESC& descOut) +{ + // Get the desc + return calcSrvDesc(resource->GetDesc(), pixelFormat, descOut); +} + +void Dx12HelperUtil::calcSrvDesc(const D3D12_RESOURCE_DESC& desc, DXGI_FORMAT pixelFormat, D3D12_SHADER_RESOURCE_VIEW_DESC& descOut) +{ + + // create SRV + descOut = D3D12_SHADER_RESOURCE_VIEW_DESC(); + + descOut.Format = (pixelFormat == DXGI_FORMAT_UNKNOWN) ? DxFormatUtil::calcFormat(DxFormatUtil::USAGE_SRV, desc.Format) : pixelFormat; + descOut.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + if (desc.DepthOrArraySize == 1) + { + descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + + descOut.Texture2D.MipLevels = desc.MipLevels; + descOut.Texture2D.MostDetailedMip = 0; + descOut.Texture2D.PlaneSlice = 0; + descOut.Texture2D.ResourceMinLODClamp = 0.0f; + } + else if (desc.DepthOrArraySize == 6) + { + descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; + + descOut.TextureCube.MipLevels = desc.MipLevels; + descOut.TextureCube.MostDetailedMip = 0; + descOut.TextureCube.ResourceMinLODClamp = 0; + } + else + { + descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; + + descOut.Texture2DArray.ArraySize = desc.DepthOrArraySize; + descOut.Texture2DArray.MostDetailedMip = 0; + descOut.Texture2DArray.MipLevels = desc.MipLevels; + descOut.Texture2DArray.FirstArraySlice = 0; + descOut.Texture2DArray.PlaneSlice = 0; + descOut.Texture2DArray.ResourceMinLODClamp = 0; + } +} + +/* static */void Dx12HelperUtil::reportLiveObjects() +{ + IDXGIDebug* dxgiDebug; + int res = DxDebugUtil::getDebugInterface(&dxgiDebug); + + if (NV_FAILED(res) || !dxgiDebug) + { + printf("Unable to access debug interface -> can't report live objects"); + return; + } + dxgiDebug->ReportLiveObjects(DXGI_DEBUG_D3D12, DXGI_DEBUG_RLO_DETAIL); +} + +/* static */int Dx12HelperUtil::serializeRootSigniture(const D3D12_ROOT_SIGNATURE_DESC& desc, D3D_ROOT_SIGNATURE_VERSION signitureVersion, ComPtr& sigBlobOut) +{ + ComPtr error; + int res = D3D12SerializeRootSignature(&desc, signitureVersion, &sigBlobOut, &error); + if (NV_SUCCEEDED(res)) + { + return res; + } + + char* errorText = (char*)error->GetBufferPointer(); + + printf("Unable to serialize Dx12 signature: %s\n", errorText); + return res; +} + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDx12HelperUtil.h b/demo/d3d12/NvCoDx12HelperUtil.h new file mode 100644 index 0000000..1c05253 --- /dev/null +++ b/demo/d3d12/NvCoDx12HelperUtil.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX12_HELPER_UTIL_H +#define NV_CO_DX12_HELPER_UTIL_H + +#include +#include +#include + +#define NOMINMAX +#include +#include +#include + +using namespace Microsoft::WRL; + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +struct Dx12HelperUtil +{ + /// Get a Shader resource view from a resourceDesc + /// If pixelFormat is UNKNOWN, will use the pixelFormat in the resourceDesc + static void calcSrvDesc(const D3D12_RESOURCE_DESC& resourceDesc, DXGI_FORMAT pixelFormat, D3D12_SHADER_RESOURCE_VIEW_DESC& descOut); + + /// Get a Shader resource view from a resource + /// If pixelFormat is UNKNOWN, will use the pixelFormat in the resourceDesc + static void calcSrvDesc(ID3D12Resource* resource, DXGI_FORMAT pixelFormat, D3D12_SHADER_RESOURCE_VIEW_DESC& descOut); + + /// Serializes the root signiture. If any errors occur will write to the log + static int serializeRootSigniture(const D3D12_ROOT_SIGNATURE_DESC& desc, D3D_ROOT_SIGNATURE_VERSION signitureVersion, ComPtr& sigBlobOut); + + /// Reports to the output debug window any live objects, using debug interface. + /// Only works on systems that have "Dxgidebug.dll" + static void reportLiveObjects(); +}; + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_DX12_DEBUG_UTIL_H diff --git a/demo/d3d12/NvCoDx12RenderTarget.cpp b/demo/d3d12/NvCoDx12RenderTarget.cpp new file mode 100644 index 0000000..2ce4d86 --- /dev/null +++ b/demo/d3d12/NvCoDx12RenderTarget.cpp @@ -0,0 +1,324 @@ + +#include "NvCoDx12RenderTarget.h" +#include "appD3D12Ctx.h" + +#include + +namespace nvidia { +namespace Common { + +Dx12RenderTarget::Dx12RenderTarget() +{ + memset(m_srvIndices, -1, sizeof(m_srvIndices)); +} + +int Dx12RenderTarget::init(AppGraphCtxD3D12* renderContext, const Desc& desc) +{ + ID3D12Device* device = renderContext->m_device; + + m_desc = desc; + + // set viewport + { + m_viewport.Width = float(desc.m_width); + m_viewport.Height = float(desc.m_height); + m_viewport.MinDepth = 0; + m_viewport.MaxDepth = 1; + m_viewport.TopLeftX = 0; + m_viewport.TopLeftY = 0; + } + + { + m_scissorRect.left = 0; + m_scissorRect.top = 0; + m_scissorRect.right = desc.m_width; + m_scissorRect.bottom = desc.m_height; + } + + if (desc.m_targetFormat != DXGI_FORMAT_UNKNOWN) + { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.NumDescriptors = 1; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + NV_RETURN_ON_FAIL(device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&m_descriptorHeapRtv))); + + DXGI_FORMAT resourceFormat = DxFormatUtil::calcResourceFormat(DxFormatUtil::USAGE_TARGET, m_desc.m_usageFlags, desc.m_targetFormat); + DXGI_FORMAT targetFormat = DxFormatUtil::calcFormat(DxFormatUtil::USAGE_TARGET, resourceFormat); + + D3D12_RESOURCE_DESC resourceDesc = CD3DX12_RESOURCE_DESC::Tex2D(resourceFormat, UINT(desc.m_width), UINT(desc.m_height), 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_TEXTURE_LAYOUT_UNKNOWN, 0); + D3D12_HEAP_PROPERTIES heapProps = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT); + + // Depending on usage this format may not be right... + D3D12_CLEAR_VALUE clearValue; + clearValue.Format = targetFormat; + clearValue.Color[0] = FLT_MAX; + clearValue.Color[1] = FLT_MAX; + clearValue.Color[2] = FLT_MAX; + clearValue.Color[3] = FLT_MAX; + + NV_RETURN_ON_FAIL(m_renderTarget.initCommitted(device, heapProps, D3D12_HEAP_FLAG_NONE, resourceDesc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, &clearValue)); + + D3D12_RENDER_TARGET_VIEW_DESC rtvDesc = {}; + rtvDesc.Format = targetFormat; + rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; + rtvDesc.Texture2D.MipSlice = 0; + rtvDesc.Texture2D.PlaneSlice = 0; + device->CreateRenderTargetView(m_renderTarget, &rtvDesc, m_descriptorHeapRtv->GetCPUDescriptorHandleForHeapStart()); + } + + // Create the depth stencil descriptor heap + if (desc.m_depthStencilFormat != DXGI_FORMAT_UNKNOWN) + { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.NumDescriptors = 1; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + NV_RETURN_ON_FAIL(device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&m_descriptorHeapDsv))); + + DXGI_FORMAT resourceFormat = DxFormatUtil::calcResourceFormat(DxFormatUtil::USAGE_DEPTH_STENCIL, m_desc.m_usageFlags, desc.m_depthStencilFormat); + DXGI_FORMAT depthStencilFormat = DxFormatUtil::calcFormat(DxFormatUtil::USAGE_DEPTH_STENCIL, resourceFormat); + + D3D12_RESOURCE_DESC resourceDesc = CD3DX12_RESOURCE_DESC::Tex2D(resourceFormat, UINT(desc.m_width), UINT(desc.m_height), 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, D3D12_TEXTURE_LAYOUT_UNKNOWN, 0); + D3D12_HEAP_PROPERTIES heapProps = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT); + + D3D12_CLEAR_VALUE clearValue; + clearValue.Format = depthStencilFormat; + clearValue.DepthStencil.Depth = 1.0f; + clearValue.DepthStencil.Stencil = 0; + NV_RETURN_ON_FAIL(m_depthStencilBuffer.initCommitted(device, heapProps, D3D12_HEAP_FLAG_NONE, resourceDesc, D3D12_RESOURCE_STATE_DEPTH_WRITE, &clearValue)); + + // Create the depth stencil view + D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = {}; + dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; + dsvDesc.Format = depthStencilFormat; + dsvDesc.Texture2D.MipSlice = 0; + dsvDesc.Flags = D3D12_DSV_FLAG_NONE; + device->CreateDepthStencilView(m_depthStencilBuffer, &dsvDesc, m_descriptorHeapDsv->GetCPUDescriptorHandleForHeapStart()); + } + + return NV_OK; +} + +/* static */DxFormatUtil::UsageType Dx12RenderTarget::getUsageType(BufferType type) +{ + switch (type) + { + case BUFFER_DEPTH_STENCIL: return DxFormatUtil::USAGE_DEPTH_STENCIL; + case BUFFER_TARGET: return DxFormatUtil::USAGE_TARGET; + default: return DxFormatUtil::USAGE_UNKNOWN; + } +} + +void Dx12RenderTarget::bind(AppGraphCtxD3D12* renderContext) +{ + ID3D12GraphicsCommandList* commandList = renderContext->m_commandList; + + // Work out what is bound + int numTargets = 0; + D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {}; + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = {}; + + if (m_renderTarget) + { + rtvHandle = m_descriptorHeapRtv->GetCPUDescriptorHandleForHeapStart(); + numTargets = 1; + } + if (m_depthStencilBuffer) + { + dsvHandle = m_descriptorHeapDsv->GetCPUDescriptorHandleForHeapStart(); + commandList->OMSetRenderTargets(numTargets, &rtvHandle, FALSE, &dsvHandle); + } + else + { + commandList->OMSetRenderTargets(numTargets, &rtvHandle, FALSE, nullptr); + } + + commandList->RSSetViewports(1, &m_viewport); + commandList->RSSetScissorRects(1, &m_scissorRect); +} + + +void Dx12RenderTarget::clear(AppGraphCtxD3D12* renderContext) +{ + ID3D12GraphicsCommandList* commandList = renderContext->m_commandList; + D3D12_RECT rect = { 0, 0, m_desc.m_width, m_desc.m_height }; + + // Clear + if (m_renderTarget) + { + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = m_descriptorHeapRtv->GetCPUDescriptorHandleForHeapStart(); + commandList->ClearRenderTargetView(rtvHandle, m_desc.m_targetClearColor, 1, &rect); + } + if (m_depthStencilBuffer) + { + D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = m_descriptorHeapDsv->GetCPUDescriptorHandleForHeapStart(); + commandList->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, m_desc.m_depthStencilClearDepth, 0, 1, &rect); + } +} + +void Dx12RenderTarget::bindAndClear(AppGraphCtxD3D12* renderContext) +{ + ID3D12GraphicsCommandList* commandList = renderContext->m_commandList; + + // Work out what is bound + int numTargets = 0; + D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {}; + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = {}; + + if (m_renderTarget) + { + rtvHandle = m_descriptorHeapRtv->GetCPUDescriptorHandleForHeapStart(); + numTargets = 1; + } + if (m_depthStencilBuffer) + { + dsvHandle = m_descriptorHeapDsv->GetCPUDescriptorHandleForHeapStart(); + commandList->OMSetRenderTargets(numTargets, &rtvHandle, FALSE, &dsvHandle); + } + else + { + commandList->OMSetRenderTargets(numTargets, &rtvHandle, FALSE, nullptr); + } + + commandList->RSSetViewports(1, &m_viewport); + commandList->RSSetScissorRects(1, &m_scissorRect); + + D3D12_RECT rect = { 0, 0, m_desc.m_width, m_desc.m_height }; + + // Clear + if (m_renderTarget) + { + commandList->ClearRenderTargetView(rtvHandle, m_desc.m_targetClearColor, 1, &rect); + } + if (m_depthStencilBuffer) + { + commandList->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, m_desc.m_depthStencilClearDepth, 0, 1, &rect); + } +} + +void Dx12RenderTarget::setShadowDefaultLight(FXMVECTOR eye, FXMVECTOR at, FXMVECTOR up) +{ + float sizeX = 50.0f; + float sizeY = 50.0f; + float znear = -200.0f; + float zfar = 200.0f; + + setShadowLightMatrices(eye, at, up, sizeX, sizeY, znear, zfar); +} + +void Dx12RenderTarget::setShadowLightMatrices(FXMVECTOR eye, FXMVECTOR lookAt, FXMVECTOR up, float sizeX, float sizeY, float zNear, float zFar) +{ + m_shadowLightView = XMMatrixLookAtLH(eye, lookAt, up); + m_shadowLightProjection = XMMatrixOrthographicLH(sizeX, sizeY, zNear, zFar); + DirectX::XMMATRIX clip2Tex(0.5, 0, 0, 0, + 0, -0.5, 0, 0, + 0, 0, 1, 0, + 0.5, 0.5, 0, 1); + DirectX::XMMATRIX viewProjection = m_shadowLightView * m_shadowLightProjection; + m_shadowLightWorldToTex = viewProjection * clip2Tex; +} + +void Dx12RenderTarget::toWritable(AppGraphCtxD3D12* renderContext) +{ + Dx12BarrierSubmitter submitter(renderContext->m_commandList); + + m_renderTarget.transition(D3D12_RESOURCE_STATE_RENDER_TARGET, submitter); + m_depthStencilBuffer.transition(D3D12_RESOURCE_STATE_DEPTH_WRITE, submitter); +} + +void Dx12RenderTarget::toReadable(AppGraphCtxD3D12* renderContext) +{ + Dx12BarrierSubmitter submitter(renderContext->m_commandList); + + m_renderTarget.transition(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, submitter); + m_depthStencilBuffer.transition(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, submitter); +} + +DXGI_FORMAT Dx12RenderTarget::getSrvFormat(BufferType type) const +{ + return Dx12Resource::calcFormat(DxFormatUtil::USAGE_SRV, getResource(type)); +} + +DXGI_FORMAT Dx12RenderTarget::getTargetFormat(BufferType type) const +{ + return Dx12Resource::calcFormat(getUsageType(type), getResource(type)); +} + +D3D12_SHADER_RESOURCE_VIEW_DESC Dx12RenderTarget::calcDefaultSrvDesc(BufferType type) const +{ + ID3D12Resource* resource = getResource(type); + + D3D12_RESOURCE_DESC resourceDesc = resource->GetDesc(); + + D3D12_SHADER_RESOURCE_VIEW_DESC desc; + + desc.Format = getSrvFormat(type); + desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + + desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + + desc.Texture2D.MipLevels = resourceDesc.MipLevels; + desc.Texture2D.MostDetailedMip = 0; + desc.Texture2D.PlaneSlice = 0; + desc.Texture2D.ResourceMinLODClamp = 0.0f; + return desc; +} + +int Dx12RenderTarget::allocateSrvView(BufferType type, ID3D12Device* device, Dx12DescriptorHeap& heap, const D3D12_SHADER_RESOURCE_VIEW_DESC* desc) +{ + if (m_srvIndices[type] >= 0) + { + printf("A srv index has already been associated!"); + return m_srvIndices[type]; + } + + if (!desc) + { + // If not set construct a default desc + D3D12_SHADER_RESOURCE_VIEW_DESC defaultDesc = calcDefaultSrvDesc(type); + return allocateSrvView(type, device, heap, &defaultDesc); + } + + // Create the srv for the shadow buffer + ID3D12Resource* resource = getResource(type); + int srvIndex = heap.allocate(); + + if (srvIndex < 0) + { + return srvIndex; + } + + // Create on the the heap + device->CreateShaderResourceView(resource, desc, heap.getCpuHandle(srvIndex)); + + m_srvIndices[type] = srvIndex; + // Return the allocated index + return srvIndex; +} + +void Dx12RenderTarget::setDebugName(BufferType type, const std::wstring& name) +{ + getResource(type).setDebugName(name); +} + +void Dx12RenderTarget::setDebugName(const std::wstring& name) +{ + std::wstring buf(name); + buf += L" [Target]"; + setDebugName(BUFFER_TARGET, buf); + buf = name; + buf += L" [DepthStencil]"; + setDebugName(BUFFER_DEPTH_STENCIL, buf); +} + + +void Dx12RenderTarget::createSrv(ID3D12Device* device, Dx12DescriptorHeap& heap, BufferType type, int descriptorIndex) +{ + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = calcDefaultSrvDesc(type); + ID3D12Resource* resource = getResource(type); + device->CreateShaderResourceView(resource, &srvDesc, heap.getCpuHandle(descriptorIndex)); +} + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDx12RenderTarget.h b/demo/d3d12/NvCoDx12RenderTarget.h new file mode 100644 index 0000000..48e7fd0 --- /dev/null +++ b/demo/d3d12/NvCoDx12RenderTarget.h @@ -0,0 +1,122 @@ +#ifndef NV_CO_DX12_RENDER_TARGET_H +#define NV_CO_DX12_RENDER_TARGET_H + +#include +#include +#include +#include "appD3D12Ctx.h" +#include "core/maths.h" + +namespace nvidia { +namespace Common { + +using namespace DirectX; + +class Dx12RenderTarget +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS_BASE(Dx12RenderTarget); +public: + enum BufferType + { + BUFFER_TARGET, + BUFFER_DEPTH_STENCIL, + BUFFER_COUNT_OF, + }; + + struct Desc + { + void init(int width, int height, DXGI_FORMAT targetFormat = DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT depthStencilFormat = DXGI_FORMAT_D32_FLOAT, int usageFlags = 0) + { + m_width = width; + m_height = height; + m_targetFormat = targetFormat; + m_depthStencilFormat = depthStencilFormat; + m_usageFlags = usageFlags; + + const Vec4 clearColor = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX }; + m_targetClearColor = clearColor; + m_depthStencilClearDepth = 1.0; + } + + int m_usageFlags; ///< Usage flags from DxFormatUtil + int m_width; + int m_height; + DXGI_FORMAT m_depthStencilFormat; ///< DXGI_FORMAT_UNKNOWN means don't allocate resource + DXGI_FORMAT m_targetFormat; ///< DXGI_FORMAT_UNKNOWN means don't allocate resource + Vec4 m_targetClearColor; + float m_depthStencilClearDepth; + }; + + int init(AppGraphCtxD3D12* renderContext, const Desc& desc); + + void setShadowDefaultLight(FXMVECTOR eye, FXMVECTOR at, FXMVECTOR up); + void setShadowLightMatrices(FXMVECTOR eye, FXMVECTOR lookAt, FXMVECTOR up, float sizeX, float sizeY, float zNear, float zFar); + + void bind(AppGraphCtxD3D12* renderContext); + + void clear(AppGraphCtxD3D12* renderContext); + void bindAndClear(AppGraphCtxD3D12* renderContext); + + void toWritable(AppGraphCtxD3D12* renderContext); + void toReadable(AppGraphCtxD3D12* renderContext); + + /// Set the debug name + void setDebugName(BufferType type, const std::wstring& name); + /// Set name (plus if depth/target) for all buffers + void setDebugName(const std::wstring& name); + + /// Get the 'primary' buffer type. + BufferType getPrimaryBufferType() const { return m_renderTarget ? BUFFER_TARGET : BUFFER_DEPTH_STENCIL; } + + /// Get the resource by the buffer type + const Dx12ResourceBase& getResource(BufferType type) const { return type == BUFFER_TARGET ? m_renderTarget : m_depthStencilBuffer; } + Dx12Resource& getResource(BufferType type) { return type == BUFFER_TARGET ? m_renderTarget : m_depthStencilBuffer; } + + /// Calculates a default shader resource view + D3D12_SHADER_RESOURCE_VIEW_DESC calcDefaultSrvDesc(BufferType type) const; + + /// Allocates a srv view. Stores the index in m_srvView. If < 0 there isn't an associated srv + /// If the desc isn't set one will be created via calcDefaultSrvDesc + int allocateSrvView(BufferType type, ID3D12Device* device, Dx12DescriptorHeap& heap, const D3D12_SHADER_RESOURCE_VIEW_DESC* desc = nullptr); + + /// Gets the appropriate format for reading as srv + DXGI_FORMAT getSrvFormat(BufferType type) const; + /// Gets the suitable target for rendering to + DXGI_FORMAT getTargetFormat(BufferType type) const; + /// Get the amount of render targets + inline int getNumRenderTargets() const { return m_renderTarget ? 1 : 0; } + + /// Create a srv at the index on the heap for the buffer type + void createSrv(ID3D12Device* device, Dx12DescriptorHeap& heap, BufferType type, int descriptorIndex); + + /// Get an associated srv heap index (as produced by allocateSrvView) + inline int getSrvHeapIndex(BufferType type) const { return m_srvIndices[type]; } + + /// Get the desc + inline const Desc& getDesc() const { return m_desc; } + + Dx12RenderTarget(); + + static DxFormatUtil::UsageType getUsageType(BufferType type); + + int m_srvIndices[BUFFER_COUNT_OF]; + + XMMATRIX m_shadowLightView; + XMMATRIX m_shadowLightProjection; + XMMATRIX m_shadowLightWorldToTex; + + Desc m_desc; + + D3D12_VIEWPORT m_viewport; + D3D12_RECT m_scissorRect; + + Dx12Resource m_renderTarget; + ComPtr m_descriptorHeapRtv; + Dx12Resource m_depthStencilBuffer; + ComPtr m_descriptorHeapDsv; +}; + +} // namespace Common +} // namespace nvidia + +#endif // NV_CO_DX12_RENDER_TARGET_H \ No newline at end of file diff --git a/demo/d3d12/NvCoDx12Resource.cpp b/demo/d3d12/NvCoDx12Resource.cpp new file mode 100644 index 0000000..e771a15 --- /dev/null +++ b/demo/d3d12/NvCoDx12Resource.cpp @@ -0,0 +1,167 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDx12Resource.h" + +#include + +#define NOMINMAX +#include +using namespace Microsoft::WRL; + +namespace nvidia { +namespace Common { + +/* !!!!!!!!!!!!!!!!!!!!!!!!! Dx12BarrierSubmitter !!!!!!!!!!!!!!!!!!!!!!!! */ + +void Dx12BarrierSubmitter::_flush() +{ + assert(m_numBarriers > 0); + + if (m_commandList) + { + m_commandList->ResourceBarrier(UINT(m_numBarriers), m_barriers); + } + m_numBarriers = 0; +} + +D3D12_RESOURCE_BARRIER& Dx12BarrierSubmitter::_expandOne() +{ + _flush(); + return m_barriers[m_numBarriers++]; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!! Dx12ResourceBase !!!!!!!!!!!!!!!!!!!!!!!! */ + +void Dx12ResourceBase::transition(D3D12_RESOURCE_STATES nextState, Dx12BarrierSubmitter& submitter) +{ + // If there is no resource, then there is nothing to transition + if (!m_resource) + { + return; + } + + if (nextState != m_state) + { + D3D12_RESOURCE_BARRIER& barrier = submitter.expandOne(); + + const UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + const D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + + memset(&barrier, 0, sizeof(barrier)); + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Flags = flags; + barrier.Transition.pResource = m_resource; + barrier.Transition.StateBefore = m_state; + barrier.Transition.StateAfter = nextState; + barrier.Transition.Subresource = subresource; + + m_prevState = m_state; + m_state = nextState; + } + else + { + if (nextState == D3D12_RESOURCE_STATE_UNORDERED_ACCESS) + { + D3D12_RESOURCE_BARRIER& barrier = submitter.expandOne(); + + memset(&barrier, 0, sizeof(barrier)); + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + barrier.UAV.pResource = m_resource; + + m_state = nextState; + } + } +} + +/* static */DXGI_FORMAT Dx12ResourceBase::calcFormat(DxFormatUtil::UsageType usage, ID3D12Resource* resource) +{ + return resource ? DxFormatUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!! Dx12Resource !!!!!!!!!!!!!!!!!!!!!!!! */ + +/* static */void Dx12Resource::setDebugName(ID3D12Resource* resource, const std::wstring& name) +{ + if (resource) + { + resource->SetName(name.c_str()); + } +} + +void Dx12Resource::setDebugName(const std::wstring& name) +{ + setDebugName(m_resource, name); +} + +void Dx12Resource::setDebugName(const wchar_t* name) +{ + if (m_resource) + { + m_resource->SetName(name); + } +} + +void Dx12Resource::setResource(ID3D12Resource* resource, D3D12_RESOURCE_STATES initialState) +{ + if (resource != m_resource) + { + if (resource) + { + resource->AddRef(); + } + if (m_resource) + { + m_resource->Release(); + } + m_resource = resource; + } + m_prevState = initialState; + m_state = initialState; +} + +void Dx12Resource::setResourceNull() +{ + if (m_resource) + { + m_resource->Release(); + m_resource = nullptr; + } +} + +int Dx12Resource::initCommitted(ID3D12Device* device, const D3D12_HEAP_PROPERTIES& heapProps, D3D12_HEAP_FLAGS heapFlags, const D3D12_RESOURCE_DESC& resourceDesc, D3D12_RESOURCE_STATES initState, const D3D12_CLEAR_VALUE * clearValue) +{ + setResourceNull(); + ComPtr resource; + NV_RETURN_ON_FAIL(device->CreateCommittedResource(&heapProps, heapFlags, &resourceDesc, initState, clearValue, IID_PPV_ARGS(&resource))); + setResource(resource.Get(), initState); + return NV_OK; +} + +ID3D12Resource* Dx12Resource::detach() +{ + ID3D12Resource* resource = m_resource; + m_resource = nullptr; + return resource; +} + +void Dx12Resource::swap(ComPtr& resourceInOut) +{ + ID3D12Resource* tmp = m_resource; + m_resource = resourceInOut.Detach(); + resourceInOut.Attach(tmp); +} + +void Dx12Resource::setState(D3D12_RESOURCE_STATES state) +{ + m_prevState = state; + m_state = state; +} + + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDx12Resource.h b/demo/d3d12/NvCoDx12Resource.h new file mode 100644 index 0000000..9bb8dab --- /dev/null +++ b/demo/d3d12/NvCoDx12Resource.h @@ -0,0 +1,140 @@ +#ifndef NV_CO_DX12_RESOURCE_H +#define NV_CO_DX12_RESOURCE_H + +#include +#include + +#define NOMINMAX +#include +#include +#include + +using namespace Microsoft::WRL; + +namespace nvidia { +namespace Common { + +// Enables more conservative barriers - restoring the state of resources after they are used. +// Should not need to be enabled in normal builds, as the barriers should correctly sync resources +// If enabling fixes an issue it implies regular barriers are not correctly used. +#define NV_CO_ENABLE_CONSERVATIVE_RESOURCE_BARRIERS 0 + +struct Dx12BarrierSubmitter +{ + enum { MAX_BARRIERS = 8 }; + + /// Expand one space to hold a barrier + inline D3D12_RESOURCE_BARRIER& expandOne() { return (m_numBarriers < MAX_BARRIERS) ? m_barriers[m_numBarriers++] : _expandOne(); } + /// Flush barriers to command list + inline void flush() { if (m_numBarriers > 0) _flush(); } + + /// Ctor + inline Dx12BarrierSubmitter(ID3D12GraphicsCommandList* commandList):m_numBarriers(0), m_commandList(commandList) { } + /// Dtor + inline ~Dx12BarrierSubmitter() { flush(); } + + protected: + D3D12_RESOURCE_BARRIER& _expandOne(); + void _flush(); + + ID3D12GraphicsCommandList* m_commandList; + ptrdiff_t m_numBarriers; + D3D12_RESOURCE_BARRIER m_barriers[MAX_BARRIERS]; +}; + +/** The base class for resource types allows for tracking of state. It does not allow for setting of the resource though, such that +an interface can return a Dx12ResourceBase, and a client cant manipulate it's state, but it cannot replace/change the actual resource */ +struct Dx12ResourceBase +{ + /// Add a transition if necessary to the list + void transition(D3D12_RESOURCE_STATES nextState, Dx12BarrierSubmitter& submitter); + /// Get the current state + inline D3D12_RESOURCE_STATES getState() const { return m_state; } + + /// Get the associated resource + inline ID3D12Resource* getResource() const { return m_resource; } + + /// True if a resource is set + inline bool isSet() const { return m_resource != nullptr; } + + /// Coercable into ID3D12Resource + inline operator ID3D12Resource*() const { return m_resource; } + + /// restore previous state +#if NV_CO_ENABLE_CONSERVATIVE_RESOURCE_BARRIERS + inline void restore(Dx12BarrierSubmitter& submitter) { transition(m_prevState, submitter); } +#else + inline void restore(Dx12BarrierSubmitter& submitter) { (void)submitter; } +#endif + + /// Given the usage, flags, and format will return the most suitable format. Will return DXGI_UNKNOWN if combination is not possible + static DXGI_FORMAT calcFormat(DxFormatUtil::UsageType usage, ID3D12Resource* resource); + + /// Ctor + inline Dx12ResourceBase() : + m_state(D3D12_RESOURCE_STATE_COMMON), + m_prevState(D3D12_RESOURCE_STATE_COMMON), + m_resource(nullptr) + {} + + protected: + /// This is protected so as clients cannot slice the class, and so state tracking is lost + ~Dx12ResourceBase() {} + + ID3D12Resource* m_resource; + D3D12_RESOURCE_STATES m_state; + D3D12_RESOURCE_STATES m_prevState; +}; + +struct Dx12Resource: public Dx12ResourceBase +{ + + /// Dtor + ~Dx12Resource() + { + if (m_resource) + { + m_resource->Release(); + } + } + + /// Initialize as committed resource + int initCommitted(ID3D12Device* device, const D3D12_HEAP_PROPERTIES& heapProps, D3D12_HEAP_FLAGS heapFlags, const D3D12_RESOURCE_DESC& resourceDesc, D3D12_RESOURCE_STATES initState, const D3D12_CLEAR_VALUE * clearValue); + + /// Set a resource with an initial state + void setResource(ID3D12Resource* resource, D3D12_RESOURCE_STATES initialState); + /// Make the resource null + void setResourceNull(); + /// Returns the attached resource (with any ref counts) and sets to nullptr on this. + ID3D12Resource* detach(); + + /// Swaps the resource contents with the contents of the smart pointer + void swap(ComPtr& resourceInOut); + + /// Sets the current state of the resource (the current state is taken to be the future state once the command list has executed) + /// NOTE! This must be used with care, otherwise state tracking can be made incorrect. + void setState(D3D12_RESOURCE_STATES state); + + /// Set the debug name on a resource + static void setDebugName(ID3D12Resource* resource, const std::wstring& name); + + /// Set the the debug name on the resource + void setDebugName(const wchar_t* name); + /// Set the debug name + void setDebugName(const std::wstring& name); +}; + +/// Convenient way to set blobs +struct Dx12Blob : public D3D12_SHADER_BYTECODE +{ + template + inline Dx12Blob(const BYTE(&in)[SIZE]) { pShaderBytecode = in; BytecodeLength = SIZE; } + inline Dx12Blob(const BYTE* in, size_t size) { pShaderBytecode = in; BytecodeLength = size; } + inline Dx12Blob() { pShaderBytecode = nullptr; BytecodeLength = 0; } + inline Dx12Blob(ID3DBlob* blob) { pShaderBytecode = blob->GetBufferPointer(); BytecodeLength = blob->GetBufferSize(); } +}; + +} // namespace Common +} // namespace nvidia + +#endif // NV_CO_DX12_RESOURCE_H diff --git a/demo/d3d12/NvCoDx12ResourceScopeManager.cpp b/demo/d3d12/NvCoDx12ResourceScopeManager.cpp new file mode 100644 index 0000000..268ecab --- /dev/null +++ b/demo/d3d12/NvCoDx12ResourceScopeManager.cpp @@ -0,0 +1,179 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDx12ResourceScopeManager.h" + +#include + +namespace nvidia { +namespace Common { + +Dx12ResourceScopeManager::Dx12ResourceScopeManager(): + m_fence(nullptr), + m_device(nullptr) +{ +} + +Dx12ResourceScopeManager::~Dx12ResourceScopeManager() +{ + while (!m_entryQueue.empty()) + { + Entry& entry = m_entryQueue.front(); + entry.m_resource->Release(); + m_entryQueue.pop_front(); + } +} + +int Dx12ResourceScopeManager::init(ID3D12Device* device, Dx12CounterFence* fence) +{ + m_fence = fence; + m_device = device; + return NV_OK; +} + +void Dx12ResourceScopeManager::addSync(uint64_t signalValue) +{ + (void)signalValue; + + assert(m_fence->getCurrentValue() == signalValue); +} + +void Dx12ResourceScopeManager::updateCompleted() +{ + const uint64_t completedValue = m_fence->getCompletedValue(); + if (!m_entryQueue.empty()) + { + const Entry& entry = m_entryQueue.front(); + if (entry.m_completedValue >= completedValue) + { + return; + } + entry.m_resource->Release(); + m_entryQueue.pop_front(); + } +} + +ID3D12Resource* Dx12ResourceScopeManager::newUploadResource(const D3D12_RESOURCE_DESC& resourceDesc, const D3D12_CLEAR_VALUE* clearValue) +{ + D3D12_HEAP_PROPERTIES heapProps; + { + heapProps.Type = D3D12_HEAP_TYPE_UPLOAD; + heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapProps.CreationNodeMask = 1; + heapProps.VisibleNodeMask = 1; + } + const D3D12_HEAP_FLAGS heapFlags = D3D12_HEAP_FLAG_NONE; + + const D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_GENERIC_READ; + + ComPtr resource; + int res = m_device->CreateCommittedResource(&heapProps, heapFlags, &resourceDesc, initialState, clearValue, IID_PPV_ARGS(&resource)); + if (NV_FAILED(res)) return nullptr; + + // Get the current fence count + const uint64_t completedValue = m_fence->getCurrentValue(); + + Entry entry; + entry.m_completedValue = completedValue; + entry.m_resource = resource.Detach(); + m_entryQueue.push_back(entry); + + return entry.m_resource; +} + +/* static */void Dx12ResourceScopeManager::copy(const D3D12_SUBRESOURCE_DATA& src, size_t rowSizeInBytes, int numRows, int numSlices, const D3D12_MEMCPY_DEST& dst) +{ + for (int i = 0; i < numSlices; ++i) + { + uint8_t* dstSlice = reinterpret_cast(dst.pData) + dst.SlicePitch * i; + const uint8_t* srcSlice = reinterpret_cast(src.pData) + src.SlicePitch * i; + for (int j = 0; j < numRows; ++j) + { + memcpy(dstSlice + dst.RowPitch * j, srcSlice + src.RowPitch * j, rowSizeInBytes); + } + } +} + +int Dx12ResourceScopeManager::upload(ID3D12GraphicsCommandList* commandList, const void* srcDataIn, ID3D12Resource* targetResource, D3D12_RESOURCE_STATES targetState) +{ + // Get the targetDesc + const D3D12_RESOURCE_DESC targetDesc = targetResource->GetDesc(); + // Ensure it is just a regular buffer + assert(targetDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER); + assert(targetDesc.Layout == D3D12_TEXTURE_LAYOUT_ROW_MAJOR); + + // The buffer size is the width + const size_t bufferSize = size_t(targetDesc.Width); + + D3D12_RESOURCE_DESC uploadDesc = targetDesc; + uploadDesc.Flags = D3D12_RESOURCE_FLAG_NONE; + + // Create the upload resource + ID3D12Resource* uploadResource = newUploadResource(uploadDesc); + + // Map it and copy + { + uint8_t* uploadMapped; + NV_RETURN_ON_FAIL(uploadResource->Map(0, nullptr, (void**)&uploadMapped)); + memcpy(uploadMapped, srcDataIn, bufferSize); + uploadResource->Unmap(0, nullptr); + } + + // Add the copy + commandList->CopyBufferRegion(targetResource, 0, uploadResource, 0, bufferSize); + + // Add the barrier + { + D3D12_RESOURCE_BARRIER barrier = {}; + + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + D3D12_RESOURCE_TRANSITION_BARRIER& transition = barrier.Transition; + transition.pResource = targetResource; + transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST; + transition.StateAfter = targetState; + transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + + commandList->ResourceBarrier(1, &barrier); + } + + return NV_OK; +} + +void Dx12ResourceScopeManager::add(ID3D12Resource* resource) +{ + assert(resource); + + // Get the current fence count + const uint64_t completedValue = m_fence->getCurrentValue(); + + Entry entry; + entry.m_completedValue = completedValue; + resource->AddRef(); + entry.m_resource = resource; + + m_entryQueue.push_back(entry); +} + +int Dx12ResourceScopeManager::uploadWithState(ID3D12GraphicsCommandList* commandList, const void* srcDataIn, Dx12Resource& target, D3D12_RESOURCE_STATES targetState) +{ + // make sure we are in the correct initial state + if (target.getState() != D3D12_RESOURCE_STATE_COPY_DEST) + { + Dx12BarrierSubmitter submitter(commandList); + target.transition(D3D12_RESOURCE_STATE_COPY_DEST, submitter); + } + // Do the upload + NV_RETURN_ON_FAIL(upload(commandList, srcDataIn, target.getResource(), targetState)); + target.setState(targetState); + return NV_OK; +} + + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDx12ResourceScopeManager.h b/demo/d3d12/NvCoDx12ResourceScopeManager.h new file mode 100644 index 0000000..7bd71ff --- /dev/null +++ b/demo/d3d12/NvCoDx12ResourceScopeManager.h @@ -0,0 +1,100 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX12_RESOURCE_SCOPE_MANAGER_H +#define NV_CO_DX12_RESOURCE_SCOPE_MANAGER_H + +#include "NvCoDx12Resource.h" +#include "NvCoDx12CounterFence.h" + +// Dx12 types +#define NOMINMAX +#include + +#include + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +/*! \brief A class to manage the lifetime of resources that are transitory (as used only for a single specific piece of GPU work), +but arbitrarily sized - such as textures. + +With Dx12 there is no management for the lifetime of resources within the Api directly. It is the duty of +the application to make sure resources are released when they are no longer being referenced. The Dx12ResourceScopeManager +tries to simplify this management for some common use cases. Firstly when creating a GPU based resource and filling it +with data, the data must first be copied to an upload buffer, and then to the target gpu based buffer. The upload buffer +is only needed whilst copying takes place. The method 'upload' will create a temporary upload buffer, and initiate the +copy into target. + +The upload resource will ONLY BE RELEASED when the fences value is greater than the current value. Assuming the command list +is added to the queue, and the fence is added afterwards (which is the appropriate way), the resources will only be released +after the fence has been hit AND when updateCompleted is called. + +The Dx12ResourceScopeManager is most useful for resource uploads that happen at startup, and might be very large. If you want to +upload constrained sized (like constant buffer) resources quickly and efficiently at runtime you might be better using Dx12CircularResourceHeap. + +The Dx12ResourceScopeManager uses the addSync/updateCompleted idiom, see details in Dx12CircularResourceHeap. + +*/ +class Dx12ResourceScopeManager +{ + //NV_CO_DECLARE_CLASS_BASE(Dx12ResourceScopeManager); +public: + /// Initialize + int init(ID3D12Device* device, Dx12CounterFence* fence); + + /// Allocate constant buffer of specified size + ID3D12Resource* newUploadResource(const D3D12_RESOURCE_DESC& resourceDesc, const D3D12_CLEAR_VALUE* clearValue = nullptr); + /// Do an upload on the specified command list + int upload(ID3D12GraphicsCommandList* commandList, const void* srcDataIn, ID3D12Resource* target, D3D12_RESOURCE_STATES targetState); + /// Upload data to the target, and set state. Will add barriers if target is in the wrong state + int uploadWithState(ID3D12GraphicsCommandList* commandList, const void* srcDataIn, Dx12Resource& target, D3D12_RESOURCE_STATES targetState); + + /// Add a resource, which will be released when updateCompleted has a greater value + void add(ID3D12Resource* resource); + + /// Look where the GPU has got to and release anything not currently used + void updateCompleted(); + /// Add a sync point - meaning that when this point is hit in the queue + /// all of the resources up to this point will no longer be used. + void addSync(uint64_t signalValue); + + /// Get the device associated with this manager + inline ID3D12Device* getDevice() const { return m_device; } + + /// Ctor + Dx12ResourceScopeManager(); + /// Dtor + ~Dx12ResourceScopeManager(); + + /// Copy from src to dst + static void copy(const D3D12_SUBRESOURCE_DATA& src, size_t rowSizeInBytes, int numRows, int numSlices, const D3D12_MEMCPY_DEST& dst); + + protected: + + struct Entry + { + uint64_t m_completedValue; ///< If less than fence value this is completed + ID3D12Resource* m_resource; ///< The mapped resource + }; + + std::deque m_entryQueue; + + Dx12CounterFence* m_fence; ///< The fence to use + ID3D12Device* m_device; ///< The device that resources will be constructed on +}; + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_DX12_RESOURCE_SCOPE_MANAGER_H diff --git a/demo/d3d12/NvCoDxDebugUtil.cpp b/demo/d3d12/NvCoDxDebugUtil.cpp new file mode 100644 index 0000000..b5ef17c --- /dev/null +++ b/demo/d3d12/NvCoDxDebugUtil.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDxDebugUtil.h" + +namespace nvidia { +namespace Common { + +/* static */int DxDebugUtil::getDebugInterface(IDXGIDebug** debugOut) +{ + HMODULE module = GetModuleHandleA("Dxgidebug.dll"); + if (module) + { + //WINAPI + typedef HRESULT(WINAPI *FuncType)(REFIID riid, void **ppDebug); + FARPROC funcAddr = GetProcAddress(module, "DXGIGetDebugInterface"); + + FuncType debugFunc = (FuncType)funcAddr; + if (debugFunc) + { + return debugFunc(__uuidof(IDXGIDebug), (void**)debugOut); + } + } + return NV_FAIL; +} + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDxDebugUtil.h b/demo/d3d12/NvCoDxDebugUtil.h new file mode 100644 index 0000000..8916ecf --- /dev/null +++ b/demo/d3d12/NvCoDxDebugUtil.h @@ -0,0 +1,37 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_DX_DEBUG_UTIL_H +#define NV_CO_DX_DEBUG_UTIL_H + +#include + +#define NOMINMAX +#include +#include + +using namespace Microsoft::WRL; + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +struct DxDebugUtil +{ + /// Get the debug interface + static int getDebugInterface(IDXGIDebug** debugOut); +}; + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_DX12_DEBUG_UTIL_H diff --git a/demo/d3d12/NvCoDxFormatUtil.cpp b/demo/d3d12/NvCoDxFormatUtil.cpp new file mode 100644 index 0000000..7facf2e --- /dev/null +++ b/demo/d3d12/NvCoDxFormatUtil.cpp @@ -0,0 +1,173 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoDxFormatUtil.h" + +#include + +namespace nvidia { +namespace Common { + +/* static */DXGI_FORMAT DxFormatUtil::calcResourceFormat(UsageType usage, int usageFlags, DXGI_FORMAT format) +{ + (void)usage; + if (usageFlags) + { + switch (format) + { + case DXGI_FORMAT_R32_FLOAT: + case DXGI_FORMAT_D32_FLOAT: return DXGI_FORMAT_R32_TYPELESS; + case DXGI_FORMAT_D24_UNORM_S8_UINT: return DXGI_FORMAT_R24G8_TYPELESS; + default: break; + } + return format; + } + return format; +} + +/* static */DXGI_FORMAT DxFormatUtil::calcFormat(UsageType usage, DXGI_FORMAT format) +{ + switch (usage) + { + case USAGE_COUNT_OF: + case USAGE_UNKNOWN: + { + return DXGI_FORMAT_UNKNOWN; + } + case USAGE_DEPTH_STENCIL: + { + switch (format) + { + case DXGI_FORMAT_D32_FLOAT: + case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_D32_FLOAT; + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: return DXGI_FORMAT_D24_UNORM_S8_UINT; + case DXGI_FORMAT_R24G8_TYPELESS: return DXGI_FORMAT_D24_UNORM_S8_UINT; + default: break; + } + return format; + } + case USAGE_TARGET: + { + switch (format) + { + case DXGI_FORMAT_D32_FLOAT: + case DXGI_FORMAT_D24_UNORM_S8_UINT: return DXGI_FORMAT_UNKNOWN; + case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT; + default: break; + } + return format; + } + case USAGE_SRV: + { + switch (format) + { + case DXGI_FORMAT_D32_FLOAT: + case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT; + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + default: break; + } + + return format; + } + } + + printf("Not reachable"); + return DXGI_FORMAT_UNKNOWN; +} + +bool DxFormatUtil::isTypeless(DXGI_FORMAT format) +{ + switch (format) + { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: + case DXGI_FORMAT_R32G32B32_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R32G32_TYPELESS: + case DXGI_FORMAT_R32G8X24_TYPELESS: + case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R16G16_TYPELESS: + case DXGI_FORMAT_R32_TYPELESS: + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case DXGI_FORMAT_R24G8_TYPELESS: + case DXGI_FORMAT_R8G8_TYPELESS: + case DXGI_FORMAT_R16_TYPELESS: + case DXGI_FORMAT_R8_TYPELESS: + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC7_TYPELESS: + { + return true; + } + default: break; + } + return false; +} + +/* static */int DxFormatUtil::getNumColorChannelBits(DXGI_FORMAT fmt) +{ + switch (fmt) + { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: + case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: + case DXGI_FORMAT_R32G32B32A32_SINT: + case DXGI_FORMAT_R32G32B32_TYPELESS: + case DXGI_FORMAT_R32G32B32_FLOAT: + case DXGI_FORMAT_R32G32B32_UINT: + case DXGI_FORMAT_R32G32B32_SINT: + return 32; + + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: + case DXGI_FORMAT_R16G16B16A16_SINT: + return 16; + + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10A2_UINT: + case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: + return 10; + + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SNORM: + case DXGI_FORMAT_R8G8B8A8_SINT: + case DXGI_FORMAT_B8G8R8A8_UNORM: + case DXGI_FORMAT_B8G8R8X8_UNORM: + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_TYPELESS: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + return 8; + + case DXGI_FORMAT_B5G6R5_UNORM: + case DXGI_FORMAT_B5G5R5A1_UNORM: + return 5; + + case DXGI_FORMAT_B4G4R4A4_UNORM: + return 4; + + default: + return 0; + } +} + + +} // namespace Common +} // namespace nvidia diff --git a/demo/d3d12/NvCoDxFormatUtil.h b/demo/d3d12/NvCoDxFormatUtil.h new file mode 100644 index 0000000..e749ea8 --- /dev/null +++ b/demo/d3d12/NvCoDxFormatUtil.h @@ -0,0 +1,41 @@ +#ifndef NV_CO_DX_FORMAT_UTIL_H +#define NV_CO_DX_FORMAT_UTIL_H + +#define NOMINMAX +#include + +namespace nvidia { +namespace Common { + +struct DxFormatUtil +{ + enum UsageType + { + USAGE_UNKNOWN, ///< Generally used to mark an error + USAGE_TARGET, ///< Format should be used when written as target + USAGE_DEPTH_STENCIL, ///< Format should be used when written as depth stencil + USAGE_SRV, ///< Format if being read as srv + USAGE_COUNT_OF, + }; + enum UsageFlag + { + USAGE_FLAG_MULTI_SAMPLE = 0x1, + USAGE_FLAG_SRV = 0x2, + }; + + /// Given the usage, flags, and format will return the most suitable format. Will return DXGI_UNKNOWN if combination is not possible + static DXGI_FORMAT calcFormat(UsageType usage, DXGI_FORMAT format); + /// Calculate appropriate format for creating a buffer for usage and flags + static DXGI_FORMAT calcResourceFormat(UsageType usage, int usageFlags, DXGI_FORMAT format); + /// True if the type is 'typeless' + static bool isTypeless(DXGI_FORMAT format); + + /// Returns number of bits used for color channel for format (for channels with multiple sizes, returns smallest ie RGB565 -> 5) + static int getNumColorChannelBits(DXGI_FORMAT fmt); + +}; + +} // namespace Common +} // namespace nvidia + +#endif // NV_CO_DX12_RESOURCE_H diff --git a/demo/d3d12/NvCoFreeList.cpp b/demo/d3d12/NvCoFreeList.cpp new file mode 100644 index 0000000..72b23b2 --- /dev/null +++ b/demo/d3d12/NvCoFreeList.cpp @@ -0,0 +1,232 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#include "NvCoFreeList.h" + +#include +#include + +#define DEFAULT_ALIGNMENT 16 + +namespace nvidia { +namespace Common { + +FreeList::~FreeList() +{ + _deallocateBlocks(m_activeBlocks); + _deallocateBlocks(m_freeBlocks); +} + +void FreeList::_init() +{ + m_top = nullptr; + m_end = nullptr; + + m_activeBlocks = nullptr; + m_freeBlocks = nullptr; + + m_freeElements = nullptr; + + m_elementSize = 0; + m_alignment = 1; + m_blockSize = 0; + m_blockAllocationSize = 0; + //m_allocator = nullptr; +} + +void FreeList::_init(size_t elementSize, size_t alignment, size_t elemsPerBlock) +{ + //allocator = allocator ? allocator : MemoryAllocator::getInstance(); + //assert(allocator); + //m_allocator = allocator; + + alignment = (alignment < sizeof(void*)) ? sizeof(void*) : alignment; + + // Alignment must be a power of 2 + assert(((alignment - 1) & alignment) == 0); + + // The elementSize must at least be + elementSize = (elementSize >= alignment) ? elementSize : alignment; + m_blockSize = elementSize * elemsPerBlock; + m_elementSize = elementSize; + m_alignment = alignment; + + // Calculate the block size neeed, correcting for alignment + const size_t alignedBlockSize = (alignment <= DEFAULT_ALIGNMENT) ? + _calcAlignedBlockSize(DEFAULT_ALIGNMENT) : + _calcAlignedBlockSize(alignment); + + // Make the block struct size aligned + m_blockAllocationSize = m_blockSize + alignedBlockSize; + + m_top = nullptr; + m_end = nullptr; + + m_activeBlocks = nullptr; + m_freeBlocks = nullptr; ///< Blocks that there are no allocations in + + m_freeElements = nullptr; +} + +void FreeList::init(size_t elementSize, size_t alignment, size_t elemsPerBlock) +{ + _deallocateBlocks(m_activeBlocks); + _deallocateBlocks(m_freeBlocks); + _init(elementSize, alignment, elemsPerBlock); +} + +void FreeList::_deallocateBlocks(Block* block) +{ + while (block) + { + Block* next = block->m_next; + +#ifdef NV_CO_FREE_LIST_INIT_MEM + Memory::set(block, 0xfd, m_blockAllocationSize); +#endif + + free(block); + block = next; + } +} + +bool FreeList::isValidAllocation(const void* dataIn) const +{ + uint8_t* data = (uint8_t*)dataIn; + + Block* block = m_activeBlocks; + while (block) + { + uint8_t* start = block->m_data; + uint8_t* end = start + m_blockSize; + + if (data >= start && data < end) + { + // Check it's aligned correctly + if ((data - start) % m_elementSize) + { + return false; + } + + // Non allocated data is between top and end + if (data >= m_top && data < m_end) + { + return false; + } + + // It can't be in the free list + Element* ele = m_freeElements; + while (ele) + { + if (ele == (Element*)data) + { + return false; + } + + ele = ele->m_next; + } + return true; + } + + block = block->m_next; + } + // It's not in an active block -> it cannot be a valid allocation + return false; +} + +void* FreeList::_allocate() +{ + Block* block = m_freeBlocks; + if (block) + { + /// Remove from the free blocks + m_freeBlocks = block->m_next; + } + else + { + block = (Block*)malloc(m_blockAllocationSize); + if (!block) + { + // Allocation failed... doh + return nullptr; + } + // Do the alignment + { + size_t fix = (size_t(block) + sizeof(Block) + m_alignment - 1) & ~(m_alignment - 1); + block->m_data = (uint8_t*)fix; + } + } + + // Attach to the active blocks + block->m_next = m_activeBlocks; + m_activeBlocks = block; + + // Set up top and end + m_end = block->m_data + m_blockSize; + + // Return the first element + uint8_t* element = block->m_data; + m_top = element + m_elementSize; + + NV_CO_FREE_LIST_INIT_ALLOCATE(element) + + return element; +} + +void FreeList::deallocateAll() +{ + Block* block = m_activeBlocks; + if (block) + { + // Find the end block + while (block->m_next) + { +#ifdef NV_CO_FREE_LIST_INIT_MEM + Memory::set(block->m_data, 0xfd, m_blockSize); +#endif + block = block->m_next; + } + // Attach to the freeblocks + block->m_next = m_freeBlocks; + // The list is now all freelists + m_freeBlocks = m_activeBlocks; + // There are no active blocks + m_activeBlocks = nullptr; + } + + m_top = nullptr; + m_end = nullptr; +} + +void FreeList::reset() +{ + _deallocateBlocks(m_activeBlocks); + _deallocateBlocks(m_freeBlocks); + + m_top = nullptr; + m_end = nullptr; + + m_activeBlocks = nullptr; + m_freeBlocks = nullptr; + + m_freeElements = nullptr; +} + + +void FreeList::_initAllocate(void* mem) +{ + memset(mem, 0xcd, m_elementSize); +} + +void FreeList::_initDeallocate(void* mem) +{ + memset(mem, 0xfd, m_elementSize); +} + +} // namespace Common +} // namespace nvidia + diff --git a/demo/d3d12/NvCoFreeList.h b/demo/d3d12/NvCoFreeList.h new file mode 100644 index 0000000..2b71c62 --- /dev/null +++ b/demo/d3d12/NvCoFreeList.h @@ -0,0 +1,154 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_CO_FREELIST_H +#define NV_CO_FREELIST_H + +#include +#include + +/** \addtogroup common +@{ +*/ + +namespace nvidia { +namespace Common { + +#if NV_DEBUG +# define NV_CO_FREE_LIST_INIT_MEM +#endif + +#ifdef NV_CO_FREE_LIST_INIT_MEM +# define NV_CO_FREE_LIST_INIT_ALLOCATE(ptr) _initAllocate(ptr); +# define NV_CO_FREE_LIST_INIT_DEALLOCATE(ptr) _initDeallocate(ptr); +#else +# define NV_CO_FREE_LIST_INIT_ALLOCATE(ptr) +# define NV_CO_FREE_LIST_INIT_DEALLOCATE(ptr) +#endif + + +/*! \brief A freelist is a simple and fast memory allocator that can allocate and free in any order identically sized blocks. + +\details A free list is a memory allocation system that performs allocations/deallocations very quickly for elements which are +all the same size. +In a freelist all elements are the same size, and elements can be allocated and freed in any order, as long as every deallocation +matches every allocation. Both allocation and deallocation are O(1), and generally just a few instructions. The underlying +memory allocator will allocate in large blocks, with multiple elements amortizing a more costly large allocation against lots +of fast small element allocations. */ +class FreeList +{ + //NV_CO_DECLARE_CLASS_BASE(FreeList); +public: + /// Free elements are held in a singly linked list. The minimum size of an element is therefore a pointer + struct Element + { + Element* m_next; + }; + struct Block + { + Block* m_next; ///< The next block + uint8_t* m_data; ///< The list of the elements each m_elementSize in size + }; + + /// Allocate a single element + inline void* allocate(); + /// Deallocate a block that was previously allocated with allocate + inline void deallocate(void* data); + + /// Returns true if this is from a valid allocation + bool isValidAllocation(const void* dataIn) const; + + /// Get the element size + inline size_t getElementSize() const { return m_elementSize; } + /// Get the total size of each individual block allocation in bytes + inline size_t getBlockSize() const { return m_blockSize; } + + /// Deallocates all elements + void deallocateAll(); + /// Deallocates all, and frees any backing memory (put in initial state) + void reset(); + + /// Initialize. If called on an already initialized heap, the heap will be deallocated. + void init(size_t elementSize, size_t alignment, size_t elemsPerBlock); + + /// Default Ctor + FreeList() { _init(); } + /// Ctor + FreeList(size_t elementSize, size_t alignment, size_t elemsPerBlock) { _init(elementSize, alignment, elemsPerBlock); } + /// Dtor + ~FreeList(); + + protected: + /// Initializes assuming freelist is not constructed + void _init(size_t elementSize, size_t alignment, size_t elemsPerBlock); + void* _allocate(); + void _deallocateBlocks(Block* block); + /// Initializes setting everything to empty (doesn't free anything if already allocated) + void _init(); + + inline static size_t _calcAlignedBlockSize(size_t align) { return (sizeof(Block) + align - 1) & ~(align - 1); } + + void _initAllocate(void* mem); + void _initDeallocate(void* mem); + + uint8_t* m_top; ///< The top position of the current block + uint8_t* m_end; ///< The end of the current block + + Block* m_activeBlocks; ///< The blocks there are potentially allocations from + Block* m_freeBlocks; ///< Blocks that there are no allocations in + + Element* m_freeElements; ///< A singly linked list of elements available + + size_t m_elementSize; + size_t m_alignment; + size_t m_blockSize; + size_t m_blockAllocationSize; ///< The actual allocation size. Maybe bigger than m_blockSize if alignment requires it. + //MemoryAllocator* m_allocator; +}; + +// -------------------------------------------------------------------------- +inline void* FreeList::allocate() +{ + // First see if there are any freeElements ready to go + { + Element* element = m_freeElements; + if (element) + { + m_freeElements = element->m_next; + NV_CO_FREE_LIST_INIT_ALLOCATE(element) + return element; + } + } + if (m_top >= m_end) + { + return _allocate(); + } + void* data = (void*)m_top; + NV_CO_FREE_LIST_INIT_ALLOCATE(data) + + m_top += m_elementSize; + return data; +} +// -------------------------------------------------------------------------- +inline void FreeList::deallocate(void* data) +{ + assert(isValidAllocation(data)); + + NV_CO_FREE_LIST_INIT_DEALLOCATE(data) + + // Put onto the singly linked free element list + Element* ele = (Element*)data; + ele->m_next = m_freeElements; + m_freeElements = ele; +} + +} // namespace Common +} // namespace nvidia + +/** @} */ + +#endif // NV_CO_FREELIST_H \ No newline at end of file diff --git a/demo/d3d12/NvResult.h b/demo/d3d12/NvResult.h new file mode 100644 index 0000000..27cf936 --- /dev/null +++ b/demo/d3d12/NvResult.h @@ -0,0 +1,137 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + +#ifndef NV_RESULT_H +#define NV_RESULT_H + +#include + +/** \addtogroup core +@{ +*/ + +/*! Result is designed to be compatible with COM HRESULT. + +It's layout in bits is as follows + +Severity | Facility | Code +---------|----------|----- +31 | 30-16 | 15-0 + +Severity - 1 fail, 0 is success. +Facility is where the error originated from +Code is the code specific to the facility. + +The layout is designed such that failure is a negative number, and success is positive due to Result +being represented by an Int32. + +Result codes have the following style + +1. NV_name +2. NV_s_f_name +3. NV_s_name + +where s is severity as a single letter S - success, and E for error +Style 1 is reserved for NV_OK and NV_FAIL as they are so common and not tied to a facility + +s is S for success, E for error +f is the short version of the facility name + +For the common used NV_OK and NV_FAIL, the name prefix is dropped +It is acceptable to expand 'f' to a longer name to differentiate a name +ie for a facility 'DRIVER' it might make sense to have an error of the form NV_E_DRIVER_OUT_OF_MEMORY */ +typedef int NvResult; + +//! Make a result +#define NV_MAKE_RESULT(sev, fac, code) ((((int)(sev))<<31) | (((int)(fac))<<16) | ((int)(code))) + +//! Will be 0 - for ok, 1 for failure +#define NV_GET_RESULT_SEVERITY(r) ((int)(((NvUInt32)(r)) >> 31)) +//! Will be 0 - for ok, 1 for failure +#define NV_GET_RESULT_FACILITY(r) ((int)(((r) >> 16) & 0x7fff)) +//! Get the result code +#define NV_GET_RESULT_CODE(r) ((int)((r) & 0xffff)) + +#define NV_SEVERITY_ERROR 1 +#define NV_SEVERITY_SUCCESS 0 + +#define NV_MAKE_ERROR(fac, code) NV_MAKE_RESULT(NV_SEVERITY_ERROR, NV_FACILITY_##fac, code) +#define NV_MAKE_SUCCESS(fac, code) NV_MAKE_RESULT(NV_SEVERITY_SUCCESS, NV_FACILITY_##fac, code) + +/*************************** Facilities ************************************/ + +//! General - careful to make compatible with HRESULT +#define NV_FACILITY_GENERAL 0 + +//! Base facility -> so as to not clash with HRESULT values +#define NV_FACILITY_BASE 0x100 + +/*! Facilities numbers must be unique across a project to make the resulting result a unique number! +It can be useful to have a consistent short name for a facility, as used in the name prefix */ +#define NV_FACILITY_DISK (NV_FACILITY_BASE + 1) +#define NV_FACILITY_INTERFACE (NV_FACILITY_BASE + 2) +#define NV_FACILITY_UNKNOWN (NV_FACILITY_BASE + 3) +#define NV_FACILITY_MEMORY (NV_FACILITY_BASE + 4) +#define NV_FACILITY_MISC (NV_FACILITY_BASE + 5) + +/// Base for external facilities. Facilities should be unique across modules. +#define NV_FACILITY_EXTERNAL_BASE 0x200 +#define NV_FACILITY_HAIR (NV_FACILITY_EXTERNAL_BASE + 1) + +/* *************************** Codes **************************************/ + +// Memory +#define NV_E_MEM_OUT_OF_MEMORY NV_MAKE_ERROR(MEMORY, 1) +#define NV_E_MEM_BUFFER_TOO_SMALL NV_MAKE_ERROR(MEMORY, 2) + +//! NV_OK indicates success, and is equivalent to NV_MAKE_RESULT(0, NV_FACILITY_GENERAL, 0) +#define NV_OK 0 +//! NV_FAIL is the generic failure code - meaning a serious error occurred and the call couldn't complete +#define NV_FAIL NV_MAKE_ERROR(GENERAL, 1) + +//! Used to identify a Result that has yet to be initialized. +//! It defaults to failure such that if used incorrectly will fail, as similar in concept to using an uninitialized variable. +#define NV_E_MISC_UNINITIALIZED NV_MAKE_ERROR(MISC, 2) +//! Returned from an async method meaning the output is invalid (thus an error), but a result for the request is pending, and will be returned on a subsequent call with the async handle. +#define NV_E_MISC_PENDING NV_MAKE_ERROR(MISC, 3) +//! Indicates that a handle passed in as parameter to a method is invalid. +#define NV_E_MISC_INVALID_HANDLE NV_MAKE_ERROR(MISC, 4) + +/*! Set NV_HANDLE_RESULT_FAIL(x) to code to be executed whenever an error occurs, and is detected by one of the macros */ +#ifndef NV_HANDLE_RESULT_FAIL +# define NV_HANDLE_RESULT_FAIL(x) +#endif + +/* !!!!!!!!!!!!!!!!!!!!!!!!! Checking codes !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +//! Use to test if a result was failure. Never use result != NV_OK to test for failure, as there may be successful codes != NV_OK. +#define NV_FAILED(status) ((status) < 0) +//! Use to test if a result succeeded. Never use result == NV_OK to test for success, as will detect other successful codes as a failure. +#define NV_SUCCEEDED(status) ((status) >= 0) + +//! Helper macro, that makes it easy to add result checking to calls in functions/methods that themselves return Result. +#define NV_RETURN_ON_FAIL(x) { NvResult _res = (x); if (NV_FAILED(_res)) { NV_HANDLE_RESULT_FAIL(_res); return _res; } } +//! Helper macro that can be used to test the return value from a call, and will return in a void method/function +#define NV_RETURN_VOID_ON_FAIL(x) { NvResult _res = (x); if (NV_FAILED(_res)) { NV_HANDLE_RESULT_FAIL(_res); return; } } +//! Helper macro that will return false on failure. +#define NV_RETURN_FALSE_ON_FAIL(x) { NvResult _res = (x); if (NV_FAILED(_res)) { NV_HANDLE_RESULT_FAIL(_res); return false; } } + +//! Helper macro that will assert if the return code from a call is failure, also returns the failure. +#define NV_CORE_ASSERT_ON_FAIL(x) { NvResult _res = (x); if (NV_FAILED(_res)) { assert(false); return _res; } } +//! Helper macro that will assert if the result from a call is a failure, also returns. +#define NV_CORE_ASSERT_VOID_ON_FAIL(x) { NvResult _res = (x); if (NV_FAILED(_res)) { assert(false); return; } } + + +#if __cplusplus +namespace nvidia { +typedef NvResult Result; +} // namespace nvidia +#endif + +/** @} */ + +#endif diff --git a/demo/d3d12/appD3D12Ctx.cpp b/demo/d3d12/appD3D12Ctx.cpp new file mode 100644 index 0000000..944453a --- /dev/null +++ b/demo/d3d12/appD3D12Ctx.cpp @@ -0,0 +1,1210 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +//direct3d headers +#define NOMINMAX +#include +#include + +// include the Direct3D Library file +#pragma comment (lib, "d3d12.lib") +#pragma comment (lib, "DXGI.lib") + +#include "appD3D12Ctx.h" + +#include + +#include +#include +#include + +namespace +{ + // COM object release utilities + template + void inline COMRelease(T& t) + { + if (t) t->Release(); + t = nullptr; + } + + template + void inline COMRelease(T& t, UINT arraySize) + { + for (UINT i = 0; i < arraySize; i++) + { + if (t[i]) t[i]->Release(); + t[i] = nullptr; + } + } +} + +AppGraphProfilerD3D12* appGraphCreateProfilerD3D12(AppGraphCtx* ctx); +void appGraphProfilerD3D12FrameBegin(AppGraphProfilerD3D12* profiler); +void appGraphProfilerD3D12FrameEnd(AppGraphProfilerD3D12* profiler); +void appGraphProfilerD3D12Enable(AppGraphProfilerD3D12* profiler, bool enabled); +void appGraphProfilerD3D12Begin(AppGraphProfilerD3D12* profiler, const char* label); +void appGraphProfilerD3D12End(AppGraphProfilerD3D12* profiler, const char* label); +bool appGraphProfilerD3D12Get(AppGraphProfilerD3D12* profiler, const char** plabel, float* cpuTime, float* gpuTime, int index); +void appGraphReleaseProfiler(AppGraphProfilerD3D12* profiler); + +AppGraphCtxD3D12::AppGraphCtxD3D12() +{ + m_profiler = appGraphCreateProfilerD3D12(cast_from_AppGraphCtxD3D12(this)); + + m_targetInfo.init(); + + memset(m_commandAllocators, 0, sizeof(m_commandAllocators)); + memset(m_fenceValues, 0, sizeof(m_fenceValues)); +} + +AppGraphCtxD3D12::~AppGraphCtxD3D12() +{ + AppGraphCtxReleaseRenderTargetD3D12(cast_from_AppGraphCtxD3D12(this)); + + COMRelease(m_device); + COMRelease(m_commandQueue); + COMRelease(m_rtvHeap); + COMRelease(m_dsvHeap); + COMRelease(m_depthSrvHeap); + COMRelease(m_commandAllocators, m_frameCount); + + COMRelease(m_fence); + CloseHandle(m_fenceEvent); + + COMRelease(m_commandList); + + m_dynamicHeapCbvSrvUav.release(); + + appGraphReleaseProfiler(m_profiler); + m_profiler = nullptr; +} + +AppGraphCtx* AppGraphCtxCreateD3D12(int deviceID) +{ + AppGraphCtxD3D12* context = new AppGraphCtxD3D12; + + HRESULT hr = S_OK; + +#if defined(_DEBUG) + // Enable the D3D12 debug layer. + { + ID3D12Debug* debugController; + if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) + { + debugController->EnableDebugLayer(); + } + COMRelease(debugController); + } +#endif + + UINT debugFlags = 0; +#ifdef _DEBUG + debugFlags |= DXGI_CREATE_FACTORY_DEBUG; +#endif + + // enumerate devices + IDXGIFactory4* pFactory = NULL; + CreateDXGIFactory2(debugFlags, IID_PPV_ARGS(&pFactory)); + IDXGIAdapter1* pAdapterTemp = NULL; + IDXGIAdapter1* pAdapter = NULL; + DXGI_ADAPTER_DESC1 adapterDesc; + int adapterIdx = 0; + while (S_OK == pFactory->EnumAdapters1(adapterIdx, &pAdapterTemp)) + { + pAdapterTemp->GetDesc1(&adapterDesc); + + context->m_dedicatedVideoMemory = (size_t)adapterDesc.DedicatedVideoMemory; + + if (deviceID == adapterIdx) + { + pAdapter = pAdapterTemp; + break; + } + else + { + pAdapterTemp->Release(); + } + adapterIdx++; + } + + // create device + if (hr = D3D12CreateDevice(pAdapter, D3D_FEATURE_LEVEL_11_0, __uuidof(ID3D12Device), (void**)&context->m_device)) + { + delete context; + return nullptr; + } + + // to disable annoying warning +#if 0 + context->m_device->SetStablePowerState(TRUE); +#endif + + // create command queue + { + D3D12_COMMAND_QUEUE_DESC desc; + desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; + desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL; + desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; + desc.NodeMask = 0; + + if (hr = context->m_device->CreateCommandQueue(&desc, IID_PPV_ARGS(&context->m_commandQueue))) + { + delete context; + return nullptr; + } + } + + // cleanup adapter and factory + COMRelease(pAdapter); + COMRelease(pFactory); + + // create RTV descriptor heap + { + D3D12_DESCRIPTOR_HEAP_DESC desc = {}; + desc.NumDescriptors = context->m_renderTargetCount; + desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + if (hr = context->m_device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&context->m_rtvHeap))) + { + delete context; + return nullptr; + } + context->m_rtvDescriptorSize = context->m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); + } + + // create DSV descriptor heap + { + D3D12_DESCRIPTOR_HEAP_DESC desc = {}; + desc.NumDescriptors = 1; + desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; + desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + if (hr = context->m_device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&context->m_dsvHeap))) + { + delete context; + return nullptr; + } + } + + // create depth SRV descriptor heap + { + D3D12_DESCRIPTOR_HEAP_DESC desc = {}; + desc.NumDescriptors = 1; + desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + if (hr = context->m_device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&context->m_depthSrvHeap))) + { + delete context; + return nullptr; + } + } + + // Create per frame resources + { + for (UINT idx = 0; idx < context->m_frameCount; idx++) + { + if (hr = context->m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&context->m_commandAllocators[idx]))) + { + delete context; + return nullptr; + } + } + } + + // create dynamic heap + { + context->m_dynamicHeapCbvSrvUav.init(context->m_device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 256u * 1024u); + } + + // Create command list and close it + { + if (hr = context->m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, + context->m_commandAllocators[context->m_frameIndex], nullptr, IID_PPV_ARGS(&context->m_commandList)) + ) + { + delete context; + return nullptr; + } + context->m_commandList->Close(); + } + + // create synchronization objects + { + if (hr = context->m_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&context->m_fence))) + { + delete context; + return nullptr; + } + + context->m_fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); + if (context->m_fenceEvent == nullptr) + { + delete context; + return nullptr; + } + } + + return cast_from_AppGraphCtxD3D12(context); +} + + +void AppGraphCtxInitRenderTargetD3D12(AppGraphCtx* contextIn, SDL_Window* window, bool fullscreen, int numMSAASamples) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + + HWND hWnd = nullptr; + // get Windows handle to this SDL window + SDL_SysWMinfo winInfo; + SDL_VERSION(&winInfo.version); + if (SDL_GetWindowWMInfo(window, &winInfo)) + { + if (winInfo.subsystem == SDL_SYSWM_WINDOWS) + { + hWnd = winInfo.info.win.window; + } + } + context->m_hWnd = hWnd; + context->m_fullscreen = fullscreen; + + HRESULT hr = S_OK; + + UINT debugFlags = 0; +#ifdef _DEBUG + debugFlags |= DXGI_CREATE_FACTORY_DEBUG; +#endif + + // enumerate devices + IDXGIFactory4* pFactory = NULL; + CreateDXGIFactory2(debugFlags, IID_PPV_ARGS(&pFactory)); + + // create the swap chain + for (int i = 0; i < 2; i++) + { + DXGI_SWAP_CHAIN_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + desc.BufferCount = context->m_renderTargetCount; + desc.BufferDesc.Width = context->m_winW; + desc.BufferDesc.Height = context->m_winH; + desc.BufferDesc.Format = context->m_rtv_format; // DXGI_FORMAT_R8G8B8A8_UNORM; + desc.BufferDesc.RefreshRate.Numerator = 0; + desc.BufferDesc.RefreshRate.Denominator = 0; + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + desc.OutputWindow = context->m_hWnd; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Windowed = context->m_fullscreen ? FALSE : TRUE; + desc.Flags = context->m_fullscreen ? 0u : DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; + + context->m_current_rtvDesc.Format = context->m_rtv_format; + context->m_current_rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; + context->m_current_rtvDesc.Texture2D.MipSlice = 0u; + context->m_current_rtvDesc.Texture2D.PlaneSlice = 0u; + + hr = pFactory->CreateSwapChain(context->m_commandQueue, &desc, (IDXGISwapChain**)&context->m_swapChain); + + if(hr != S_OK) + { + COMRelease(context->m_swapChain); + context->m_fullscreen = false; + continue; + } + + if (!context->m_fullscreen) + { + context->m_swapChainWaitableObject = context->m_swapChain->GetFrameLatencyWaitableObject(); + context->m_swapChain->SetMaximumFrameLatency(context->m_renderTargetCount - 2); + } + else + { + hr = context->m_swapChain->SetFullscreenState(true, nullptr); + if (hr != S_OK) + { + COMRelease(context->m_swapChain); + context->m_fullscreen = false; + continue; + } + DXGI_SWAP_CHAIN_DESC desc = {}; + context->m_swapChain->GetDesc(&desc); + + context->m_winW = desc.BufferDesc.Width; + context->m_winH = desc.BufferDesc.Height; + } + + context->m_frameIndex = context->m_swapChain->GetCurrentBackBufferIndex(); + break; + } + + // configure scissor and viewport + { + context->m_viewport.Width = float(context->m_winW); + context->m_viewport.Height = float(context->m_winH); + context->m_viewport.MaxDepth = 1.f; + + context->m_scissorRect.right = context->m_winW; + context->m_scissorRect.bottom = context->m_winH; + } + + COMRelease(pFactory); + + // create per render target resources + { + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = context->m_rtvHeap->GetCPUDescriptorHandleForHeapStart(); + + for (UINT idx = 0; idx < context->m_renderTargetCount; idx++) + { + ComPtr backBuffer; + if (hr = context->m_swapChain->GetBuffer(idx, IID_PPV_ARGS(&backBuffer))) + { + return; + } + context->m_backBuffers[idx].setDebugName(L"Backbuffer"); + context->m_backBuffers[idx].setResource(backBuffer.Get(), D3D12_RESOURCE_STATE_COMMON); + // Assume they are the same thing for now... + context->m_renderTargets[idx] = &context->m_backBuffers[idx]; + + // If we are multi-sampling - create a render target separate from the back buffer + if (context->m_numMsaaSamples > 1) + { + D3D12_HEAP_PROPERTIES heapProps = {}; + heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; + D3D12_RESOURCE_DESC desc = backBuffer->GetDesc(); + + DXGI_FORMAT resourceFormat; + + if (desc.Format == DXGI_FORMAT_R32_FLOAT || desc.Format == DXGI_FORMAT_D32_FLOAT) + { + resourceFormat = DXGI_FORMAT_R32_TYPELESS; + } + else if (desc.Format == DXGI_FORMAT_D24_UNORM_S8_UINT) + { + resourceFormat = DXGI_FORMAT_R24G8_TYPELESS; + } + else + { + resourceFormat = desc.Format; + } + + DXGI_FORMAT targetFormat = nvidia::Common::DxFormatUtil::calcFormat(nvidia::Common::DxFormatUtil::USAGE_TARGET, resourceFormat); + + // Set the target format + context->m_targetInfo.m_renderTargetFormats[0] = targetFormat; + + D3D12_CLEAR_VALUE clearValue = {}; + clearValue.Format = targetFormat; + + desc.Format = resourceFormat; + desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + desc.SampleDesc.Count = context->m_targetInfo.m_numSamples; + desc.SampleDesc.Quality = context->m_targetInfo.m_sampleQuality; + desc.Alignment = 0; + + context->m_renderTargetResources[idx].initCommitted(context->m_device, heapProps, D3D12_HEAP_FLAG_NONE, desc, D3D12_RESOURCE_STATE_RENDER_TARGET, &clearValue); + context->m_renderTargets[idx] = &context->m_renderTargetResources[idx]; + + context->m_renderTargetResources[idx].setDebugName(L"Render Target"); + } + + context->m_device->CreateRenderTargetView(*context->m_renderTargets[idx], nullptr, rtvHandle); + rtvHandle.ptr += context->m_rtvDescriptorSize; + } + } + + // create the depth stencil + { + D3D12_HEAP_PROPERTIES heapProps = {}; + heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; + heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapProps.CreationNodeMask = 0u; + heapProps.VisibleNodeMask = 0u; + + D3D12_RESOURCE_DESC texDesc = {}; + texDesc.MipLevels = 1u; + texDesc.Format = context->m_depth_format; // DXGI_FORMAT_R32_TYPELESS; // DXGI_FORMAT_R24G8_TYPELESS + texDesc.Width = context->m_winW; + texDesc.Height = context->m_winH; + texDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL /*| D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE*/; + texDesc.DepthOrArraySize = 1u; + texDesc.SampleDesc.Count = context->m_targetInfo.m_numSamples; + texDesc.SampleDesc.Quality = context->m_targetInfo.m_sampleQuality; + texDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + + D3D12_CLEAR_VALUE clearValue; + clearValue.Format = context->m_dsv_format; // DXGI_FORMAT_D32_FLOAT; + clearValue.DepthStencil.Depth = 1.f; + clearValue.DepthStencil.Stencil = 0; + + if (hr = context->m_device->CreateCommittedResource( + &heapProps, + D3D12_HEAP_FLAG_NONE, + &texDesc, + D3D12_RESOURCE_STATE_DEPTH_WRITE, + &clearValue, + IID_PPV_ARGS(&context->m_depthStencil) + )) + { + return; + } + + // create the depth stencil view + D3D12_DEPTH_STENCIL_VIEW_DESC viewDesc = {}; + viewDesc.Format = context->m_dsv_format; // DXGI_FORMAT_D32_FLOAT; + viewDesc.ViewDimension = (context->m_numMsaaSamples>1) ? D3D12_DSV_DIMENSION_TEXTURE2DMS : D3D12_DSV_DIMENSION_TEXTURE2D; + viewDesc.Flags = D3D12_DSV_FLAG_NONE; + viewDesc.Texture2D.MipSlice = 0; + + context->m_current_dsvDesc = viewDesc; + + context->m_device->CreateDepthStencilView(context->m_depthStencil, &viewDesc, context->m_dsvHeap->GetCPUDescriptorHandleForHeapStart()); + + context->m_targetInfo.m_depthStencilFormat = context->m_dsv_format; + } +} + +bool AppGraphCtxUpdateSizeD3D12(AppGraphCtx* contextIn, SDL_Window* window, bool fullscreen, int numMSAASamples) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + + bool sizeChanged = false; + + // sync with window + { + HWND hWnd = nullptr; + // get Windows handle to this SDL window + SDL_SysWMinfo winInfo; + SDL_VERSION(&winInfo.version); + if (SDL_GetWindowWMInfo(window, &winInfo)) + { + if (winInfo.subsystem == SDL_SYSWM_WINDOWS) + { + hWnd = winInfo.info.win.window; + } + } + context->m_hWnd = hWnd; + context->m_fullscreen = fullscreen; + + HRESULT hr = S_OK; + + RECT rc; + GetClientRect(context->m_hWnd, &rc); + UINT width = rc.right - rc.left; + UINT height = rc.bottom - rc.top; + + if (context->m_winW != width || context->m_winH != height) + { + context->m_winW = width; + context->m_winH = height; + sizeChanged = true; + context->m_valid = (context->m_winW != 0 && context->m_winH != 0); + } + } + + context->m_numMsaaSamples = numMSAASamples; + context->m_targetInfo.m_numSamples = numMSAASamples; + + if (sizeChanged) + { + AppGraphCtxReleaseRenderTargetD3D12(cast_from_AppGraphCtxD3D12(context)); + } + if (sizeChanged && context->m_valid) + { + AppGraphCtxInitRenderTargetD3D12(cast_from_AppGraphCtxD3D12(context), window, fullscreen, numMSAASamples); + } + + return context->m_valid; +} + +void AppGraphCtxReleaseRenderTargetD3D12(AppGraphCtx* contextIn) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + + if (context->m_swapChain == nullptr) + { + return; + } + + // need to make sure the pipeline is flushed + for (UINT i = 0; i < context->m_frameCount; i++) + { + // check dependencies + UINT64 fenceCompleted = context->m_fence->GetCompletedValue(); + if (fenceCompleted < context->m_fenceValues[i]) + { + context->m_fence->SetEventOnCompletion(context->m_fenceValues[i], context->m_fenceEvent); + WaitForSingleObjectEx(context->m_fenceEvent, INFINITE, FALSE); + } + } + + BOOL bFullscreen = FALSE; + context->m_swapChain->GetFullscreenState(&bFullscreen, nullptr); + if (bFullscreen == TRUE) context->m_swapChain->SetFullscreenState(FALSE, nullptr); + + COMRelease(context->m_swapChain); + COMRelease(context->m_depthStencil); + + for(int i=0;i!= context->m_renderTargetCount; i++) + context->m_renderTargets[i]->setResourceNull(); + + context->m_valid = false; + context->m_winW = 0u; + context->m_winH = 0u; +} + +void AppGraphCtxReleaseD3D12(AppGraphCtx* context) +{ + if (context == nullptr) return; + + delete cast_to_AppGraphCtxD3D12(context); +} + +void AppGraphCtxFrameStartD3D12(AppGraphCtx* contextIn, AppGraphColor clearColor) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + + // Get back render target index + context->m_renderTargetIndex = context->m_swapChain->GetCurrentBackBufferIndex(); + + // check dependencies + UINT64 fenceCompleted = context->m_fence->GetCompletedValue(); + if (fenceCompleted < context->m_fenceValues[context->m_frameIndex]) + { + context->m_fence->SetEventOnCompletion(context->m_fenceValues[context->m_frameIndex], context->m_fenceEvent); + WaitForSingleObjectEx(context->m_fenceEvent, INFINITE, FALSE); + } + + // The fence ID associated with completion of this frame + context->m_thisFrameFenceID = context->m_frameID + 1; + context->m_lastFenceComplete = context->m_fence->GetCompletedValue(); + + // reset this frame's command allocator + context->m_commandAllocators[context->m_frameIndex]->Reset(); + + // reset command list with this frame's allocator + context->m_commandList->Reset(context->m_commandAllocators[context->m_frameIndex], nullptr); + + appGraphProfilerD3D12FrameBegin(context->m_profiler); + + context->m_commandList->RSSetViewports(1, &context->m_viewport); + context->m_commandList->RSSetScissorRects(1, &context->m_scissorRect); + + { + nvidia::Common::Dx12BarrierSubmitter submitter(context->m_commandList); + context->m_renderTargets[context->m_renderTargetIndex]->transition(D3D12_RESOURCE_STATE_RENDER_TARGET, submitter); + } + + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = context->m_rtvHeap->GetCPUDescriptorHandleForHeapStart(); + rtvHandle.ptr += context->m_renderTargetIndex * context->m_rtvDescriptorSize; + + D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = context->m_dsvHeap->GetCPUDescriptorHandleForHeapStart(); + context->m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle); + + context->m_commandList->ClearRenderTargetView(rtvHandle, &clearColor.r, 0, nullptr); + context->m_commandList->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.f, 0, 0, nullptr); + + /// to simplify interop implementation + context->m_current_renderTarget = context->m_renderTargets[context->m_renderTargetIndex]->getResource(); + context->m_current_rtvHandle = rtvHandle; + context->m_current_dsvHandle = dsvHandle; + context->m_current_depth_srvHandle = context->m_depthSrvHeap->GetCPUDescriptorHandleForHeapStart(); +} + +void AppGraphCtxFramePresentD3D12(AppGraphCtx* contextIn, bool fullsync) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + + // check if now is good time to present + bool shouldPresent = context->m_fullscreen ? true : WaitForSingleObjectEx(context->m_swapChainWaitableObject, 0, TRUE) != WAIT_TIMEOUT; + if (shouldPresent) + { + context->m_swapChain->Present(fullsync, 0); + context->m_renderTargetID++; + } + + appGraphProfilerD3D12FrameEnd(context->m_profiler); + + // signal for this frame id + context->m_frameID++; + context->m_fenceValues[context->m_frameIndex] = context->m_frameID; + context->m_commandQueue->Signal(context->m_fence, context->m_frameID); + + // increment frame index after signal + context->m_frameIndex = (context->m_frameIndex + 1) % context->m_frameCount; + + if (fullsync) + { + // check dependencies + for (int frameIndex = 0; frameIndex < context->m_frameCount; frameIndex++) + { + UINT64 fenceCompleted = context->m_fence->GetCompletedValue(); + if (fenceCompleted < context->m_fenceValues[frameIndex]) + { + context->m_fence->SetEventOnCompletion(context->m_fenceValues[frameIndex], context->m_fenceEvent); + WaitForSingleObjectEx(context->m_fenceEvent, INFINITE, FALSE); + } + } + } +} + +void AppGraphCtxWaitForFramesD3D12(AppGraphCtx* contextIn, unsigned int maxFramesInFlight) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + + unsigned int framesActive = maxFramesInFlight; + while (framesActive >= maxFramesInFlight) + { + // reset count each cycle, and get latest fence value + framesActive = 0u; + UINT64 fenceCompleted = context->m_fence->GetCompletedValue(); + + // determine how many frames are in flight + for (int frameIndex = 0; frameIndex < context->m_frameCount; frameIndex++) + { + if (fenceCompleted < context->m_fenceValues[frameIndex]) + { + framesActive++; + } + } + + if (framesActive >= maxFramesInFlight) + { + // find the active frame with the lowest fence ID + UINT64 minFenceID = 0; + unsigned int minFrameIdx = 0; + for (int frameIndex = 0; frameIndex < context->m_frameCount; frameIndex++) + { + if (fenceCompleted < context->m_fenceValues[frameIndex]) + { + if (minFenceID == 0) + { + minFenceID = context->m_fenceValues[frameIndex]; + minFrameIdx = frameIndex; + } + else if (context->m_fenceValues[frameIndex] < minFenceID) + { + minFenceID = context->m_fenceValues[frameIndex]; + minFrameIdx = frameIndex; + } + } + } + // Wait for min frame + { + unsigned int frameIndex = minFrameIdx; + fenceCompleted = context->m_fence->GetCompletedValue(); + if (fenceCompleted < context->m_fenceValues[frameIndex]) + { + context->m_fence->SetEventOnCompletion(context->m_fenceValues[frameIndex], context->m_fenceEvent); + WaitForSingleObjectEx(context->m_fenceEvent, INFINITE, FALSE); + } + } + } + } +} + +void AppGraphCtxProfileEnableD3D12(AppGraphCtx* contextIn, bool enabled) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + appGraphProfilerD3D12Enable(context->m_profiler, enabled); +} + +void AppGraphCtxProfileBeginD3D12(AppGraphCtx* contextIn, const char* label) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + appGraphProfilerD3D12Begin(context->m_profiler, label); +} + +void AppGraphCtxProfileEndD3D12(AppGraphCtx* contextIn, const char* label) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + appGraphProfilerD3D12End(context->m_profiler, label); +} + +bool AppGraphCtxProfileGetD3D12(AppGraphCtx* contextIn, const char** plabel, float* cpuTime, float* gpuTime, int index) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + return appGraphProfilerD3D12Get(context->m_profiler, plabel, cpuTime, gpuTime, index); +} + +// ******************************* Dynamic descriptor heap ****************************** + +void AppDynamicDescriptorHeapD3D12::init(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, UINT minHeapSize) +{ + m_device = device; + m_heapSize = minHeapSize; + m_startSlot = 0u; + m_descriptorSize = m_device->GetDescriptorHandleIncrementSize(heapType); + + D3D12_DESCRIPTOR_HEAP_DESC desc = {}; + desc.NumDescriptors = m_heapSize; + desc.Type = heapType; + desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + m_device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_heap)); +} + +void AppDynamicDescriptorHeapD3D12::release() +{ + m_device = nullptr; + COMRelease(m_heap); + m_descriptorSize = 0u; + m_startSlot = 0u; + m_heapSize = 0u; +} + +AppDescriptorReserveHandleD3D12 AppDynamicDescriptorHeapD3D12::reserveDescriptors(UINT numDescriptors, UINT64 lastFenceCompleted, UINT64 nextFenceValue) +{ + UINT endSlot = m_startSlot + numDescriptors; + if (endSlot >= m_heapSize) + { + m_startSlot = 0u; + endSlot = numDescriptors; + } + D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle; + D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle; + cpuHandle = m_heap->GetCPUDescriptorHandleForHeapStart(); + cpuHandle.ptr += m_startSlot * m_descriptorSize; + gpuHandle = m_heap->GetGPUDescriptorHandleForHeapStart(); + gpuHandle.ptr += m_startSlot * m_descriptorSize; + + // advance start slot + m_startSlot = endSlot; + + AppDescriptorReserveHandleD3D12 handle = {}; + handle.heap = m_heap; + handle.descriptorSize = m_descriptorSize; + handle.cpuHandle = cpuHandle; + handle.gpuHandle = gpuHandle; + return handle; +} + +// ******************************* Profiler ********************************* + +namespace +{ + struct TimerCPU + { + LARGE_INTEGER oldCount; + LARGE_INTEGER count; + LARGE_INTEGER freq; + TimerCPU() + { + QueryPerformanceCounter(&count); + QueryPerformanceFrequency(&freq); + oldCount = count; + } + double getDeltaTime() + { + QueryPerformanceCounter(&count); + double dt = double(count.QuadPart - oldCount.QuadPart) / double(freq.QuadPart); + oldCount = count; + return dt; + } + }; + + struct TimerGPU + { + ID3D12QueryHeap* m_queryHeap = nullptr; + ID3D12Resource* m_queryReadback = nullptr; + UINT64 m_queryFrequency = 0; + UINT64 m_queryReadbackFenceVal = ~0llu; + + TimerGPU() {} + ~TimerGPU() + { + COMRelease(m_queryHeap); + COMRelease(m_queryReadback); + } + }; + + struct Timer + { + TimerCPU m_cpu; + TimerGPU m_gpu; + + const char* m_label = nullptr; + float m_cpuTime = 0.f; + float m_gpuTime = 0.f; + + Timer() {} + ~Timer() {} + }; + + struct TimerValue + { + const char* m_label = nullptr; + float m_cpuTime = 0.f; + float m_gpuTime = 0.f; + + struct Stat + { + float m_time = 0.f; + float m_maxTime = 0.f; + float m_maxTimeAge = 0.f; + + float m_smoothTime = 0.f; + float m_smoothTimeSum = 0.f; + float m_smoothTimeCount = 0.f; + + Stat() {} + void push(float time) + { + m_time = time; + + if (m_time > m_maxTime) + { + m_maxTime = m_time; + m_maxTimeAge = 0.f; + } + + if (fabsf(m_time - m_maxTime) < 0.25f * m_maxTime) + { + m_smoothTimeSum += m_time; + m_smoothTimeCount += 1.f; + m_smoothTimeSum *= 0.98f; + m_smoothTimeCount *= 0.98f; + m_smoothTime = m_smoothTimeSum / m_smoothTimeCount; + } + } + + float pull(float frameTime) + { + m_maxTimeAge += frameTime; + + if (m_maxTimeAge > 1.f) + { + m_maxTimeAge = 0.f; + m_maxTime = m_time; + m_smoothTimeSum = 0.f; + m_smoothTimeCount = 0.f; + } + return m_smoothTime; + } + }; + + Stat m_cpu; + Stat m_gpu; + + void push(float cpuTime, float gpuTime) + { + m_cpu.push(cpuTime); + m_gpu.push(gpuTime); + } + + void pull(float frameTime) + { + m_cpuTime = m_cpu.pull(frameTime); + m_gpuTime = m_gpu.pull(frameTime); + } + }; + + struct HeapPropsReadback : public D3D12_HEAP_PROPERTIES + { + HeapPropsReadback() + { + Type = D3D12_HEAP_TYPE_READBACK; + CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + CreationNodeMask = 0u; + VisibleNodeMask = 0u; + } + }; + struct ResourceDescBuffer : public D3D12_RESOURCE_DESC + { + ResourceDescBuffer(UINT64 size) + { + Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + Alignment = 0u; + Width = size; + Height = 1u; + DepthOrArraySize = 1u; + MipLevels = 1; + Format = DXGI_FORMAT_UNKNOWN; + SampleDesc.Count = 1u; + SampleDesc.Quality = 0u; + Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + Flags = D3D12_RESOURCE_FLAG_NONE; + } + }; +} + +struct AppGraphProfilerD3D12 +{ + AppGraphCtxD3D12* m_context; + + int m_state = 0; + bool m_enabled = false; + + TimerCPU m_frameTimer; + float m_frameTime = 0.f; + + static const int m_timersCap = 64; + Timer m_timers[m_timersCap]; + int m_timersSize = 0; + + TimerValue m_timerValues[m_timersCap]; + int m_timerValuesSize = 0; + + AppGraphProfilerD3D12(AppGraphCtx* context); + ~AppGraphProfilerD3D12(); +}; + +AppGraphProfilerD3D12::AppGraphProfilerD3D12(AppGraphCtx* context) : m_context(cast_to_AppGraphCtxD3D12(context)) +{ +} + +AppGraphProfilerD3D12::~AppGraphProfilerD3D12() +{ +} + +AppGraphProfilerD3D12* appGraphCreateProfilerD3D12(AppGraphCtx* ctx) +{ + return new AppGraphProfilerD3D12(ctx); +} + +void appGraphReleaseProfiler(AppGraphProfilerD3D12* profiler) +{ + delete profiler; +} + +void appGraphProfilerD3D12FrameBegin(AppGraphProfilerD3D12* p) +{ + p->m_frameTime = (float)p->m_frameTimer.getDeltaTime(); + + if (p->m_state == 0 && p->m_enabled) + { + p->m_timersSize = 0; + + p->m_state = 1; + } +} + +void appGraphProfilerD3D12FrameEnd(AppGraphProfilerD3D12* p) +{ + if (p->m_state == 1) + { + p->m_state = 2; + } +} + +void appGraphProfilerD3D12Enable(AppGraphProfilerD3D12* p, bool enabled) +{ + p->m_enabled = enabled; +} + +void appGraphProfilerD3D12Begin(AppGraphProfilerD3D12* p, const char* label) +{ + if (p->m_state == 1 && p->m_timersSize < p->m_timersCap) + { + auto& timer = p->m_timers[p->m_timersSize++]; + timer.m_label = label; + timer.m_cpu.getDeltaTime(); + + auto device = p->m_context->m_device; + + if (timer.m_gpu.m_queryHeap == nullptr) + { + D3D12_QUERY_HEAP_DESC queryDesc = {}; + queryDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP; + queryDesc.Count = 2; + queryDesc.NodeMask = 0; + + device->CreateQueryHeap(&queryDesc, IID_PPV_ARGS(&timer.m_gpu.m_queryHeap)); + + HeapPropsReadback readbackProps; + ResourceDescBuffer resDesc(2 * sizeof(UINT64)); + resDesc.Flags = D3D12_RESOURCE_FLAG_NONE; + + device->CreateCommittedResource(&readbackProps, D3D12_HEAP_FLAG_NONE, + &resDesc, D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, IID_PPV_ARGS(&timer.m_gpu.m_queryReadback)); + } + + p->m_context->m_commandQueue->GetTimestampFrequency(&timer.m_gpu.m_queryFrequency); + + p->m_context->m_commandList->EndQuery(timer.m_gpu.m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0); + } +} + +void appGraphProfilerD3D12End(AppGraphProfilerD3D12* p, const char* label) +{ + if (p->m_state == 1) + { + Timer* timer = nullptr; + for (int i = 0; i < p->m_timersSize; i++) + { + if (strcmp(p->m_timers[i].m_label, label) == 0) + { + timer = &p->m_timers[i]; + break; + } + } + if (timer) + { + p->m_context->m_commandList->EndQuery(timer->m_gpu.m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 1); + + p->m_context->m_commandList->ResolveQueryData(timer->m_gpu.m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0, 2, timer->m_gpu.m_queryReadback, 0u); + + timer->m_gpu.m_queryReadbackFenceVal = p->m_context->m_thisFrameFenceID; + + timer->m_cpuTime = (float)timer->m_cpu.getDeltaTime(); + } + } +} + +bool appGraphProfilerD3D12Flush(AppGraphProfilerD3D12* p) +{ + if (p->m_state == 2) + { + for (int i = 0; i < p->m_timersSize; i++) + { + Timer& timer = p->m_timers[i]; + + if (timer.m_gpu.m_queryReadbackFenceVal > p->m_context->m_lastFenceComplete) + { + return false; + } + + UINT64 tsBegin, tsEnd; + { + void* data; + // Read range is nullptr, meaning full read access + D3D12_RANGE readRange; + readRange.Begin = 0u; + readRange.End = 2 * sizeof(UINT64); + timer.m_gpu.m_queryReadback->Map(0u, &readRange, &data); + if (data) + { + auto mapped = (UINT64*)data; + tsBegin = mapped[0]; + tsEnd = mapped[1]; + + D3D12_RANGE writeRange{}; + timer.m_gpu.m_queryReadback->Unmap(0u, &writeRange); + } + } + + timer.m_gpuTime = float(tsEnd - tsBegin) / float(timer.m_gpu.m_queryFrequency); + + // update TimerValue + int j = 0; + for (; j < p->m_timerValuesSize; j++) + { + TimerValue& value = p->m_timerValues[j]; + if (strcmp(value.m_label, timer.m_label) == 0) + { + value.push(timer.m_cpuTime, timer.m_gpuTime); + break; + } + } + if (j >= p->m_timerValuesSize && p->m_timerValuesSize < p->m_timersCap) + { + TimerValue& value = p->m_timerValues[p->m_timerValuesSize++]; + value.m_label = timer.m_label; + value.push(timer.m_cpuTime, timer.m_gpuTime); + } + } + + p->m_state = 0; + } + return false; +} + +bool appGraphProfilerD3D12Get(AppGraphProfilerD3D12* p, const char** plabel, float* cpuTime, float* gpuTime, int index) +{ + appGraphProfilerD3D12Flush(p); + { + if (index < p->m_timerValuesSize) + { + TimerValue& timer = p->m_timerValues[index]; + + timer.pull(p->m_frameTime); + + if (plabel) *plabel = timer.m_label; + if (cpuTime) *cpuTime = timer.m_cpuTime; + if (gpuTime) *gpuTime = timer.m_gpuTime; + + return true; + } + } + return false; +} + +size_t AppGraphCtxDedicatedVideoMemoryD3D12(AppGraphCtx* contextIn) +{ + auto context = cast_to_AppGraphCtxD3D12(contextIn); + return context->m_dedicatedVideoMemory; +} + +void AppGraphCtxBeginGpuWork(AppGraphCtxD3D12* context) +{ + if (context->m_commandListOpenCount == 0) + { + // It's not open so open it + ID3D12GraphicsCommandList* commandList = context->m_commandList; + + commandList->Reset(context->m_commandAllocators[context->m_frameIndex], nullptr); + } + context->m_commandListOpenCount++; +} + +void AppGraphCtxEndGpuWork(AppGraphCtxD3D12* context) +{ + assert(context->m_commandListOpenCount); + ID3D12GraphicsCommandList* commandList = context->m_commandList; + + NV_CORE_ASSERT_VOID_ON_FAIL(commandList->Close()); + { + // Execute the command list. + ID3D12CommandList* commandLists[] = { commandList }; + context->m_commandQueue->ExecuteCommandLists(_countof(commandLists), commandLists); + } + + AppGraphCtxWaitForGPU(context); + + // Dec the count. If >0 it needs to still be open + --context->m_commandListOpenCount; + + // Reopen if needs to be open + if (context->m_commandListOpenCount) + { + // Reopen + context->m_commandList->Reset(context->m_commandAllocators[context->m_frameIndex], nullptr); + } +} + +void AppGraphCtxPrepareRenderTarget(AppGraphCtxD3D12* context) +{ + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = context->m_rtvHeap->GetCPUDescriptorHandleForHeapStart(); + rtvHandle.ptr += context->m_renderTargetIndex * context->m_rtvDescriptorSize; + + D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = context->m_dsvHeap->GetCPUDescriptorHandleForHeapStart(); + context->m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle); + + // Set necessary state. + context->m_commandList->RSSetViewports(1, &context->m_viewport); + context->m_commandList->RSSetScissorRects(1, &context->m_scissorRect); +} + +void AppGraphCtxWaitForGPU(AppGraphCtxD3D12* context) +{ + context->m_frameID++; + context->m_fenceValues[context->m_frameIndex] = context->m_frameID; + + context->m_commandQueue->Signal(context->m_fence, context->m_frameID); + + for (int frameIndex = 0; frameIndex < context->m_frameCount; frameIndex++) + { + UINT64 fenceCompleted = context->m_fence->GetCompletedValue(); + if (fenceCompleted < context->m_fenceValues[frameIndex]) + { + context->m_fence->SetEventOnCompletion(context->m_fenceValues[frameIndex], context->m_fenceEvent); + WaitForSingleObjectEx(context->m_fenceEvent, INFINITE, FALSE); + } + } +} \ No newline at end of file diff --git a/demo/d3d12/appD3D12Ctx.h b/demo/d3d12/appD3D12Ctx.h new file mode 100644 index 0000000..4f6ba77 --- /dev/null +++ b/demo/d3d12/appD3D12Ctx.h @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#ifndef APP_D3D12_CTX_H +#define APP_D3D12_CTX_H + +#include "../d3d/appGraphCtx.h" +#include "NvCoDx12Resource.h" +#include "NvCoDx12Handle.h" + +struct IDXGISwapChain3; + +struct AppGraphProfilerD3D12; + +struct AppDescriptorReserveHandleD3D12 +{ + ID3D12DescriptorHeap* heap; + UINT descriptorSize; + D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle; + D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle; +}; + +struct AppDynamicDescriptorHeapD3D12 +{ + ID3D12Device* m_device = nullptr; + ID3D12DescriptorHeap* m_heap = nullptr; + UINT m_descriptorSize = 0u; + UINT m_startSlot = 0u; + UINT m_heapSize = 0u; + + void init(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, UINT minHeapSize); + void release(); + AppDescriptorReserveHandleD3D12 reserveDescriptors(UINT numDescriptors, UINT64 lastFenceCompleted, UINT64 nextFenceValue); + + AppDynamicDescriptorHeapD3D12() {} + ~AppDynamicDescriptorHeapD3D12() { release(); } +}; + +struct AppGraphCtxD3D12 +{ + HWND m_hWnd = nullptr; + + int m_winW = 0; + int m_winH = 0; + bool m_fullscreen = false; + bool m_valid = false; + + size_t m_dedicatedVideoMemory = 0u; + + // D3D12 non-replicated objects + D3D12_VIEWPORT m_viewport = {}; + D3D12_RECT m_scissorRect = {}; + ID3D12Device* m_device = nullptr; + ID3D12CommandQueue* m_commandQueue = nullptr; + + // D3D12 render target pipeline + static const UINT m_renderTargetCount = 6u; + UINT m_renderTargetIndex = 0u; + UINT64 m_renderTargetID = 0u; + IDXGISwapChain3* m_swapChain = nullptr; + HANDLE m_swapChainWaitableObject = nullptr; + ID3D12DescriptorHeap* m_rtvHeap = nullptr; + UINT m_rtvDescriptorSize = 0u; + nvidia::Common::Dx12Resource m_backBuffers[m_renderTargetCount]; + nvidia::Common::Dx12Resource m_renderTargetResources[m_renderTargetCount]; + nvidia::Common::Dx12Resource* m_renderTargets[m_renderTargetCount]; + + ID3D12Resource* m_depthStencil = nullptr; + ID3D12DescriptorHeap* m_dsvHeap = nullptr; + ID3D12DescriptorHeap* m_depthSrvHeap = nullptr; + + // D3D12 frame pipeline objects + static const UINT m_frameCount = 8u; + UINT m_frameIndex = 0u; + UINT64 m_frameID = 0u; + ID3D12CommandAllocator* m_commandAllocators[m_frameCount]; + + // D3D12 synchronization objects + ID3D12Fence* m_fence = nullptr; + HANDLE m_fenceEvent = 0u; + UINT64 m_fenceValues[m_frameCount]; + + // fence values for library synchronization + UINT64 m_lastFenceComplete = 1u; + UINT64 m_thisFrameFenceID = 2u; + + // D3D12 per asset objects + ID3D12GraphicsCommandList* m_commandList = nullptr; + UINT m_commandListOpenCount = 0; + ID3D12Resource* m_current_renderTarget = nullptr; + D3D12_CPU_DESCRIPTOR_HANDLE m_current_rtvHandle; + D3D12_RENDER_TARGET_VIEW_DESC m_current_rtvDesc; + D3D12_CPU_DESCRIPTOR_HANDLE m_current_dsvHandle; + D3D12_DEPTH_STENCIL_VIEW_DESC m_current_dsvDesc; + D3D12_CPU_DESCRIPTOR_HANDLE m_current_depth_srvHandle; + D3D12_SHADER_RESOURCE_VIEW_DESC m_current_depth_srvDesc; + + DXGI_FORMAT m_rtv_format = DXGI_FORMAT_R8G8B8A8_UNORM; + DXGI_FORMAT m_dsv_format = DXGI_FORMAT_D32_FLOAT; + DXGI_FORMAT m_depth_srv_format = DXGI_FORMAT_R32_FLOAT; + DXGI_FORMAT m_depth_format = DXGI_FORMAT_R32_TYPELESS; + + UINT m_numMsaaSamples = 1; + + nvidia::Common::Dx12TargetInfo m_targetInfo; + + AppDynamicDescriptorHeapD3D12 m_dynamicHeapCbvSrvUav; + + AppGraphProfilerD3D12* m_profiler = nullptr; + + AppGraphCtxD3D12(); + ~AppGraphCtxD3D12(); +}; + +inline AppGraphCtxD3D12* cast_to_AppGraphCtxD3D12(AppGraphCtx* appctx) +{ + return (AppGraphCtxD3D12*)(appctx); +} + +inline AppGraphCtx* cast_from_AppGraphCtxD3D12(AppGraphCtxD3D12* appctx) +{ + return (AppGraphCtx*)(appctx); +} + +APP_GRAPH_CTX_API AppGraphCtx* AppGraphCtxCreateD3D12(int deviceID); + +APP_GRAPH_CTX_API bool AppGraphCtxUpdateSizeD3D12(AppGraphCtx* context, SDL_Window* window, bool fullscreen, int numMSAASamples); + +APP_GRAPH_CTX_API void AppGraphCtxReleaseRenderTargetD3D12(AppGraphCtx* context); + +APP_GRAPH_CTX_API void AppGraphCtxReleaseD3D12(AppGraphCtx* context); + +APP_GRAPH_CTX_API void AppGraphCtxFrameStartD3D12(AppGraphCtx* context, AppGraphColor clearColor); + +APP_GRAPH_CTX_API void AppGraphCtxFramePresentD3D12(AppGraphCtx* context, bool fullsync); + +APP_GRAPH_CTX_API void AppGraphCtxWaitForFramesD3D12(AppGraphCtx* context, unsigned int maxFramesInFlight); + +APP_GRAPH_CTX_API void AppGraphCtxProfileEnableD3D12(AppGraphCtx* context, bool enabled); + +APP_GRAPH_CTX_API void AppGraphCtxProfileBeginD3D12(AppGraphCtx* context, const char* label); + +APP_GRAPH_CTX_API void AppGraphCtxProfileEndD3D12(AppGraphCtx* context, const char* label); + +APP_GRAPH_CTX_API bool AppGraphCtxProfileGetD3D12(AppGraphCtx* context, const char** plabel, float* cpuTime, float* gpuTime, int index); + +APP_GRAPH_CTX_API size_t AppGraphCtxDedicatedVideoMemoryD3D12(AppGraphCtx* context); + +APP_GRAPH_CTX_API void AppGraphCtxBeginGpuWork(AppGraphCtxD3D12* context); + +APP_GRAPH_CTX_API void AppGraphCtxEndGpuWork(AppGraphCtxD3D12* context); + +APP_GRAPH_CTX_API void AppGraphCtxPrepareRenderTarget(AppGraphCtxD3D12* context); + +APP_GRAPH_CTX_API void AppGraphCtxWaitForGPU(AppGraphCtxD3D12* context); + +/// ScopeGpuWork is used to handle gpu work that must be synchronized with the CPU. +/// It is guaranteed when scope is released the CPU and GPU will sync. NOTE! This means +/// you don't want to do this as part of render/update unless you have to because it will be slow. +struct ScopeGpuWork +{ + inline ScopeGpuWork(AppGraphCtxD3D12* context) : + m_context(context) + { + AppGraphCtxBeginGpuWork(context); + } + inline ~ScopeGpuWork() + { + AppGraphCtxEndGpuWork(m_context); + } +private: + AppGraphCtxD3D12* m_context; +}; +#endif \ No newline at end of file diff --git a/demo/d3d12/bufferD3D12.cpp b/demo/d3d12/bufferD3D12.cpp new file mode 100644 index 0000000..b7954ea --- /dev/null +++ b/demo/d3d12/bufferD3D12.cpp @@ -0,0 +1,118 @@ +/* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. */ + + +#include +#include + +#include "bufferD3D12.h" + +#include + +namespace FlexSample { + +int IndexBufferD3D12::init(const RenderStateD3D12& state, int stride, ptrdiff_t numIndices, const void* sysMem) +{ + assert(sysMem); + assert(stride == 4); + const size_t bufferSize = stride * numIndices; + + { + ComPtr resource; + CD3DX12_HEAP_PROPERTIES defaultHeapProps(D3D12_HEAP_TYPE_DEFAULT); + D3D12_RESOURCE_DESC resourceDesc(CD3DX12_RESOURCE_DESC::Buffer(bufferSize)); + if (sysMem) + { + NV_RETURN_ON_FAIL(state.m_device->CreateCommittedResource(&defaultHeapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, + IID_PPV_ARGS(&resource))); + NV_RETURN_ON_FAIL(state.m_scopeManager->upload(state.m_commandList, sysMem, resource.Get(), D3D12_RESOURCE_STATE_COMMON)); + } + else + { + NV_RETURN_ON_FAIL(state.m_device->CreateCommittedResource(&defaultHeapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, + IID_PPV_ARGS(&resource))); + } + setResource(resource.Get(), D3D12_RESOURCE_STATE_COMMON); + } + + memset(&m_indexBufferView, 0, sizeof(m_indexBufferView)); + m_indexBufferView.BufferLocation = m_resource->GetGPUVirtualAddress(); + m_indexBufferView.SizeInBytes = UINT(bufferSize); + m_indexBufferView.Format = DXGI_FORMAT_R32_UINT; + return NV_OK; +} + +int VertexBufferD3D12::init(const RenderStateD3D12& state, int stride, ptrdiff_t numElements, const void* sysMem, D3D12_RESOURCE_FLAGS resourceFlags) +{ + if (!sysMem) + { + memset(&m_vertexBufferView, 0, sizeof(m_vertexBufferView)); + return NV_OK; + } + + size_t bufferSize = size_t(numElements * stride); + + { + CD3DX12_HEAP_PROPERTIES defaultHeapProps(D3D12_HEAP_TYPE_DEFAULT); + D3D12_RESOURCE_DESC resourceDesc(CD3DX12_RESOURCE_DESC::Buffer(bufferSize, resourceFlags)); + ComPtr resource; + + if (sysMem) + { + NV_RETURN_ON_FAIL(state.m_device->CreateCommittedResource(&defaultHeapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, + IID_PPV_ARGS(&resource))); + NV_RETURN_ON_FAIL(state.m_scopeManager->upload(state.m_commandList, sysMem, resource.Get(), D3D12_RESOURCE_STATE_COMMON)); + } + else + { + NV_RETURN_ON_FAIL(state.m_device->CreateCommittedResource(&defaultHeapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, + IID_PPV_ARGS(&resource))); + } + setResource(resource.Get(), D3D12_RESOURCE_STATE_COMMON); + } + + { + memset(&m_vertexBufferView, 0, sizeof(m_vertexBufferView)); + m_vertexBufferView.BufferLocation = m_resource->GetGPUVirtualAddress(); + m_vertexBufferView.SizeInBytes = UINT(bufferSize); + m_vertexBufferView.StrideInBytes = stride; + } + + return NV_OK; +} + +int VertexBufferD3D12::init(const RenderStateD3D12& state, int srcStride, int dstStride, ptrdiff_t numElements, const void* sysMem, D3D12_RESOURCE_FLAGS resourceFlags) +{ + if (srcStride == dstStride || sysMem == nullptr) + { + return init(state, dstStride, numElements, sysMem, resourceFlags); + } + else + { + if (srcStride == 4 * 4 && dstStride == 4 * 3) + { + std::vector buf(numElements * 3); + uint32_t* dst = &buf.front(); + const uint32_t* src = (const uint32_t*)sysMem; + + for (ptrdiff_t i = 0; i < numElements; i++, dst += 3, src += 4) + { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + } + + return init(state, dstStride, numElements, &buf.front(), resourceFlags); + } + } + + assert(!"Unhandled conversion"); + return NV_FAIL; +} + + +} // namespace FlexSample diff --git a/demo/d3d12/bufferD3D12.h b/demo/d3d12/bufferD3D12.h new file mode 100644 index 0000000..b2bd98a --- /dev/null +++ b/demo/d3d12/bufferD3D12.h @@ -0,0 +1,38 @@ +#ifndef BUFFER_D3D12_H +#define BUFFER_D3D12_H + +#include + +#include "renderStateD3D12.h" + +#define NOMINMAX +#include +#include + +namespace FlexSample { +using namespace nvidia; + +struct IndexBufferD3D12: public NvCo::Dx12Resource +{ + int init(const RenderStateD3D12& state, int stride, ptrdiff_t numIndices, const void* sysMem); + /// Reset + void reset() { setResourceNull(); } + + D3D12_INDEX_BUFFER_VIEW m_indexBufferView; +}; + +struct VertexBufferD3D12: public NvCo::Dx12Resource +{ + /// + int init(const RenderStateD3D12& state, int stride, ptrdiff_t numElements, const void* sysMem, D3D12_RESOURCE_FLAGS resourceFlags = D3D12_RESOURCE_FLAG_NONE); + int init(const RenderStateD3D12& state, int srcStride, int stride, ptrdiff_t numElements, const void* sysMem, D3D12_RESOURCE_FLAGS resourceFlags = D3D12_RESOURCE_FLAG_NONE); + + /// Ctor + VertexBufferD3D12() {} + + D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView; +}; + +} // namespace FlexSample + +#endif // BUFFER_D3D12_H diff --git a/demo/d3d12/demoContextD3D12.cpp b/demo/d3d12/demoContextD3D12.cpp new file mode 100644 index 0000000..8a698f7 --- /dev/null +++ b/demo/d3d12/demoContextD3D12.cpp @@ -0,0 +1,1410 @@ +// to fix min max windows macros +#define NOMINMAX + +#include "meshRendererD3D12.h" + +// Pipelines + +#include "meshRenderPipelineD3D12.h" +#include "pointRenderPipelineD3D12.h" +#include "fluidEllipsoidRenderPipelineD3D12.h" +#include "fluidSmoothRenderPipelineD3D12.h" +#include "fluidCompositeRenderPipelineD3D12.h" +#include "diffusePointRenderPipelineD3D12.h" +#include "lineRenderPipelineD3D12.h" + +#include "meshUtil.h" + +#include + +// SDL +#include + +#include "d3d/shadersDemoContext.h" + +// Flex +#include "core/maths.h" +#include "core/extrude.h" + +#define NOMINMAX +#include +#include + +#include "imguiGraphD3D12.h" + +#include "../d3d/loader.h" + +#include "demoContextD3D12.h" + +// include the Direct3D Library file +#pragma comment (lib, "d3d12.lib") +#pragma comment (lib, "DXGI.lib") + +using namespace DirectX; + +static float gSpotMin = 0.5f; +static float gSpotMax = 1.0f; +static float gShadowBias = 0.075f; +static const int kShadowResolution = 2048; + +// Global externally +extern Colour g_colors[]; + +#define NV_PRINT_F_U64 "%I64u" + +DemoContext* CreateDemoContextD3D12() +{ + return new FlexSample::DemoContextD3D12; +} + +namespace FlexSample { + +DemoContextD3D12::DemoContextD3D12() +{ + m_shadowMapLinearSamplerIndex = -1; + m_fluidPointDepthSrvIndex = -1; + m_currentShadowMap = nullptr; + m_targetShadowMap = nullptr; + + m_inLineDraw = false; + memset(&m_meshDrawParams, 0, sizeof(m_meshDrawParams)); + + m_hwnd = nullptr; + m_window = nullptr; + + // Allocate space for all debug vertices + m_debugLineVertices.resize(MAX_DEBUG_LINE_SIZE); +} + +DemoContextD3D12::~DemoContextD3D12() +{ + imguiGraphDestroy(); +} + +bool DemoContextD3D12::initialize(const RenderInitOptions& options) +{ + // must always have at least one sample + m_msaaSamples = Max(1, options.numMsaaSamples); + + { + // Load external modules + loadModules(APP_CONTEXT_D3D12); + } + + m_appGraphCtx = AppGraphCtxCreate(0); + m_renderContext = cast_to_AppGraphCtxD3D12(m_appGraphCtx); + + AppGraphCtxUpdateSize(m_appGraphCtx, options.window, options.fullscreen, m_msaaSamples); + + using namespace NvCo; + // Get the hwnd + m_hwnd = nullptr; + m_window = options.window; + { + // get Windows handle to this SDL window + SDL_SysWMinfo winInfo; + SDL_VERSION(&winInfo.version); + if (SDL_GetWindowWMInfo(options.window, &winInfo)) + { + if (winInfo.subsystem == SDL_SYSWM_WINDOWS) + { + m_hwnd = winInfo.info.win.window; + } + } + } + + { + WCHAR buffer[_MAX_PATH]; + DWORD size = GetModuleFileNameW(nullptr, buffer, _MAX_PATH); + if (size == 0 || size == _MAX_PATH) + { + // Method failed or path was truncated. + return false; + } + std::wstring path; + path += buffer; + const size_t lastSlash = path.find_last_of(L"\\"); + if (lastSlash >= 0) + { + path.resize(lastSlash + 1); + } + + m_executablePath.swap(path); + } + + { + m_shadersPath = m_executablePath; + m_shadersPath += L"../../demo/d3d/shaders/"; + } + + int width, height; + SDL_GetWindowSize(m_window, &width, &height); + + { + ScopeGpuWork scope(getRenderContext()); + NV_RETURN_FALSE_ON_FAIL(_initRenderResources(options)); + + { + // create imgui, connect to app graph context + ImguiGraphDescD3D12 desc; + desc.device = m_renderContext->m_device; + desc.commandList = m_renderContext->m_commandList; + desc.lastFenceCompleted = 0; + desc.nextFenceValue = 1; + desc.winW = m_renderContext->m_winW; + desc.winW = m_renderContext->m_winH; + desc.numMSAASamples = options.numMsaaSamples; + desc.dynamicHeapCbvSrvUav.userdata = this; + desc.dynamicHeapCbvSrvUav.reserveDescriptors = NULL; + + int defaultFontHeight = (options.defaultFontHeight <= 0) ? 13 : options.defaultFontHeight; + + if (!imguiGraphInit("../../data/DroidSans.ttf", float(defaultFontHeight), (ImguiGraphDesc*)&desc)) + { + return false; + } + } + } + + return true; +} + +int DemoContextD3D12::_initRenderResources(const RenderInitOptions& options) +{ + AppGraphCtxD3D12* renderContext = getRenderContext(); + ID3D12Device* device = renderContext->m_device; + + { + // https://msdn.microsoft.com/en-us/library/windows/desktop/dn859253(v=vs.85).aspx + // https://msdn.microsoft.com/en-us/library/windows/desktop/ff476876(v=vs.85).aspx#Overview + D3D12_FEATURE_DATA_D3D12_OPTIONS options; + device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)); + } + + { + // Make enough space for largest _single_ dynamic buffer allocation + NV_RETURN_ON_FAIL(m_renderStateManager.initialize(renderContext, 16 * 1024 * 1024)); + m_renderState = m_renderStateManager.getState(); + } + + // Create the renderer + { + std::unique_ptr renderer(new MeshRendererD3D12); + NV_RETURN_ON_FAIL(renderer->initialize(m_renderState)); + m_meshRenderer = std::move(renderer); + } + + { + // NOTE! Must be in this order, as compositePS expects s0, s1 = linear, shadow samplers, in that order + m_linearSamplerIndex = m_renderState.m_samplerDescriptorHeap->allocate(); + m_shadowMapLinearSamplerIndex = m_renderState.m_samplerDescriptorHeap->allocate(); + + { + // linear sampler with comparator - used for shadow map sampling + D3D12_SAMPLER_DESC desc = + { + D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + 0.0f, 0, D3D12_COMPARISON_FUNC_LESS_EQUAL, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, + }; + device->CreateSampler(&desc, m_renderState.m_samplerDescriptorHeap->getCpuHandle(m_shadowMapLinearSamplerIndex)); + } + { + // A regular linear sampler + D3D12_SAMPLER_DESC desc = + { + D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + 0.0, 0, D3D12_COMPARISON_FUNC_NEVER, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, + }; + device->CreateSampler(&desc, m_renderState.m_samplerDescriptorHeap->getCpuHandle(m_linearSamplerIndex)); + } + } + + // Allocate the srvs used for fluid render targets + { + m_fluidPointDepthSrvIndex = m_renderState.m_srvCbvUavDescriptorHeap->allocate(); + m_fluidCompositeSrvBaseIndex = m_renderState.m_srvCbvUavDescriptorHeap->allocate(NUM_COMPOSITE_SRVS); + } + + // Create the shadow map + { + m_shadowMap = std::unique_ptr(new NvCo::Dx12RenderTarget); + + NvCo::Dx12RenderTarget::Desc desc; + desc.init(kShadowResolution, kShadowResolution); + desc.m_targetFormat = DXGI_FORMAT_UNKNOWN; + desc.m_depthStencilFormat = DXGI_FORMAT_R32_TYPELESS; + + // Make a small shadow map so we can configure pipeline correctly + NV_RETURN_ON_FAIL(m_shadowMap->init(renderContext, desc)); + + m_shadowMap->setDebugName(L"ShadowMap"); + + if (m_shadowMap->allocateSrvView(NvCo::Dx12RenderTarget::BUFFER_DEPTH_STENCIL, device, *m_renderState.m_srvCbvUavDescriptorHeap) < 0) + { + printf("Unable to allocate shadow buffer srv index"); + + return NV_FAIL; + } + } + + // Init fluid resources + NV_RETURN_ON_FAIL(_initFluidRenderTargets()); + + // Create pipelines + { + + // Mesh + { + std::unique_ptr pipeline(new MeshRenderPipelineD3D12); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath, FRONT_WINDING_COUNTER_CLOCKWISE, m_shadowMapLinearSamplerIndex, m_shadowMap.get(), options.asyncComputeBenchmark)); + m_meshPipeline = std::move(pipeline); + } + // Point + { + std::unique_ptr pipeline(new PointRenderPipelineD3D12); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath, m_shadowMapLinearSamplerIndex, m_shadowMap.get())); + m_pointPipeline = std::move(pipeline); + } + // FluidPoint + { + std::unique_ptr pipeline(new FluidEllipsoidRenderPipelineD3D12); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath, m_fluidPointRenderTarget.get())); + m_fluidPointPipeline = std::move(pipeline); + } + // FluidSmooth + { + std::unique_ptr pipeline(new FluidSmoothRenderPipelineD3D12(m_fluidPointDepthSrvIndex)); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath, m_fluidSmoothRenderTarget.get())); + m_fluidSmoothPipeline = std::move(pipeline); + } + // FluidComposite + { + std::unique_ptr pipeline(new FluidCompositeRenderPipelineD3D12); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath)); + m_fluidCompositePipeline = std::move(pipeline); + } + // DiffusePoint + { + std::unique_ptr pipeline(new DiffusePointRenderPipelineD3D12); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath, m_linearSamplerIndex, m_shadowMap.get())); + m_diffusePointPipeline = std::move(pipeline); + } + // Line + { + std::unique_ptr pipeline(new LineRenderPipelineD3D12); + NV_RETURN_ON_FAIL(pipeline->initialize(m_renderState, m_shadersPath, m_shadowMap.get())); + m_linePipeline = std::move(pipeline); + } + } + + { + // Create a passthru screen quad + uint32_t indices[] = { 0, 1, 2, 0, 2, 3 }; + Vec3 pos[] = { { -1, -1, 0} , {1, -1, 0}, {1, 1, 0}, {-1, 1, 0} }; + Vec2 uvs[] = { { 0, 0}, {1, 0}, {1, 1}, {0, 1} }; + + MeshData mesh; + mesh.init(); + + mesh.indices = indices; + mesh.positions = pos; + mesh.texcoords = uvs; + mesh.numFaces = _countof(indices) / 3; + mesh.numVertices = _countof(pos); + + m_screenQuadMesh = std::unique_ptr(m_meshRenderer->createMesh(mesh)); + } + + // create synchronization objects + { + m_graphicsCompleteEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); + if (!m_graphicsCompleteEvent) + { + return E_FAIL; + } + NV_RETURN_ON_FAIL(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_graphicsCompleteFence))); + m_graphicsCompleteFenceValue = 1; + } + + { + // Query heap and results buffer + + // Create timestamp query heap and results buffer + const int queryCount = 2; + D3D12_QUERY_HEAP_DESC queryHeapDesc = { D3D12_QUERY_HEAP_TYPE_TIMESTAMP, queryCount, 0 /* NodeMask */ }; + NV_RETURN_ON_FAIL(device->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&m_queryHeap))); + + D3D12_HEAP_PROPERTIES heapProps = + { + D3D12_HEAP_TYPE_READBACK, + D3D12_CPU_PAGE_PROPERTY_UNKNOWN, + D3D12_MEMORY_POOL_UNKNOWN, + 0, + 0 + }; + + D3D12_RESOURCE_DESC queryBufDesc = + { + D3D12_RESOURCE_DIMENSION_BUFFER, + 0u, + queryCount * sizeof(uint64_t), + 1u, + 1u, + 1, + DXGI_FORMAT_UNKNOWN, + { 1u, 0u }, + D3D12_TEXTURE_LAYOUT_ROW_MAJOR, + D3D12_RESOURCE_FLAG_NONE + }; + + NV_RETURN_ON_FAIL(device->CreateCommittedResource( + &heapProps, + D3D12_HEAP_FLAG_NONE, + &queryBufDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS(&m_queryResults))); + } + return NV_OK; +} + +int DemoContextD3D12::_initFluidRenderTargets() +{ + AppGraphCtxD3D12* renderContext = getRenderContext(); + ID3D12Device* device = renderContext->m_device; + + // Fluid point render target + { + { + std::unique_ptr target(new NvCo::Dx12RenderTarget); + NvCo::Dx12RenderTarget::Desc desc; + desc.init(renderContext->m_winW, renderContext->m_winH, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_TYPELESS); + for(int i=0;i!=4;i++) desc.m_targetClearColor[i] = 0; + + NV_RETURN_ON_FAIL(target->init(renderContext, desc)); + + target->setDebugName(L"Fluid Point"); + m_fluidPointRenderTarget = std::move(target); + } + + } + + // Fluid smooth + { + std::unique_ptr target(new NvCo::Dx12RenderTarget); + NvCo::Dx12RenderTarget::Desc desc; + desc.init(renderContext->m_winW, renderContext->m_winH, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN); + for (int i = 0; i != 4; i++) desc.m_targetClearColor[i] = 0; + + NV_RETURN_ON_FAIL(target->init(renderContext, desc)); + + target->setDebugName(L"Fluid Smooth"); + m_fluidSmoothRenderTarget = std::move(target); + } + + // The resolved target for final compose + { + std::unique_ptr target(new NvCo::Dx12RenderTarget); + NvCo::Dx12RenderTarget::Desc desc; + Vec4 clearColor = { 1, 0, 1, 1 }; + desc.m_targetClearColor = clearColor; + desc.init(renderContext->m_winW, renderContext->m_winH, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN); + + NV_RETURN_ON_FAIL(target->init(renderContext, desc)); + + target->setDebugName(L"Fluid Resolved Target"); + m_fluidResolvedTarget = std::move(target); + } + + // Init all of the srvs!!!! + + { + NvCo::Dx12DescriptorHeap& heap = *m_renderState.m_srvCbvUavDescriptorHeap; + // Set up the srv for accessing this buffer + { + m_fluidPointRenderTarget->createSrv(device, heap, NvCo::Dx12RenderTarget::BUFFER_TARGET, m_fluidPointDepthSrvIndex); + } + + { + // 0 - is the depth texture m_fluidSmoothRenderTarget (target) + // 1 - is the 'composite' scene texture m_fluidResolvedTarget (target) + // 2 - shadow texture m_shadowMap (depth stencil) + + m_fluidSmoothRenderTarget->createSrv(device, heap, NvCo::Dx12RenderTarget::BUFFER_TARGET, m_fluidCompositeSrvBaseIndex + 0); + m_fluidResolvedTarget->createSrv(device, heap, NvCo::Dx12RenderTarget::BUFFER_TARGET, m_fluidCompositeSrvBaseIndex + 1); + m_shadowMap->createSrv(device, heap, NvCo::Dx12RenderTarget::BUFFER_DEPTH_STENCIL, m_fluidCompositeSrvBaseIndex + 2); + } + } + + return NV_OK; +} + +void DemoContextD3D12::onSizeChanged(int width, int height, bool minimized) +{ + // Free any set render targets + m_fluidPointRenderTarget.reset(); + m_fluidSmoothRenderTarget.reset(); + m_fluidResolvedTarget.reset(); + + // Will need to create the render targets.. + _initFluidRenderTargets(); +} + +void DemoContextD3D12::startFrame(FlexVec4 colorIn) +{ + AppGraphCtxD3D12* renderContext = getRenderContext(); + + // Work out what what can be recovered, as GPU no longer accessing + m_renderStateManager.updateCompleted(); + + AppGraphColor clearColor = { colorIn.x, colorIn.y, colorIn.z, colorIn.w }; + AppGraphCtxFrameStart(cast_from_AppGraphCtxD3D12(renderContext), clearColor); + + { + MeshDrawParamsD3D& params = m_meshDrawParams; + memset(¶ms, 0, sizeof(MeshDrawParamsD3D)); + params.renderStage = MESH_DRAW_LIGHT; + params.renderMode = MESH_RENDER_SOLID; + params.cullMode = MESH_CULL_BACK; + params.projection = XMMatrixIdentity(); + params.view = XMMatrixIdentity(); + params.model = DirectX::XMMatrixMultiply( + DirectX::XMMatrixScaling(1.0f, 1.0f, 1.0f), + DirectX::XMMatrixTranslation(0.0f, 0.0f, 0.0f) + ); + } +} + +void DemoContextD3D12::endFrame() +{ + { + ImguiGraphDescD3D12 desc; + desc.device = m_renderContext->m_device; + desc.commandList = m_renderContext->m_commandList; + desc.winW = m_renderContext->m_winW; + desc.winH = m_renderContext->m_winH; + + imguiGraphUpdate((ImguiGraphDesc*)&desc); + } + + AppGraphCtxD3D12* renderContext = getRenderContext(); + + nvidia::Common::Dx12Resource& backBuffer = renderContext->m_backBuffers[renderContext->m_renderTargetIndex]; + if (renderContext->m_numMsaaSamples > 1) + { + // MSAA resolve + nvidia::Common::Dx12Resource& renderTarget = *renderContext->m_renderTargets[renderContext->m_renderTargetIndex]; + assert(&renderTarget != &backBuffer); + // Barriers to wait for the render target, and the backbuffer to be in correct state + { + nvidia::Common::Dx12BarrierSubmitter submitter(renderContext->m_commandList); + renderTarget.transition(D3D12_RESOURCE_STATE_RESOLVE_SOURCE, submitter); + backBuffer.transition(D3D12_RESOURCE_STATE_RESOLVE_DEST, submitter); + } + // Do the resolve... + renderContext->m_commandList->ResolveSubresource(backBuffer, 0, renderTarget, 0, renderContext->m_targetInfo.m_renderTargetFormats[0]); + } + + { + nvidia::Common::Dx12BarrierSubmitter submitter(renderContext->m_commandList); + backBuffer.transition(D3D12_RESOURCE_STATE_PRESENT, submitter); + } + + renderContext->m_commandList->Close(); + + // submit command list + ID3D12CommandList* cmdLists[] = { renderContext->m_commandList }; + renderContext->m_commandQueue->ExecuteCommandLists(1, cmdLists); + + renderContext->m_commandListOpenCount = 0; + + // Inform the manager that the work has been submitted + m_renderStateManager.onGpuWorkSubmitted(renderContext->m_commandQueue); + + HANDLE completeEvent = m_graphicsCompleteEvent; + + renderContext->m_commandQueue->Signal(m_graphicsCompleteFence.Get(), m_graphicsCompleteFenceValue); +} + +void DemoContextD3D12::getRenderDevice(void** device, void** context) +{ + *device = m_renderContext->m_device; + *context = m_renderContext->m_commandQueue; +} + +void DemoContextD3D12::startGpuWork() +{ + AppGraphCtxBeginGpuWork(m_renderContext); +} + +void DemoContextD3D12::endGpuWork() +{ + AppGraphCtxEndGpuWork(m_renderContext); +} + +void DemoContextD3D12::presentFrame(bool fullsync) +{ + AppGraphCtxFramePresent(cast_from_AppGraphCtxD3D12(m_renderContext), fullsync); +} + +void DemoContextD3D12::getViewRay(int x, int y, FlexVec3& origin, FlexVec3& dir) +{ + //using namespace DirectX; + AppGraphCtxD3D12* renderContext = getRenderContext(); + + int width = renderContext->m_winW; + int height = renderContext->m_winH; + + XMVECTOR nearVector = XMVector3Unproject(XMVectorSet(float(x), float(height - y), 0.0f, 0.0f), 0.0f, 0.0f, (float)width, (float)height, 0.0f, 1.0f, (XMMATRIX)m_proj, XMMatrixIdentity(), (XMMATRIX)m_view); + XMVECTOR farVector = XMVector3Unproject(XMVectorSet(float(x), float(height - y), 1.0f, 0.0f), 0.0f, 0.0f, (float)width, (float)height, 0.0f, 1.0f, (XMMATRIX)m_proj, XMMatrixIdentity(), (XMMATRIX)m_view); + + origin = FlexVec3(XMVectorGetX(nearVector), XMVectorGetY(nearVector), XMVectorGetZ(nearVector)); + XMVECTOR tmp = farVector - nearVector; + dir = Normalize(FlexVec3(XMVectorGetX(tmp), XMVectorGetY(tmp), XMVectorGetZ(tmp))); +} + +void DemoContextD3D12::setView(Matrix44 view, Matrix44 projection) +{ + Matrix44 vp = projection*view; + MeshDrawParamsD3D& params = m_meshDrawParams; + + params.model = XMMatrixIdentity(); + params.view = (XMMATRIX)view; + params.projection = (XMMATRIX)(RenderParamsUtilD3D::convertGLToD3DProjection(projection)); + + m_view = view; + m_proj = RenderParamsUtilD3D::convertGLToD3DProjection(projection); +} + +void DemoContextD3D12::renderEllipsoids(FluidRenderer* renderer, FluidRenderBuffers* buffersIn, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, FlexVec3 lightPos, FlexVec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, FlexVec4 color, float blur, float ior, bool debug) +{ + FluidRenderBuffersD3D12& buffers = *reinterpret_cast(buffersIn); + if (n == 0) + return; + + typedef PointRenderAllocationD3D12 Alloc; + + Alloc alloc; + alloc.init(PRIMITIVE_POINT); + + alloc.m_numPrimitives = buffers.m_numParticles; + alloc.m_numPositions = 0; ///? We don't know here yet... + + alloc.m_indexBufferView = buffers.m_indicesView; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_DENSITY] = buffers.m_densitiesView; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION] = buffers.m_positionsView; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1] = buffers.m_anisotropiesViewArr[0]; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY2] = buffers.m_anisotropiesViewArr[1]; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY3] = buffers.m_anisotropiesViewArr[2]; + + AppGraphCtxD3D12* renderContext = getRenderContext(); + + FluidDrawParamsD3D params; + + params.renderMode = FLUID_RENDER_SOLID; + params.cullMode = FLUID_CULL_BACK; + params.model = XMMatrixIdentity(); + params.view = (XMMATRIX&)m_view; + params.projection = (XMMATRIX&)m_proj; + + params.offset = offset; + params.n = n; + params.renderStage = FLUID_DRAW_LIGHT; + + const float viewHeight = tanf(fov / 2.0f); + params.invViewport = Hlsl::float3(1.0f / screenWidth, screenAspect / screenWidth, 1.0f); + params.invProjection = Hlsl::float3(screenAspect * viewHeight, viewHeight, 1.0f); + params.debug = 0; + + params.shadowMap = nullptr; + + { + m_fluidPointRenderTarget->toWritable(renderContext); + m_fluidPointRenderTarget->bindAndClear(renderContext); + + // Draw the ellipsoids + m_meshRenderer->drawTransitory(alloc, sizeof(Alloc), m_fluidPointPipeline.get(), ¶ms); + + m_fluidPointRenderTarget->toReadable(renderContext); + } + + //--------------------------------------------------------------- + // build smooth depth + + { + m_fluidSmoothRenderTarget->toWritable(renderContext); + m_fluidSmoothRenderTarget->bind(renderContext); + + params.blurRadiusWorld = radius * 0.5f; + params.blurScale = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); + params.invTexScale = Hlsl::float4(1.0f / screenAspect, 1.0f, 0.0f, 0.0f); + params.blurFalloff = blur; + params.debug = debug; + + m_meshRenderer->draw(m_screenQuadMesh.get(), m_fluidSmoothPipeline.get(), ¶ms); + + m_fluidSmoothRenderTarget->toReadable(renderContext); + } + + // First lets resolve the render target + ID3D12GraphicsCommandList* commandList = m_renderContext->m_commandList; + { + // Lets take what's rendered so far and + NvCo::Dx12ResourceBase* targetResource = m_renderContext->m_renderTargets[m_renderContext->m_renderTargetIndex]; + NvCo::Dx12ResourceBase& fluidResolvedTarget = m_fluidResolvedTarget->getResource(NvCo::Dx12RenderTarget::BUFFER_TARGET); + + if (m_renderContext->m_numMsaaSamples > 1) + { + // If enabled can stop/reduce flickering issues on some GPUs related to a problem around ResolveSubresource/ + //m_renderContext->submitGpuWork(); + + { + NvCo::Dx12BarrierSubmitter submitter(commandList); + targetResource->transition(D3D12_RESOURCE_STATE_RESOLVE_SOURCE, submitter); + fluidResolvedTarget.transition(D3D12_RESOURCE_STATE_RESOLVE_DEST, submitter); + } + // Do the resolve + const DXGI_FORMAT format = fluidResolvedTarget.getResource()->GetDesc().Format; + commandList->ResolveSubresource(fluidResolvedTarget, 0, *targetResource, 0, format); + { + NvCo::Dx12BarrierSubmitter submitter(commandList); + targetResource->transition(D3D12_RESOURCE_STATE_RENDER_TARGET, submitter); + fluidResolvedTarget.transition(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, submitter); + } + } + else + { + { + NvCo::Dx12BarrierSubmitter submitter(commandList); + targetResource->transition(D3D12_RESOURCE_STATE_COPY_SOURCE, submitter); + fluidResolvedTarget.transition(D3D12_RESOURCE_STATE_COPY_DEST, submitter); + } + commandList->CopyResource(fluidResolvedTarget, *targetResource); + } + } + + //--------------------------------------------------------------- + // composite + + { + m_shadowMap->toReadable(renderContext); + + AppGraphCtxPrepareRenderTarget(renderContext); + + FlexVec4 aspectWork(1.0f / screenWidth, screenAspect / screenWidth, 0, 0); + params.invTexScale = (Hlsl::float4&)aspectWork; + FlexVec4 clipPosToEyeWork(tanf(fov*0.5f)*screenAspect, tanf(fov*0.5f), 0, 0); + params.clipPosToEye = (Hlsl::float4&)clipPosToEyeWork; + params.color = (Hlsl::float4&)color; + params.ior = ior; + params.spotMin = gSpotMin; + params.spotMax = gSpotMax; + params.debug = debug; + + params.lightPos = (Hlsl::float3&)lightPos; + FlexVec3 lightDirWork = -Normalize(lightTarget - lightPos); + params.lightDir = (Hlsl::float3&)lightDirWork; + Matrix44 lightTransformWork = RenderParamsUtilD3D::convertGLToD3DProjection(lightTransform); + params.lightTransform = (XMMATRIX&)lightTransformWork; + + params.m_srvDescriptorBase = m_fluidCompositeSrvBaseIndex; + params.m_sampleDescriptorBase = m_linearSamplerIndex; + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + m_meshRenderer->draw(m_screenQuadMesh.get(), m_fluidCompositePipeline.get(), ¶ms); + } +} + +void DemoContextD3D12::updateFluidRenderBuffers(FluidRenderBuffers* buffersIn, FlexVec4* particles, float* densities, FlexVec4* anisotropy1, FlexVec4* anisotropy2, FlexVec4* anisotropy3, int numParticles, int* indices, int numIndices) +{ + FluidRenderBuffersD3D12& buffers = *reinterpret_cast(buffersIn); + + typedef PointRenderAllocationD3D12 Alloc; + Alloc alloc; + + PointData pointData; + + pointData.positions = (const Vec4*)particles; + pointData.density = densities; + pointData.phase = nullptr; + pointData.indices = (uint32_t*)indices; + pointData.numIndices = numIndices; + pointData.numPoints = numParticles; + pointData.anisotropy[0] = (const Vec4*)anisotropy1; + pointData.anisotropy[1] = (const Vec4*)anisotropy2; + pointData.anisotropy[2] = (const Vec4*)anisotropy3; + + m_meshRenderer->allocateTransitory(pointData, alloc, sizeof(alloc)); + + buffers.m_positionsView = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION]; + buffers.m_densitiesView = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_DENSITY]; + + buffers.m_anisotropiesViewArr[0] = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1]; + buffers.m_anisotropiesViewArr[1] = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY2]; + buffers.m_anisotropiesViewArr[2] = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY3]; + + buffers.m_indicesView = alloc.m_indexBufferView; + + buffers.m_numParticles = numIndices; +} + +void DemoContextD3D12::shadowBegin(::ShadowMap* map) +{ + assert(map); + assert(m_targetShadowMap == nullptr); + + AppGraphCtxD3D12* renderContext = getRenderContext(); + NvCo::Dx12RenderTarget* shadowMap = reinterpret_cast(map); + + shadowMap->toWritable(renderContext); + shadowMap->bindAndClear(renderContext); + + m_targetShadowMap = shadowMap; + + m_meshDrawParams.renderStage = MESH_DRAW_SHADOW; +} + +void DemoContextD3D12::shadowEnd() +{ + AppGraphCtxD3D12* renderContext = getRenderContext(); + NvCo::Dx12RenderTarget* shadowMap = m_targetShadowMap; + shadowMap->toReadable(renderContext); + m_targetShadowMap = nullptr; + + // Restore to regular render target + AppGraphCtxPrepareRenderTarget(renderContext); + + m_meshDrawParams.renderStage = MESH_DRAW_NULL; +} + +void DemoContextD3D12::drawMesh(const Mesh* m, FlexVec3 color) +{ + MeshDrawParamsD3D& params = m_meshDrawParams; + + if (m) + { + MeshData meshData; + + meshData.positions = (Vec3*)&m->m_positions[0]; + meshData.normals = (Vec3*)&m->m_normals[0]; + meshData.colors = nullptr; + meshData.texcoords = nullptr; + meshData.indices = (uint32_t*)&m->m_indices[0]; + meshData.numFaces = m->GetNumFaces(); + meshData.numVertices = m->GetNumVertices(); + + params.colorArray = 0; + if (m->m_colours.size()) + { + params.colorArray = 1; + meshData.colors = (Vec4*)&m->m_colours[0]; + } + + params.color = Hlsl::float4(color.x, color.y, color.z, 1); + params.secondaryColor = params.color; + params.objectTransform = (Hlsl::float4x4&)Matrix44::kIdentity; + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + m_meshRenderer->drawImmediate(meshData, m_meshPipeline.get(), ¶ms); + + if (m->m_colours.size()) + { + params.colorArray = 0; + } + } +} + +void DemoContextD3D12::drawCloth(const FlexVec4* positions, const FlexVec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth) +{ + if (!numTris) + return; + + MeshData2 meshData; + + meshData.positions = (const Vec4*)positions; + meshData.normals = (const Vec4*)normals; + meshData.texcoords = nullptr; /* (const Vec2*)uvs; */ + meshData.colors = nullptr; + meshData.numFaces = numTris; + meshData.indices = (const uint32_t*)indices; + meshData.numVertices = numPositions; + + if (twosided) + SetCullMode(false); + + MeshDrawParamsD3D& params = m_meshDrawParams; + + params.bias = 0.0f; + params.expand = expand; + + params.color = (Hlsl::float4&)(g_colors[colorIndex + 1] * 1.5f); + params.secondaryColor = (Hlsl::float4&)(g_colors[colorIndex] * 1.5f); + params.objectTransform = (Hlsl::float4x4&)Matrix44::kIdentity; + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + m_meshRenderer->drawImmediate(meshData, m_meshPipeline.get(), ¶ms); + + if (twosided) + SetCullMode(true); + + params.bias = gShadowBias; + params.expand = 0.0f; +} + +void DemoContextD3D12::drawRope(FlexVec4* positions, int* indices, int numIndices, float radius, int color) +{ + if (numIndices < 2) + return; + + std::vector vertices; + std::vector normals; + std::vector triangles; + + // flatten curve + std::vector curve(numIndices); + for (int i = 0; i < numIndices; ++i) + { + curve[i] = FlexVec3(positions[indices[i]]); + } + + const int resolution = 8; + const int smoothing = 3; + + vertices.reserve(resolution*numIndices*smoothing); + normals.reserve(resolution*numIndices*smoothing); + triangles.reserve(numIndices*resolution * 6 * smoothing); + + Extrude(&curve[0], int(curve.size()), vertices, normals, triangles, radius, resolution, smoothing); + + SetCullMode(false); + + MeshDrawParamsD3D& params = m_meshDrawParams; + + params.color = (Hlsl::float4&)(g_colors[color % 8] * 1.5f); + params.secondaryColor = (Hlsl::float4&)(g_colors[color % 8] * 1.5f); + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + MeshData meshData; + + meshData.positions = (const Vec3*)&vertices[0]; + meshData.normals = (const Vec3*)&normals[0]; + meshData.texcoords = nullptr; + meshData.colors = nullptr; + meshData.indices = (const uint32_t*)&triangles[0]; + meshData.numFaces = int(triangles.size()) / 3; + meshData.numVertices = int(vertices.size()); + + m_meshRenderer->drawImmediate(meshData, m_meshPipeline.get(), ¶ms); + + SetCullMode(true); +} + +void DemoContextD3D12::drawPlane(const FlexVec4& p, bool color) +{ + std::vector vertices; + std::vector normals; + std::vector indices; + + FlexVec3 u, v; + BasisFromVector(FlexVec3(p.x, p.y, p.z), &u, &v); + + FlexVec3 c = FlexVec3(p.x, p.y, p.z)*-p.w; + + MeshDrawParamsD3D& params = m_meshDrawParams; + + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + if (color) + params.color = (Hlsl::float4&)(p * 0.5f + FlexVec4(0.5f, 0.5f, 0.5f, 0.5f)); + + const float kSize = 200.0f; + const int kGrid = 3; + + // draw a grid of quads, otherwise z precision suffers + for (int x = -kGrid; x <= kGrid; ++x) + { + for (int y = -kGrid; y <= kGrid; ++y) + { + FlexVec3 coff = c + u*float(x)*kSize*2.0f + v*float(y)*kSize*2.0f; + + int indexStart = int(vertices.size()); + + vertices.push_back(FlexVec3(coff + u*kSize + v*kSize)); + vertices.push_back(FlexVec3(coff - u*kSize + v*kSize)); + vertices.push_back(FlexVec3(coff - u*kSize - v*kSize)); + vertices.push_back(FlexVec3(coff + u*kSize - v*kSize)); + + normals.push_back(FlexVec3(p.x, p.y, p.z)); + normals.push_back(FlexVec3(p.x, p.y, p.z)); + normals.push_back(FlexVec3(p.x, p.y, p.z)); + normals.push_back(FlexVec3(p.x, p.y, p.z)); + + + indices.push_back(indexStart + 0); + indices.push_back(indexStart + 1); + indices.push_back(indexStart + 2); + + indices.push_back(indexStart + 2); + indices.push_back(indexStart + 3); + indices.push_back(indexStart + 0); + } + } + + MeshData meshData; + meshData.texcoords = nullptr; + meshData.colors = nullptr; + meshData.positions = (Vec3*)&vertices[0]; + meshData.normals = (Vec3*)&normals[0]; + meshData.indices = (uint32_t*)&indices[0]; + meshData.numFaces = int(indices.size() / 3); + meshData.numVertices = int(vertices.size()); + + m_meshRenderer->drawImmediate(meshData, m_meshPipeline.get(), ¶ms); +} + +void DemoContextD3D12::drawPlanes(FlexVec4* planes, int n, float bias) +{ + MeshDrawParamsD3D& params = m_meshDrawParams; + + params.color = (Hlsl::float4&)FlexVec4(0.9f, 0.9f, 0.9f, 1.0f); + + params.bias = 0.0f; + params.grid = 1; + params.expand = 0; + + for (int i = 0; i < n; ++i) + { + FlexVec4 p = planes[i]; + p.w -= bias; + + drawPlane(p, false); + } + + params.grid = 0; + params.bias = gShadowBias; +} + +void DemoContextD3D12::drawPoints(FluidRenderBuffers* buffersIn, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, FlexVec3 lightPos, FlexVec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowTex, bool showDensity) +{ + FluidRenderBuffersD3D12* buffers = reinterpret_cast(buffersIn); + // Okay we can draw the particles here. The update can copy the point positions into the heap, so here we just draw them + + if (n == 0) + return; + + PointRenderAllocationD3D12 pointAlloc; + pointAlloc.init(PRIMITIVE_POINT); + pointAlloc.m_vertexBufferViews[PointRenderAllocationD3D12::VERTEX_VIEW_POSITION] = buffers->m_positionsView; + // It says 'color' as the parameter but actually its the 'density' parameter that is passed in here + pointAlloc.m_vertexBufferViews[PointRenderAllocationD3D12::VERTEX_VIEW_DENSITY] = buffers->m_densitiesView; + pointAlloc.m_indexBufferView = buffers->m_indicesView; + // TODO: JS - I don't know the amount of positions/colors... but the render call doesn't need to know. So just set to 0 for now + pointAlloc.m_numPositions = 0; + pointAlloc.m_numPrimitives = n; + + PointDrawParamsD3D params; + + params.renderMode = POINT_RENDER_SOLID; + params.cullMode = POINT_CULL_BACK; + params.model = XMMatrixIdentity(); + params.view = (XMMATRIX&)m_view; + params.projection = (XMMATRIX&)m_proj; + + params.pointRadius = radius; + params.pointScale = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); + params.spotMin = gSpotMin; + params.spotMax = gSpotMax; + + int mode = 0; + if (showDensity) + mode = 1; + if (shadowTex == 0) + mode = 2; + params.mode = mode; + + for (int i = 0; i < 8; i++) + params.colors[i] = *((Hlsl::float4*)&g_colors[i].r); + + // set shadow parameters + ShadowParamsD3D shadow; + RenderParamsUtilD3D::calcShadowParams(lightPos, lightTarget, lightTransform, gShadowBias, &shadow); + params.lightTransform = shadow.lightTransform; + params.lightDir = shadow.lightDir; + params.lightPos = shadow.lightPos; + memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); + + if (m_meshDrawParams.renderStage == MESH_DRAW_SHADOW) + { + params.renderStage = POINT_DRAW_SHADOW; + params.mode = 2; + } + else + params.renderStage = POINT_DRAW_LIGHT; + + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + m_meshRenderer->drawTransitory(pointAlloc, sizeof(pointAlloc), m_pointPipeline.get(), ¶ms); +} + +void DemoContextD3D12::graphicsTimerBegin() +{ + ID3D12GraphicsCommandList* commandList = m_renderContext->m_commandList; + + commandList->EndQuery(m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, 0); +} + +void DemoContextD3D12::graphicsTimerEnd() +{ + ID3D12GraphicsCommandList* commandList = m_renderContext->m_commandList; + + commandList->EndQuery(m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, 1); + commandList->ResolveQueryData(m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, 0, 2, m_queryResults.Get(), 0); +} + +float DemoContextD3D12::rendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) +{ + AppGraphCtxD3D12* renderContext = getRenderContext(); + ID3D12CommandQueue* commandQueue = m_renderContext->m_commandQueue; + + AppGraphCtxWaitForGPU(renderContext); + + // Get timer frequency + static uint64_t frequency = 0; + + if (frequency == 0) + { + commandQueue->GetTimestampFrequency(&frequency); + } + + //Get render timestamps + uint64_t* times; + //m_queryResults->Map(0, nullptr, (void**)×); + D3D12_RANGE readRange = { 0, 1 }; + m_queryResults->Map(0, &readRange, (void**)×); + uint64_t renderBegin = times[0]; + uint64_t renderEnd = times[1]; + D3D12_RANGE writtenRange = { 0, 0 }; // nothing was written + m_queryResults->Unmap(0, &writtenRange); + + double renderTime = double(renderEnd - renderBegin) / double(frequency); + + if (begin) *begin = renderBegin; + if (end) *end = renderEnd; + if (freq) *freq = frequency; + + return float(renderTime); +} + +void DemoContextD3D12::bindSolidShader(FlexVec3 lightPos, FlexVec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float bias, FlexVec4 fogColor) +{ + MeshDrawParamsD3D& params = m_meshDrawParams; + + params.renderStage = MESH_DRAW_LIGHT; + + params.grid = 0; + params.spotMin = gSpotMin; + params.spotMax = gSpotMax; + params.fogColor = (Hlsl::float4&)fogColor; + + params.objectTransform = (Hlsl::float4x4&)Matrix44::kIdentity; + + ShadowParamsD3D shadow; + RenderParamsUtilD3D::calcShadowParams(lightPos, lightTarget, lightTransform, gShadowBias, &shadow); + params.lightTransform = shadow.lightTransform; + params.lightDir = shadow.lightDir; + params.lightPos = shadow.lightPos; + params.bias = shadow.bias; + memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); + + m_currentShadowMap = (NvCo::Dx12RenderTarget*)shadowMap; +} + +void DemoContextD3D12::drawGpuMesh(GpuMesh* m, const Matrix44& xform, const FlexVec3& color) +{ + if (m) + { + MeshDrawParamsD3D params(m_meshDrawParams); + + params.color = (Hlsl::float4&)color; + params.secondaryColor = (Hlsl::float4&)color; + params.objectTransform = (Hlsl::float4x4&)xform; + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + RenderMesh* renderMesh = (RenderMesh*)m; + + m_meshRenderer->draw(renderMesh, m_meshPipeline.get(), ¶ms); + } +} + +void DemoContextD3D12::drawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const FlexVec3& color) +{ + if (m) + { + MeshDrawParamsD3D& contextParams = m_meshDrawParams; + + contextParams.color = (Hlsl::float4&)color; + contextParams.secondaryColor = (Hlsl::float4&)color; + contextParams.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + // copy params + MeshDrawParamsD3D params(contextParams); + + for (int i = 0; i < n; ++i) + { + params.objectTransform = (Hlsl::float4x4&)xforms[i]; + RenderMesh* renderMesh = (RenderMesh*)m; + m_meshRenderer->draw(renderMesh, m_meshPipeline.get(), ¶ms); + } + } +} + +void DemoContextD3D12::drawDiffuse(FluidRenderer* render, const DiffuseRenderBuffers* buffersIn, int n, float radius, float screenWidth, float screenAspect, float fov, FlexVec4 color, FlexVec3 lightPos, FlexVec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front) +{ + const DiffuseRenderBuffersD3D12& buffers = *reinterpret_cast(buffersIn); + if (n == 0) + return; + + typedef PointRenderAllocationD3D12 Alloc; + Alloc alloc; + alloc.init(PRIMITIVE_POINT); + + alloc.m_numPrimitives = buffers.m_numParticles; + alloc.m_numPositions = 0; // ! We don't know + alloc.m_indexBufferView = buffers.m_indicesView; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION] = buffers.m_positionsView; + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1] = buffers.m_velocitiesView; // Velocity stored in ANISO1 + + DiffuseDrawParamsD3D params; + + params.model = XMMatrixIdentity(); + params.view = (const XMMATRIX&)m_view; + params.projection = (const XMMATRIX&)m_proj; + params.diffuseRadius = screenWidth / screenAspect * (1.0f / (tanf(fov * 0.5f))); + params.diffuseScale = radius; + params.spotMin = gSpotMin; + params.spotMax = gSpotMax; + params.color = Hlsl::float4(1.0f, 1.0f, 1.0f, 1.0f); + params.motionScale = motionBlur; + + // set shadow parameters + ShadowParamsD3D shadow; + RenderParamsUtilD3D::calcShadowParams(lightPos, lightTarget, lightTransform, gShadowBias, &shadow); + params.lightTransform = shadow.lightTransform; + params.lightDir = shadow.lightDir; + params.lightPos = shadow.lightPos; + params.shadowMap = (ShadowMapD3D*)m_currentShadowMap; + + memcpy(params.shadowTaps, shadow.shadowTaps, sizeof(shadow.shadowTaps)); + + m_meshRenderer->drawTransitory(alloc, sizeof(alloc), m_diffusePointPipeline.get(), ¶ms); +} + +void DemoContextD3D12::beginLines() +{ + assert(!m_inLineDraw); + m_inLineDraw = true; + m_debugLineVertices.clear(); +} + +void DemoContextD3D12::drawLine(const Vec3& p, const Vec3& q, const Vec4& color) +{ + assert(m_inLineDraw); + + if (m_debugLineVertices.size() + 2 > MAX_DEBUG_LINE_SIZE) + { + _flushDebugLines(); + } + + LineData::Vertex dst[2]; + dst[0].position = (const Vec3&)p; + dst[0].color = (const Vec4&)color; + dst[1].position = (const Vec3&)q; + dst[1].color = (const Vec4&)color; + + m_debugLineVertices.push_back(dst[0]); + m_debugLineVertices.push_back(dst[1]); +} + +void DemoContextD3D12::_flushDebugLines() +{ + assert(m_inLineDraw); + + if (m_debugLineVertices.size() > 0) + { + LineDrawParams params; + + const Matrix44 modelWorldProjection = ((Matrix44&)(m_meshDrawParams.projection)) * ((Matrix44&)(m_meshDrawParams.view)); + // draw + params.m_modelWorldProjection = (const Hlsl::float4x4&)modelWorldProjection; + params.m_drawStage = (m_targetShadowMap) ? LINE_DRAW_SHADOW : LINE_DRAW_NORMAL; + + LineData lineData; + lineData.init(); + lineData.vertices = &m_debugLineVertices.front(); + lineData.numVertices = m_debugLineVertices.size(); + lineData.numLines = lineData.numVertices / 2; + + m_meshRenderer->drawImmediate(lineData, m_linePipeline.get(), ¶ms); + + m_debugLineVertices.clear(); + } +} + +void DemoContextD3D12::endLines() +{ + _flushDebugLines(); + // No longer in line drawing + m_inLineDraw = false; +} + +void DemoContextD3D12::flushGraphicsAndWait() +{ + AppGraphCtxWaitForGPU(getRenderContext()); +} + +FluidRenderer* DemoContextD3D12::createFluidRenderer(uint32_t width, uint32_t height) +{ + // It's always created.. so just return the context + return (FluidRenderer*)this; +} + +void DemoContextD3D12::destroyFluidRenderer(FluidRenderer* renderer) +{ + /// Don't need to do anything, as will be destroyed with context +} + +FluidRenderBuffers* DemoContextD3D12::createFluidRenderBuffers(int numParticles, bool enableInterop) +{ + return reinterpret_cast(new FluidRenderBuffersD3D12(numParticles)); +} + +void DemoContextD3D12::updateFluidRenderBuffers(FluidRenderBuffers* buffers, NvFlexSolver* flex, bool anisotropy, bool density) +{ + printf("Not implemented"); + assert(0); +} + +void DemoContextD3D12::destroyFluidRenderBuffers(FluidRenderBuffers* buffers) +{ + delete reinterpret_cast(buffers); +} + +ShadowMap* DemoContextD3D12::shadowCreate() +{ + // Currently only allows single shadow map, which is pre created + return (::ShadowMap*)m_shadowMap.get(); +} + +void DemoContextD3D12::shadowDestroy(ShadowMap* map) +{ + assert(map); + assert(m_shadowMap.get() == (NvCo::Dx12RenderTarget*)map); +} + +void DemoContextD3D12::unbindSolidShader() +{ + m_meshDrawParams.renderStage = MESH_DRAW_NULL; + + // !!! Other code appears to assume that this will be set + //context->m_currentShadowMap = nullptr; +} + +GpuMesh* DemoContextD3D12::createGpuMesh(const Mesh* m) +{ + if (m) + { + return (GpuMesh*)MeshUtil::createRenderMesh(m_meshRenderer.get(), *m); + } + return nullptr; +} + +void DemoContextD3D12::destroyGpuMesh(GpuMesh* m) +{ + delete reinterpret_cast(m); +} + + +DiffuseRenderBuffers* DemoContextD3D12::createDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop) +{ + return reinterpret_cast(new DiffuseRenderBuffersD3D12(numDiffuseParticles)); +} + +void DemoContextD3D12::destroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers) +{ + delete reinterpret_cast(buffers); +} + +int DemoContextD3D12::getNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers) +{ + return reinterpret_cast(buffers)->m_numParticles; +} + +void DemoContextD3D12::updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffersIn, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles) +{ + DiffuseRenderBuffersD3D12& buffers = *reinterpret_cast(buffersIn); + + typedef PointRenderAllocationD3D12 Alloc; + + Alloc alloc; + + PointData pointData; + pointData.init(); + pointData.numIndices = numDiffuseParticles; + pointData.positions = (Vec4*)diffusePositions; + pointData.anisotropy[0] = (Vec4*)diffuseVelocities; // We'll store the velocities in the anisotropy buffer, cos it's the right size + pointData.numPoints = buffers.m_numParticles; + + m_meshRenderer->allocateTransitory(pointData, alloc, sizeof(alloc)); + + buffers.m_indicesView = alloc.m_indexBufferView; + buffers.m_positionsView = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION]; + buffers.m_velocitiesView = alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1]; // The velocity + + buffers.m_numParticles = numDiffuseParticles; +} + +void DemoContextD3D12::updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, NvFlexSolver* solver) +{ + printf("Not implemented"); + assert(0); +} + +void* DemoContextD3D12::getGraphicsCommandQueue() +{ + return m_renderContext->m_commandQueue; +} + +void DemoContextD3D12::setFillMode(bool wire) +{ + m_meshDrawParams.renderMode = wire ? MESH_RENDER_WIREFRAME : MESH_RENDER_SOLID; +} + +void DemoContextD3D12::setCullMode(bool enabled) +{ + m_meshDrawParams.cullMode = enabled ? MESH_CULL_BACK : MESH_CULL_NONE; +} + +void DemoContextD3D12::drawImguiGraph() +{ + imguiGraphDraw(); + /* + const imguiGfxCmd* cmds = imguiGetRenderQueue(); + int numCmds = imguiGetRenderQueueSize(); + m_imguiGraphContext->draw(cmds, numCmds); */ +} + + +} // namespace FlexSample + + + diff --git a/demo/d3d12/demoContextD3D12.h b/demo/d3d12/demoContextD3D12.h new file mode 100644 index 0000000..5f43c31 --- /dev/null +++ b/demo/d3d12/demoContextD3D12.h @@ -0,0 +1,256 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef DEMO_CONTEXT_D3D12_H +#define DEMO_CONTEXT_D3D12_H + +#include +#include + +#include "meshRenderer.h" +#include "renderStateD3D12.h" +#include "appD3D12Ctx.h" + +// SDL +#include +#include + +#include "shaders.h" +#include "d3d/demoContext.h" + +#define NOMINMAX +#include + +namespace FlexSample { + +struct FlexBuffer +{ + inline FlexBuffer():m_buffer(nullptr) {} + inline operator NvFlexBuffer* () const { return m_buffer; } + ~FlexBuffer() { if (m_buffer) { NvFlexUnregisterD3DBuffer(m_buffer); } } + + NvFlexBuffer* m_buffer; +}; + +struct FluidRenderBuffersD3D12 +{ + FluidRenderBuffersD3D12(int numParticles = 0) + { + m_numParticles = numParticles; + { + const D3D12_VERTEX_BUFFER_VIEW nullView = {}; + m_positionsView = nullView; + m_densitiesView = nullView; + m_fluidView = nullView; + for (int i = 0; i < _countof(m_anisotropiesViewArr); i++) + { + m_anisotropiesViewArr[i] = nullView; + } + } + { + D3D12_INDEX_BUFFER_VIEW nullView = {}; + m_indicesView = nullView; + } + } + + int m_numParticles; + + D3D12_VERTEX_BUFFER_VIEW m_positionsView; + D3D12_VERTEX_BUFFER_VIEW m_densitiesView; + D3D12_VERTEX_BUFFER_VIEW m_anisotropiesViewArr[3]; + D3D12_INDEX_BUFFER_VIEW m_indicesView; + + D3D12_VERTEX_BUFFER_VIEW m_fluidView; // to be removed + + // wrapper buffers that allow Flex to write directly to VBOs + FlexBuffer m_positionsBuf; + FlexBuffer m_densitiesBuf; + FlexBuffer m_anisotropiesBufArr[3]; + FlexBuffer m_indicesBuf; +}; + +// vertex buffers for diffuse particles +struct DiffuseRenderBuffersD3D12 +{ + DiffuseRenderBuffersD3D12(int numParticles = 0) + { + m_numParticles = numParticles; + { + const D3D12_VERTEX_BUFFER_VIEW nullView = {}; + m_positionsView = nullView; + m_velocitiesView = nullView; + } + { + D3D12_INDEX_BUFFER_VIEW nullView = {}; + m_indicesView = nullView; + } + } + + int m_numParticles; + + D3D12_VERTEX_BUFFER_VIEW m_positionsView; + D3D12_VERTEX_BUFFER_VIEW m_velocitiesView; + D3D12_INDEX_BUFFER_VIEW m_indicesView; + + FlexBuffer m_indicesBuf; + FlexBuffer m_positionsBuf; + FlexBuffer m_velocitiesBuf; +}; + +struct DemoContextD3D12: public DemoContext +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS_BASE(DemoContextD3D12) +public: + enum + { + NUM_COMPOSITE_SRVS = 3, + MAX_DEBUG_LINE_SIZE = 1024 * 4, // Will flush if exceeds this + }; + + // DemoContext Impl + virtual bool initialize(const RenderInitOptions& options) override; + virtual void startFrame(Vec4 colorIn) override; + virtual void endFrame() override; + virtual void presentFrame(bool fullsync) override; + + virtual void getViewRay(int x, int y, Vec3& origin, Vec3& dir) override; + virtual void setView(Matrix44 view, Matrix44 projection) override; + virtual void renderEllipsoids(FluidRenderer* renderer, FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) override; + + virtual void drawMesh(const Mesh* m, Vec3 color) override; + virtual void drawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex, float expand, bool twosided, bool smooth) override; + virtual void drawRope(Vec4* positions, int* indices, int numIndices, float radius, int color) override; + virtual void drawPlane(const Vec4& p, bool color) override; + virtual void drawPlanes(Vec4* planes, int n, float bias) override; + virtual void drawPoints(FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowTex, bool showDensity) override; + + virtual void graphicsTimerBegin() override; + virtual void graphicsTimerEnd() override; + + virtual float rendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) override; + + virtual void bindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float bias, Vec4 fogColor) override; + virtual void unbindSolidShader() override; + + virtual ShadowMap* shadowCreate() override; + virtual void shadowDestroy(ShadowMap* map) override; + virtual void shadowBegin(ShadowMap* map) override; + virtual void shadowEnd() override; + + virtual FluidRenderer* createFluidRenderer(uint32_t width, uint32_t height) override; + virtual void destroyFluidRenderer(FluidRenderer* renderer) override; + + virtual FluidRenderBuffers* createFluidRenderBuffers(int numParticles, bool enableInterop) override; + virtual void updateFluidRenderBuffers(FluidRenderBuffers* buffers, NvFlexSolver* flex, bool anisotropy, bool density) override; + virtual void updateFluidRenderBuffers(FluidRenderBuffers* buffers, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) override; + virtual void destroyFluidRenderBuffers(FluidRenderBuffers* buffers) override; + + virtual GpuMesh* createGpuMesh(const Mesh* m) override; + virtual void destroyGpuMesh(GpuMesh* mesh) override; + virtual void drawGpuMesh(GpuMesh* m, const Matrix44& xform, const Vec3& color) override; + virtual void drawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const Vec3& color) override; + + virtual DiffuseRenderBuffers* createDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop) override; + virtual void drawDiffuse(FluidRenderer* render, const DiffuseRenderBuffers* buffers, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ::ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadowEnabled, bool front) override; + virtual void destroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers) override; + virtual void updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles) override; + virtual void updateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, NvFlexSolver* solver) override; + virtual int getNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers) override; + + virtual void beginLines() override; + virtual void drawLine(const Vec3& p, const Vec3& q, const Vec4& color) override; + virtual void endLines() override; + + virtual void onSizeChanged(int width, int height, bool minimized) override; + + virtual void startGpuWork() override; + virtual void endGpuWork() override; + virtual void flushGraphicsAndWait() override; + + virtual void setFillMode(bool wire) override; + virtual void setCullMode(bool enabled) override; + + virtual void getRenderDevice(void** device, void** context) override; + virtual void drawImguiGraph() override; + virtual void* getGraphicsCommandQueue() override; + + /// Get the render context + inline AppGraphCtxD3D12* getRenderContext() const { return m_renderContext; } + + DemoContextD3D12(); + ~DemoContextD3D12(); + + int _initRenderResources(const RenderInitOptions& options); + int _initFluidRenderTargets(); + + void _flushDebugLines(); + + MeshDrawParamsD3D m_meshDrawParams; + + Matrix44 m_view; + Matrix44 m_proj; + + // NOTE! These are allocated such that they are in order. This is required because on compositePS.hlsl, I need s0, and s1 to be linear, and then shadowMap samplers. + int m_linearSamplerIndex; ///< Index to a linear sample on the m_samplerDescriptorHeap + int m_shadowMapLinearSamplerIndex; ///< Index to shadow map depth comparator sampler descriptor in m_samplerDescriptorHeap + + int m_fluidPointDepthSrvIndex; ///< Index into srv heap that holds srv for the m_flexMeshPipeline + int m_fluidCompositeSrvBaseIndex; ///< We have a set of NUM_COMPOSITE_SRVS for every back buffer there is + + AppGraphCtx* m_appGraphCtx; + AppGraphCtxD3D12* m_renderContext; + + std::unique_ptr m_meshRenderer; + + // Render pipelines + std::unique_ptr m_meshPipeline; + std::unique_ptr m_pointPipeline; + std::unique_ptr m_fluidPointPipeline; + std::unique_ptr m_fluidSmoothPipeline; + std::unique_ptr m_fluidCompositePipeline; + std::unique_ptr m_diffusePointPipeline; + std::unique_ptr m_linePipeline; + + std::unique_ptr m_fluidPointRenderTarget; + std::unique_ptr m_fluidSmoothRenderTarget; + std::unique_ptr m_fluidResolvedTarget; ///< The main render target resolved, such that it can be sampled from + + std::unique_ptr m_screenQuadMesh; + + std::unique_ptr m_shadowMap; + + NvCo::Dx12RenderTarget* m_currentShadowMap; ///< The current read from shadow buffer + NvCo::Dx12RenderTarget* m_targetShadowMap; ///< The shadow map bound to render to (ie for write with Begin/EndShadow + + std::wstring m_executablePath; + std::wstring m_shadersPath; + + RenderStateManagerD3D12 m_renderStateManager; + RenderStateD3D12 m_renderState; + + SDL_Window* m_window; + HWND m_hwnd; + + int m_msaaSamples; + + // Synchronization and timing for async compute benchmarking + ComPtr m_graphicsCompleteFence; + HANDLE m_graphicsCompleteEvent; + UINT64 m_graphicsCompleteFenceValue; + ComPtr m_queryHeap; + ComPtr m_queryResults; + + bool m_inLineDraw; + std::vector m_debugLineVertices; +}; + +} // namespace FlexSample + +#endif // DEMO_CONTEXT_D3D12_H \ No newline at end of file diff --git a/demo/d3d12/diffusePointRenderPipelineD3D12.cpp b/demo/d3d12/diffusePointRenderPipelineD3D12.cpp new file mode 100644 index 0000000..3641a36 --- /dev/null +++ b/demo/d3d12/diffusePointRenderPipelineD3D12.cpp @@ -0,0 +1,223 @@ +#define NOMINMAX + +#include + +#include + +#include "pipelineUtilD3D12.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +// Shaders +#include "../d3d/shaders/diffuseVS.hlsl.h" +#include "../d3d/shaders/diffuseGS.hlsl.h" +#include "../d3d/shaders/diffusePS.hlsl.h" + +// this +#include "diffusePointRenderPipelineD3D12.h" + +namespace FlexSample { + +static const D3D12_INPUT_ELEMENT_DESC InputElementDescs[] = +{ + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "VELOCITY", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, +}; + +DiffusePointRenderPipelineD3D12::DiffusePointRenderPipelineD3D12(): + Parent(PRIMITIVE_POINT), + m_shadowMapLinearSamplerIndex(-1) +{ +} + +static D3D12_FILL_MODE _getFillMode(DiffusePointRenderPipelineD3D12::PipelineStateType type) +{ + return D3D12_FILL_MODE_SOLID; +} + +static D3D12_CULL_MODE _getCullMode(DiffusePointRenderPipelineD3D12::PipelineStateType type) +{ + return D3D12_CULL_MODE_NONE; +} + +static void _initRasterizerDesc(DiffusePointRenderPipelineD3D12::PipelineStateType type, D3D12_RASTERIZER_DESC& desc) +{ + PipelineUtilD3D::initRasterizerDesc(FRONT_WINDING_COUNTER_CLOCKWISE, desc); + desc.FillMode = _getFillMode(type); + desc.CullMode = _getCullMode(type); +} + +static void _initPipelineStateDesc(DiffusePointRenderPipelineD3D12::PipelineStateType type, NvCo::Dx12RenderTarget* shadowMap, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + PipelineUtilD3D::initTargetFormat(nullptr, renderContext, psoDesc); + + // Z test, but don't write + { + D3D12_DEPTH_STENCIL_DESC& desc = psoDesc.DepthStencilState; + desc.DepthEnable = TRUE; + desc.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO; + desc.DepthFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL; + } + + psoDesc.InputLayout.NumElements = _countof(InputElementDescs); + psoDesc.InputLayout.pInputElementDescs = InputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; +} + +int DiffusePointRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, int shadowMapLinearSamplerIndex, NvCo::Dx12RenderTarget* shadowMap) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + m_shadowMapLinearSamplerIndex = shadowMapLinearSamplerIndex; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + { + // create blend state + D3D12_BLEND_DESC& desc = psoDesc.BlendState; + desc.AlphaToCoverageEnable = FALSE; + desc.IndependentBlendEnable = FALSE; + { + const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = + { + TRUE,FALSE, + D3D12_BLEND_ONE, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, + D3D12_BLEND_ONE, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, + D3D12_LOGIC_OP_NOOP, + D3D12_COLOR_WRITE_ENABLE_ALL, + }; + for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) + desc.RenderTarget[i] = defaultRenderTargetBlendDesc; + } + } + + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[3]; + + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0u; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_diffuseVS); + psoDesc.GS = Dx12Blob(g_diffuseGS); + psoDesc.PS = Dx12Blob(g_diffusePS); + + NV_RETURN_ON_FAIL(_initPipelineState(state, shadowMap, PIPELINE_STATE_LIGHT_SOLID, signiture.Get(), psoDesc)); + } + } + + return NV_OK; +} + +int DiffusePointRenderPipelineD3D12::_initPipelineState(const RenderStateD3D12& state, NvCo::Dx12RenderTarget* shadowMap, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + ID3D12Device* device = state.m_device; + + _initRasterizerDesc(pipeType, psoDesc.RasterizerState); + _initPipelineStateDesc(pipeType, shadowMap, state.m_renderContext, psoDesc); + + psoDesc.pRootSignature = signiture; + + PipelineStateD3D12& pipeState = m_states[pipeType]; + pipeState.m_rootSignature = signiture; + + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + return NV_OK; +} + +int DiffusePointRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + const DiffuseDrawParamsD3D& params = *(DiffuseDrawParamsD3D*)paramsIn; + + // Set up constant buffer + NvCo::Dx12CircularResourceHeap::Cursor cursor; + { + Hlsl::DiffuseShaderConst constBuf; + RenderParamsUtilD3D::calcDiffuseConstantBuffer(params, constBuf); + cursor = state.m_constantHeap->newConstantBuffer(constBuf); + if (!cursor.isValid()) + { + return NV_FAIL; + } + } + + const PipelineStateType pipeType = PIPELINE_STATE_LIGHT_SOLID; + PipelineStateD3D12& pipeState = m_states[pipeType]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + { + ID3D12DescriptorHeap* heaps[] = { state.m_srvCbvUavDescriptorHeap->getHeap() }; + commandList->SetDescriptorHeaps(_countof(heaps), heaps); + } + return NV_OK; +} + +int DiffusePointRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + typedef PointRenderAllocationD3D12 Alloc; + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + + assert(sizeof(Alloc) == sizeOfAlloc); + const Alloc& alloc = static_cast(allocIn); + + assert(alloc.m_numPrimitives >= 0); + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + D3D12_VERTEX_BUFFER_VIEW vertexBufferViews[] = + { + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION], + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1], // Actually holds velocity + }; + + commandList->IASetVertexBuffers(0, _countof(vertexBufferViews), vertexBufferViews); + commandList->IASetIndexBuffer(&alloc.m_indexBufferView); + commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST); + + if (alloc.m_indexBufferView.SizeInBytes) + { + commandList->DrawIndexedInstanced((UINT)allocIn.m_numPrimitives, 1, 0, 0, 0); + } + else + { + commandList->DrawInstanced((UINT)allocIn.m_numPrimitives, 1, 0, 0); + } + return NV_OK; +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/diffusePointRenderPipelineD3D12.h b/demo/d3d12/diffusePointRenderPipelineD3D12.h new file mode 100644 index 0000000..39f6292 --- /dev/null +++ b/demo/d3d12/diffusePointRenderPipelineD3D12.h @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef DIFFUSE_POINT_RENDER_PIPELINE_D3D12_H +#define DIFFUSE_POINT_RENDER_PIPELINE_D3D12_H + +#include +#include "../d3d/renderParamsD3D.h" +#include "renderStateD3D12.h" +#include "meshRenderer.h" + +#include + +namespace FlexSample { +using namespace nvidia; + +struct DiffusePointRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(DiffusePointRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_STATE_LIGHT_SOLID, + PIPELINE_STATE_COUNT_OF, + }; + + DiffusePointRenderPipelineD3D12(); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersDir, int shadowMapLinearSamplerIndex, NvCo::Dx12RenderTarget* shadowMap); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + protected: + + int _initPipelineState(const RenderStateD3D12& state, NvCo::Dx12RenderTarget* shadowMap, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); + + int m_shadowMapLinearSamplerIndex; //< The index to the linear sampler in the m_samplerHeap + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; +}; + +} // namespace FlexSample + +#endif // DIFFUSE_POINT_RENDER_PIPELINE_D3D12_H \ No newline at end of file diff --git a/demo/d3d12/fluidCompositeRenderPipelineD3D12.cpp b/demo/d3d12/fluidCompositeRenderPipelineD3D12.cpp new file mode 100644 index 0000000..87dafd2 --- /dev/null +++ b/demo/d3d12/fluidCompositeRenderPipelineD3D12.cpp @@ -0,0 +1,166 @@ +#define NOMINMAX + +#include +#include + +#include "pipelineUtilD3D12.h" +#include "meshRenderer.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +// Shaders +#include "../d3d/shaders/passThroughVS.hlsl.h" +#include "../d3d/shaders/compositePS.hlsl.h" + +// this +#include "fluidCompositeRenderPipelineD3D12.h" + +#define NOMINMAX +#include +using namespace Microsoft::WRL; + +namespace FlexSample { + +FluidCompositeRenderPipelineD3D12::FluidCompositeRenderPipelineD3D12(): + Parent(PRIMITIVE_TRIANGLE) +{ +} + +static void _initPipelineStateDesc(FluidCompositeRenderPipelineD3D12::PipelineStateType type, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + PipelineUtilD3D::initTargetFormat(nullptr, renderContext, psoDesc); + + psoDesc.InputLayout.NumElements = _countof(MeshRendererD3D12::MeshInputElementDescs); + psoDesc.InputLayout.pInputElementDescs = MeshRendererD3D12::MeshInputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; +} + +int FluidCompositeRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + PipelineUtilD3D::initSolidBlendDesc(psoDesc.BlendState); + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[10]; + + int rangeIndex = 0; + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + // depthTex, sceneTex, shadowTex + const int numSrvs = 3; + if (numSrvs > 0) + { + ranges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, numSrvs, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[rangeIndex], D3D12_SHADER_VISIBILITY_PIXEL); + rangeIndex++; + } + + const int numSamplers = 2; + if (numSamplers > 1) + { + ranges[rangeIndex].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, numSamplers, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[rangeIndex], D3D12_SHADER_VISIBILITY_PIXEL); + rangeIndex++; + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0u; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_passThroughVS); + psoDesc.PS = Dx12Blob(g_compositePS); + + NV_RETURN_ON_FAIL(_initPipelineState(state, PIPELINE_STATE_NORMAL, signiture.Get(), psoDesc)); + } + } + + return NV_OK; +} + +int FluidCompositeRenderPipelineD3D12::_initPipelineState(const RenderStateD3D12& state, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + ID3D12Device* device = state.m_device; + + PipelineUtilD3D::initRasterizerDesc(FRONT_WINDING_CLOCKWISE, psoDesc.RasterizerState); + _initPipelineStateDesc(pipeType, state.m_renderContext, psoDesc); + + psoDesc.pRootSignature = signiture; + + PipelineStateD3D12& pipeState = m_states[pipeType]; + pipeState.m_rootSignature = signiture; + + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + return NV_OK; +} + +int FluidCompositeRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + const FluidDrawParamsD3D& params = *(FluidDrawParamsD3D*)paramsIn; + + PipelineStateD3D12& pipeState = m_states[PIPELINE_STATE_NORMAL]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + NvCo::Dx12CircularResourceHeap::Cursor cursor; + { + Hlsl::FluidShaderConst constBuf; + RenderParamsUtilD3D::calcFluidCompositeConstantBuffer(params, constBuf); + cursor = state.m_constantHeap->newConstantBuffer(constBuf); + if (!cursor.isValid()) + { + return NV_FAIL; + } + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + ID3D12DescriptorHeap* heaps[] = { state.m_srvCbvUavDescriptorHeap->getHeap(), state.m_samplerDescriptorHeap->getHeap() }; + commandList->SetDescriptorHeaps(_countof(heaps), heaps); + + // Bind the srvs + commandList->SetGraphicsRootDescriptorTable(1, state.m_srvCbvUavDescriptorHeap->getGpuHandle(params.m_srvDescriptorBase)); + // Bind the samplers + commandList->SetGraphicsRootDescriptorTable(2, state.m_samplerDescriptorHeap->getGpuHandle(params.m_sampleDescriptorBase)); + return NV_OK; +} + +int FluidCompositeRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + return MeshRendererD3D12::defaultDraw(allocIn, sizeOfAlloc, platformState); +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/fluidCompositeRenderPipelineD3D12.h b/demo/d3d12/fluidCompositeRenderPipelineD3D12.h new file mode 100644 index 0000000..509acea --- /dev/null +++ b/demo/d3d12/fluidCompositeRenderPipelineD3D12.h @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef FLUID_COMPOSITE_RENDER_PIPELINE_D3D12_H +#define FLUID_COMPOSITE_RENDER_PIPELINE_D3D12_H + +#include +#include "../d3d/renderParamsD3D.h" +#include "renderStateD3D12.h" +#include "meshRenderer.h" + +#include + +#include "fluidEllipsoidRenderPipelineD3D12.h" + +namespace FlexSample { + +struct FluidCompositeRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(FluidCompositeRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_STATE_NORMAL, + PIPELINE_STATE_COUNT_OF, + }; + + FluidCompositeRenderPipelineD3D12(); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersPath); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + protected: + + int _initPipelineState(const RenderStateD3D12& state, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); + + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/fluidEllipsoidRenderPipelineD3D12.cpp b/demo/d3d12/fluidEllipsoidRenderPipelineD3D12.cpp new file mode 100644 index 0000000..1c7ff53 --- /dev/null +++ b/demo/d3d12/fluidEllipsoidRenderPipelineD3D12.cpp @@ -0,0 +1,176 @@ +#define NOMINMAX + +#include + +#include + +#include "pipelineUtilD3D12.h" +#include "meshRenderer.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +#include "../d3d/shaders/ellipsoidDepthVS.hlsl.h" +#include "../d3d/shaders/ellipsoidDepthGS.hlsl.h" +#include "../d3d/shaders/ellipsoidDepthPS.hlsl.h" + +// this +#include "fluidEllipsoidRenderPipelineD3D12.h" + +namespace FlexSample { + +static const D3D12_INPUT_ELEMENT_DESC AnisotropicInputElementDescs[] = +{ + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "U", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "V", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "W", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, +}; + +FluidEllipsoidRenderPipelineD3D12::FluidEllipsoidRenderPipelineD3D12(): + Parent(PRIMITIVE_POINT) +{ +} + +static void _initPipelineStateDesc(FluidEllipsoidRenderPipelineD3D12::PipelineStateType type, NvCo::Dx12RenderTarget* renderTarget, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + PipelineUtilD3D::initTargetFormat(renderTarget, nullptr, psoDesc); + + psoDesc.InputLayout.NumElements = _countof(AnisotropicInputElementDescs); + psoDesc.InputLayout.pInputElementDescs = AnisotropicInputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; +} + +int FluidEllipsoidRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, NvCo::Dx12RenderTarget* renderTarget) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + PipelineUtilD3D::initSolidBlendDesc(psoDesc.BlendState); + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[3]; + + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0u; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_ellipsoidDepthVS); + psoDesc.GS = Dx12Blob(g_ellipsoidDepthGS); + psoDesc.PS = Dx12Blob(g_ellipsoidDepthPS); + + NV_RETURN_ON_FAIL(_initPipelineState(state, FRONT_WINDING_COUNTER_CLOCKWISE, renderTarget, PIPELINE_NORMAL, signiture.Get(), psoDesc)); + } + } + + return NV_OK; +} + +int FluidEllipsoidRenderPipelineD3D12::_initPipelineState(const RenderStateD3D12& state, FrontWindingType winding, NvCo::Dx12RenderTarget* renderTarget, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + ID3D12Device* device = state.m_device; + + PipelineUtilD3D::initRasterizerDesc(winding, psoDesc.RasterizerState); + + _initPipelineStateDesc(pipeType, renderTarget, psoDesc); + + psoDesc.pRootSignature = signiture; + + PipelineStateD3D12& pipeState = m_states[pipeType]; + pipeState.m_rootSignature = signiture; + + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + return NV_OK; +} + +int FluidEllipsoidRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + const FluidDrawParamsD3D& params = *(FluidDrawParamsD3D*)paramsIn; + + PipelineStateType pipeType = getPipelineStateType(params.renderStage, params.renderMode, params.cullMode); + PipelineStateD3D12& pipeState = m_states[pipeType]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + NvCo::Dx12CircularResourceHeap::Cursor cursor; + { + Hlsl::FluidShaderConst constBuf; + RenderParamsUtilD3D::calcFluidConstantBuffer(params, constBuf); + cursor = state.m_constantHeap->newConstantBuffer(constBuf); + if (!cursor.isValid()) + { + return NV_FAIL; + } + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + ID3D12DescriptorHeap* heaps[] = { nullptr }; + commandList->SetDescriptorHeaps(0, heaps); + + return NV_OK; +} + +int FluidEllipsoidRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + typedef PointRenderAllocationD3D12 Alloc; + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + + assert(sizeof(Alloc) == sizeOfAlloc); + const Alloc& alloc = static_cast(allocIn); + + assert(allocIn.m_numPrimitives >= 0); + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + D3D12_VERTEX_BUFFER_VIEW vertexBufferViews[4] = + { + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION], + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1], + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY2], + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY3], + }; + + commandList->IASetVertexBuffers(0, _countof(vertexBufferViews), vertexBufferViews); + commandList->IASetIndexBuffer(&alloc.m_indexBufferView); + + commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST); + + commandList->DrawIndexedInstanced((UINT)allocIn.m_numPrimitives, 1, 0, 0, 0); + return NV_OK; +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/fluidEllipsoidRenderPipelineD3D12.h b/demo/d3d12/fluidEllipsoidRenderPipelineD3D12.h new file mode 100644 index 0000000..96d326b --- /dev/null +++ b/demo/d3d12/fluidEllipsoidRenderPipelineD3D12.h @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef FLUID_ELLIPSOID_RENDER_PIPELINE_D3D12_H +#define FLUID_ELLIPSOID_RENDER_PIPELINE_D3D12_H + +#include +#include "RenderStateD3D12.h" +#include "../d3d/renderParamsD3D.h" +#include "meshRenderer.h" + +#include + +namespace FlexHlsl { +struct FluidShaderConst; +} // namespace FlexHlsl + +namespace FlexSample { +using namespace nvidia; + +struct FluidEllipsoidRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(FluidEllipsoidRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_NORMAL, + PIPELINE_STATE_COUNT_OF, + }; + + FluidEllipsoidRenderPipelineD3D12(); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersDir, NvCo::Dx12RenderTarget* renderTarget); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + /// Convert into a single pipeline state type + static PipelineStateType getPipelineStateType(FluidDrawStage stage, FluidRenderMode mode, FluidCullMode cull) { return PIPELINE_NORMAL; } + + protected: + + int _initPipelineState(const RenderStateD3D12& state, FrontWindingType winding, NvCo::Dx12RenderTarget* renderTarget, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); + + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/fluidSmoothRenderPipelineD3D12.cpp b/demo/d3d12/fluidSmoothRenderPipelineD3D12.cpp new file mode 100644 index 0000000..6d6c489 --- /dev/null +++ b/demo/d3d12/fluidSmoothRenderPipelineD3D12.cpp @@ -0,0 +1,158 @@ +#define NOMINMAX + +#include +#include + +#include "meshRenderer.h" +#include "pipelineUtilD3D12.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +// this +#include "fluidSmoothRenderPipelineD3D12.h" + +// Shaders +#include "../d3d/shaders/passThroughVS.hlsl.h" +#include "../d3d/shaders/blurDepthPS.hlsl.h" + +namespace FlexSample { + +FluidSmoothRenderPipelineD3D12::FluidSmoothRenderPipelineD3D12(int fluidPointDepthSrvIndex): + Parent(PRIMITIVE_TRIANGLE), + m_fluidPointDepthSrvIndex(fluidPointDepthSrvIndex) +{ +} + +static void _initPipelineStateDesc(FluidSmoothRenderPipelineD3D12::PipelineStateType type, NvCo::Dx12RenderTarget* renderTarget, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + PipelineUtilD3D::initTargetFormat(renderTarget, nullptr, psoDesc); + + psoDesc.InputLayout.NumElements = _countof(MeshRendererD3D12::MeshInputElementDescs); + psoDesc.InputLayout.pInputElementDescs = MeshRendererD3D12::MeshInputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; +} + +int FluidSmoothRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, NvCo::Dx12RenderTarget* renderTarget) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + PipelineUtilD3D::initSolidBlendDesc(psoDesc.BlendState); + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[3]; + + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + const int numSrvs = 1; + if (numSrvs > 0) + { + ranges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, numSrvs, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[0], D3D12_SHADER_VISIBILITY_PIXEL); + } + const int numSamplers = 0; + if (numSamplers > 0) + { + ranges[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, numSamplers, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[1], D3D12_SHADER_VISIBILITY_PIXEL); + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0u; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_passThroughVS); + psoDesc.PS = Dx12Blob(g_blurDepthPS); + + NV_RETURN_ON_FAIL(_initPipelineState(state, renderTarget, PIPELINE_STATE_NORMAL, signiture.Get(), psoDesc)); + } + } + + return NV_OK; +} + +int FluidSmoothRenderPipelineD3D12::_initPipelineState(const RenderStateD3D12& state, NvCo::Dx12RenderTarget* renderTarget, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + ID3D12Device* device = state.m_device; + + PipelineUtilD3D::initRasterizerDesc(FRONT_WINDING_CLOCKWISE, psoDesc.RasterizerState); + _initPipelineStateDesc(pipeType, renderTarget, state.m_renderContext, psoDesc); + + psoDesc.pRootSignature = signiture; + + PipelineStateD3D12& pipeState = m_states[pipeType]; + pipeState.m_rootSignature = signiture; + + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + return NV_OK; +} + +int FluidSmoothRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + const FluidDrawParamsD3D& params = *(FluidDrawParamsD3D*)paramsIn; + + PipelineStateD3D12& pipeState = m_states[PIPELINE_STATE_NORMAL]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + NvCo::Dx12CircularResourceHeap::Cursor cursor; + { + Hlsl::FluidShaderConst constBuf; + RenderParamsUtilD3D::calcFluidConstantBuffer(params, constBuf); + cursor = state.m_constantHeap->newConstantBuffer(constBuf); + if (!cursor.isValid()) + { + return NV_FAIL; + } + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + NvCo::Dx12RenderTarget* sourceMap = (NvCo::Dx12RenderTarget*)params.shadowMap; + + ID3D12DescriptorHeap* heaps[] = { state.m_srvCbvUavDescriptorHeap->getHeap(), state.m_samplerDescriptorHeap->getHeap() }; + commandList->SetDescriptorHeaps(_countof(heaps), heaps); + + // Bind the srvs + commandList->SetGraphicsRootDescriptorTable(1, state.m_srvCbvUavDescriptorHeap->getGpuHandle(m_fluidPointDepthSrvIndex)); + return NV_OK; +} + +int FluidSmoothRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + return MeshRendererD3D12::defaultDraw(allocIn, sizeOfAlloc, platformState); +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/fluidSmoothRenderPipelineD3D12.h b/demo/d3d12/fluidSmoothRenderPipelineD3D12.h new file mode 100644 index 0000000..fc08981 --- /dev/null +++ b/demo/d3d12/fluidSmoothRenderPipelineD3D12.h @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef FLUID_SMOOTH_RENDER_PIPELINE_D3D12_H +#define FLUID_SMOOTH_RENDER_PIPELINE_D3D12_H + +#include +#include "RenderStateD3D12.h" +#include "MeshRenderer.h" + +#include + +#include "FluidEllipsoidRenderPipelineD3D12.h" + +namespace FlexSample { + +struct FluidSmoothRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(FluidSmoothRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_STATE_NORMAL, + PIPELINE_STATE_COUNT_OF, + }; + + FluidSmoothRenderPipelineD3D12(int fluidPointDepthSrvIndex); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, NvCo::Dx12RenderTarget* renderTarget); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + protected: + + int _initPipelineState(const RenderStateD3D12& state, NvCo::Dx12RenderTarget* renderTarget, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); + + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; + + int m_fluidPointDepthSrvIndex; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/imguiGraphD3D12.cpp b/demo/d3d12/imguiGraphD3D12.cpp new file mode 100644 index 0000000..64c507d --- /dev/null +++ b/demo/d3d12/imguiGraphD3D12.cpp @@ -0,0 +1,667 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +//direct3d headers +#define NOMINMAX +#include + +#include "imguiGraphD3D12.h" + +#include "../d3d/shaders/imguiVS.hlsl.h" +#include "../d3d/shaders/imguiPS.hlsl.h" + +namespace +{ + template + void inline COMRelease(T& t) + { + if (t) t->Release(); + t = nullptr; + } +} + +namespace +{ + ImguiGraphDescD3D12 m_desc = {}; + + struct Vertex + { + float x, y; + float u, v; + uint8_t rgba[4]; + }; + + ID3D12RootSignature* m_rootSignature = nullptr; + ID3D12PipelineState* m_pipelineState = nullptr; + ID3D12Resource* m_constantBuffer = nullptr; + UINT8* m_constantBufferData = nullptr; + ID3D12Resource* m_vertexBuffer = nullptr; + Vertex* m_vertexBufferData = nullptr; + D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView = {}; + + struct Scissor + { + int beginIdx; + int stopIdx; + int x; + int y; + int width; + int height; + }; + Scissor m_stateScissor = {}; + + ID3D12Resource* m_textureUploadHeap = nullptr; + ID3D12Resource* m_texture = nullptr; + + ID3D12DescriptorHeap* m_srvUavHeapCPU = nullptr; + ID3D12DescriptorHeap* m_srvUavHeapGPU = nullptr; + + Vertex m_stateVert; + uint32_t m_stateVertIdx = 0u; + + struct Params + { + float projection[16]; + + float padding[64 - 16]; + }; + static const int frameCount = 4; + int frameIndex = 0; +} + +void imguiGraphContextInitD3D12(const ImguiGraphDesc* descIn) +{ + const auto desc = cast_to_imguiGraphDescD3D12(descIn); + + m_desc = *desc; + + // create the root signature + { + D3D12_DESCRIPTOR_RANGE ranges[1]; + ranges[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; + ranges[0].NumDescriptors = 1u; + ranges[0].BaseShaderRegister = 0u; + ranges[0].RegisterSpace = 0u; + ranges[0].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; + + D3D12_ROOT_PARAMETER params[2]; + params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + params[0].Descriptor.ShaderRegister = 0u; + params[0].Descriptor.RegisterSpace = 0u; + params[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + params[1].DescriptorTable.NumDescriptorRanges = 1; + params[1].DescriptorTable.pDescriptorRanges = ranges; + params[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; + + D3D12_STATIC_SAMPLER_DESC sampler = {}; + sampler.Filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; + sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_BORDER; + sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_BORDER; + sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_BORDER; + sampler.MipLODBias = 0; + sampler.MaxAnisotropy = 0; + sampler.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER; + sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; + sampler.MinLOD = 0.f; + sampler.MaxLOD = D3D12_FLOAT32_MAX; + sampler.ShaderRegister = 0; + sampler.RegisterSpace = 0; + sampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = 2; + desc.pParameters = params; + desc.NumStaticSamplers = 1u; + desc.pStaticSamplers = &sampler; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ID3DBlob* signature = nullptr; + ID3DBlob* error = nullptr; + HRESULT hr = S_OK; + if (hr = D3D12SerializeRootSignature(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error)) + { + return; + } + if (hr = m_desc.device->CreateRootSignature(0u, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_rootSignature))) + { + return; + } + COMRelease(signature); + COMRelease(error); + } + + // create the pipeline state object + { + D3D12_INPUT_ELEMENT_DESC inputElementDescs[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + }; + + const bool wireFrame = false; + + D3D12_RASTERIZER_DESC rasterDesc; + if (wireFrame) + { + rasterDesc.FillMode = D3D12_FILL_MODE_WIREFRAME; + rasterDesc.CullMode = D3D12_CULL_MODE_NONE; + } + else + { + rasterDesc.FillMode = D3D12_FILL_MODE_SOLID; + rasterDesc.CullMode = D3D12_CULL_MODE_BACK; + } + rasterDesc.FrontCounterClockwise = TRUE; // FALSE; + rasterDesc.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; + rasterDesc.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; + rasterDesc.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; + rasterDesc.DepthClipEnable = TRUE; + rasterDesc.MultisampleEnable = FALSE; + rasterDesc.AntialiasedLineEnable = FALSE; + rasterDesc.ForcedSampleCount = 0; + rasterDesc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; + + D3D12_BLEND_DESC blendDesc; + blendDesc.AlphaToCoverageEnable = FALSE; + blendDesc.IndependentBlendEnable = FALSE; + { + const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = + { + TRUE,FALSE, + D3D12_BLEND_SRC_ALPHA, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, + D3D12_BLEND_SRC_ALPHA, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, + D3D12_LOGIC_OP_NOOP, + D3D12_COLOR_WRITE_ENABLE_ALL, + }; + for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) + blendDesc.RenderTarget[i] = defaultRenderTargetBlendDesc; + } + + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + psoDesc.InputLayout.NumElements = 3; + psoDesc.InputLayout.pInputElementDescs = inputElementDescs; + psoDesc.pRootSignature = m_rootSignature; + psoDesc.VS.pShaderBytecode = g_imguiVS; + psoDesc.VS.BytecodeLength = sizeof(g_imguiVS); + psoDesc.PS.pShaderBytecode = g_imguiPS; + psoDesc.PS.BytecodeLength = sizeof(g_imguiPS); + psoDesc.RasterizerState = rasterDesc; + psoDesc.BlendState = blendDesc; + psoDesc.DepthStencilState.DepthEnable = FALSE; + psoDesc.DepthStencilState.StencilEnable = FALSE; + psoDesc.SampleMask = UINT_MAX; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + psoDesc.NumRenderTargets = 1; + psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; + psoDesc.SampleDesc.Count = desc->numMSAASamples; + HRESULT hr = S_OK; + if (hr = m_desc.device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_pipelineState))) + { + return; + } + } + + // create a constant buffer + { + Params params = { + 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f + }; + + HRESULT hr = S_OK; + + D3D12_HEAP_PROPERTIES heapProps = {}; + heapProps.Type = D3D12_HEAP_TYPE_UPLOAD; + heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapProps.CreationNodeMask = 0u; + heapProps.VisibleNodeMask = 0u; + + D3D12_RESOURCE_DESC desc = {}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Alignment = 0u; + desc.Width = frameCount*sizeof(params); + desc.Height = 1u; + desc.DepthOrArraySize = 1u; + desc.MipLevels = 1; + desc.Format = DXGI_FORMAT_UNKNOWN; + desc.SampleDesc.Count = 1u; + desc.SampleDesc.Quality = 0u; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Flags = D3D12_RESOURCE_FLAG_NONE; + + if (hr = m_desc.device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, IID_PPV_ARGS(&m_constantBuffer))) + { + return; + } + + UINT8* pdata; + D3D12_RANGE readRange = {}; + if (hr = m_constantBuffer->Map(0, &readRange, (void**)&pdata)) + { + return; + } + else + { + memcpy(pdata, ¶ms, sizeof(params)); + m_constantBufferData = pdata; + //m_constantBuffer->Unmap(0, nullptr); // leave mapped + } + } + + // create a vertex buffer + { + HRESULT hr = S_OK; + + UINT bufferSize = (UINT)(m_desc.maxVertices * frameCount) * sizeof(Vertex); + + D3D12_HEAP_PROPERTIES heapProps = {}; + heapProps.Type = D3D12_HEAP_TYPE_UPLOAD; + heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapProps.CreationNodeMask = 0u; + heapProps.VisibleNodeMask = 0u; + + D3D12_RESOURCE_DESC desc = {}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Alignment = 0u; + desc.Width = bufferSize; + desc.Height = 1u; + desc.DepthOrArraySize = 1u; + desc.MipLevels = 1; + desc.Format = DXGI_FORMAT_UNKNOWN; + desc.SampleDesc.Count = 1u; + desc.SampleDesc.Quality = 0u; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Flags = D3D12_RESOURCE_FLAG_NONE; + + if (hr = m_desc.device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, IID_PPV_ARGS(&m_vertexBuffer))) + { + return; + } + + UINT8* pdata; + D3D12_RANGE readRange = {}; + if (hr = m_vertexBuffer->Map(0, &readRange, (void**)&pdata)) + { + return; + } + else + { + m_vertexBufferData = (Vertex*)pdata; + //m_vertexBufferUpload->Unmap(0, nullptr); + } + + m_vertexBufferView.BufferLocation = m_vertexBuffer->GetGPUVirtualAddress(); + m_vertexBufferView.StrideInBytes = sizeof(Vertex); + m_vertexBufferView.SizeInBytes = bufferSize; + } +} + +void imguiGraphContextUpdateD3D12(const ImguiGraphDesc* descIn) +{ + const auto desc = cast_to_imguiGraphDescD3D12(descIn); + + m_desc = *desc; +} + +void imguiGraphContextDestroyD3D12() +{ + COMRelease(m_rootSignature); + COMRelease(m_pipelineState); + COMRelease(m_constantBuffer); + COMRelease(m_vertexBuffer); +} + +void imguiGraphRecordBeginD3D12() +{ + frameIndex = (frameIndex + 1) % frameCount; + + Params params = { + 2.f / float(m_desc.winW), 0.f, 0.f, -1.f, + 0.f, 2.f / float(m_desc.winH), 0.f, -1.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f + }; + + memcpy(m_constantBufferData + frameIndex*sizeof(Params), ¶ms, sizeof(Params)); + + // clear state + m_stateVert = Vertex{ 0.f, 0.f, -1.f, -1.f, 0,0,0,0 }; + m_stateVertIdx = 0u; + + m_stateScissor = Scissor { 0, 0, 0, 0, m_desc.winW, m_desc.winH }; + + // configure for triangle renderering + ID3D12GraphicsCommandList* commandList = m_desc.commandList; + + D3D12_CPU_DESCRIPTOR_HANDLE srvHandleCPU; + D3D12_GPU_DESCRIPTOR_HANDLE srvHandleGPU; + ID3D12DescriptorHeap* heap = nullptr; + if (m_desc.dynamicHeapCbvSrvUav.reserveDescriptors) + { + auto handle = m_desc.dynamicHeapCbvSrvUav.reserveDescriptors(m_desc.dynamicHeapCbvSrvUav.userdata, + 1u, m_desc.lastFenceCompleted, m_desc.nextFenceValue); + heap = handle.heap; + srvHandleCPU = handle.cpuHandle; + srvHandleGPU = handle.gpuHandle; + } + else + { + if (m_srvUavHeapGPU == nullptr) + { + D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {}; + srvHeapDesc.NumDescriptors = 1; + srvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + srvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + m_desc.device->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&m_srvUavHeapGPU)); + } + heap = m_srvUavHeapGPU; + srvHandleCPU = m_srvUavHeapGPU->GetCPUDescriptorHandleForHeapStart(); + srvHandleGPU = m_srvUavHeapGPU->GetGPUDescriptorHandleForHeapStart(); + } + + commandList->SetDescriptorHeaps(1, &heap); + + m_desc.device->CopyDescriptorsSimple(1u, srvHandleCPU, m_srvUavHeapCPU->GetCPUDescriptorHandleForHeapStart(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + commandList->SetGraphicsRootSignature(m_rootSignature); + commandList->SetPipelineState(m_pipelineState); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = m_constantBuffer->GetGPUVirtualAddress(); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle + frameIndex * sizeof(Params)); + + commandList->SetGraphicsRootDescriptorTable(1, srvHandleGPU); + + commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + commandList->IASetVertexBuffers(0, 1, &m_vertexBufferView); +} + +static void imguiGraphFlush() +{ + ID3D12GraphicsCommandList* commandList = m_desc.commandList; + + Scissor& p = m_stateScissor; + if (p.beginIdx < p.stopIdx) + { + int winH = m_desc.winH; + D3D12_RECT rect; + rect.left = p.x; + rect.right = p.x + p.width; + rect.top = (winH) - (p.y + p.height); + rect.bottom = (winH) - (p.y); + commandList->RSSetScissorRects(1, &rect); + + UINT vertexCount = (p.stopIdx - p.beginIdx); + UINT startIndex = p.beginIdx + frameIndex * m_desc.maxVertices; + commandList->DrawInstanced(vertexCount, 1, startIndex, 0); + } +} + +void imguiGraphRecordEndD3D12() +{ + ID3D12GraphicsCommandList* commandList = m_desc.commandList; + + // no need to hold onto this + COMRelease(m_textureUploadHeap); + + // restore scissor + Scissor& p = m_stateScissor; + int winH = m_desc.winH; + D3D12_RECT rect; + rect.left = p.x; + rect.right = p.x + p.width; + rect.top = (winH) - (p.y + p.height); + rect.bottom = (winH) - (p.y); + commandList->RSSetScissorRects(1, &rect); +} + +void imguiGraphEnableScissorD3D12(int x, int y, int width, int height) +{ + // mark end of last region + m_stateScissor.stopIdx = m_stateVertIdx; + + imguiGraphFlush(); + + m_stateScissor.beginIdx = m_stateVertIdx; + m_stateScissor.stopIdx = m_stateVertIdx; + m_stateScissor.x = x; + m_stateScissor.y = y; + m_stateScissor.width = width; + m_stateScissor.height = height; +} + +void imguiGraphDisableScissorD3D12() +{ + if (m_stateVertIdx == 0) return; + + // mark end of last region + m_stateScissor.stopIdx = m_stateVertIdx; + + imguiGraphFlush(); + + m_stateScissor.beginIdx = m_stateVertIdx; + m_stateScissor.stopIdx = m_stateVertIdx; + m_stateScissor.x = 0; + m_stateScissor.y = 0; + m_stateScissor.width = m_desc.winW; + m_stateScissor.height = m_desc.winH; +} + +void imguiGraphVertex2fD3D12(float x, float y) +{ + float v[2] = { x,y }; + imguiGraphVertex2fvD3D12(v); +} + +void imguiGraphVertex2fvD3D12(const float* v) +{ + // update state + m_stateVert.x = v[0]; + m_stateVert.y = v[1]; + + Vertex* vdata = &m_vertexBufferData[frameIndex * m_desc.maxVertices]; + + // push vertex + if ((m_stateVertIdx) < m_desc.maxVertices) + { + vdata[m_stateVertIdx++] = m_stateVert; + } +} + +void imguiGraphTexCoord2fD3D12(float u, float v) +{ + m_stateVert.u = u; + m_stateVert.v = v; +} + +void imguiGraphColor4ubD3D12(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) +{ + m_stateVert.rgba[0] = red; + m_stateVert.rgba[1] = green; + m_stateVert.rgba[2] = blue; + m_stateVert.rgba[3] = alpha; +} + +void imguiGraphColor4ubvD3D12(const uint8_t* v) +{ + m_stateVert.rgba[0] = v[0]; + m_stateVert.rgba[1] = v[1]; + m_stateVert.rgba[2] = v[2]; + m_stateVert.rgba[3] = v[3]; +} + +void imguiGraphFontTextureEnableD3D12() +{ + +} + +void imguiGraphFontTextureDisableD3D12() +{ + m_stateVert.u = -1.f; + m_stateVert.v = -1.f; +} + +void imguiGraphFontTextureInitD3D12(unsigned char* data) +{ + ID3D12GraphicsCommandList* commandList = m_desc.commandList; + + // Create the texture + { + UINT width = 512; + UINT height = 512; + + D3D12_HEAP_PROPERTIES heapProps = {}; + heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; + heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapProps.CreationNodeMask = 0u; + heapProps.VisibleNodeMask = 0u; + + D3D12_RESOURCE_DESC texDesc = {}; + texDesc.MipLevels = 1u; + texDesc.Format = DXGI_FORMAT_R8_UNORM; + texDesc.Width = width; + texDesc.Height = height; + texDesc.Flags = D3D12_RESOURCE_FLAG_NONE; + texDesc.DepthOrArraySize = 1u; + texDesc.SampleDesc.Count = 1u; + texDesc.SampleDesc.Quality = 0u; + texDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + + if (m_desc.device->CreateCommittedResource( + &heapProps, + D3D12_HEAP_FLAG_NONE, + &texDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS(&m_texture) + )) + { + return; + } + + // get footprint information + D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint = {}; + UINT64 uploadHeapSize = 0u; + m_desc.device->GetCopyableFootprints(&texDesc, 0u, 1u, 0u, &footprint, nullptr, nullptr, &uploadHeapSize); + + heapProps.Type = D3D12_HEAP_TYPE_UPLOAD; + D3D12_RESOURCE_DESC bufferDesc = texDesc; + bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + bufferDesc.Alignment = 0u; + bufferDesc.Width = uploadHeapSize; + bufferDesc.Height = 1u; + bufferDesc.DepthOrArraySize = 1u; + bufferDesc.MipLevels = 1; + bufferDesc.Format = DXGI_FORMAT_UNKNOWN; + bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + bufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; + + if (m_desc.device->CreateCommittedResource( + &heapProps, + D3D12_HEAP_FLAG_NONE, + &bufferDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, + IID_PPV_ARGS(&m_textureUploadHeap) + )) + { + return; + } + + // map upload heap, and convert rgb bitmap to rgba + UINT8* pdata; + D3D12_RANGE readRange = {}; + if (m_textureUploadHeap->Map(0, &readRange, (void**)&pdata)) + { + return; + } + else + { + UINT8* dst = pdata; + UINT elements = width*height; + UINT8* src = data; + for (UINT j = 0; j < height; j++) + { + for (UINT i = 0; i < width; i++) + { + UINT idx = j * (footprint.Footprint.RowPitch) + i; + + UINT8 a = src[j * width + i]; + dst[idx] = a; + } + } + + m_textureUploadHeap->Unmap(0, nullptr); + } + + // add copy from upload heap to default heap to command list + D3D12_TEXTURE_COPY_LOCATION dstCopy = {}; + D3D12_TEXTURE_COPY_LOCATION srcCopy = {}; + dstCopy.pResource = m_texture; + dstCopy.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + dstCopy.SubresourceIndex = 0u; + srcCopy.pResource = m_textureUploadHeap; + srcCopy.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + srcCopy.PlacedFootprint = footprint; + commandList->CopyTextureRegion(&dstCopy, 0, 0, 0, &srcCopy, nullptr); + + D3D12_RESOURCE_BARRIER barrier[1] = {}; + auto textureBarrier = [&barrier](UINT idx, ID3D12Resource* texture) + { + barrier[idx].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier[idx].Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + barrier[idx].Transition.pResource = texture; + barrier[idx].Transition.Subresource = 0u; + barrier[idx].Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST; + barrier[idx].Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + }; + textureBarrier(0, m_texture); + commandList->ResourceBarrier(1, barrier); + + // create an SRV heap and descriptor for the texture + D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {}; + srvHeapDesc.NumDescriptors = 1; + srvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + srvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + if (m_desc.device->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&m_srvUavHeapCPU))) + { + return; + } + + D3D12_CPU_DESCRIPTOR_HANDLE srvUavHandle = m_srvUavHeapCPU->GetCPUDescriptorHandleForHeapStart(); + + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srvDesc.Format = texDesc.Format; + srvDesc.Texture2D.MipLevels = 1; + srvDesc.Texture2D.MostDetailedMip = 0; + srvDesc.Texture2D.ResourceMinLODClamp = 0.f; + + m_desc.device->CreateShaderResourceView(m_texture, &srvDesc, srvUavHandle); + } + +} + +void imguiGraphFontTextureReleaseD3D12() +{ + COMRelease(m_texture); + COMRelease(m_textureUploadHeap); + COMRelease(m_srvUavHeapCPU); + COMRelease(m_srvUavHeapGPU); +} \ No newline at end of file diff --git a/demo/d3d12/imguiGraphD3D12.h b/demo/d3d12/imguiGraphD3D12.h new file mode 100644 index 0000000..fc2e67e --- /dev/null +++ b/demo/d3d12/imguiGraphD3D12.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +#ifndef IMGUI_GRAPH_D3D12_H +#define IMGUI_GRAPH_D3D12_H + +#include + +#include "../d3d/imguiGraph.h" + +struct ImguiDescriptorReserveHandleD3D12 +{ + ID3D12DescriptorHeap* heap; + UINT descriptorSize; + D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle; + D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle; +}; + +struct ImguiDynamicDescriptorHeapD3D12 +{ + void* userdata; + ImguiDescriptorReserveHandleD3D12(*reserveDescriptors)(void* userdata, UINT numDescriptors, UINT64 lastFenceCompleted, UINT64 nextFenceValue); +}; + +struct ImguiGraphDescD3D12 +{ + ID3D12Device* device = nullptr; + ID3D12GraphicsCommandList* commandList = nullptr; + UINT64 lastFenceCompleted; + UINT64 nextFenceValue; + int winW; + int winH; + int numMSAASamples = 1; + + uint32_t maxVertices = 64 * 4096u; + + ImguiDynamicDescriptorHeapD3D12 dynamicHeapCbvSrvUav = {}; + + ImguiGraphDescD3D12() {} +}; + +inline const ImguiGraphDescD3D12* cast_to_imguiGraphDescD3D12(const ImguiGraphDesc* desc) +{ + return (const ImguiGraphDescD3D12*)(desc); +} + +inline ImguiGraphDesc* cast_from_imguiGraphDescD3D12(ImguiGraphDescD3D12* desc) +{ + return (ImguiGraphDesc*)(desc); +} + +IMGUI_GRAPH_API void imguiGraphContextInitD3D12(const ImguiGraphDesc* desc); + +IMGUI_GRAPH_API void imguiGraphContextUpdateD3D12(const ImguiGraphDesc* desc); + +IMGUI_GRAPH_API void imguiGraphContextDestroyD3D12(); + +IMGUI_GRAPH_API void imguiGraphRecordBeginD3D12(); + +IMGUI_GRAPH_API void imguiGraphRecordEndD3D12(); + +IMGUI_GRAPH_API void imguiGraphVertex2fD3D12(float x, float y); + +IMGUI_GRAPH_API void imguiGraphVertex2fvD3D12(const float* v); + +IMGUI_GRAPH_API void imguiGraphTexCoord2fD3D12(float u, float v); + +IMGUI_GRAPH_API void imguiGraphColor4ubD3D12(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha); + +IMGUI_GRAPH_API void imguiGraphColor4ubvD3D12(const uint8_t* v); + +IMGUI_GRAPH_API void imguiGraphFontTextureEnableD3D12(); + +IMGUI_GRAPH_API void imguiGraphFontTextureDisableD3D12(); + +IMGUI_GRAPH_API void imguiGraphEnableScissorD3D12(int x, int y, int width, int height); + +IMGUI_GRAPH_API void imguiGraphDisableScissorD3D12(); + +IMGUI_GRAPH_API void imguiGraphFontTextureInitD3D12(unsigned char* data); + +IMGUI_GRAPH_API void imguiGraphFontTextureReleaseD3D12(); + +#endif \ No newline at end of file diff --git a/demo/d3d12/imguiInteropD3D12.cpp b/demo/d3d12/imguiInteropD3D12.cpp new file mode 100644 index 0000000..23d7422 --- /dev/null +++ b/demo/d3d12/imguiInteropD3D12.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + + //direct3d headers +#define NOMINMAX +#include + +// include the Direct3D Library file +#pragma comment (lib, "d3d12.lib") + +#include "imguiGraphD3D12.h" + +#include "appD3D12Ctx.h" + +struct AppGraphCtx; + +namespace NvCo = nvidia::Common; + +inline void imguiInteropUpdateDesc(ImguiGraphDescD3D12& desc, AppGraphCtx* appctxIn) +{ + auto context = cast_to_AppGraphCtxD3D12(appctxIn); + + desc.device = context->m_device; + desc.commandList = context->m_commandList; + + desc.lastFenceCompleted = 0; + desc.nextFenceValue = 1; + + desc.winW = context->m_winW; + desc.winH = context->m_winH; + desc.numMSAASamples = context->m_numMsaaSamples; + desc.dynamicHeapCbvSrvUav.userdata = context; + desc.dynamicHeapCbvSrvUav.reserveDescriptors = nullptr; +} + +IMGUI_GRAPH_API bool imguiInteropGraphInitD3D12(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx); + +IMGUI_GRAPH_API void imguiInteropGraphUpdateD3D12(imguiGraphUpdate_t func, AppGraphCtx* appctx); + +bool imguiInteropGraphInitD3D12(imguiGraphInit_t func, const char* fontpath, AppGraphCtx* appctx) +{ + ImguiGraphDescD3D12 desc; + imguiInteropUpdateDesc(desc, appctx); + + return func(fontpath, cast_from_imguiGraphDescD3D12(&desc)); +} + +void imguiInteropGraphUpdateD3D12(imguiGraphUpdate_t func, AppGraphCtx* appctx) +{ + ImguiGraphDescD3D12 desc; + imguiInteropUpdateDesc(desc, appctx); + + return func(cast_from_imguiGraphDescD3D12(&desc)); +} \ No newline at end of file diff --git a/demo/d3d12/lineRenderPipelineD3D12.cpp b/demo/d3d12/lineRenderPipelineD3D12.cpp new file mode 100644 index 0000000..e6d75a1 --- /dev/null +++ b/demo/d3d12/lineRenderPipelineD3D12.cpp @@ -0,0 +1,140 @@ +#define NOMINMAX + +#include +#include + +#include "pipelineUtilD3D12.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +// this +#include "lineRenderPipelineD3D12.h" + +// Shaders +#include "../d3d/shaders/debugLineVS.hlsl.h" +#include "../d3d/shaders/debugLinePS.hlsl.h" + +namespace FlexSample { + +static const D3D12_INPUT_ELEMENT_DESC InputElementDescs[] = +{ + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, sizeof(Vec3), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, +}; + +LineRenderPipelineD3D12::LineRenderPipelineD3D12(): + Parent(PRIMITIVE_LINE) +{ +} + +int LineRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, NvCo::Dx12RenderTarget* shadowMap) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + PipelineUtilD3D::initSolidBlendDesc(psoDesc.BlendState); + PipelineUtilD3D::initRasterizerDesc(FRONT_WINDING_CLOCKWISE, psoDesc.RasterizerState); + + { + PipelineUtilD3D::initTargetFormat(nullptr, state.m_renderContext, psoDesc); + + psoDesc.InputLayout.NumElements = _countof(InputElementDescs); + psoDesc.InputLayout.pInputElementDescs = InputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; + } + + //psoDesc.RasterizerState.MultisampleEnable = TRUE; + psoDesc.RasterizerState.FrontCounterClockwise = TRUE; + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[3]; + + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0u; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + psoDesc.VS = Dx12Blob(g_debugLineVS); + psoDesc.PS = Dx12Blob(g_debugLinePS); + psoDesc.pRootSignature = signiture.Get(); + + { + PipelineStateD3D12& pipeState = m_states[PIPELINE_STATE_NORMAL]; + pipeState.m_rootSignature = signiture.Get(); + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + } + { + // Setup for shadow + PipelineUtilD3D::initTargetFormat(shadowMap, nullptr, psoDesc); + + PipelineStateD3D12& pipeState = m_states[PIPELINE_STATE_SHADOW]; + pipeState.m_rootSignature = signiture.Get(); + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + } + } + + return NV_OK; +} + +int LineRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + LineDrawParams& params = *(LineDrawParams*)paramsIn; + + // Set up constant buffer + NvCo::Dx12CircularResourceHeap::Cursor cursor = state.m_constantHeap->newConstantBuffer(params); + if (!cursor.isValid()) + { + return NV_FAIL; + } + + PipelineStateD3D12& pipeState = (params.m_drawStage == LINE_DRAW_NORMAL) ? m_states[PIPELINE_STATE_NORMAL] : m_states[PIPELINE_STATE_SHADOW]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + { + ID3D12DescriptorHeap* heaps[] = { state.m_srvCbvUavDescriptorHeap->getHeap() }; + commandList->SetDescriptorHeaps(_countof(heaps), heaps); + } + + return NV_OK; +} + +int LineRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + return MeshRendererD3D12::defaultDraw(allocIn, sizeOfAlloc, platformState); +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/lineRenderPipelineD3D12.h b/demo/d3d12/lineRenderPipelineD3D12.h new file mode 100644 index 0000000..ce3db58 --- /dev/null +++ b/demo/d3d12/lineRenderPipelineD3D12.h @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef LINE_RENDER_PIPELINE_D3D12_H +#define LINE_RENDER_PIPELINE_D3D12_H + +#include +#include "renderStateD3D12.h" +#include "meshRenderer.h" + +#include + +#include + +namespace FlexSample { +using namespace nvidia; + +enum LineDrawStage +{ + LINE_DRAW_NORMAL, + LINE_DRAW_SHADOW, +}; + +struct LineDrawParams +{ + Hlsl::float4x4 m_modelWorldProjection; /// Transforms point from world-space to clip space + LineDrawStage m_drawStage; +}; + +struct LineRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(LineRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_STATE_NORMAL, + PIPELINE_STATE_SHADOW, + PIPELINE_STATE_COUNT_OF, + }; + + LineRenderPipelineD3D12(); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersDir, NvCo::Dx12RenderTarget* shadowMap); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + protected: + + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/meshRenderPipelineD3D12.cpp b/demo/d3d12/meshRenderPipelineD3D12.cpp new file mode 100644 index 0000000..167a032 --- /dev/null +++ b/demo/d3d12/meshRenderPipelineD3D12.cpp @@ -0,0 +1,284 @@ +#define NOMINMAX + +#include +#include + +#include "pipelineUtilD3D12.h" +#include "meshRenderer.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +// this +#include "meshRenderPipelineD3D12.h" + +// Shaders +#include "../d3d/shaders/meshVS.hlsl.h" +#include "../d3d/shaders/meshPS.hlsl.h" +#include "../d3d/shaders/meshShadowPS.hlsl.h" + +namespace FlexSample { + +// Make async compute benchmark shader have a unique name +namespace AsyncComputeBench +{ +#include "../d3d/shaders/meshAsyncComputeBenchPS.hlsl.h" +} + +MeshRenderPipelineD3D12::MeshRenderPipelineD3D12(): + Parent(PRIMITIVE_TRIANGLE), + m_shadowMapLinearSamplerIndex(-1) +{ +} + +/* static */MeshRenderPipelineD3D12::PipelineStateType MeshRenderPipelineD3D12::getPipelineStateType(MeshDrawStage stage, MeshRenderMode mode, MeshCullMode cull) +{ + switch (stage) + { + case MESH_DRAW_NULL: + case MESH_DRAW_REFLECTION: + case MESH_DRAW_LIGHT: + { + if (mode == MESH_RENDER_WIREFRAME) + { + return PIPELINE_STATE_LIGHT_WIREFRAME; + } + + switch (cull) + { + case MESH_CULL_BACK: return PIPELINE_STATE_LIGHT_SOLID_CULL_BACK; + case MESH_CULL_FRONT: return PIPELINE_STATE_LIGHT_SOLID_CULL_FRONT; + default: + case MESH_CULL_NONE: return PIPELINE_STATE_LIGHT_SOLID_CULL_NONE; + } + } + case MESH_DRAW_SHADOW: + { + switch (cull) + { + case MESH_CULL_BACK: return PIPELINE_STATE_SHADOW_CULL_BACK; + default: + case MESH_CULL_NONE: return PIPELINE_STATE_SHADOW_CULL_NONE; + } + } + } + + printf("Unhandled option!"); + return PIPELINE_STATE_LIGHT_SOLID_CULL_BACK; +} + +static D3D12_FILL_MODE _getFillMode(MeshRenderPipelineD3D12::PipelineStateType type) +{ + switch (type) + { + default: return D3D12_FILL_MODE_SOLID; + case MeshRenderPipelineD3D12::PIPELINE_STATE_LIGHT_WIREFRAME: return D3D12_FILL_MODE_WIREFRAME; + } +} + +static D3D12_CULL_MODE _getCullMode(MeshRenderPipelineD3D12::PipelineStateType type) +{ + switch (type) + { + case MeshRenderPipelineD3D12::PIPELINE_STATE_COUNT_OF: break; + + case MeshRenderPipelineD3D12::PIPELINE_STATE_SHADOW_CULL_BACK: return D3D12_CULL_MODE_BACK; + + case MeshRenderPipelineD3D12::PIPELINE_STATE_LIGHT_SOLID_CULL_FRONT: return D3D12_CULL_MODE_FRONT; + case MeshRenderPipelineD3D12::PIPELINE_STATE_LIGHT_SOLID_CULL_BACK: return D3D12_CULL_MODE_BACK; + + case MeshRenderPipelineD3D12::PIPELINE_STATE_SHADOW_CULL_NONE: + case MeshRenderPipelineD3D12::PIPELINE_STATE_LIGHT_WIREFRAME: + case MeshRenderPipelineD3D12::PIPELINE_STATE_LIGHT_SOLID_CULL_NONE: return D3D12_CULL_MODE_NONE; + } + + printf("Unhandled option!"); + return D3D12_CULL_MODE_NONE; +} + +static void _initRasterizerDesc(MeshRenderPipelineD3D12::PipelineStateType type, FrontWindingType winding, D3D12_RASTERIZER_DESC& desc) +{ + PipelineUtilD3D::initRasterizerDesc(winding, desc); + + desc.FillMode = _getFillMode(type); + desc.CullMode = _getCullMode(type); +} + +static void _initPipelineStateDesc(MeshRenderPipelineD3D12::PipelineStateType type, NvCo::Dx12RenderTarget* shadowMap, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + PipelineUtilD3D::initTargetFormat((shadowMap && MeshRenderPipelineD3D12::isShadow(type)) ? shadowMap : nullptr, renderContext, psoDesc); + + psoDesc.InputLayout.NumElements = _countof(MeshRendererD3D12::MeshInputElementDescs); + psoDesc.InputLayout.pInputElementDescs = MeshRendererD3D12::MeshInputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; +} + +int MeshRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, FrontWindingType winding, int shadowMapLinearSamplerIndex, NvCo::Dx12RenderTarget* shadowMap, bool asyncComputeBenchmark) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + m_shadowMapLinearSamplerIndex = shadowMapLinearSamplerIndex; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + PipelineUtilD3D::initSolidBlendDesc(psoDesc.BlendState); + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[3]; + + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + const int numSrvs = 1; + if (numSrvs > 0) + { + ranges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, numSrvs, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[0], D3D12_SHADER_VISIBILITY_PIXEL); + } + const int numSamplers = 1; + if (numSamplers > 0) + { + ranges[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, numSamplers, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[1], D3D12_SHADER_VISIBILITY_PIXEL); + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_meshVS); + psoDesc.PS = asyncComputeBenchmark ? Dx12Blob(AsyncComputeBench::g_meshPS) : Dx12Blob(g_meshPS);; + + NV_RETURN_ON_FAIL(_initPipelineState(state, winding, shadowMap, PIPELINE_STATE_LIGHT_SOLID_CULL_FRONT, signiture.Get(), psoDesc)); + NV_RETURN_ON_FAIL(_initPipelineState(state, winding, shadowMap, PIPELINE_STATE_LIGHT_SOLID_CULL_BACK, signiture.Get(), psoDesc)); + NV_RETURN_ON_FAIL(_initPipelineState(state, winding, shadowMap, PIPELINE_STATE_LIGHT_SOLID_CULL_NONE, signiture.Get(), psoDesc)); + NV_RETURN_ON_FAIL(_initPipelineState(state, winding, shadowMap, PIPELINE_STATE_LIGHT_WIREFRAME, signiture.Get(), psoDesc)); + } + + // Shadow rendering + + { + D3D12_ROOT_PARAMETER params[1]; + params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + params[0].Descriptor.ShaderRegister = 0u; + params[0].Descriptor.RegisterSpace = 0u; + params[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = 1; + desc.pParameters = params; + desc.NumStaticSamplers = 0; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_meshVS); + psoDesc.PS = Dx12Blob(g_meshPS_Shadow); + + NV_RETURN_ON_FAIL(_initPipelineState(state, winding, shadowMap, PIPELINE_STATE_SHADOW_CULL_BACK, signiture.Get(), psoDesc)); + NV_RETURN_ON_FAIL(_initPipelineState(state, winding, shadowMap, PIPELINE_STATE_SHADOW_CULL_NONE, signiture.Get(), psoDesc)); + } + } + + return NV_OK; +} + +int MeshRenderPipelineD3D12::_initPipelineState(const RenderStateD3D12& state, FrontWindingType winding, NvCo::Dx12RenderTarget* shadowMap, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + ID3D12Device* device = state.m_device; + + _initRasterizerDesc(pipeType, winding, psoDesc.RasterizerState); + _initPipelineStateDesc(pipeType, shadowMap, state.m_renderContext, psoDesc); + + psoDesc.pRootSignature = signiture; + + PipelineStateD3D12& pipeState = m_states[pipeType]; + pipeState.m_rootSignature = signiture; + + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + return NV_OK; +} + +int MeshRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + const MeshDrawParamsD3D& params = *(MeshDrawParamsD3D*)paramsIn; + + NvCo::Dx12CircularResourceHeap::Cursor cursor; + { + Hlsl::MeshShaderConst constBuf; + RenderParamsUtilD3D::calcMeshConstantBuffer(params, constBuf); + cursor = state.m_constantHeap->newConstantBuffer(constBuf); + if (!cursor.isValid()) + { + return NV_FAIL; + } + } + + const PipelineStateType pipeType = getPipelineStateType(params.renderStage, params.renderMode, params.cullMode); + PipelineStateD3D12& pipeState = m_states[pipeType]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + if (isShadow(pipeType)) + { + ID3D12DescriptorHeap* heaps[] = { nullptr }; + commandList->SetDescriptorHeaps(0, heaps); + } + else + { + NvCo::Dx12RenderTarget* shadowMap = (NvCo::Dx12RenderTarget*)params.shadowMap; + + ID3D12DescriptorHeap* heaps[] = { state.m_srvCbvUavDescriptorHeap->getHeap(), state.m_samplerDescriptorHeap->getHeap() }; + commandList->SetDescriptorHeaps(_countof(heaps), heaps); + + // Bind the srvs + commandList->SetGraphicsRootDescriptorTable(1, state.m_srvCbvUavDescriptorHeap->getGpuHandle(shadowMap->getSrvHeapIndex(shadowMap->getPrimaryBufferType()))); + // Bind the samplers + commandList->SetGraphicsRootDescriptorTable(2, state.m_samplerDescriptorHeap->getGpuHandle(m_shadowMapLinearSamplerIndex)); + } + + return NV_OK; +} + +int MeshRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + return MeshRendererD3D12::defaultDraw(allocIn, sizeOfAlloc, platformState); +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/meshRenderPipelineD3D12.h b/demo/d3d12/meshRenderPipelineD3D12.h new file mode 100644 index 0000000..be2511f --- /dev/null +++ b/demo/d3d12/meshRenderPipelineD3D12.h @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef MESH_RENDER_PIPELINE_D3D12_H +#define MESH_RENDER_PIPELINE_D3D12_H + +#include +#include "renderStateD3D12.h" +#include "../d3d/shaderCommonD3D.h" +#include "meshRenderer.h" +#include "../d3d/renderParamsD3D.h" + +#include + +namespace FlexSample { +using namespace nvidia; + +struct MeshRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(MeshRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_STATE_SHADOW_CULL_BACK, // Is cull back + PIPELINE_STATE_SHADOW_CULL_NONE, + PIPELINE_STATE_LIGHT_WIREFRAME, // No culling + PIPELINE_STATE_LIGHT_SOLID_CULL_FRONT, + PIPELINE_STATE_LIGHT_SOLID_CULL_BACK, + PIPELINE_STATE_LIGHT_SOLID_CULL_NONE, + PIPELINE_STATE_COUNT_OF, + }; + + MeshRenderPipelineD3D12(); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersDir, FrontWindingType winding, int shadowMapLinearSamplerIndex, NvCo::Dx12RenderTarget* shadowMap, bool asyncComputeBenchmark); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + /// Convert into a single pipeline state type + static PipelineStateType getPipelineStateType(MeshDrawStage stage, MeshRenderMode mode, MeshCullMode cull); + /// true if it's a shadowing type + static bool isShadow(PipelineStateType type) { return type == PIPELINE_STATE_SHADOW_CULL_BACK || type == PIPELINE_STATE_SHADOW_CULL_NONE; } + + protected: + + int _initPipelineState(const RenderStateD3D12& state, FrontWindingType winding, NvCo::Dx12RenderTarget* shadowMap, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); + + int m_shadowMapLinearSamplerIndex; //< The index to the linear sampler in the m_samplerHeap + + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/meshRenderer.cpp b/demo/d3d12/meshRenderer.cpp new file mode 100644 index 0000000..5b8a41e --- /dev/null +++ b/demo/d3d12/meshRenderer.cpp @@ -0,0 +1,15 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#include "meshRenderer.h" + +namespace FlexSample { + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/meshRenderer.h b/demo/d3d12/meshRenderer.h new file mode 100644 index 0000000..5acc701 --- /dev/null +++ b/demo/d3d12/meshRenderer.h @@ -0,0 +1,194 @@ + +#ifndef MESH_RENDERER_H +#define MESH_RENDERER_H + +#include "core/maths.h" + +namespace FlexSample { + +enum FrontWindingType +{ + FRONT_WINDING_CLOCKWISE, + FRONT_WINDING_COUNTER_CLOCKWISE, +}; + +struct RenderAllocation; + +enum PrimitiveType +{ + PRIMITIVE_UNKNOWN, + PRIMITIVE_POINT, + PRIMITIVE_LINE, + PRIMITIVE_TRIANGLE, +}; + +/* Abstraction for how something is rendered. A pipeline indicates what kind of rendering it can be used with via the usage type */ +struct RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS_BASE(RenderPipeline); +public: + /// Bind with platform specific state + virtual int bind(const void* paramsIn, const void* platformState) = 0; + virtual int draw(const RenderAllocation& pointAlloc, size_t sizeOfAlloc, const void* platformState) = 0; + + /// Get the usage type + inline PrimitiveType getPrimitiveType() const { return m_primitiveType; } + + /// Ctor + RenderPipeline(PrimitiveType primitiveType): m_primitiveType(primitiveType) {} + + virtual ~RenderPipeline() {} + private: + PrimitiveType m_primitiveType; +}; + +struct MeshData +{ + void init() + { + positions = nullptr; + normals = nullptr; + texcoords = nullptr; + colors = nullptr; + indices = nullptr; + numFaces = 0; + numVertices = 0; + } + + const Vec3* positions; + const Vec3* normals; + const Vec2* texcoords; + const Vec4* colors; + const uint32_t* indices; + int numVertices; + int numFaces; +}; + +struct MeshData2 +{ + void init() + { + positions = nullptr; + normals = nullptr; + texcoords = nullptr; + colors = nullptr; + indices = nullptr; + numFaces = 0; + numVertices = 0; + } + + const Vec4* positions; + const Vec4* normals; + const Vec2* texcoords; + const Vec4* colors; + const uint32_t* indices; + ptrdiff_t numVertices; + ptrdiff_t numFaces; +}; + + +struct LineData +{ + struct Vertex + { + Vec3 position; + Vec4 color; + }; + void init() + { + vertices = nullptr; + indices = nullptr; + numLines = 0; + numVertices = 0; + } + const Vertex* vertices; ///< Must be set, and holds numPositions. If indices is nullptr, must hold at least numLines * 2 + const uint32_t* indices; ///< If not nullptr holds 2 * numLines + ptrdiff_t numVertices; ///< The total amount of positions + ptrdiff_t numLines; ///< The total number of lines +}; + +struct PointData +{ + void init() + { + positions = nullptr; + density = nullptr; + phase = nullptr; + numPoints = 0; + for (int i = 0; i < 3; i++) + { + anisotropy[i] = nullptr; + } + indices = nullptr; + numIndices = 0; + } + + const Vec4* positions; + const float* density; + const int* phase; + ptrdiff_t numPoints; //< The number of values in position, density and phase. It must be +1 the maximum particle indexed + + const Vec4* anisotropy[3]; // Holds anisotropy or can be nullptr if not used + + const uint32_t* indices; //< The indices to used particles + ptrdiff_t numIndices; +}; + +struct RenderMesh +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS_BASE(RenderMesh); +public: + virtual ~RenderMesh() {}; +}; + +struct RenderAllocation +{ + void init(PrimitiveType primType) + { + m_numPositions = -1; + m_numPrimitives = -1; + m_primitiveType = primType; + } + + PrimitiveType m_primitiveType; ///< The primitive type to draw + ptrdiff_t m_numPositions; ///< The total number of positions + ptrdiff_t m_numPrimitives; ///< The total number of primitives +}; + +struct MeshRenderer +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS_BASE(MeshRenderer); +public: + /// Draw a pre-created mesh + virtual int draw(RenderMesh* mesh, RenderPipeline* pipeline, const void* params) = 0; + + /// Do an immediate mode draw + virtual int drawImmediate(const MeshData& meshData, RenderPipeline* pipeline, const void* params) = 0; + /// Do an immediate mode draw + virtual int drawImmediate(const MeshData2& meshData, RenderPipeline* pipeline, const void* params) = 0; + /// Draw particles immediately + virtual int drawImmediate(const PointData& pointData, RenderPipeline* pipeline, const void* params) = 0; + /// Draw lines immediately + virtual int drawImmediate(const LineData& lineData, RenderPipeline* pipeline, const void* params) = 0; + + /// Render immediately using a previously transitory allocation + virtual int drawTransitory(RenderAllocation& allocation, size_t sizeOfAlloc, RenderPipeline* pipeline, const void* params) = 0; + + /// Allocate rendering data temporarily in gpu accessible memory. Render with drawTransitory. + /// A transitory allocations lifetime is dependent on rendering API, but typically stays in scope for a frame, so multiple + /// draw Transitory allocation can be done for a single allocation - but only in drawing a single frame. + /// NOTE! The PointAllocation/MeshAllocation structures must be the derived type for the API being used (say Dx12PointAllocation) + /// this is verified by the sizeOfAlloc being that size. + virtual int allocateTransitory(const PointData& pointData, RenderAllocation& allocation, size_t sizeOfAlloc) = 0; + virtual int allocateTransitory(const MeshData& meshData, RenderAllocation& allocation, size_t sizeOfAlloc) = 0; + virtual int allocateTransitory(const MeshData2& meshData, RenderAllocation& allocation, size_t sizeOfAlloc) = 0; + virtual int allocateTransitory(const LineData& lineData, RenderAllocation& allocation, size_t sizeOfAlloc) = 0; + + /// Create a render mesh from mesh data + virtual RenderMesh* createMesh(const MeshData& meshData) = 0; + virtual RenderMesh* createMesh(const MeshData2& meshData) = 0; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/meshRendererD3D12.cpp b/demo/d3d12/meshRendererD3D12.cpp new file mode 100644 index 0000000..3ea4012 --- /dev/null +++ b/demo/d3d12/meshRendererD3D12.cpp @@ -0,0 +1,419 @@ + +// this +#include "meshRendererD3D12.h" + +namespace FlexSample { + +/* static */ const D3D12_INPUT_ELEMENT_DESC MeshRendererD3D12::MeshInputElementDescs[4] = +{ + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 3, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } +}; + +/* static */ const D3D12_INPUT_ELEMENT_DESC MeshRendererD3D12::PointInputElementDescs[3] = +{ + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "DENSITY", 0, DXGI_FORMAT_R32_FLOAT, 1, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, + { "PHASE", 0, DXGI_FORMAT_R32_SINT, 2, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, +}; + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dx12RenderMesh !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +RenderMeshD3D12::RenderMeshD3D12() +{ + m_numVertices = 0; + m_numFaces = 0; +} + +int RenderMeshD3D12::initialize(const RenderStateD3D12& state, const MeshData& meshData) +{ + NV_RETURN_ON_FAIL(m_positionBuffer.init(state, sizeof(Vec3), meshData.numVertices, meshData.positions)); + NV_RETURN_ON_FAIL(m_normalBuffer.init(state, sizeof(Vec3), meshData.numVertices, meshData.normals)); + NV_RETURN_ON_FAIL(m_texcoordBuffer.init(state, sizeof(Vec2), meshData.numVertices, meshData.texcoords)); + NV_RETURN_ON_FAIL(m_colorBuffer.init(state, sizeof(Vec4), meshData.numVertices, meshData.colors)); + NV_RETURN_ON_FAIL(m_indexBuffer.init(state, sizeof(uint32_t), meshData.numFaces * 3, meshData.indices)); + + m_numVertices = meshData.numVertices; + m_numFaces = meshData.numFaces; + + _setBufferNames(); + return NV_OK; +} + +int RenderMeshD3D12::initialize(const RenderStateD3D12& state, const MeshData2& meshData) +{ + NV_RETURN_ON_FAIL(m_positionBuffer.init(state, sizeof(Vec4), sizeof(Vec3), meshData.numVertices, meshData.positions)); + NV_RETURN_ON_FAIL(m_normalBuffer.init(state, sizeof(Vec4), sizeof(Vec3), meshData.numVertices, meshData.normals)); + NV_RETURN_ON_FAIL(m_texcoordBuffer.init(state, sizeof(Vec2), meshData.numVertices, meshData.texcoords)); + NV_RETURN_ON_FAIL(m_colorBuffer.init(state, sizeof(Vec4), meshData.numVertices, meshData.colors)); + NV_RETURN_ON_FAIL(m_indexBuffer.init(state, sizeof(uint32_t), meshData.numFaces * 3, meshData.indices)); + + m_numVertices = meshData.numVertices; + m_numFaces = meshData.numFaces; + + _setBufferNames(); + return NV_OK; +} + +void RenderMeshD3D12::_setBufferNames() +{ + m_positionBuffer.setDebugName(L"positions"); + m_normalBuffer.setDebugName(L"normals"); + m_texcoordBuffer.setDebugName(L"texcoords"); + m_colorBuffer.setDebugName(L"colors"); + m_indexBuffer.setDebugName(L"indices"); +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dx12MeshRenderer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + +MeshRendererD3D12::MeshRendererD3D12() +{ +} + +int MeshRendererD3D12::initialize(const RenderStateD3D12& state) +{ + m_renderState = state; + return NV_OK; +} + +D3D12_VERTEX_BUFFER_VIEW MeshRendererD3D12::_newImmediateVertexBuffer(const void* data, int stride, ptrdiff_t numVertices) +{ + D3D12_VERTEX_BUFFER_VIEW view = {}; + if (data) + { + const size_t bufferSize = stride * numVertices; + NvCo::Dx12CircularResourceHeap::Cursor cursor = m_renderState.m_constantHeap->allocateVertexBuffer(bufferSize); + + memcpy(cursor.m_position, data, bufferSize); + + view.BufferLocation = m_renderState.m_constantHeap->getGpuHandle(cursor); + view.SizeInBytes = UINT(bufferSize); + view.StrideInBytes = stride; + } + return view; +} + +D3D12_VERTEX_BUFFER_VIEW MeshRendererD3D12::_newStridedImmediateVertexBuffer(const void* data, int srcStride, int dstStride, ptrdiff_t numElements) +{ + if (srcStride == dstStride) + { + return _newImmediateVertexBuffer(data, srcStride, numElements); + } + + D3D12_VERTEX_BUFFER_VIEW view = {}; + if (srcStride == 4 * 4 && dstStride == 4 * 3) + { + const size_t bufferSize = dstStride * numElements; + NvCo::Dx12CircularResourceHeap::Cursor cursor = m_renderState.m_constantHeap->allocateVertexBuffer(bufferSize); + + uint32_t* dst = (uint32_t*)cursor.m_position; + const uint32_t* src = (const uint32_t*)data; + + // Copy taking into account stride difference + for (ptrdiff_t i = 0; i < numElements; i++, dst += 3, src += 4) + { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + } + + view.BufferLocation = m_renderState.m_constantHeap->getGpuHandle(cursor); + view.SizeInBytes = UINT(bufferSize); + view.StrideInBytes = dstStride; + + return view; + } + + printf("Unhandled conversion"); + return view; +} + +D3D12_INDEX_BUFFER_VIEW MeshRendererD3D12::_newImmediateIndexBuffer(const void* data, int stride, ptrdiff_t numIndices) +{ + assert(stride == sizeof(uint32_t)); + D3D12_INDEX_BUFFER_VIEW view = {}; + + if (data) + { + const size_t bufferSize = stride * numIndices; + NvCo::Dx12CircularResourceHeap::Cursor cursor = m_renderState.m_constantHeap->allocateVertexBuffer(bufferSize); + + memcpy(cursor.m_position, data, bufferSize); + + view.BufferLocation = m_renderState.m_constantHeap->getGpuHandle(cursor); + view.SizeInBytes = UINT(bufferSize); + view.Format = DXGI_FORMAT_R32_UINT; + } + + return view; +} + +int MeshRendererD3D12::draw(RenderMesh* meshIn, RenderPipeline* pipeline, const void* params) +{ + RenderMeshD3D12* mesh = static_cast(meshIn); + + // Set up the allocation block + MeshRenderAllocationD3D12 alloc; + alloc.init(PRIMITIVE_TRIANGLE); + + alloc.m_vertexBufferViews[0] = mesh->m_positionBuffer.m_vertexBufferView; + alloc.m_vertexBufferViews[1] = mesh->m_normalBuffer.m_vertexBufferView; + alloc.m_vertexBufferViews[2] = mesh->m_texcoordBuffer.m_vertexBufferView; + alloc.m_vertexBufferViews[3] = mesh->m_colorBuffer.m_vertexBufferView; + + alloc.m_indexBufferView = mesh->m_indexBuffer.m_indexBufferView; + alloc.m_numPrimitives = mesh->m_numFaces; + alloc.m_numPositions = mesh->m_numVertices; + + return drawTransitory(alloc, sizeof(MeshRenderAllocationD3D12), pipeline, params); +} + +int MeshRendererD3D12::drawImmediate(const MeshData& mesh, RenderPipeline* pipeline, const void* params) +{ + MeshRenderAllocationD3D12 alloc; + allocateTransitory(mesh, alloc, sizeof(alloc)); + return drawTransitory(alloc, sizeof(alloc), pipeline, params); +} + +int MeshRendererD3D12::drawImmediate(const MeshData2& mesh, RenderPipeline* pipeline, const void* params) +{ + MeshRenderAllocationD3D12 alloc; + allocateTransitory(mesh, alloc, sizeof(alloc)); + return drawTransitory(alloc, sizeof(alloc), pipeline, params); +} + +int MeshRendererD3D12::drawImmediate(const LineData& lineData, RenderPipeline* pipeline, const void* params) +{ + LineRenderAllocationD3D12 alloc; + allocateTransitory(lineData, alloc, sizeof(alloc)); + return drawTransitory(alloc, sizeof(alloc), pipeline, params); +} + +int MeshRendererD3D12::drawImmediate(const PointData& pointData, RenderPipeline* pipeline, const void* params) +{ + PointRenderAllocationD3D12 alloc; + allocateTransitory(pointData, alloc, sizeof(alloc)); + return drawTransitory(alloc, sizeof(alloc), pipeline, params); +} + +int MeshRendererD3D12::allocateTransitory(const PointData& pointData, RenderAllocation& allocIn, size_t sizeOfAlloc) +{ + typedef PointRenderAllocationD3D12 Alloc; + + assert(sizeof(Alloc) == sizeOfAlloc); + + Alloc& alloc = static_cast(allocIn); + alloc.init(PRIMITIVE_POINT); + + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION] = _newImmediateVertexBuffer(pointData.positions, sizeof(Vec4), pointData.numPoints); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_DENSITY] = _newImmediateVertexBuffer(pointData.density, sizeof(float), pointData.numPoints); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_PHASE] = _newImmediateVertexBuffer(pointData.phase, sizeof(int), pointData.numPoints); + + if (pointData.anisotropy[0]) + { + for (int i = 0; i < 3; i++) + { + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_ANISOTROPY1 + i] = _newImmediateVertexBuffer(pointData.anisotropy[i], sizeof(Vec4), pointData.numPoints); + } + } + + alloc.m_indexBufferView = _newImmediateIndexBuffer(pointData.indices, sizeof(uint32_t), pointData.numIndices); + + alloc.m_numPrimitives = pointData.numIndices; + alloc.m_numPositions = pointData.numPoints; + return NV_OK; +} + +int MeshRendererD3D12::allocateTransitory(const MeshData2& mesh, RenderAllocation& allocIn, size_t sizeOfAlloc) +{ + typedef MeshRenderAllocationD3D12 Alloc; + assert(sizeof(Alloc) == sizeOfAlloc); + + Alloc& alloc = static_cast(allocIn); + alloc.init(PRIMITIVE_TRIANGLE); + + const int numIndices = int(mesh.numFaces * 3); + alloc.m_indexBufferView = _newImmediateIndexBuffer(mesh.indices, sizeof(uint32_t), numIndices); + + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION] = _newStridedImmediateVertexBuffer(mesh.positions, sizeof(Vec4), sizeof(Vec3), mesh.numVertices); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_NORMAL] = _newStridedImmediateVertexBuffer(mesh.normals, sizeof(Vec4), sizeof(Vec3), mesh.numVertices); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_TEX_COORDS] = _newImmediateVertexBuffer(mesh.texcoords, sizeof(Vec2), mesh.numVertices); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_COLOR] = _newImmediateVertexBuffer(mesh.colors, sizeof(Vec4), mesh.numVertices); + + alloc.m_numPrimitives = mesh.numFaces; + alloc.m_numPositions = mesh.numVertices; + return NV_OK; +} + +int MeshRendererD3D12::allocateTransitory(const LineData& lineData, RenderAllocation& allocIn, size_t sizeOfAlloc) +{ + typedef LineRenderAllocationD3D12 Alloc; + assert(sizeof(Alloc) == sizeOfAlloc); + + Alloc& alloc = static_cast(allocIn); + alloc.init(PRIMITIVE_LINE); + + alloc.m_vertexBufferView = _newImmediateVertexBuffer(lineData.vertices, sizeof(LineData::Vertex), lineData.numVertices); + alloc.m_indexBufferView = _newImmediateIndexBuffer(lineData.indices, sizeof(uint32_t), lineData.numLines * 2); + + alloc.m_numPrimitives = lineData.numLines; + alloc.m_numPositions = lineData.numVertices; + return NV_OK; +} + +int MeshRendererD3D12::allocateTransitory(const MeshData& mesh, RenderAllocation& allocIn, size_t sizeOfAlloc) +{ + typedef MeshRenderAllocationD3D12 Alloc; + assert(sizeof(Alloc) == sizeOfAlloc); + + Alloc& alloc = static_cast(allocIn); + + alloc.init(PRIMITIVE_TRIANGLE); + + const int numIndices = int(mesh.numFaces * 3); + alloc.m_indexBufferView = _newImmediateIndexBuffer(mesh.indices, sizeof(uint32_t), numIndices); + + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_POSITION] = _newImmediateVertexBuffer(mesh.positions, sizeof(Vec3), mesh.numVertices); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_NORMAL] = _newImmediateVertexBuffer(mesh.normals, sizeof(Vec3), mesh.numVertices); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_TEX_COORDS] = _newImmediateVertexBuffer(mesh.texcoords, sizeof(Vec2), mesh.numVertices); + alloc.m_vertexBufferViews[Alloc::VERTEX_VIEW_COLOR] = _newImmediateVertexBuffer(mesh.colors, sizeof(Vec4), mesh.numVertices); + + alloc.m_numPrimitives = mesh.numFaces; + alloc.m_numPositions = mesh.numVertices; + + return NV_OK; +} + +int MeshRendererD3D12::drawTransitory(RenderAllocation& allocIn, size_t sizeOfAlloc, RenderPipeline* pipeline, const void* params) +{ + if (allocIn.m_primitiveType == PRIMITIVE_UNKNOWN) + { + return NV_OK; + } + if (allocIn.m_primitiveType != pipeline->getPrimitiveType()) + { + printf("Wrong pipeline primitive type"); + return NV_FAIL; + } + + NV_RETURN_ON_FAIL(pipeline->bind(params, &m_renderState)); + NV_RETURN_ON_FAIL(pipeline->draw(allocIn, sizeOfAlloc, &m_renderState)); + return NV_OK; +} + +RenderMesh* MeshRendererD3D12::createMesh(const MeshData& meshData) +{ + RenderMeshD3D12* mesh = new RenderMeshD3D12; + if (NV_FAILED(mesh->initialize(m_renderState, meshData))) + { + delete mesh; + return nullptr; + } + return mesh; +} + +RenderMesh* MeshRendererD3D12::createMesh(const MeshData2& meshData) +{ + RenderMeshD3D12* mesh = new RenderMeshD3D12; + if (NV_FAILED(mesh->initialize(m_renderState, meshData))) + { + delete mesh; + return nullptr; + } + return mesh; +} + + +/* static */int MeshRendererD3D12::defaultDraw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + switch (allocIn.m_primitiveType) + { + case PRIMITIVE_POINT: + { + typedef PointRenderAllocationD3D12 Alloc; + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + + assert(sizeof(Alloc) == sizeOfAlloc); + const Alloc& alloc = static_cast(allocIn); + + assert(allocIn.m_numPrimitives >= 0); + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + + commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST); + commandList->IASetVertexBuffers(0, Alloc::NUM_DEFAULT_VERTEX_VIEWS, alloc.m_vertexBufferViews); + commandList->IASetIndexBuffer(&alloc.m_indexBufferView); + + if (alloc.m_indexBufferView.SizeInBytes) + { + commandList->DrawIndexedInstanced((UINT)allocIn.m_numPrimitives, 1, 0, 0, 0); + } + else + { + commandList->DrawInstanced((UINT)allocIn.m_numPrimitives, 1, 0, 0); + } + break; + } + case PRIMITIVE_LINE: + { + typedef LineRenderAllocationD3D12 Alloc; + assert(sizeof(Alloc) == sizeOfAlloc); + const Alloc& alloc = static_cast(allocIn); + + assert(alloc.m_numPrimitives >= 0); + + const int numIndices = int(alloc.m_numPrimitives * 2); + + commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINELIST); + commandList->IASetVertexBuffers(0, 1, &alloc.m_vertexBufferView); + + if (alloc.m_indexBufferView.SizeInBytes) + { + commandList->IASetIndexBuffer(nullptr); + commandList->DrawIndexedInstanced((UINT)numIndices, 1, 0, 0, 0); + } + else + { + commandList->IASetIndexBuffer(&alloc.m_indexBufferView); + commandList->DrawInstanced((UINT)numIndices, 1, 0, 0); + } + break; + } + case PRIMITIVE_TRIANGLE: + { + typedef MeshRenderAllocationD3D12 Alloc; + assert(sizeof(Alloc) == sizeOfAlloc); + const Alloc& alloc = static_cast(allocIn); + + const int numIndices = int(alloc.m_numPrimitives * 3); + + commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + commandList->IASetVertexBuffers(0, _countof(alloc.m_vertexBufferViews), alloc.m_vertexBufferViews); + commandList->IASetIndexBuffer(&alloc.m_indexBufferView); + + if (alloc.m_indexBufferView.SizeInBytes) + { + commandList->DrawIndexedInstanced((UINT)numIndices, 1, 0, 0, 0); + } + else + { + commandList->DrawInstanced((UINT)numIndices, 1, 0, 0); + } + break; + } + default: + { + printf("Unhandled primitive type"); + } + } + + return NV_OK; +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/meshRendererD3D12.h b/demo/d3d12/meshRendererD3D12.h new file mode 100644 index 0000000..1afb6b3 --- /dev/null +++ b/demo/d3d12/meshRendererD3D12.h @@ -0,0 +1,175 @@ +#ifndef MESH_RENDERER_D3D12_H +#define MESH_RENDERER_D3D12_H + +#include "bufferD3D12.h" + +#include "renderStateD3D12.h" +#include "meshRenderer.h" + +// Predeclare so all use the same +struct ShadowMap; + +namespace FlexSample { +using namespace nvidia; + +struct MeshRendererD3D12; +struct RenderMeshD3D12: public RenderMesh +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(RenderMeshD3D12, RenderMesh); +public: + typedef RenderMesh Parent; + + friend struct MeshRendererD3D12; + + RenderMeshD3D12(); + int initialize(const RenderStateD3D12& state, const MeshData& meshData); + int initialize(const RenderStateD3D12& state, const MeshData2& meshData); + + protected: + void _setBufferNames(); + + VertexBufferD3D12 m_positionBuffer; + VertexBufferD3D12 m_normalBuffer; + VertexBufferD3D12 m_texcoordBuffer; + VertexBufferD3D12 m_colorBuffer; + IndexBufferD3D12 m_indexBuffer; + + ptrdiff_t m_numVertices; + ptrdiff_t m_numFaces; +}; + +struct PointRenderAllocationD3D12: public RenderAllocation +{ + typedef RenderAllocation Parent; + enum VertexViewType + { + // NOTE! Do not change order without fixing pipelines that use it! + VERTEX_VIEW_POSITION, + VERTEX_VIEW_DENSITY, + VERTEX_VIEW_PHASE, + + VERTEX_VIEW_ANISOTROPY1, + VERTEX_VIEW_ANISOTROPY2, + VERTEX_VIEW_ANISOTROPY3, + + VERTEX_VIEW_COUNT_OF, + }; + enum + { + // For typical point rendering we don't need anisotropy, so typically just bind the first 3 + NUM_DEFAULT_VERTEX_VIEWS = VERTEX_VIEW_PHASE + 1 + }; + + /// Initialize state + void init(PrimitiveType primitiveType) + { + Parent::init(primitiveType); + D3D12_VERTEX_BUFFER_VIEW nullView = {}; + for (int i = 0; i < _countof(m_vertexBufferViews); i++) + { + m_vertexBufferViews[i] = nullView; + } + D3D12_INDEX_BUFFER_VIEW nullIndexView = {}; + m_indexBufferView = nullIndexView; + } + + D3D12_VERTEX_BUFFER_VIEW m_vertexBufferViews[VERTEX_VIEW_COUNT_OF]; + D3D12_INDEX_BUFFER_VIEW m_indexBufferView; +}; + +struct MeshRenderAllocationD3D12:public RenderAllocation +{ + typedef RenderAllocation Parent; + + // Vertex buffer viewer are in the order to be set + enum VertexViewType + { + // NOTE! Do not change order without fixing pipelines that use it! + VERTEX_VIEW_POSITION, + VERTEX_VIEW_NORMAL, + VERTEX_VIEW_TEX_COORDS, + VERTEX_VIEW_COLOR, + + VERTEX_VIEW_COUNT_OF, + }; + + void init(PrimitiveType primType) + { + Parent::init(primType); + D3D12_VERTEX_BUFFER_VIEW nullView = {}; + for (int i = 0; i < _countof(m_vertexBufferViews); i++) + { + m_vertexBufferViews[i] = nullView; + } + D3D12_INDEX_BUFFER_VIEW nullIndexView = {}; + m_indexBufferView = nullIndexView; + } + + D3D12_VERTEX_BUFFER_VIEW m_vertexBufferViews[VERTEX_VIEW_COUNT_OF]; + D3D12_INDEX_BUFFER_VIEW m_indexBufferView; +}; + +struct LineRenderAllocationD3D12 :public RenderAllocation +{ + typedef RenderAllocation Parent; + + void init(PrimitiveType primType) + { + Parent::init(primType); + const D3D12_VERTEX_BUFFER_VIEW nullView = {}; + m_vertexBufferView = nullView; + const D3D12_INDEX_BUFFER_VIEW nullIndexView = {}; + m_indexBufferView = nullIndexView; + } + + D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView; + D3D12_INDEX_BUFFER_VIEW m_indexBufferView; +}; + +struct MeshRendererD3D12: public MeshRenderer +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(MeshRendererD3D12, MeshRenderer); +public: + typedef MeshRenderer Parent; + + /// MeshRenderer + virtual int draw(RenderMesh* mesh, RenderPipeline* pipeline, const void* params) override; + virtual int drawImmediate(const MeshData& mesh, RenderPipeline* pipeline, const void* params) override; + virtual int drawImmediate(const MeshData2& meshData, RenderPipeline* pipeline, const void* params) override; + virtual int drawImmediate(const PointData& pointData, RenderPipeline* pipeline, const void* params) override; + virtual int drawImmediate(const LineData& lineData, RenderPipeline* pipeline, const void* params) override; + + virtual RenderMesh* createMesh(const MeshData& meshData) override; + virtual RenderMesh* createMesh(const MeshData2& meshData) override; + + virtual int allocateTransitory(const PointData& pointData, RenderAllocation& allocation, size_t sizeOfAlloc) override; + virtual int allocateTransitory(const MeshData& meshData, RenderAllocation& allocIn, size_t sizeofAlloc) override; + virtual int allocateTransitory(const MeshData2& meshData, RenderAllocation& allocation, size_t sizeofAlloc) override; + virtual int allocateTransitory(const LineData& lineData, RenderAllocation& allocation, size_t sizeOfAlloc) override; + + virtual int drawTransitory(RenderAllocation& allocation, size_t sizeOfAlloc, RenderPipeline* pipeline, const void* params) override; + + int initialize(const RenderStateD3D12& state); + + MeshRendererD3D12(); + + /// Default drawing impls, can be used in pipelines + static int defaultDraw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState); + + /// The input desc layout used + static const D3D12_INPUT_ELEMENT_DESC MeshInputElementDescs[4]; + /// Layout for points + static const D3D12_INPUT_ELEMENT_DESC PointInputElementDescs[3]; + + protected: + + D3D12_VERTEX_BUFFER_VIEW _newImmediateVertexBuffer(const void* data, int stride, ptrdiff_t numVertices); + D3D12_VERTEX_BUFFER_VIEW _newStridedImmediateVertexBuffer(const void* data, int srcStride, int dstStride, ptrdiff_t numElements); + D3D12_INDEX_BUFFER_VIEW _newImmediateIndexBuffer(const void* data, int stride, ptrdiff_t numIndices); + + RenderStateD3D12 m_renderState; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/meshUtil.cpp b/demo/d3d12/meshUtil.cpp new file mode 100644 index 0000000..b83a3f4 --- /dev/null +++ b/demo/d3d12/meshUtil.cpp @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#include "meshUtil.h" + +namespace FlexSample { + +/* static */RenderMesh* MeshUtil::createRenderMesh(MeshRenderer* renderer, const Mesh& mesh) +{ + int numFaces = mesh.GetNumFaces(); + int numVertices = mesh.GetNumVertices(); + + MeshData data; + data.colors = (mesh.m_colours.size() > 0) ? (const Vec4*)&mesh.m_colours[0] : nullptr; + data.positions = (mesh.m_positions.size() > 0) ? (const Vec3*)&mesh.m_positions[0] : nullptr; + data.normals = (mesh.m_normals.size() > 0) ? (const Vec3*)&mesh.m_normals[0] : nullptr; + data.indices = (mesh.m_indices.size() > 0) ? (const uint32_t*)&mesh.m_indices[0] : nullptr; + data.texcoords = (mesh.m_texcoords[0].size() > 0) ? (const Vec2*)&mesh.m_texcoords[0] : nullptr; + + data.numFaces = numFaces; + data.numVertices = numVertices; + + return renderer->createMesh(data); +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/meshUtil.h b/demo/d3d12/meshUtil.h new file mode 100644 index 0000000..a9070b7 --- /dev/null +++ b/demo/d3d12/meshUtil.h @@ -0,0 +1,26 @@ +#ifndef MESH_UTIL_H +#define MESH_UTIL_H + +// Needed for mesh.h +#pragma warning( disable : 4458 ) + +#include "meshRenderer.h" + +#include + +typedef ::Vec4 FlexVec4; +typedef ::Vec3 FlexVec3; +typedef ::Vec2 FlexVec2; + +namespace FlexSample { +//using namespace nvidia; + +/* Tools/types to implify use of the flex 'Mesh' types */ +struct MeshUtil +{ + static RenderMesh* createRenderMesh(MeshRenderer* renderer, const Mesh& mesh); +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/pipelineUtilD3D12.cpp b/demo/d3d12/pipelineUtilD3D12.cpp new file mode 100644 index 0000000..81e2581 --- /dev/null +++ b/demo/d3d12/pipelineUtilD3D12.cpp @@ -0,0 +1,78 @@ + +// this +#include "pipelineUtilD3D12.h" + +namespace NvCo = nvidia::Common; + +namespace FlexSample { + +/* static */void PipelineUtilD3D::initRasterizerDesc(FrontWindingType winding, D3D12_RASTERIZER_DESC& desc) +{ + desc.FillMode = D3D12_FILL_MODE_SOLID; + desc.CullMode = D3D12_CULL_MODE_NONE; + + desc.FrontCounterClockwise = (winding == FRONT_WINDING_COUNTER_CLOCKWISE); + + desc.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; + desc.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; + desc.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; + desc.DepthClipEnable = TRUE; + desc.MultisampleEnable = FALSE; + desc.AntialiasedLineEnable = FALSE; + desc.ForcedSampleCount = 0; + desc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; +} + +/* static */void PipelineUtilD3D::initSolidBlendDesc(D3D12_BLEND_DESC& desc) +{ + desc.AlphaToCoverageEnable = FALSE; + desc.IndependentBlendEnable = FALSE; + { + const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = + { + FALSE,FALSE, + D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, + D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, + D3D12_LOGIC_OP_NOOP, + D3D12_COLOR_WRITE_ENABLE_ALL, + }; + for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) + desc.RenderTarget[i] = defaultRenderTargetBlendDesc; + } +} + +/* static */void PipelineUtilD3D::initTargetFormat(NvCo::Dx12RenderTarget* renderTarget, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + psoDesc.DepthStencilState.DepthEnable = TRUE; + psoDesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; + psoDesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL; + psoDesc.DepthStencilState.StencilEnable = FALSE; + psoDesc.SampleMask = UINT_MAX; + + // Normally single render target + psoDesc.NumRenderTargets = 1; + + if (renderTarget) + { + psoDesc.RTVFormats[0] = renderTarget->getTargetFormat(NvCo::Dx12RenderTarget::BUFFER_TARGET); + psoDesc.DSVFormat = renderTarget->getTargetFormat(NvCo::Dx12RenderTarget::BUFFER_DEPTH_STENCIL); + psoDesc.NumRenderTargets = renderTarget->getNumRenderTargets(); + psoDesc.SampleDesc.Count = 1; + } + else + { + const NvCo::Dx12TargetInfo& targetInfo = renderContext->m_targetInfo; + + psoDesc.RTVFormats[0] = targetInfo.m_renderTargetFormats[0]; + psoDesc.DSVFormat = targetInfo.m_depthStencilFormat; + psoDesc.SampleDesc.Count = targetInfo.m_numSamples; + } + + // If no depth buffer, disable + if (psoDesc.DSVFormat == DXGI_FORMAT_UNKNOWN) + { + psoDesc.DepthStencilState.DepthEnable = FALSE; + } +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/pipelineUtilD3D12.h b/demo/d3d12/pipelineUtilD3D12.h new file mode 100644 index 0000000..2949bd3 --- /dev/null +++ b/demo/d3d12/pipelineUtilD3D12.h @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef PIPELINE_UTIL_D3D12_H +#define PIPELINE_UTIL_D3D12_H + +#define NOMINMAX +#include +#include + +#include "meshRenderer.h" +#include + +namespace FlexSample { +using namespace nvidia; + +struct PipelineUtilD3D +{ + /// Default initializes rasterizer + static void initRasterizerDesc(FrontWindingType winding, D3D12_RASTERIZER_DESC& desc); + /// Initialize default blend desc for solid rendering + static void initSolidBlendDesc(D3D12_BLEND_DESC& desc); + /// Set on psoDesc the format/samples and set up other default state. + /// If renderTarget is NV_NULL then the format that's set on the Dx12RenderInterface/RenderContext is used + static void initTargetFormat(Common::Dx12RenderTarget* renderTarget, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/pointRenderPipelineD3D12.cpp b/demo/d3d12/pointRenderPipelineD3D12.cpp new file mode 100644 index 0000000..7650c49 --- /dev/null +++ b/demo/d3d12/pointRenderPipelineD3D12.cpp @@ -0,0 +1,227 @@ +#define NOMINMAX + +#include +#include + +#include "pipelineUtilD3D12.h" +#include "bufferD3D12.h" +#include "meshRendererD3D12.h" +#include "../d3d/shaderCommonD3D.h" + +// this +#include "pointRenderPipelineD3D12.h" + +// Shaders +#include "../d3d/shaders/pointVS.hlsl.h" +#include "../d3d/shaders/pointGS.hlsl.h" +#include "../d3d/shaders/pointPS.hlsl.h" +#include "../d3d/shaders/pointShadowPS.hlsl.h" + +namespace FlexSample { + +PointRenderPipelineD3D12::PointRenderPipelineD3D12(): + Parent(PRIMITIVE_POINT), + m_shadowMapLinearSamplerIndex(-1) +{ +} + +/* static */PointRenderPipelineD3D12::PipelineStateType PointRenderPipelineD3D12::getPipelineStateType(PointDrawStage stage, PointRenderMode mode, PointCullMode cull) +{ + switch (stage) + { + case POINT_DRAW_SHADOW: return PIPELINE_STATE_SHADOW; + default: return PIPELINE_STATE_LIGHT_SOLID; + } +} + +static D3D12_FILL_MODE _getFillMode(PointRenderPipelineD3D12::PipelineStateType type) +{ + return D3D12_FILL_MODE_SOLID; +} + +static D3D12_CULL_MODE _getCullMode(PointRenderPipelineD3D12::PipelineStateType type) +{ + return D3D12_CULL_MODE_NONE; +} + +static void _initRasterizerDesc(PointRenderPipelineD3D12::PipelineStateType type, D3D12_RASTERIZER_DESC& desc) +{ + PipelineUtilD3D::initRasterizerDesc(FRONT_WINDING_COUNTER_CLOCKWISE, desc); + desc.FillMode = _getFillMode(type); + desc.CullMode = _getCullMode(type); +} + +static void _initPipelineStateDesc(PointRenderPipelineD3D12::PipelineStateType type, NvCo::Dx12RenderTarget* shadowMap, AppGraphCtxD3D12* renderContext, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + PipelineUtilD3D::initTargetFormat((shadowMap && type == PointRenderPipelineD3D12::PIPELINE_STATE_SHADOW) ? shadowMap : nullptr, renderContext, psoDesc); + + psoDesc.InputLayout.NumElements = _countof(MeshRendererD3D12::PointInputElementDescs); + psoDesc.InputLayout.pInputElementDescs = MeshRendererD3D12::PointInputElementDescs; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; +} + +int PointRenderPipelineD3D12::initialize(const RenderStateD3D12& state, const std::wstring& shadersPath, int shadowMapLinearSamplerIndex, NvCo::Dx12RenderTarget* shadowMap) +{ + using namespace NvCo; + ID3D12Device* device = state.m_device; + + m_shadowMapLinearSamplerIndex = shadowMapLinearSamplerIndex; + + // create the pipeline state object + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + PipelineUtilD3D::initSolidBlendDesc(psoDesc.BlendState); + + // create the root signature + ComPtr signiture; + { + CD3DX12_DESCRIPTOR_RANGE ranges[2]; + CD3DX12_ROOT_PARAMETER params[3]; + + UINT rootIndex = 0; + { + D3D12_ROOT_PARAMETER& param = params[rootIndex++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0u; + param.Descriptor.RegisterSpace = 0u; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + } + + const int numSrvs = 1; + if (numSrvs > 0) + { + ranges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, numSrvs, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[0], D3D12_SHADER_VISIBILITY_PIXEL); + } + const int numSamplers = 1; + if (numSamplers > 0) + { + ranges[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, numSamplers, 0); + params[rootIndex++].InitAsDescriptorTable(1, &ranges[1], D3D12_SHADER_VISIBILITY_PIXEL); + } + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = rootIndex; + desc.pParameters = params; + desc.NumStaticSamplers = 0; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_pointVS); + psoDesc.GS = Dx12Blob(g_pointGS); + psoDesc.PS = Dx12Blob(g_pointPS); + + NV_RETURN_ON_FAIL(_initPipelineState(state, shadowMap, PIPELINE_STATE_LIGHT_SOLID, signiture.Get(), psoDesc)); + } + + // Shadow rendering + { + D3D12_ROOT_PARAMETER params[1]; + params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + params[0].Descriptor.ShaderRegister = 0u; + params[0].Descriptor.RegisterSpace = 0u; + params[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + + D3D12_ROOT_SIGNATURE_DESC desc; + desc.NumParameters = 1; + desc.pParameters = params; + desc.NumStaticSamplers = 0u; + desc.pStaticSamplers = nullptr; + desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + ComPtr sigBlob; + NV_RETURN_ON_FAIL(Dx12HelperUtil::serializeRootSigniture(desc, D3D_ROOT_SIGNATURE_VERSION_1, sigBlob)); + NV_RETURN_ON_FAIL(device->CreateRootSignature(0u, sigBlob->GetBufferPointer(), sigBlob->GetBufferSize(), IID_PPV_ARGS(&signiture))); + } + + { + psoDesc.VS = Dx12Blob(g_pointVS); + psoDesc.GS = Dx12Blob(g_pointGS); + psoDesc.PS = Dx12Blob(g_pointShadowPS); + + NV_RETURN_ON_FAIL(_initPipelineState(state, shadowMap, PIPELINE_STATE_SHADOW, signiture.Get(), psoDesc)); + } + } + + return NV_OK; +} + +int PointRenderPipelineD3D12::_initPipelineState(const RenderStateD3D12& state, NvCo::Dx12RenderTarget* shadowMap, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc) +{ + ID3D12Device* device = state.m_device; + + _initRasterizerDesc(pipeType, psoDesc.RasterizerState); + _initPipelineStateDesc(pipeType, shadowMap, state.m_renderContext, psoDesc); + + psoDesc.pRootSignature = signiture; + + PipelineStateD3D12& pipeState = m_states[pipeType]; + pipeState.m_rootSignature = signiture; + + NV_RETURN_ON_FAIL(device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipeState.m_pipelineState))); + return NV_OK; +} + +int PointRenderPipelineD3D12::bind(const void* paramsIn, const void* platformState) +{ + const RenderStateD3D12& state = *(RenderStateD3D12*)platformState; + const PointDrawParamsD3D& params = *(PointDrawParamsD3D*)paramsIn; + + // Set up constant buffer + NvCo::Dx12CircularResourceHeap::Cursor cursor; + { + Hlsl::PointShaderConst constBuf; + RenderParamsUtilD3D::calcPointConstantBuffer(params, constBuf); + cursor = state.m_constantHeap->newConstantBuffer(constBuf); + if (!cursor.isValid()) + { + return NV_FAIL; + } + } + + const PipelineStateType pipeType = getPipelineStateType(params.renderStage, params.renderMode, params.cullMode); + PipelineStateD3D12& pipeState = m_states[pipeType]; + if (!pipeState.isValid()) + { + return NV_FAIL; + } + + ID3D12GraphicsCommandList* commandList = state.m_commandList; + commandList->SetGraphicsRootSignature(pipeState.m_rootSignature.Get()); + commandList->SetPipelineState(pipeState.m_pipelineState.Get()); + + D3D12_GPU_VIRTUAL_ADDRESS cbvHandle = state.m_constantHeap->getGpuHandle(cursor); + commandList->SetGraphicsRootConstantBufferView(0, cbvHandle); + + if (pipeType == PIPELINE_STATE_SHADOW) + { + ID3D12DescriptorHeap* heaps[] = { nullptr }; + commandList->SetDescriptorHeaps(0, heaps); + } + else + { + NvCo::Dx12RenderTarget* shadowMap = (NvCo::Dx12RenderTarget*)params.shadowMap; + + ID3D12DescriptorHeap* heaps[] = { state.m_srvCbvUavDescriptorHeap->getHeap(), state.m_samplerDescriptorHeap->getHeap() }; + commandList->SetDescriptorHeaps(_countof(heaps), heaps); + // Bind the srvs + commandList->SetGraphicsRootDescriptorTable(1, state.m_srvCbvUavDescriptorHeap->getGpuHandle(shadowMap->getSrvHeapIndex(shadowMap->getPrimaryBufferType()))); + // Bind the samplers + commandList->SetGraphicsRootDescriptorTable(2, state.m_samplerDescriptorHeap->getGpuHandle(m_shadowMapLinearSamplerIndex)); + } + + return NV_OK; +} + +int PointRenderPipelineD3D12::draw(const RenderAllocation& allocIn, size_t sizeOfAlloc, const void* platformState) +{ + return MeshRendererD3D12::defaultDraw(allocIn, sizeOfAlloc, platformState); +} + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/pointRenderPipelineD3D12.h b/demo/d3d12/pointRenderPipelineD3D12.h new file mode 100644 index 0000000..cdd03bc --- /dev/null +++ b/demo/d3d12/pointRenderPipelineD3D12.h @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef POINT_RENDER_PIPELINE_D3D12_H +#define POINT_RENDER_PIPELINE_D3D12_H + +#include +#include "renderStateD3D12.h" +#include "meshRenderer.h" + +#include + +#include "../d3d/renderParamsD3D.h" + +namespace FlexSample { +using namespace nvidia; + +struct PointRenderPipelineD3D12: public RenderPipeline +{ + //NV_CO_DECLARE_POLYMORPHIC_CLASS(PointRenderPipelineD3D12, RenderPipeline); +public: + typedef RenderPipeline Parent; + + enum PipelineStateType + { + PIPELINE_STATE_SHADOW, + PIPELINE_STATE_LIGHT_SOLID, + PIPELINE_STATE_COUNT_OF, + }; + + PointRenderPipelineD3D12(); + + /// Initialize + int initialize(const RenderStateD3D12& state, const std::wstring& shadersDir, int shadowMapLinearSamplerIndex, NvCo::Dx12RenderTarget* shadowMap); + /// Do the binding + virtual int bind(const void* paramsIn, const void* platformState) override; + virtual int draw(const RenderAllocation& alloc, size_t sizeOfAlloc, const void* platformState) override; + + /// Convert into a single pipeline state type + static PipelineStateType getPipelineStateType(PointDrawStage stage, PointRenderMode mode, PointCullMode cull); + + protected: + + int _initPipelineState(const RenderStateD3D12& state, NvCo::Dx12RenderTarget* shadowMap, PipelineStateType pipeType, ID3D12RootSignature* signiture, D3D12_GRAPHICS_PIPELINE_STATE_DESC& psoDesc); + + int m_shadowMapLinearSamplerIndex; //< The index to the linear sampler in the m_samplerHeap + + PipelineStateD3D12 m_states[PIPELINE_STATE_COUNT_OF]; +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/d3d12/renderStateD3D12.cpp b/demo/d3d12/renderStateD3D12.cpp new file mode 100644 index 0000000..28a69f4 --- /dev/null +++ b/demo/d3d12/renderStateD3D12.cpp @@ -0,0 +1,67 @@ + +#include "renderStateD3D12.h" + +namespace FlexSample { + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dx12RenderStateManager !!!!!!!!!!!!!!!!!!!!!!!!!! */ + +int RenderStateManagerD3D12::initialize(AppGraphCtxD3D12* renderContext, size_t maxHeapAlloc) +{ + m_renderContext = renderContext; + m_device = renderContext->m_device; + + m_fence.init(m_device); + m_scopeManager.init(m_device, &m_fence); + m_srvCbvUavDescriptorHeap.init(m_device, 256, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE); + m_samplerDescriptorHeap.init(m_device, 64, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE); + + { + NvCo::Dx12CircularResourceHeap::Desc desc; + desc.init(); + desc.m_blockSize = maxHeapAlloc; + m_constantHeap.init(m_device, desc, &m_fence); + } + + return NV_OK; +} + +void RenderStateManagerD3D12::updateCompleted() +{ + m_scopeManager.updateCompleted(); + m_constantHeap.updateCompleted(); +} + +void RenderStateManagerD3D12::onGpuWorkSubmitted(ID3D12CommandQueue* commandQueue) +{ + assert(commandQueue); + if (!commandQueue) + { + printf("Must pass a ID3D12CommandQueue to onGpuWorkSubmitted"); + return; + } + + const uint64_t signalValue = m_fence.nextSignal(commandQueue); + + m_scopeManager.addSync(signalValue); + m_constantHeap.addSync(signalValue); +} + +RenderStateD3D12 RenderStateManagerD3D12::getState() +{ + RenderStateD3D12 state; + + state.m_renderContext = m_renderContext; + state.m_commandList = m_renderContext->m_commandList; + state.m_device = m_device; + + state.m_constantHeap = &m_constantHeap; + state.m_srvCbvUavDescriptorHeap = &m_srvCbvUavDescriptorHeap; + state.m_fence = &m_fence; + state.m_scopeManager = &m_scopeManager; + state.m_samplerDescriptorHeap = &m_samplerDescriptorHeap; + + return state; +} + + +} // namespace FlexSample \ No newline at end of file diff --git a/demo/d3d12/renderStateD3D12.h b/demo/d3d12/renderStateD3D12.h new file mode 100644 index 0000000..1fb1f7d --- /dev/null +++ b/demo/d3d12/renderStateD3D12.h @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2008-2016, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef RENDER_STATE_D3D12_H +#define RENDER_STATE_D3D12_H + +#include +#include +#include +#include "appD3D12Ctx.h" + +namespace NvCo = nvidia::Common; + +namespace FlexSample { +using namespace nvidia; + +struct PipelineStateD3D12 +{ + /// True if contents is all set and therefore 'valid' + inline bool isValid() const { return m_rootSignature && m_pipelineState; } + + ComPtr m_rootSignature; + ComPtr m_pipelineState; +}; + +struct RenderStateD3D12 +{ + AppGraphCtxD3D12* m_renderContext; + + ID3D12Device* m_device; + ID3D12GraphicsCommandList* m_commandList; + + NvCo::Dx12ResourceScopeManager* m_scopeManager; ///< Holds resources in scope + NvCo::Dx12DescriptorHeap* m_srvCbvUavDescriptorHeap; ///< Can hold cbv, srv, uavs + NvCo::Dx12DescriptorHeap* m_samplerDescriptorHeap; ///< Descriptor heap + NvCo::Dx12CircularResourceHeap* m_constantHeap; ///< Can hold transitory constant buffers, and vertex buffers + NvCo::Dx12CounterFence* m_fence; ///< Main fence to track lifetimes +}; + +struct RenderStateManagerD3D12 +{ + RenderStateManagerD3D12(): + m_renderContext(nullptr), + m_device(nullptr) + {} + + int initialize(AppGraphCtxD3D12* renderContext, size_t maxHeapAlloc); + + void onGpuWorkSubmitted(ID3D12CommandQueue* handle); + void updateCompleted(); + + /// Get the render state + RenderStateD3D12 getState(); + + AppGraphCtxD3D12* m_renderContext; + ID3D12Device* m_device; + + NvCo::Dx12ResourceScopeManager m_scopeManager; ///< Holds resources in scope + NvCo::Dx12DescriptorHeap m_srvCbvUavDescriptorHeap; ///< Can hold cbv, srv, uavs + NvCo::Dx12DescriptorHeap m_samplerDescriptorHeap; ///< Holds sampler descriptions + NvCo::Dx12CircularResourceHeap m_constantHeap; ///< Can hold transitory constant buffers, and vertex buffers + NvCo::Dx12CounterFence m_fence; ///< Main fence to track lifetimes +}; + +} // namespace FlexSample + +#endif \ No newline at end of file diff --git a/demo/helpers.h b/demo/helpers.h index 5aec028..adc9af5 100644 --- a/demo/helpers.h +++ b/demo/helpers.h @@ -214,7 +214,7 @@ void CreateParticleShape(const Mesh* srcMesh, Vec3 lower, Vec3 scale, float rota meshLower -= meshOffset; //Voxelize(*mesh, dx, dy, dz, &voxels[0], meshLower - Vec3(spacing*0.05f) , meshLower + Vec3(maxDim*spacing) + Vec3(spacing*0.05f)); - Voxelize((const float*)&mesh.m_positions[0], mesh.m_positions.size(), (const int*)&mesh.m_indices[0], mesh.m_indices.size(), maxDim, maxDim, maxDim, &voxels[0], meshLower, meshLower + Vec3(maxDim*spacing)); + Voxelize((const Vec3*)&mesh.m_positions[0], mesh.m_positions.size(), (const int*)&mesh.m_indices[0], mesh.m_indices.size(), maxDim, maxDim, maxDim, &voxels[0], meshLower, meshLower + Vec3(maxDim*spacing)); vector indices(maxDim*maxDim*maxDim); vector sdf(maxDim*maxDim*maxDim); @@ -330,7 +330,7 @@ void CreateParticleShape(const Mesh* srcMesh, Vec3 lower, Vec3 scale, float rota float distances[g_numSkinWeights] = {FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX }; if (LengthSq(color) == 0.0f) - g_mesh->m_colours[i] = 1.25f*colors[phase%7]; + g_mesh->m_colours[i] = 1.25f*colors[((unsigned int)(phase))%7]; else g_mesh->m_colours[i] = Colour(color); @@ -439,7 +439,7 @@ void SkinMesh() } } -void AddBox(Vec3 halfEdge = Vec3(2.0f), Vec3 center=Vec3(0.0f), Quat quat=Quat(), bool dynamic=false) +void AddBox(Vec3 halfEdge = Vec3(2.0f), Vec3 center=Vec3(0.0f), Quat quat=Quat(), bool dynamic=false, int channels=eNvFlexPhaseShapeChannelMask) { // transform g_buffers->shapePositions.push_back(Vec4(center.x, center.y, center.z, 0.0f)); @@ -454,7 +454,7 @@ void AddBox(Vec3 halfEdge = Vec3(2.0f), Vec3 center=Vec3(0.0f), Quat quat=Quat() geo.box.halfExtents[2] = halfEdge.z; g_buffers->shapeGeometry.push_back(geo); - g_buffers->shapeFlags.push_back(NvFlexMakeShapeFlags(eNvFlexShapeBox, dynamic)); + g_buffers->shapeFlags.push_back(NvFlexMakeShapeFlagsWithChannels(eNvFlexShapeBox, dynamic, channels)); } // helper that creates a plinth whose center matches the particle bounds @@ -513,7 +513,7 @@ void CreateSDF(const Mesh* mesh, uint32_t dim, Vec3 lower, Vec3 upper, float* sd double startVoxelize = GetSeconds(); uint32_t* volume = new uint32_t[dim*dim*dim]; - Voxelize((const float*)&mesh->m_positions[0], mesh->m_positions.size(), (const int*)&mesh->m_indices[0], mesh->m_indices.size(), dim, dim, dim, volume, lower, upper); + Voxelize((const Vec3*)&mesh->m_positions[0], mesh->m_positions.size(), (const int*)&mesh->m_indices[0], mesh->m_indices.size(), dim, dim, dim, volume, lower, upper); printf("End mesh voxelization (%.2fs)\n", (GetSeconds()-startVoxelize)); @@ -1161,14 +1161,11 @@ int PickParticle(Vec3 origin, Vec3 dir, Vec4* particles, int* phases, int n, flo return minIndex; } -// calculates local space positions given a set of particles and rigid indices -void CalculateRigidLocalPositions(const Vec4* restPositions, int numRestPositions, const int* offsets, const int* indices, int numRigids, Vec3* localPositions) +// calculates the center of mass of every rigid given a set of particle positions and rigid indices +void CalculateRigidCentersOfMass(const Vec4* restPositions, int numRestPositions, const int* offsets, Vec3* translations, const int* indices, int numRigids) { - - // To improve the accuracy of the result, first transform the restPositions to relative coordinates (by finding the mean and subtracting that from all points) + // To improve the accuracy of the result, first transform the restPositions to relative coordinates (by finding the mean and subtracting that from all positions) // Note: If this is not done, one might see ghost forces if the mean of the restPositions is far from the origin. - - // Calculate mean Vec3 shapeOffset(0.0f); for (int i = 0; i < numRestPositions; i++) @@ -1178,12 +1175,10 @@ void CalculateRigidLocalPositions(const Vec4* restPositions, int numRestPosition shapeOffset /= float(numRestPositions); - int count = 0; - - for (int r=0; r < numRigids; ++r) + for (int i=0; i < numRigids; ++i) { - const int startIndex = offsets[r]; - const int endIndex = offsets[r+1]; + const int startIndex = offsets[i]; + const int endIndex = offsets[i+1]; const int n = endIndex-startIndex; @@ -1191,22 +1186,41 @@ void CalculateRigidLocalPositions(const Vec4* restPositions, int numRestPosition Vec3 com; - for (int i=startIndex; i < endIndex; ++i) + for (int j=startIndex; j < endIndex; ++j) { - const int r = indices[i]; + const int r = indices[j]; - // By substracting meshOffset the calculation is done in relative coordinates + // By subtracting shapeOffset the calculation is done in relative coordinates com += Vec3(restPositions[r]) - shapeOffset; } com /= float(n); - for (int i=startIndex; i < endIndex; ++i) + // Add the shapeOffset to switch back to absolute coordinates + com += shapeOffset; + + translations[i] = com; + + } +} + +// calculates local space positions given a set of particle positions, rigid indices and centers of mass of the rigids +void CalculateRigidLocalPositions(const Vec4* restPositions, const int* offsets, const Vec3* translations, const int* indices, int numRigids, Vec3* localPositions) +{ + int count = 0; + + for (int i=0; i < numRigids; ++i) + { + const int startIndex = offsets[i]; + const int endIndex = offsets[i+1]; + + assert(endIndex-startIndex); + + for (int j=startIndex; j < endIndex; ++j) { - const int r = indices[i]; + const int r = indices[j]; - // By substracting meshOffset the calculation is done in relative coordinates - localPositions[count++] = (Vec3(restPositions[r]) - shapeOffset) - com; + localPositions[count++] = Vec3(restPositions[r]) - translations[i]; } } } @@ -1224,6 +1238,48 @@ void DrawImguiString(int x, int y, Vec3 color, int align, const char* s, ...) imguiDrawText(x, y, align, buf, imguiRGBA((unsigned char)(color.x*255), (unsigned char)(color.y*255), (unsigned char)(color.z*255))); } +enum +{ + HELPERS_SHADOW_OFFSET = 1, +}; + +void DrawShadowedText(int x, int y, Vec3 color, int align, const char* s, ...) +{ + char buf[2048]; + + va_list args; + + va_start(args, s); + vsnprintf(buf, 2048, s, args); + va_end(args); + + + imguiDrawText(x + HELPERS_SHADOW_OFFSET, y - HELPERS_SHADOW_OFFSET, align, buf, imguiRGBA(0, 0, 0)); + imguiDrawText(x, y, align, buf, imguiRGBA((unsigned char)(color.x * 255), (unsigned char)(color.y * 255), (unsigned char)(color.z * 255))); +} + +void DrawRect(float x, float y, float w, float h, Vec3 color) +{ + imguiDrawRect(x, y, w, h, imguiRGBA((unsigned char)(color.x * 255), (unsigned char)(color.y * 255), (unsigned char)(color.z * 255))); +} + +void DrawShadowedRect(float x, float y, float w, float h, Vec3 color) +{ + imguiDrawRect(x + HELPERS_SHADOW_OFFSET, y - HELPERS_SHADOW_OFFSET, w, h, imguiRGBA(0, 0, 0)); + imguiDrawRect(x, y, w, h, imguiRGBA((unsigned char)(color.x * 255), (unsigned char)(color.y * 255), (unsigned char)(color.z * 255))); +} + +void DrawLine(float x0, float y0, float x1, float y1, float r, Vec3 color) +{ + imguiDrawLine(x0, y0, x1, y1, r, imguiRGBA((unsigned char)(color.x * 255), (unsigned char)(color.y * 255), (unsigned char)(color.z * 255))); +} + +void DrawShadowedLine(float x0, float y0, float x1, float y1, float r, Vec3 color) +{ + imguiDrawLine(x0 + HELPERS_SHADOW_OFFSET, y0 - HELPERS_SHADOW_OFFSET, x1 + HELPERS_SHADOW_OFFSET, y1 - HELPERS_SHADOW_OFFSET, r, imguiRGBA(0, 0, 0)); + imguiDrawLine(x0, y0, x1, y1, r, imguiRGBA((unsigned char)(color.x * 255), (unsigned char)(color.y * 255), (unsigned char)(color.z * 255))); +} + // Soft body support functions Vec3 CalculateMean(const Vec3* particles, const int* indices, int numIndices) @@ -1545,7 +1601,7 @@ void SampleMesh(Mesh* mesh, Vec3 lower, Vec3 scale, float rotation, float radius meshLower -= meshOffset; //Voxelize(*mesh, dx, dy, dz, &voxels[0], meshLower - Vec3(spacing*0.05f) , meshLower + Vec3(maxDim*spacing) + Vec3(spacing*0.05f)); - Voxelize((const float*)&mesh->m_positions[0], mesh->m_positions.size(), (const int*)&mesh->m_indices[0], mesh->m_indices.size(), maxDim, maxDim, maxDim, &voxels[0], meshLower, meshLower + Vec3(maxDim*spacing)); + Voxelize((const Vec3*)&mesh->m_positions[0], mesh->m_positions.size(), (const int*)&mesh->m_indices[0], mesh->m_indices.size(), maxDim, maxDim, maxDim, &voxels[0], meshLower, meshLower + Vec3(maxDim*spacing)); // sample interior for (int x = 0; x < maxDim; ++x) diff --git a/demo/imgui.cpp b/demo/imgui.cpp index bc42082..cccaf3f 100644 --- a/demo/imgui.cpp +++ b/demo/imgui.cpp @@ -33,10 +33,10 @@ static char g_textPool[TEXT_POOL_SIZE]; static unsigned g_textPoolSize = 0; static const char* allocText(const char* text) { - int len = (int)(strlen(text)+1); + int len = (int)(strlen(text) + 1); if (g_textPoolSize + len >= TEXT_POOL_SIZE) return 0; - char* dst = &g_textPool[g_textPoolSize]; + char* dst = &g_textPool[g_textPoolSize]; memcpy(dst, text, len); g_textPoolSize += len; return dst; @@ -147,13 +147,13 @@ struct GuiState mx(-1), my(-1), scroll(0), active(0), hot(0), hotToBe(0), isHot(false), isActive(false), wentActive(false), dragX(0), dragY(0), dragOrig(0), widgetX(0), widgetY(0), widgetW(100), - insideCurrentScroll(false), areaId(0), widgetId(0) + insideCurrentScroll(false), areaId(0), widgetId(0) { } bool left; bool leftPressed, leftReleased; - int mx,my; + int mx, my; int scroll; unsigned int active; unsigned int hot; @@ -165,7 +165,7 @@ struct GuiState float dragOrig; int widgetX, widgetY, widgetW; bool insideCurrentScroll; - + unsigned int areaId; unsigned int widgetId; }; @@ -198,7 +198,7 @@ inline bool isHot(unsigned int id) inline bool inRect(int x, int y, int w, int h, bool checkScroll = true) { - return (!checkScroll || g_state.insideCurrentScroll) && g_state.mx >= x && g_state.mx <= x+w && g_state.my >= y && g_state.my <= y+h; + return (!checkScroll || g_state.insideCurrentScroll) && g_state.mx >= x && g_state.mx <= x + w && g_state.my >= y && g_state.my <= y + h; } inline void clearInput() @@ -223,12 +223,12 @@ inline void setActive(unsigned int id) inline void setHot(unsigned int id) { - g_state.hotToBe = id; -// Begin Add Android Support + g_state.hotToBe = id; + // Begin Add Android Support #ifdef ANDROID - g_state.hot = id; + g_state.hot = id; #endif -// End Add Android Support + // End Add Android Support } @@ -240,7 +240,7 @@ static bool buttonLogic(unsigned int id, bool over) { if (over) setHot(id); -// Begin Add Android Support + // Begin Add Android Support #ifdef ANDROID if (isHot(id) && g_state.leftPressed && over) setActive(id); @@ -248,7 +248,7 @@ static bool buttonLogic(unsigned int id, bool over) if (isHot(id) && g_state.leftPressed) setActive(id); #endif -// End Add Android Support + // End Add Android Support } // if button is active, then react on left up @@ -286,7 +286,7 @@ static void updateInput(int mx, int my, unsigned char mbut, int scroll) void imguiBeginFrame(int mx, int my, unsigned char mbut, int scroll) { - updateInput(mx,my,mbut,scroll); + updateInput(mx, my, mbut, scroll); g_state.hot = g_state.hotToBe; g_state.hotToBe = 0; @@ -346,29 +346,29 @@ bool imguiBeginScrollArea(const char* name, int x, int y, int w, int h, int* scr { g_state.areaId++; g_state.widgetId = 0; - g_scrollId = (g_state.areaId<<16) | g_state.widgetId; + g_scrollId = (g_state.areaId << 16) | g_state.widgetId; g_state.widgetX = x + SCROLL_AREA_PADDING; - g_state.widgetY = y+h-AREA_HEADER + (*scroll); - g_state.widgetW = w - SCROLL_AREA_PADDING*4; - g_scrollTop = y-AREA_HEADER+h; - g_scrollBottom = y+SCROLL_AREA_PADDING; - g_scrollRight = x+w - SCROLL_AREA_PADDING*3; + g_state.widgetY = y + h - AREA_HEADER + (*scroll); + g_state.widgetW = w - SCROLL_AREA_PADDING * 4; + g_scrollTop = y - AREA_HEADER + h; + g_scrollBottom = y + SCROLL_AREA_PADDING; + g_scrollRight = x + w - SCROLL_AREA_PADDING * 3; g_scrollVal = scroll; g_scrollAreaTop = g_state.widgetY; - g_focusTop = y-AREA_HEADER; - g_focusBottom = y-AREA_HEADER+h; + g_focusTop = y - AREA_HEADER; + g_focusBottom = y - AREA_HEADER + h; g_insideScrollArea = inRect(x, y, w, h, false); g_state.insideCurrentScroll = g_insideScrollArea; - addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 6, imguiRGBA(0,0,0,192)); + addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 6, imguiRGBA(0, 0, 0, 192)); - addGfxCmdText(x+AREA_HEADER/2, y+h-AREA_HEADER/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, name, imguiRGBA(255,255,255,128)); + addGfxCmdText(x + AREA_HEADER / 2, y + h - AREA_HEADER / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, name, imguiRGBA(255, 255, 255, 128)); - addGfxCmdScissor(x+SCROLL_AREA_PADDING, y+SCROLL_AREA_PADDING, w-SCROLL_AREA_PADDING*4, h-AREA_HEADER-SCROLL_AREA_PADDING); + addGfxCmdScissor(x + SCROLL_AREA_PADDING, y + SCROLL_AREA_PADDING, w - SCROLL_AREA_PADDING * 4, h - AREA_HEADER - SCROLL_AREA_PADDING); return g_insideScrollArea; } @@ -376,39 +376,39 @@ bool imguiBeginScrollArea(const char* name, int x, int y, int w, int h, int* scr void imguiEndScrollArea() { // Disable scissoring. - addGfxCmdScissor(-1,-1,-1,-1); + addGfxCmdScissor(-1, -1, -1, -1); // Draw scroll bar - int x = g_scrollRight+SCROLL_AREA_PADDING/2; + int x = g_scrollRight + SCROLL_AREA_PADDING / 2; int y = g_scrollBottom; - int w = SCROLL_AREA_PADDING*2; + int w = SCROLL_AREA_PADDING * 2; int h = g_scrollTop - g_scrollBottom; int stop = g_scrollAreaTop; int sbot = g_state.widgetY; int sh = stop - sbot; // The scrollable area height. - float barHeight = (float)h/(float)sh; - + float barHeight = (float)h / (float)sh; + if (barHeight < 1) { - float barY = (float)(y - sbot)/(float)sh; + float barY = (float)(y - sbot) / (float)sh; if (barY < 0) barY = 0; if (barY > 1) barY = 1; - + // Handle scroll bar logic. unsigned int hid = g_scrollId; int hx = x; int hy = y + (int)(barY*h); int hw = w; int hh = (int)(barHeight*h); - - const int range = h - (hh-1); + + const int range = h - (hh - 1); bool over = inRect(hx, hy, hw, hh); buttonLogic(hid, over); if (isActive(hid)) { - float u = (float)(hy-y) / (float)range; + float u = (float)(hy - y) / (float)range; if (g_state.wentActive) { g_state.dragY = g_state.my; @@ -419,26 +419,26 @@ void imguiEndScrollArea() u = g_state.dragOrig + (g_state.my - g_state.dragY) / (float)range; if (u < 0) u = 0; if (u > 1) u = 1; - *g_scrollVal = (int)((1-u) * (sh - h)); + *g_scrollVal = (int)((1 - u) * (sh - h)); } } - + // BG - addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)w/2-1, imguiRGBA(0,0,0,196)); + addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)w / 2 - 1, imguiRGBA(0, 0, 0, 196)); // Bar if (isActive(hid)) - addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, imguiRGBA(255,196,0,196)); + addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w / 2 - 1, imguiRGBA(255, 196, 0, 196)); else - addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, isHot(hid) ? imguiRGBA(255,196,0,96) : imguiRGBA(255,255,255,64)); + addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w / 2 - 1, isHot(hid) ? imguiRGBA(255, 196, 0, 96) : imguiRGBA(255, 255, 255, 64)); // Handle mouse scrolling. if (g_insideScrollArea) // && !anyActive()) { if (g_state.scroll) { - *g_scrollVal += 20*g_state.scroll; + *g_scrollVal += 20 * g_state.scroll; if (*g_scrollVal < 0) *g_scrollVal = 0; - if (*g_scrollVal > (sh - h)) *g_scrollVal = (sh - h); + if (*g_scrollVal >(sh - h)) *g_scrollVal = (sh - h); } } } @@ -448,8 +448,8 @@ void imguiEndScrollArea() bool imguiButton(const char* text, bool enabled) { g_state.widgetId++; - unsigned int id = (g_state.areaId<<16) | g_state.widgetId; - + unsigned int id = (g_state.areaId << 16) | g_state.widgetId; + int x = g_state.widgetX; int y = g_state.widgetY - BUTTON_HEIGHT; int w = g_state.widgetW; @@ -459,16 +459,16 @@ bool imguiButton(const char* text, bool enabled) bool over = enabled && inRect(x, y, w, h); bool res = buttonLogic(id, over); - addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)BUTTON_HEIGHT/2-1, imguiRGBA(128,128,128, isActive(id)?196:96)); + addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)BUTTON_HEIGHT / 2 - 1, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96)); if (enabled) - addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200)); + addGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200)); else - addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200)); + addGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128, 128, 128, 200)); return res; } -bool imguiItem(const char* text, bool enabled, unsigned int color, bool forceHot) +bool imguiItem(const char* text, bool enabled, unsigned int color) { g_state.widgetId++; unsigned int id = (g_state.areaId << 16) | g_state.widgetId; @@ -484,8 +484,6 @@ bool imguiItem(const char* text, bool enabled, unsigned int color, bool forceHot if (isHot(id)) addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 2.0f, imguiRGBA(255, 196, 0, isActive(id) ? 196 : 96)); - else if (forceHot) - addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 2.0f, imguiRGBA(128, 128, 128, 96)); if (enabled) addGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, color); @@ -498,8 +496,8 @@ bool imguiItem(const char* text, bool enabled, unsigned int color, bool forceHot bool imguiCheck(const char* text, bool checked, bool enabled) { g_state.widgetId++; - unsigned int id = (g_state.areaId<<16) | g_state.widgetId; - + unsigned int id = (g_state.areaId << 16) | g_state.widgetId; + int x = g_state.widgetX; int y = g_state.widgetY - BUTTON_HEIGHT; int w = g_state.widgetW; @@ -508,22 +506,22 @@ bool imguiCheck(const char* text, bool checked, bool enabled) bool over = enabled && inRect(x, y, w, h); bool res = buttonLogic(id, over); - - const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2; - const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2; - addGfxCmdRoundedRect((float)cx-3, (float)cy-3, (float)CHECK_SIZE+6, (float)CHECK_SIZE+6, 4, imguiRGBA(128,128,128, isActive(id)?196:96)); + + const int cx = x + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2; + const int cy = y + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2; + addGfxCmdRoundedRect((float)cx - 3, (float)cy - 3, (float)CHECK_SIZE + 6, (float)CHECK_SIZE + 6, 4, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96)); if (checked) { if (enabled) - addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE/2-1, imguiRGBA(255,255,255,isActive(id)?255:200)); + addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE / 2 - 1, imguiRGBA(255, 255, 255, isActive(id) ? 255 : 200)); else - addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE/2-1, imguiRGBA(128,128,128,200)); + addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE / 2 - 1, imguiRGBA(128, 128, 128, 200)); } if (enabled) - addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200)); + addGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200)); else - addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200)); + addGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128, 128, 128, 200)); return res; } @@ -531,33 +529,33 @@ bool imguiCheck(const char* text, bool checked, bool enabled) bool imguiCollapse(const char* text, const char* subtext, bool checked, bool enabled) { g_state.widgetId++; - unsigned int id = (g_state.areaId<<16) | g_state.widgetId; - + unsigned int id = (g_state.areaId << 16) | g_state.widgetId; + int x = g_state.widgetX; int y = g_state.widgetY - BUTTON_HEIGHT; int w = g_state.widgetW; int h = BUTTON_HEIGHT; g_state.widgetY -= BUTTON_HEIGHT; // + DEFAULT_SPACING; - const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2; - const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2; + const int cx = x + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2; + const int cy = y + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2; bool over = enabled && inRect(x, y, w, h); bool res = buttonLogic(id, over); - + if (checked) - addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 2, imguiRGBA(255,255,255,isActive(id)?255:200)); + addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 2, imguiRGBA(255, 255, 255, isActive(id) ? 255 : 200)); else - addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 1, imguiRGBA(255,255,255,isActive(id)?255:200)); + addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 1, imguiRGBA(255, 255, 255, isActive(id) ? 255 : 200)); if (enabled) - addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200)); + addGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200)); else - addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200)); + addGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128, 128, 128, 200)); if (subtext) - addGfxCmdText(x+w-BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, subtext, imguiRGBA(255,255,255,128)); - + addGfxCmdText(x + w - BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_RIGHT, subtext, imguiRGBA(255, 255, 255, 128)); + return res; } @@ -566,7 +564,7 @@ void imguiLabel(const char* text) int x = g_state.widgetX; int y = g_state.widgetY - BUTTON_HEIGHT; g_state.widgetY -= BUTTON_HEIGHT; - addGfxCmdText(x, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(255,255,255,255)); + addGfxCmdText(x, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, imguiRGBA(255, 255, 255, 255)); } void imguiValue(const char* text) @@ -575,31 +573,31 @@ void imguiValue(const char* text) const int y = g_state.widgetY - BUTTON_HEIGHT; const int w = g_state.widgetW; g_state.widgetY -= BUTTON_HEIGHT; - - addGfxCmdText(x+w-BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, text, imguiRGBA(255,255,255,200)); + + addGfxCmdText(x + w - BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_RIGHT, text, imguiRGBA(255, 255, 255, 200)); } bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vinc, bool enabled) { g_state.widgetId++; - unsigned int id = (g_state.areaId<<16) | g_state.widgetId; - + unsigned int id = (g_state.areaId << 16) | g_state.widgetId; + int x = g_state.widgetX; int y = g_state.widgetY - BUTTON_HEIGHT; int w = g_state.widgetW; int h = SLIDER_HEIGHT; g_state.widgetY -= SLIDER_HEIGHT + DEFAULT_SPACING; - addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 4.0f, imguiRGBA(0,0,0,128)); + addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 4.0f, imguiRGBA(0, 0, 0, 128)); const int range = w - SLIDER_MARKER_WIDTH; - float u = (*val - vmin) / (vmax-vmin); + float u = (*val - vmin) / (vmax - vmin); if (u < 0) u = 0; if (u > 1) u = 1; int m = (int)(u * range); - bool over = enabled && inRect(x+m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT); + bool over = enabled && inRect(x + m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT); bool res = buttonLogic(id, over); bool valChanged = false; @@ -615,17 +613,17 @@ bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vin u = g_state.dragOrig + (float)(g_state.mx - g_state.dragX) / (float)range; if (u < 0) u = 0; if (u > 1) u = 1; - *val = vmin + u*(vmax-vmin); - *val = floorf(*val/vinc+0.5f)*vinc; // Snap to vinc + *val = vmin + u*(vmax - vmin); + *val = floorf(*val / vinc + 0.5f)*vinc; // Snap to vinc m = (int)(u * range); valChanged = true; } } if (isActive(id)) - addGfxCmdRoundedRect((float)(x+m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, imguiRGBA(255,255,255,255)); + addGfxCmdRoundedRect((float)(x + m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, imguiRGBA(255, 255, 255, 255)); else - addGfxCmdRoundedRect((float)(x+m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, isHot(id) ? imguiRGBA(255,196,0,128) : imguiRGBA(255,255,255,64)); + addGfxCmdRoundedRect((float)(x + m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, isHot(id) ? imguiRGBA(255, 196, 0, 128) : imguiRGBA(255, 255, 255, 64)); // TODO: fix this, take a look at 'nicenum'. int digits = (int)(ceilf(log10f(vinc))); @@ -633,16 +631,16 @@ bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vin snprintf(fmt, 16, "%%.%df", digits >= 0 ? 0 : -digits); char msg[128]; snprintf(msg, 128, fmt, *val); - + if (enabled) { - addGfxCmdText(x+SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200)); - addGfxCmdText(x+w-SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, msg, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200)); + addGfxCmdText(x + SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200)); + addGfxCmdText(x + w - SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_RIGHT, msg, isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200)); } else { - addGfxCmdText(x+SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200)); - addGfxCmdText(x+w-SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, msg, imguiRGBA(128,128,128,200)); + addGfxCmdText(x + SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128, 128, 128, 200)); + addGfxCmdText(x + w - SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, IMGUI_ALIGN_RIGHT, msg, imguiRGBA(128, 128, 128, 200)); } return res || valChanged; @@ -663,18 +661,18 @@ void imguiUnindent() void imguiSeparator() { - g_state.widgetY -= DEFAULT_SPACING*3; + g_state.widgetY -= DEFAULT_SPACING * 3; } void imguiSeparatorLine() { int x = g_state.widgetX; - int y = g_state.widgetY - DEFAULT_SPACING*2; + int y = g_state.widgetY - DEFAULT_SPACING * 2; int w = g_state.widgetW; int h = 1; - g_state.widgetY -= DEFAULT_SPACING*4; + g_state.widgetY -= DEFAULT_SPACING * 4; - addGfxCmdRect((float)x, (float)y, (float)w, (float)h, imguiRGBA(255,255,255,32)); + addGfxCmdRect((float)x, (float)y, (float)w, (float)h, imguiRGBA(255, 255, 255, 32)); } void imguiDrawText(int x, int y, int align, const char* text, unsigned int color) diff --git a/demo/imgui.h b/demo/imgui.h index 10ff3ab..e01f374 100644 --- a/demo/imgui.h +++ b/demo/imgui.h @@ -21,8 +21,8 @@ enum imguiMouseButton { - IMGUI_MBUT_LEFT = 0x01, - IMGUI_MBUT_RIGHT = 0x02, + IMGUI_MBUT_LEFT = 0x01, + IMGUI_MBUT_RIGHT = 0x02, }; enum imguiTextAlign @@ -32,13 +32,11 @@ enum imguiTextAlign IMGUI_ALIGN_RIGHT, }; -inline unsigned int imguiRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) +inline unsigned int imguiRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255) { return (r) | (g << 8) | (b << 16) | (a << 24); } -struct imguiGfxRect; - void imguiBeginFrame(int mx, int my, unsigned char mbut, int scroll); void imguiEndFrame(); @@ -51,7 +49,7 @@ void imguiSeparator(); void imguiSeparatorLine(); bool imguiButton(const char* text, bool enabled = true); -bool imguiItem(const char* text, bool enabled = true, unsigned int color = imguiRGBA(255, 255, 255, 200), bool forceHot = false); +bool imguiItem(const char* text, bool enabled = true, unsigned int color = imguiRGBA(255, 255, 255, 200)); bool imguiCheck(const char* text, bool checked, bool enabled = true); bool imguiCollapse(const char* text, const char* subtext, bool checked, bool enabled = true); void imguiLabel(const char* text); @@ -75,18 +73,18 @@ enum imguiGfxCmdType struct imguiGfxRect { - short x,y,w,h,r; + short x, y, w, h, r; }; struct imguiGfxText { - short x,y,align; + short x, y, align; const char* text; }; struct imguiGfxLine { - short x0,y0,x1,y1,r; + short x0, y0, x1, y1, r; }; struct imguiGfxCmd @@ -107,4 +105,4 @@ const imguiGfxCmd* imguiGetRenderQueue(); int imguiGetRenderQueueSize(); -#endif // IMGUI_H +#endif // IMGUI_H \ No newline at end of file diff --git a/demo/main.cpp b/demo/main.cpp index 1ee4049..df05ef7 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -49,6 +49,13 @@ #include "shaders.h" #include "imgui.h" +#if FLEX_DX +#include "d3d/shadersDemoContext.h" +class DemoContext; +extern DemoContext* CreateDemoContextD3D12(); +extern DemoContext* CreateDemoContextD3D11(); +#endif // FLEX_DX + SDL_Window* g_window; // window handle unsigned int g_windowId; // window id @@ -116,12 +123,15 @@ bool g_extensions = true; bool g_teamCity = false; bool g_interop = true; bool g_d3d12 = false; +bool g_useAsyncCompute = true; +bool g_increaseGfxLoadForAsyncComputeTesting = false; FluidRenderer* g_fluidRenderer; -FluidRenderBuffers g_fluidRenderBuffers; -DiffuseRenderBuffers g_diffuseRenderBuffers; +FluidRenderBuffers* g_fluidRenderBuffers; +DiffuseRenderBuffers* g_diffuseRenderBuffers; -NvFlexSolver* g_flex; +NvFlexSolver* g_solver; +NvFlexSolverDesc g_solverDesc; NvFlexLibrary* g_flexLib; NvFlexParams g_params; NvFlexTimers g_timers; @@ -148,6 +158,19 @@ std::map g_fields; // flag to request collision shapes be updated bool g_shapesChanged = false; +/* Note that this array of colors is altered by demo code, and is also read from global by graphics API impls */ +Colour g_colors[] = +{ + Colour(0.0f, 0.5f, 1.0f), + Colour(0.797f, 0.354f, 0.000f), + Colour(0.092f, 0.465f, 0.820f), + Colour(0.000f, 0.349f, 0.173f), + Colour(0.875f, 0.782f, 0.051f), + Colour(0.000f, 0.170f, 0.453f), + Colour(0.673f, 0.111f, 0.000f), + Colour(0.612f, 0.194f, 0.394f) +}; + struct SimBuffers { NvFlexVector positions; @@ -162,7 +185,8 @@ struct SimBuffers NvFlexVector smoothPositions; NvFlexVector diffusePositions; NvFlexVector diffuseVelocities; - NvFlexVector diffuseIndices; + NvFlexVector diffuseCount; + NvFlexVector activeIndices; // convexes @@ -178,6 +202,8 @@ struct SimBuffers NvFlexVector rigidIndices; NvFlexVector rigidMeshSize; NvFlexVector rigidCoefficients; + NvFlexVector rigidPlasticThresholds; + NvFlexVector rigidPlasticCreeps; NvFlexVector rigidRotations; NvFlexVector rigidTranslations; NvFlexVector rigidLocalPositions; @@ -202,10 +228,10 @@ struct SimBuffers SimBuffers(NvFlexLibrary* l) : positions(l), restPositions(l), velocities(l), phases(l), densities(l), anisotropy1(l), anisotropy2(l), anisotropy3(l), normals(l), smoothPositions(l), - diffusePositions(l), diffuseVelocities(l), diffuseIndices(l), activeIndices(l), + diffusePositions(l), diffuseVelocities(l), diffuseCount(l), activeIndices(l), shapeGeometry(l), shapePositions(l), shapeRotations(l), shapePrevPositions(l), shapePrevRotations(l), shapeFlags(l), rigidOffsets(l), rigidIndices(l), rigidMeshSize(l), - rigidCoefficients(l), rigidRotations(l), rigidTranslations(l), + rigidCoefficients(l), rigidPlasticThresholds(l), rigidPlasticCreeps(l), rigidRotations(l), rigidTranslations(l), rigidLocalPositions(l), rigidLocalNormals(l), inflatableTriOffsets(l), inflatableTriCounts(l), inflatableVolumes(l), inflatableCoefficients(l), inflatablePressures(l), springIndices(l), springLengths(l), @@ -228,7 +254,7 @@ void MapBuffers(SimBuffers* buffers) buffers->normals.map(); buffers->diffusePositions.map(); buffers->diffuseVelocities.map(); - buffers->diffuseIndices.map(); + buffers->diffuseCount.map(); buffers->smoothPositions.map(); buffers->activeIndices.map(); @@ -244,6 +270,8 @@ void MapBuffers(SimBuffers* buffers) buffers->rigidIndices.map(); buffers->rigidMeshSize.map(); buffers->rigidCoefficients.map(); + buffers->rigidPlasticThresholds.map(); + buffers->rigidPlasticCreeps.map(); buffers->rigidRotations.map(); buffers->rigidTranslations.map(); buffers->rigidLocalPositions.map(); @@ -279,7 +307,7 @@ void UnmapBuffers(SimBuffers* buffers) buffers->normals.unmap(); buffers->diffusePositions.unmap(); buffers->diffuseVelocities.unmap(); - buffers->diffuseIndices.unmap(); + buffers->diffuseCount.unmap(); buffers->smoothPositions.unmap(); buffers->activeIndices.unmap(); @@ -296,6 +324,8 @@ void UnmapBuffers(SimBuffers* buffers) buffers->rigidIndices.unmap(); buffers->rigidMeshSize.unmap(); buffers->rigidCoefficients.unmap(); + buffers->rigidPlasticThresholds.unmap(); + buffers->rigidPlasticCreeps.unmap(); buffers->rigidRotations.unmap(); buffers->rigidTranslations.unmap(); buffers->rigidLocalPositions.unmap(); @@ -339,7 +369,7 @@ void DestroyBuffers(SimBuffers* buffers) buffers->normals.destroy(); buffers->diffusePositions.destroy(); buffers->diffuseVelocities.destroy(); - buffers->diffuseIndices.destroy(); + buffers->diffuseCount.destroy(); buffers->smoothPositions.destroy(); buffers->activeIndices.destroy(); @@ -356,6 +386,8 @@ void DestroyBuffers(SimBuffers* buffers) buffers->rigidIndices.destroy(); buffers->rigidMeshSize.destroy(); buffers->rigidCoefficients.destroy(); + buffers->rigidPlasticThresholds.destroy(); + buffers->rigidPlasticCreeps.destroy(); buffers->rigidRotations.destroy(); buffers->rigidTranslations.destroy(); buffers->rigidLocalPositions.destroy(); @@ -476,6 +508,8 @@ int g_lasty; int g_lastb = -1; bool g_profile = false; +bool g_outputAllFrameTimes = false; +bool g_asyncComputeBenchmark = false; ShadowMap* g_shadowMap; @@ -525,7 +559,7 @@ void Init(int scene, bool centerCamera = true) { RandInit(); - if (g_flex) + if (g_solver) { if (g_buffers) DestroyBuffers(g_buffers); @@ -556,8 +590,8 @@ void Init(int scene, bool centerCamera = true) g_meshes.clear(); g_convexes.clear(); - NvFlexDestroySolver(g_flex); - g_flex = NULL; + NvFlexDestroySolver(g_solver); + g_solver = NULL; } // alloc buffers @@ -576,6 +610,8 @@ void Init(int scene, bool centerCamera = true) g_buffers->rigidRotations.resize(0); g_buffers->rigidTranslations.resize(0); g_buffers->rigidCoefficients.resize(0); + g_buffers->rigidPlasticThresholds.resize(0); + g_buffers->rigidPlasticCreeps.resize(0); g_buffers->rigidLocalPositions.resize(0); g_buffers->rigidLocalNormals.resize(0); @@ -592,6 +628,8 @@ void Init(int scene, bool centerCamera = true) g_emitters.resize(1); g_emitters[0].mEnabled = false; g_emitters[0].mSpeed = 1.0f; + g_emitters[0].mLeftOver = 0.0f; + g_emitters[0].mWidth = 8; g_buffers->shapeGeometry.resize(0); g_buffers->shapePositions.resize(0); @@ -670,9 +708,6 @@ void Init(int scene, bool centerCamera = true) g_params.particleCollisionMargin = 0.0f; g_params.shapeCollisionMargin = 0.0f; g_params.collisionDistance = 0.0f; - g_params.plasticThreshold = 0.0f; - g_params.plasticCreep = 0.0f; - g_params.fluid = false; g_params.sleepThreshold = 0.0f; g_params.shockPropagation = 0.0f; g_params.restitution = 0.0f; @@ -692,9 +727,6 @@ void Init(int scene, bool centerCamera = true) g_params.diffuseBuoyancy = 1.0f; g_params.diffuseDrag = 0.8f; g_params.diffuseBallistic = 16; - g_params.diffuseSortAxis[0] = 0.0f; - g_params.diffuseSortAxis[1] = 0.0f; - g_params.diffuseSortAxis[2] = 0.0f; g_params.diffuseLifetime = 2.0f; g_numSubsteps = 2; @@ -710,8 +742,7 @@ void Init(int scene, bool centerCamera = true) g_diffuseOutscatter = 0.53f; // reset phase 0 particle color to blue - extern Colour gColors[]; - gColors[0] = Colour(0.0f, 0.5f, 1.0f); + g_colors[0] = Colour(0.0f, 0.5f, 1.0f); g_numSolidParticles = 0; @@ -730,26 +761,27 @@ void Init(int scene, bool centerCamera = true) g_sceneLower = FLT_MAX; g_sceneUpper = -FLT_MAX; + // initialize solver desc + NvFlexSetSolverDescDefaults(&g_solverDesc); + // create scene + StartGpuWork(); g_scenes[g_scene]->Initialize(); + EndGpuWork(); uint32_t numParticles = g_buffers->positions.size(); uint32_t maxParticles = numParticles + g_numExtraParticles*g_numExtraMultiplier; + + if (g_params.solidRestDistance == 0.0f) + g_params.solidRestDistance = g_params.radius; - // by default solid particles use the maximum radius - if (g_params.fluid && g_params.solidRestDistance == 0.0f) + // if fluid present then we assume solid particles have the same radius + if (g_params.fluidRestDistance > 0.0f) g_params.solidRestDistance = g_params.fluidRestDistance; - else - g_params.solidRestDistance = g_params.radius; - // collision distance with shapes half the radius + // set collision distance automatically based on rest distance if not alraedy set if (g_params.collisionDistance == 0.0f) - { - g_params.collisionDistance = g_params.radius*0.5f; - - if (g_params.fluid) - g_params.collisionDistance = g_params.fluidRestDistance*0.5f; - } + g_params.collisionDistance = Max(g_params.solidRestDistance, g_params.fluidRestDistance)*0.5f; // default particle friction to 10% of shape friction if (g_params.particleFriction == 0.0f) @@ -788,7 +820,7 @@ void Init(int scene, bool centerCamera = true) g_buffers->diffusePositions.resize(g_maxDiffuseParticles); g_buffers->diffuseVelocities.resize(g_maxDiffuseParticles); - g_buffers->diffuseIndices.resize(g_maxDiffuseParticles); + g_buffers->diffuseCount.resize(1, 0); // for fluid rendering these are the Laplacian smoothed positions g_buffers->smoothPositions.resize(maxParticles); @@ -825,8 +857,12 @@ void Init(int scene, bool centerCamera = true) g_meshRestPositions.resize(0); } + g_solverDesc.maxParticles = maxParticles; + g_solverDesc.maxDiffuseParticles = g_maxDiffuseParticles; + g_solverDesc.maxNeighborsPerParticle = g_maxNeighborsPerParticle; + // main create method for the Flex solver - g_flex = NvFlexCreateSolver(g_flexLib, maxParticles, g_maxDiffuseParticles, g_maxNeighborsPerParticle); + g_solver = NvFlexCreateSolver(g_flexLib, &g_solverDesc); // give scene a chance to do some post solver initialization g_scenes[g_scene]->PostInitialize(); @@ -868,13 +904,20 @@ void Init(int scene, bool centerCamera = true) const int numRigids = g_buffers->rigidOffsets.size() - 1; + // If the centers of mass for the rigids are not yet computed, this is done here + // (If the CreateParticleShape method is used instead of the NvFlexExt methods, the centers of mass will be calculated here) + if (g_buffers->rigidTranslations.size() == 0) + { + g_buffers->rigidTranslations.resize(g_buffers->rigidOffsets.size() - 1, Vec3()); + CalculateRigidCentersOfMass(&g_buffers->positions[0], g_buffers->positions.size(), &g_buffers->rigidOffsets[0], &g_buffers->rigidTranslations[0], &g_buffers->rigidIndices[0], numRigids); + } + // calculate local rest space positions g_buffers->rigidLocalPositions.resize(g_buffers->rigidOffsets.back()); - CalculateRigidLocalPositions(&g_buffers->positions[0], g_buffers->positions.size(), &g_buffers->rigidOffsets[0], &g_buffers->rigidIndices[0], numRigids, &g_buffers->rigidLocalPositions[0]); + CalculateRigidLocalPositions(&g_buffers->positions[0], &g_buffers->rigidOffsets[0], &g_buffers->rigidTranslations[0], &g_buffers->rigidIndices[0], numRigids, &g_buffers->rigidLocalPositions[0]); + // set rigidRotations to correct length, probably NULL up until here g_buffers->rigidRotations.resize(g_buffers->rigidOffsets.size() - 1, Quat()); - g_buffers->rigidTranslations.resize(g_buffers->rigidOffsets.size() - 1, Vec3()); - } // unmap so we can start transferring data to GPU @@ -883,47 +926,53 @@ void Init(int scene, bool centerCamera = true) //----------------------------- // Send data to Flex - NvFlexSetParams(g_flex, &g_params); - NvFlexSetParticles(g_flex, g_buffers->positions.buffer, numParticles); - NvFlexSetVelocities(g_flex, g_buffers->velocities.buffer, numParticles); - NvFlexSetNormals(g_flex, g_buffers->normals.buffer, numParticles); - NvFlexSetPhases(g_flex, g_buffers->phases.buffer, g_buffers->phases.size()); - NvFlexSetRestParticles(g_flex, g_buffers->restPositions.buffer, g_buffers->restPositions.size()); + NvFlexCopyDesc copyDesc; + copyDesc.dstOffset = 0; + copyDesc.srcOffset = 0; + copyDesc.elementCount = numParticles; - NvFlexSetActive(g_flex, g_buffers->activeIndices.buffer, numParticles); + NvFlexSetParams(g_solver, &g_params); + NvFlexSetParticles(g_solver, g_buffers->positions.buffer, ©Desc); + NvFlexSetVelocities(g_solver, g_buffers->velocities.buffer, ©Desc); + NvFlexSetNormals(g_solver, g_buffers->normals.buffer, ©Desc); + NvFlexSetPhases(g_solver, g_buffers->phases.buffer, ©Desc); + NvFlexSetRestParticles(g_solver, g_buffers->restPositions.buffer, ©Desc); + NvFlexSetActive(g_solver, g_buffers->activeIndices.buffer, ©Desc); + NvFlexSetActiveCount(g_solver, numParticles); + // springs if (g_buffers->springIndices.size()) { assert((g_buffers->springIndices.size() & 1) == 0); assert((g_buffers->springIndices.size() / 2) == g_buffers->springLengths.size()); - NvFlexSetSprings(g_flex, g_buffers->springIndices.buffer, g_buffers->springLengths.buffer, g_buffers->springStiffness.buffer, g_buffers->springLengths.size()); + NvFlexSetSprings(g_solver, g_buffers->springIndices.buffer, g_buffers->springLengths.buffer, g_buffers->springStiffness.buffer, g_buffers->springLengths.size()); } // rigids if (g_buffers->rigidOffsets.size()) { - NvFlexSetRigids(g_flex, g_buffers->rigidOffsets.buffer, g_buffers->rigidIndices.buffer, g_buffers->rigidLocalPositions.buffer, g_buffers->rigidLocalNormals.buffer, g_buffers->rigidCoefficients.buffer, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer, g_buffers->rigidOffsets.size() - 1, g_buffers->rigidIndices.size()); + NvFlexSetRigids(g_solver, g_buffers->rigidOffsets.buffer, g_buffers->rigidIndices.buffer, g_buffers->rigidLocalPositions.buffer, g_buffers->rigidLocalNormals.buffer, g_buffers->rigidCoefficients.buffer, g_buffers->rigidPlasticThresholds.buffer, g_buffers->rigidPlasticCreeps.buffer, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer, g_buffers->rigidOffsets.size() - 1, g_buffers->rigidIndices.size()); } // inflatables if (g_buffers->inflatableTriOffsets.size()) { - NvFlexSetInflatables(g_flex, g_buffers->inflatableTriOffsets.buffer, g_buffers->inflatableTriCounts.buffer, g_buffers->inflatableVolumes.buffer, g_buffers->inflatablePressures.buffer, g_buffers->inflatableCoefficients.buffer, g_buffers->inflatableTriOffsets.size()); + NvFlexSetInflatables(g_solver, g_buffers->inflatableTriOffsets.buffer, g_buffers->inflatableTriCounts.buffer, g_buffers->inflatableVolumes.buffer, g_buffers->inflatablePressures.buffer, g_buffers->inflatableCoefficients.buffer, g_buffers->inflatableTriOffsets.size()); } // dynamic triangles if (g_buffers->triangles.size()) { - NvFlexSetDynamicTriangles(g_flex, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); + NvFlexSetDynamicTriangles(g_solver, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); } // collision shapes if (g_buffers->shapeFlags.size()) { NvFlexSetShapes( - g_flex, + g_solver, g_buffers->shapeGeometry.buffer, g_buffers->shapePositions.buffer, g_buffers->shapeRotations.buffer, @@ -946,20 +995,20 @@ void Init(int scene, bool centerCamera = true) NvFlexParams copy = g_params; copy.numIterations = 4; - NvFlexSetParams(g_flex, ©); + NvFlexSetParams(g_solver, ©); const int kWarmupIterations = 100; for (int i = 0; i < kWarmupIterations; ++i) { - NvFlexUpdateSolver(g_flex, 0.0001f, 1, false); - NvFlexSetVelocities(g_flex, g_buffers->velocities.buffer, maxParticles); + NvFlexUpdateSolver(g_solver, 0.0001f, 1, false); + NvFlexSetVelocities(g_solver, g_buffers->velocities.buffer, NULL); } // udpate host copy - NvFlexGetParticles(g_flex, g_buffers->positions.buffer, g_buffers->positions.size()); - NvFlexGetSmoothParticles(g_flex, g_buffers->smoothPositions.buffer, g_buffers->smoothPositions.size()); - NvFlexGetAnisotropy(g_flex, g_buffers->anisotropy1.buffer, g_buffers->anisotropy2.buffer, g_buffers->anisotropy3.buffer); + NvFlexGetParticles(g_solver, g_buffers->positions.buffer, NULL); + NvFlexGetSmoothParticles(g_solver, g_buffers->smoothPositions.buffer, NULL); + NvFlexGetAnisotropy(g_solver, g_buffers->anisotropy1.buffer, g_buffers->anisotropy2.buffer, g_buffers->anisotropy3.buffer, NULL); printf("Finished warm up.\n"); } @@ -996,7 +1045,7 @@ void Shutdown() g_fields.clear(); g_meshes.clear(); - NvFlexDestroySolver(g_flex); + NvFlexDestroySolver(g_solver); NvFlexShutdown(g_flexLib); #if _WIN32 @@ -1019,7 +1068,7 @@ void UpdateEmitters() // process emitters if (g_emit) { - int activeCount = NvFlexGetActiveCount(g_flex); + int activeCount = NvFlexGetActiveCount(g_solver); size_t e = 0; @@ -1036,19 +1085,9 @@ void UpdateEmitters() Vec3 emitterRight = g_emitters[e].mRight; Vec3 emitterPos = g_emitters[e].mPos; - float r; - int phase; - if (g_params.fluid) - { - r = g_params.fluidRestDistance; - phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid); - } - else - { - r = g_params.solidRestDistance; - phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide); - } + float r = g_params.fluidRestDistance; + int phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid); float numParticles = (g_emitters[e].mSpeed / r)*g_dt; @@ -1124,7 +1163,7 @@ void UpdateMouse() Vec3 origin, dir; GetViewRay(g_lastx, g_screenHeight - g_lasty, origin, dir); - const int numActive = NvFlexGetActiveCount(g_flex); + const int numActive = NvFlexGetActiveCount(g_solver); g_mouseParticle = PickParticle(origin, dir, &g_buffers->positions[0], &g_buffers->phases[0], numActive, g_params.radius*0.8f, g_mouseT); @@ -1190,8 +1229,8 @@ void UpdateScene() void RenderScene() { - const int numParticles = NvFlexGetActiveCount(g_flex); - const int numDiffuse = NvFlexGetDiffuseParticles(g_flex, NULL, NULL, NULL); + const int numParticles = NvFlexGetActiveCount(g_solver); + const int numDiffuse = g_buffers->diffuseCount[0]; //--------------------------------------------------- // use VBO buffer wrappers to allow Flex to write directly to the OpenGL buffers @@ -1203,7 +1242,7 @@ void RenderScene() if (g_interop) { // copy data directly from solver to the renderer buffers - UpdateFluidRenderBuffers(g_fluidRenderBuffers, g_flex, g_drawEllipsoids, g_drawDensity); + UpdateFluidRenderBuffers(g_fluidRenderBuffers, g_solver, g_drawEllipsoids, g_drawDensity); } else { @@ -1235,13 +1274,16 @@ void RenderScene() } } } + + // GPU Render time doesn't include CPU->GPU copy time + GraphicsTimerBegin(); if (numDiffuse) { if (g_interop) { // copy data directly from solver to the renderer buffers - UpdateDiffuseRenderBuffers(g_diffuseRenderBuffers, g_flex); + UpdateDiffuseRenderBuffers(g_diffuseRenderBuffers, g_solver); } else { @@ -1249,7 +1291,6 @@ void RenderScene() UpdateDiffuseRenderBuffers(g_diffuseRenderBuffers, &g_buffers->diffusePositions[0], &g_buffers->diffuseVelocities[0], - &g_buffers->diffuseIndices[0], numDiffuse); } } @@ -1287,15 +1328,8 @@ void RenderScene() Matrix44 lightView = LookAtMatrix(Point3(g_lightPos), Point3(g_lightTarget)); Matrix44 lightTransform = lightPerspective*lightView; - // non-fluid particles maintain radius distance (not 2.0f*radius) so multiply by a half - float radius = g_params.solidRestDistance; - - // fluid particles overlap twice as much again, so half the radius again - if (g_params.fluid) - radius = g_params.fluidRestDistance; - - radius *= 0.5f; - radius *= g_pointScale; + // radius used for drawing + float radius = Max(g_params.solidRestDistance, g_params.fluidRestDistance)*0.5f*g_pointScale; //------------------------------------- // shadowing pass @@ -1335,7 +1369,7 @@ void RenderScene() { shadowParticles = 0; - if (g_drawEllipsoids && g_params.fluid) + if (g_drawEllipsoids) { shadowParticles = numParticles - g_numSolidParticles; shadowParticlesOffset = g_numSolidParticles; @@ -1350,7 +1384,7 @@ void RenderScene() } if (g_buffers->activeIndices.size()) - DrawPoints(g_fluidRenderBuffers.mPositionVBO, g_fluidRenderBuffers.mDensityVBO, g_fluidRenderBuffers.mIndices, shadowParticles, shadowParticlesOffset, radius, 2048, 1.0f, lightFov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_drawDensity); + DrawPoints(g_fluidRenderBuffers, shadowParticles, shadowParticlesOffset, radius, 2048, 1.0f, lightFov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_drawDensity); ShadowEnd(); @@ -1362,26 +1396,33 @@ void RenderScene() SetView(view, proj); SetCullMode(true); - DrawPlanes((Vec4*)g_params.planes, g_params.numPlanes, g_drawPlaneBias); + // When the benchmark measures async compute, we need a graphics workload that runs for a whole frame. + // We do this by rerendering our simple graphics many times. + int passes = g_increaseGfxLoadForAsyncComputeTesting ? 50 : 1; - if (g_drawMesh) - DrawMesh(g_mesh, g_meshColor); + for (int i = 0; i != passes; i++) + { + DrawPlanes((Vec4*)g_params.planes, g_params.numPlanes, g_drawPlaneBias); - DrawShapes(); + if (g_drawMesh) + DrawMesh(g_mesh, g_meshColor); - if (g_drawCloth && g_buffers->triangles.size()) - DrawCloth(&g_buffers->positions[0], &g_buffers->normals[0], g_buffers->uvs.size() ? &g_buffers->uvs[0].x : NULL, &g_buffers->triangles[0], g_buffers->triangles.size() / 3, g_buffers->positions.size(), 3, g_expandCloth); - if (g_drawRopes) - { - for (size_t i = 0; i < g_ropes.size(); ++i) - DrawRope(&g_buffers->positions[0], &g_ropes[i].mIndices[0], g_ropes[i].mIndices.size(), g_params.radius*0.5f*g_ropeScale, i); - } + DrawShapes(); - // give scene a chance to do custom drawing - g_scenes[g_scene]->Draw(0); + if (g_drawCloth && g_buffers->triangles.size()) + DrawCloth(&g_buffers->positions[0], &g_buffers->normals[0], g_buffers->uvs.size() ? &g_buffers->uvs[0].x : NULL, &g_buffers->triangles[0], g_buffers->triangles.size() / 3, g_buffers->positions.size(), 3, g_expandCloth); + + if (g_drawRopes) + { + for (size_t i = 0; i < g_ropes.size(); ++i) + DrawRope(&g_buffers->positions[0], &g_ropes[i].mIndices[0], g_ropes[i].mIndices.size(), g_params.radius*0.5f*g_ropeScale, i); + } + // give scene a chance to do custom drawing + g_scenes[g_scene]->Draw(0); + } UnbindSolidShader(); @@ -1389,11 +1430,11 @@ void RenderScene() if (g_drawDiffuse) RenderDiffuse(g_fluidRenderer, g_diffuseRenderBuffers, numDiffuse, radius*g_diffuseScale, float(g_screenWidth), aspect, fov, g_diffuseColor, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_diffuseMotionScale, g_diffuseInscatter, g_diffuseOutscatter, g_diffuseShadow, false); - if (g_drawEllipsoids && g_params.fluid) + if (g_drawEllipsoids) { // draw solid particles separately if (g_numSolidParticles && g_drawPoints) - DrawPoints(g_fluidRenderBuffers.mPositionVBO, g_fluidRenderBuffers.mDensityVBO, g_fluidRenderBuffers.mIndices, g_numSolidParticles, 0, radius, float(g_screenWidth), aspect, fov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_drawDensity); + DrawPoints(g_fluidRenderBuffers, g_numSolidParticles, 0, radius, float(g_screenWidth), aspect, fov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_drawDensity); // render fluid surface RenderEllipsoids(g_fluidRenderer, g_fluidRenderBuffers, numParticles - g_numSolidParticles, g_numSolidParticles, radius, float(g_screenWidth), aspect, fov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_fluidColor, g_blur, g_ior, g_drawOpaque); @@ -1410,10 +1451,11 @@ void RenderScene() int offset = g_drawMesh ? g_numSolidParticles : 0; if (g_buffers->activeIndices.size()) - DrawPoints(g_fluidRenderBuffers.mPositionVBO, g_fluidRenderBuffers.mDensityVBO, g_fluidRenderBuffers.mIndices, numParticles - offset, offset, radius, float(g_screenWidth), aspect, fov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_drawDensity); + DrawPoints(g_fluidRenderBuffers, numParticles - offset, offset, radius, float(g_screenWidth), aspect, fov, g_lightPos, g_lightTarget, lightTransform, g_shadowMap, g_drawDensity); } } + GraphicsTimerEnd(); } void RenderDebug() @@ -1472,7 +1514,7 @@ void RenderDebug() NvFlexVector contactIndices(g_flexLib, g_buffers->positions.size()); NvFlexVector contactCounts(g_flexLib, g_buffers->positions.size()); - NvFlexGetContacts(g_flex, contactPlanes.buffer, contactVelocities.buffer, contactIndices.buffer, contactCounts.buffer); + NvFlexGetContacts(g_solver, contactPlanes.buffer, contactVelocities.buffer, contactIndices.buffer, contactCounts.buffer); // ensure transfers have finished contactPlanes.map(); @@ -1528,7 +1570,7 @@ void RenderDebug() if (g_drawNormals) { - NvFlexGetNormals(g_flex, g_buffers->normals.buffer, g_buffers->normals.size()); + NvFlexGetNormals(g_solver, g_buffers->normals.buffer, NULL); BeginLines(); @@ -1655,8 +1697,8 @@ int DoUI() if (g_showHelp) { - const int numParticles = NvFlexGetActiveCount(g_flex); - const int numDiffuse = NvFlexGetDiffuseParticles(g_flex, NULL, NULL, NULL); + const int numParticles = NvFlexGetActiveCount(g_solver); + const int numDiffuse = g_buffers->diffuseCount[0]; int x = g_screenWidth - 200; int y = g_screenHeight - 23; @@ -1687,6 +1729,8 @@ int DoUI() { DrawImguiString(x, y, Vec3(1.0f), IMGUI_ALIGN_RIGHT, "Sim Time (CPU): %.2fms", g_updateTime*1000.0f); y -= fontHeight; DrawImguiString(x, y, Vec3(0.97f, 0.59f, 0.27f), IMGUI_ALIGN_RIGHT, "Sim Latency (GPU): %.2fms", g_simLatency); y -= fontHeight * 2; + + BenchmarkUpdateGraph(); } else { @@ -1750,7 +1794,7 @@ int DoUI() for (int i = 0; i < int(g_scenes.size()); ++i) { unsigned int color = g_scene == i ? imguiRGBA(255, 151, 61, 255) : imguiRGBA(255, 255, 255, 200); - if (imguiItem(g_scenes[i]->GetName(), true, color, i == g_selectedScene)) + if (imguiItem(g_scenes[i]->GetName(), true, color)) // , i == g_selectedScene)) { newScene = i; } @@ -1842,11 +1886,6 @@ int DoUI() imguiSlider("Collision Distance", &g_params.collisionDistance, 0.0f, 0.5f, 0.001f); imguiSlider("Collision Margin", &g_params.shapeCollisionMargin, 0.0f, 5.0f, 0.01f); - // rigid params - imguiSeparatorLine(); - imguiSlider("Plastic Creep", &g_params.plasticCreep, 0.0f, 1.0f, 0.001f); - imguiSlider("Plastic Threshold", &g_params.plasticThreshold, 0.0f, 0.5f, 0.001f); - // cloth params imguiSeparatorLine(); imguiSlider("Wind", &g_windStrength, -1.0f, 1.0f, 0.01f); @@ -1855,9 +1894,6 @@ int DoUI() imguiSeparatorLine(); // fluid params - if (imguiCheck("Fluid", g_params.fluid)) - g_params.fluid = !g_params.fluid; - imguiSlider("Adhesion", &g_params.adhesion, 0.0f, 10.0f, 0.01f); imguiSlider("Cohesion", &g_params.cohesion, 0.0f, 0.2f, 0.0001f); imguiSlider("Surface Tension", &g_params.surfaceTension, 0.0f, 50.0f, 0.01f); @@ -1891,13 +1927,9 @@ int DoUI() imguiEndFrame(); // kick render commands - imguiGraphDraw(); + DrawImguiGraph(); } - // update benchmark and change scene if one is requested - if (g_benchmark) - newScene = BenchmarkUpdate(); - return newScene; } @@ -2003,6 +2035,11 @@ void UpdateFrame() double waitEndTime = GetSeconds(); + // Getting timers causes CPU/GPU sync, so we do it after a map + float newSimLatency = NvFlexGetDeviceLatency(g_solver, &g_GpuTimers.computeBegin, &g_GpuTimers.computeEnd, &g_GpuTimers.computeFreq); + float newGfxLatency = RendererGetDeviceTimestamps(&g_GpuTimers.renderBegin, &g_GpuTimers.renderEnd,&g_GpuTimers.renderFreq); + (void)newGfxLatency; + UpdateCamera(); if (!g_pause || g_step) @@ -2018,27 +2055,33 @@ void UpdateFrame() double renderBeginTime = GetSeconds(); - if (g_profile && (!g_pause || g_step)) { - if (g_benchmark) { - g_numDetailTimers = NvFlexGetDetailTimers(g_flex, &g_detailTimers); + if (g_profile && (!g_pause || g_step)) + { + if (g_benchmark) + { + g_numDetailTimers = NvFlexGetDetailTimers(g_solver, &g_detailTimers); } - else { + else + { memset(&g_timers, 0, sizeof(g_timers)); - NvFlexGetTimers(g_flex, &g_timers); + NvFlexGetTimers(g_solver, &g_timers); } } - float newSimLatency = NvFlexGetDeviceLatency(g_flex); - StartFrame(Vec4(g_clearColor, 1.0f)); // main scene render RenderScene(); RenderDebug(); + int newScene = DoUI(); + EndFrame(); - const int newScene = DoUI(); + // If user has disabled async compute, ensure that no compute can overlap + // graphics by placing a sync between them + if (!g_useAsyncCompute) + NvFlexComputeWaitForGraphics(g_flexLib); UnmapBuffers(g_buffers); @@ -2074,26 +2117,18 @@ void UpdateFrame() g_resetScene = false; } - // if gui requested a scene change process it now - if (newScene != -1) - { - g_scene = newScene; - Init(g_scene); - return; - } - - - //------------------------------------------------------------------- // Flex Update double updateBeginTime = GetSeconds(); // send any particle updates to the solver - NvFlexSetParticles(g_flex, g_buffers->positions.buffer, g_buffers->positions.size()); - NvFlexSetVelocities(g_flex, g_buffers->velocities.buffer, g_buffers->velocities.size()); - NvFlexSetPhases(g_flex, g_buffers->phases.buffer, g_buffers->phases.size()); - NvFlexSetActive(g_flex, g_buffers->activeIndices.buffer, g_buffers->activeIndices.size()); + NvFlexSetParticles(g_solver, g_buffers->positions.buffer, NULL); + NvFlexSetVelocities(g_solver, g_buffers->velocities.buffer, NULL); + NvFlexSetPhases(g_solver, g_buffers->phases.buffer, NULL); + NvFlexSetActive(g_solver, g_buffers->activeIndices.buffer, NULL); + + NvFlexSetActiveCount(g_solver, g_buffers->activeIndices.size()); // allow scene to update constraints etc SyncScene(); @@ -2101,7 +2136,7 @@ void UpdateFrame() if (g_shapesChanged) { NvFlexSetShapes( - g_flex, + g_solver, g_buffers->shapeGeometry.buffer, g_buffers->shapePositions.buffer, g_buffers->shapeRotations.buffer, @@ -2116,8 +2151,8 @@ void UpdateFrame() if (!g_pause || g_step) { // tick solver - NvFlexSetParams(g_flex, &g_params); - NvFlexUpdateSolver(g_flex, g_dt, g_numSubsteps, g_profile); + NvFlexSetParams(g_solver, &g_params); + NvFlexUpdateSolver(g_solver, g_dt, g_numSubsteps, g_profile); g_frame++; g_step = false; @@ -2128,36 +2163,42 @@ void UpdateFrame() // to be executed later. // When we're ready to read the fetched buffers we'll Map them, and that's when // the CPU will wait for the GPU flex update and GPU copy to finish. - NvFlexGetParticles(g_flex, g_buffers->positions.buffer, g_buffers->positions.size()); - NvFlexGetVelocities(g_flex, g_buffers->velocities.buffer, g_buffers->velocities.size()); - NvFlexGetNormals(g_flex, g_buffers->normals.buffer, g_buffers->normals.size()); + NvFlexGetParticles(g_solver, g_buffers->positions.buffer, NULL); + NvFlexGetVelocities(g_solver, g_buffers->velocities.buffer, NULL); + NvFlexGetNormals(g_solver, g_buffers->normals.buffer, NULL); // readback triangle normals if (g_buffers->triangles.size()) - NvFlexGetDynamicTriangles(g_flex, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); + NvFlexGetDynamicTriangles(g_solver, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); // readback rigid transforms if (g_buffers->rigidOffsets.size()) - NvFlexGetRigidTransforms(g_flex, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer); + NvFlexGetRigids(g_solver, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer); if (!g_interop) { // if not using interop then we read back fluid data to host if (g_drawEllipsoids) { - NvFlexGetSmoothParticles(g_flex, g_buffers->smoothPositions.buffer, g_buffers->smoothPositions.size()); - NvFlexGetAnisotropy(g_flex, g_buffers->anisotropy1.buffer, g_buffers->anisotropy2.buffer, g_buffers->anisotropy3.buffer); + NvFlexGetSmoothParticles(g_solver, g_buffers->smoothPositions.buffer, NULL); + NvFlexGetAnisotropy(g_solver, g_buffers->anisotropy1.buffer, g_buffers->anisotropy2.buffer, g_buffers->anisotropy3.buffer, NULL); } // read back diffuse data to host if (g_drawDensity) - NvFlexGetDensities(g_flex, g_buffers->densities.buffer, g_buffers->positions.size()); + NvFlexGetDensities(g_solver, g_buffers->densities.buffer, NULL); - if (g_diffuseRenderBuffers.mNumDiffuseParticles) + if (GetNumDiffuseRenderParticles(g_diffuseRenderBuffers)) { - NvFlexGetDiffuseParticles(g_flex, g_buffers->diffusePositions.buffer, g_buffers->diffuseVelocities.buffer, g_buffers->diffuseIndices.buffer); + NvFlexGetDiffuseParticles(g_solver, g_buffers->diffusePositions.buffer, g_buffers->diffuseVelocities.buffer, g_buffers->diffuseCount.buffer); } } + else + { + // read back just the new diffuse particle count, render buffers will be updated during rendering + NvFlexGetDiffuseParticles(g_solver, NULL, NULL, g_buffers->diffuseCount.buffer); + } + double updateEndTime = GetSeconds(); @@ -2176,6 +2217,15 @@ void UpdateFrame() g_waitTime = (g_waitTime == 0.0f) ? newWaitTime : Lerp(g_waitTime, newWaitTime, timerSmoothing); g_simLatency = (g_simLatency == 0.0f) ? newSimLatency : Lerp(g_simLatency, newSimLatency, timerSmoothing); + if(g_benchmark) newScene = BenchmarkUpdate(); + + // if gui or benchmark requested a scene change process it now + if (newScene != -1) + { + g_scene = newScene; + Init(g_scene); + } + PresentFrame(g_vsync); } @@ -2548,10 +2598,10 @@ void MouseMotionFunc(unsigned state, int x, int y) bool g_Error = false; -void ErrorCallback(NvFlexErrorSeverity, const char* msg, const char* file, int line) +void ErrorCallback(NvFlexErrorSeverity severity, const char* msg, const char* file, int line) { printf("Flex: %s - %s:%d\n", msg, file, line); - g_Error = true; + g_Error = (severity == eNvFlexLogError); //assert(0); asserts are bad for TeamCity } @@ -2606,9 +2656,14 @@ void SDLInit(const char* title) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0) // Initialize SDL's Video subsystem and game controllers printf("Unable to initialize SDL"); - // Create our window centered +#if FLEX_DX + unsigned int flags = SDL_WINDOW_RESIZABLE; +#else + unsigned int flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL; +#endif + g_window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - g_screenWidth, g_screenHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + g_screenWidth, g_screenHeight, flags); g_windowId = SDL_GetWindowID(g_window); } @@ -2692,17 +2747,32 @@ int main(int argc, char* argv[]) if (sscanf(argv[i], "-extensions=%d", &d)) g_extensions = d != 0; - if (strstr(argv[i], "-benchmark")) + if (strcmp(argv[i], "-benchmark") == 0) { g_benchmark = true; g_profile = true; + g_outputAllFrameTimes = false; + g_vsync = false; + g_fullscreen = true; } - if (strstr(argv[i], "-d3d12")) + if (strcmp(argv[i], "-d3d12") == 0) + { g_d3d12 = true; + // Currently interop doesn't work on d3d12 + g_interop = false; + } + + if (strcmp(argv[i], "-benchmarkAllFrameTimes") == 0) + { + g_benchmark = true; + g_outputAllFrameTimes = true; + } - if (strstr(argv[i], "-tc")) + if (strcmp(argv[i], "-tc") == 0) + { g_teamCity = true; + } if (sscanf(argv[i], "-msaa=%d", &d)) g_msaaSamples = d; @@ -2715,13 +2785,26 @@ int main(int argc, char* argv[]) g_screenHeight = h; g_fullscreen = true; } - else if (strstr(argv[i], "-fullscreen")) + else if (strcmp(argv[i], "-fullscreen") == 0) { g_screenWidth = w; g_screenHeight = h; g_fullscreen = true; } + if (sscanf(argv[i], "-windowed=%dx%d", &w, &h) == 2) + { + g_screenWidth = w; + g_screenHeight = h; + g_fullscreen = false; + } + else if (strstr(argv[i], "-windowed")) + { + g_screenWidth = w; + g_screenHeight = h; + g_fullscreen = false; + } + if (sscanf(argv[i], "-vsync=%d", &d)) g_vsync = d != 0; @@ -2730,100 +2813,174 @@ int main(int argc, char* argv[]) g_numExtraMultiplier = d; } - if (strstr(argv[i], "-disabletweak")) + if (strcmp(argv[i], "-disabletweak") == 0) { g_tweakPanel = false; } - if (strstr(argv[i], "-disableinterop")) + if (strcmp(argv[i], "-disableinterop") == 0) { g_interop = false; } + if (sscanf(argv[i], "-asynccompute=%d", &d) == 1) + { + g_useAsyncCompute = (d != 0); + } } // opening scene g_scenes.push_back(new PotPourri("Pot Pourri")); - // soft body scenes - SoftBody* softOctopus = new SoftBody("Soft Octopus", "../../data/softs/octopus.obj"); - softOctopus->mScale = Vec3(32.0f); - softOctopus->mClusterSpacing = 2.75f; - softOctopus->mClusterRadius = 3.0f; - softOctopus->mClusterStiffness = 0.15f; - softOctopus->mSurfaceSampling = 1.0f; - softOctopus->mStack[1] = 3; - - SoftBody* softRope = new SoftBody("Soft Rope", "../../data/rope.obj"); - softRope->mScale = Vec3(50.0f); - softRope->mClusterSpacing = 1.5f; - softRope->mClusterRadius = 0.0f; - softRope->mClusterStiffness = 0.55f; - - SoftBody* softBowl = new SoftBody("Soft Bowl", "../../data/bowl_high.ply"); - softBowl->mScale = Vec3(10.0f); - softBowl->mClusterSpacing = 2.0f; - softBowl->mClusterRadius = 2.0f; - softBowl->mClusterStiffness = 0.55f; - - SoftBody* softCloth = new SoftBody("Soft Cloth", "../../data/box_ultra_high.ply"); - softCloth->mScale = Vec3(20.0f, 0.2f, 20.0f); - softCloth->mRadius = 0.05f; - softCloth->mClusterSpacing = 1.0f; - softCloth->mClusterRadius = 2.0f; - softCloth->mClusterStiffness = 0.2f; - softCloth->mLinkRadius = 2.0f; - softCloth->mLinkStiffness = 1.0f; - softCloth->mSkinningFalloff = 1.0f; - softCloth->mSkinningMaxDistance = 100.f; - - SoftBodyFixed* softRod = new SoftBodyFixed("Soft Rod", "../../data/box_very_high.ply"); - softRod->mScale = Vec3(20.0f, 2.0f, 2.0f); - softRod->mOffset = Vec3(-0.3f, 1.0f, 0.0f); - softRod->mClusterSpacing = 2.0f; - softRod->mClusterRadius = 2.0f; - softRod->mClusterStiffness = 0.225f; - softRod->mStack[2] = 3; - - SoftBody* softTeapot = new SoftBody("Soft Teapot", "../../data/teapot.ply"); - softTeapot->mScale = Vec3(25.0f); - softTeapot->mClusterSpacing = 3.0f; - softTeapot->mClusterRadius = 0.0f; - softTeapot->mClusterStiffness = 0.1f; - - SoftBody* softArmadillo = new SoftBody("Soft Armadillo", "../../data/armadillo.ply"); - softArmadillo->mScale = Vec3(25.0f); - softArmadillo->mClusterSpacing = 3.0f; - softArmadillo->mClusterRadius = 0.0f; - - SoftBody* softBunny = new SoftBody("Soft Bunny", "../../data/bunny.ply"); - softBunny->mScale = Vec3(20.0f); - softBunny->mClusterSpacing = 3.5f; - softBunny->mClusterRadius = 0.0f; - softBunny->mClusterStiffness = 0.2f; - - SoftBody* plasticBunnies = new SoftBody("Plastic Bunnies", "../../data/bunny.ply"); - plasticBunnies->mScale = Vec3(10.0f); - plasticBunnies->mClusterSpacing = 1.0f; - plasticBunnies->mClusterRadius = 0.0f; - plasticBunnies->mClusterStiffness = 0.0f; - plasticBunnies->mGlobalStiffness = 1.0f; - plasticBunnies->mPlasticThreshold = 0.0015f; - plasticBunnies->mPlasticCreep = 0.15f; - plasticBunnies->mRelaxationFactor = 1.0f; - plasticBunnies->mOffset[1] = 5.0f; - plasticBunnies->mStack[1] = 10; - plasticBunnies->mPlinth = true; - - g_scenes.push_back(softOctopus); - g_scenes.push_back(softTeapot); - g_scenes.push_back(softRope); - g_scenes.push_back(softCloth); - g_scenes.push_back(softBowl); - g_scenes.push_back(softRod); - g_scenes.push_back(softArmadillo); - g_scenes.push_back(softBunny); - g_scenes.push_back(plasticBunnies); + SoftBody::Instance octopus("../../data/softs/octopus.obj"); + octopus.mScale = Vec3(32.0f); + octopus.mClusterSpacing = 2.75f; + octopus.mClusterRadius = 3.0f; + octopus.mClusterStiffness = 0.15f; + octopus.mSurfaceSampling = 1.0f; + SoftBody* softOctopusSceneNew = new SoftBody("Soft Octopus"); + softOctopusSceneNew->AddStack(octopus, 1, 3, 1); + + SoftBody::Instance rope("../../data/rope.obj"); + rope.mScale = Vec3(50.0f); + rope.mClusterSpacing = 1.5f; + rope.mClusterRadius = 0.0f; + rope.mClusterStiffness = 0.55f; + SoftBody* softRopeSceneNew = new SoftBody("Soft Rope"); + softRopeSceneNew->AddInstance(rope); + + SoftBody::Instance bowl("../../data/bowl_high.ply"); + bowl.mScale = Vec3(10.0f); + bowl.mClusterSpacing = 2.0f; + bowl.mClusterRadius = 2.0f; + bowl.mClusterStiffness = 0.55f; + SoftBody* softBowlSceneNew = new SoftBody("Soft Bowl"); + softBowlSceneNew->AddInstance(bowl); + + SoftBody::Instance cloth("../../data/box_ultra_high.ply"); + cloth.mScale = Vec3(20.0f, 0.2f, 20.0f); + cloth.mClusterSpacing = 1.0f; + cloth.mClusterRadius = 2.0f; + cloth.mClusterStiffness = 0.2f; + cloth.mLinkRadius = 2.0f; + cloth.mLinkStiffness = 1.0f; + cloth.mSkinningFalloff = 1.0f; + cloth.mSkinningMaxDistance = 100.f; + SoftBody* softClothSceneNew = new SoftBody("Soft Cloth"); + softClothSceneNew->mRadius = 0.05f; + softClothSceneNew->AddInstance(cloth); + + SoftBody::Instance rod("../../data/box_very_high.ply"); + rod.mScale = Vec3(20.0f, 2.0f, 2.0f); + rod.mTranslation = Vec3(-0.3f, 1.0f, 0.0f); + rod.mClusterSpacing = 2.0f; + rod.mClusterRadius = 2.0f; + rod.mClusterStiffness = 0.225f; + SoftBodyFixed* softRodSceneNew = new SoftBodyFixed("Soft Rod"); + softRodSceneNew->AddStack(rod, 3); + + SoftBody::Instance teapot("../../data/teapot.ply"); + teapot.mScale = Vec3(25.0f); + teapot.mClusterSpacing = 3.0f; + teapot.mClusterRadius = 0.0f; + teapot.mClusterStiffness = 0.1f; + SoftBody* softTeapotSceneNew = new SoftBody("Soft Teapot"); + softTeapotSceneNew->AddInstance(teapot); + + SoftBody::Instance armadillo("../../data/armadillo.ply"); + armadillo.mScale = Vec3(25.0f); + armadillo.mClusterSpacing = 3.0f; + armadillo.mClusterRadius = 0.0f; + SoftBody* softArmadilloSceneNew = new SoftBody("Soft Armadillo"); + softArmadilloSceneNew->AddInstance(armadillo); + + SoftBody::Instance softbunny("../../data/bunny.ply"); + softbunny.mScale = Vec3(20.0f); + softbunny.mClusterSpacing = 3.5f; + softbunny.mClusterRadius = 0.0f; + softbunny.mClusterStiffness = 0.2f; + SoftBody* softBunnySceneNew = new SoftBody("Soft Bunny"); + softBunnySceneNew->AddInstance(softbunny); + + // plastic scenes + SoftBody::Instance plasticbunny("../../data/bunny.ply"); + plasticbunny.mScale = Vec3(10.0f); + plasticbunny.mClusterSpacing = 1.0f; + plasticbunny.mClusterRadius = 0.0f; + plasticbunny.mClusterStiffness = 0.0f; + plasticbunny.mGlobalStiffness = 1.0f; + plasticbunny.mClusterPlasticThreshold = 0.0015f; + plasticbunny.mClusterPlasticCreep = 0.15f; + plasticbunny.mTranslation[1] = 5.0f; + SoftBody* plasticBunniesSceneNew = new SoftBody("Plastic Bunnies"); + plasticBunniesSceneNew->mPlinth = true; + plasticBunniesSceneNew->AddStack(plasticbunny, 1, 10, 1, true); + + SoftBody::Instance bunny1("../../data/bunny.ply"); + bunny1.mScale = Vec3(10.0f); + bunny1.mClusterSpacing = 1.0f; + bunny1.mClusterRadius = 0.0f; + bunny1.mClusterStiffness = 0.0f; + bunny1.mGlobalStiffness = 1.0f; + bunny1.mClusterPlasticThreshold = 0.0015f; + bunny1.mClusterPlasticCreep = 0.15f; + bunny1.mTranslation[1] = 5.0f; + SoftBody::Instance bunny2("../../data/bunny.ply"); + bunny2.mScale = Vec3(10.0f); + bunny2.mClusterSpacing = 1.0f; + bunny2.mClusterRadius = 0.0f; + bunny2.mClusterStiffness = 0.0f; + bunny2.mGlobalStiffness = 1.0f; + bunny2.mClusterPlasticThreshold = 0.0015f; + bunny2.mClusterPlasticCreep = 0.30f; + bunny2.mTranslation[1] = 5.0f; + bunny2.mTranslation[0] = 2.0f; + SoftBody* plasticComparisonScene = new SoftBody("Plastic Comparison"); + plasticComparisonScene->AddInstance(bunny1); + plasticComparisonScene->AddInstance(bunny2); + plasticComparisonScene->mPlinth = true; + + SoftBody::Instance stackBox("../../data/box_high.ply"); + stackBox.mScale = Vec3(10.0f); + stackBox.mClusterSpacing = 1.5f; + stackBox.mClusterRadius = 0.0f; + stackBox.mClusterStiffness = 0.0f; + stackBox.mGlobalStiffness = 1.0f; + stackBox.mClusterPlasticThreshold = 0.0015f; + stackBox.mClusterPlasticCreep = 0.25f; + stackBox.mTranslation[1] = 1.0f; + SoftBody::Instance stackSphere("../../data/sphere.ply"); + stackSphere.mScale = Vec3(10.0f); + stackSphere.mClusterSpacing = 1.5f; + stackSphere.mClusterRadius = 0.0f; + stackSphere.mClusterStiffness = 0.0f; + stackSphere.mGlobalStiffness = 1.0f; + stackSphere.mClusterPlasticThreshold = 0.0015f; + stackSphere.mClusterPlasticCreep = 0.25f; + stackSphere.mTranslation[1] = 2.0f; + SoftBody* plasticStackScene = new SoftBody("Plastic Stack"); + plasticStackScene->AddInstance(stackBox); + plasticStackScene->AddInstance(stackSphere); + for (int i = 0; i < 3; i++) { + stackBox.mTranslation[1] += 2.0f; + stackSphere.mTranslation[1] += 2.0f; + plasticStackScene->AddInstance(stackBox); + plasticStackScene->AddInstance(stackSphere); + } + + + g_scenes.push_back(softOctopusSceneNew); + g_scenes.push_back(softTeapotSceneNew); + g_scenes.push_back(softRopeSceneNew); + g_scenes.push_back(softClothSceneNew); + g_scenes.push_back(softBowlSceneNew); + g_scenes.push_back(softRodSceneNew); + g_scenes.push_back(softArmadilloSceneNew); + g_scenes.push_back(softBunnySceneNew); + + g_scenes.push_back(plasticBunniesSceneNew); + g_scenes.push_back(plasticComparisonScene); + g_scenes.push_back(plasticStackScene); // collision scenes @@ -2832,6 +2989,7 @@ int main(int argc, char* argv[]) g_scenes.push_back(new FrictionMovingShape("Friction Moving Sphere", 1)); g_scenes.push_back(new FrictionMovingShape("Friction Moving Capsule", 2)); g_scenes.push_back(new ShapeCollision("Shape Collision")); + g_scenes.push_back(new ShapeChannels("Shape Channels")); g_scenes.push_back(new TriangleCollision("Triangle Collision")); g_scenes.push_back(new LocalSpaceFluid("Local Space Fluid")); g_scenes.push_back(new LocalSpaceCloth("Local Space Cloth")); @@ -2886,7 +3044,6 @@ int main(int argc, char* argv[]) g_scenes.push_back(new RigidPile("Rigid8", 12)); g_scenes.push_back(new BananaPile("Bananas")); g_scenes.push_back(new LowDimensionalShapes("Low Dimensional Shapes")); - g_scenes.push_back(new PlasticStack("Plastic Stack")); // granular scenes g_scenes.push_back(new GranularPile("Granular Pile")); @@ -2911,7 +3068,34 @@ int main(int argc, char* argv[]) SDLInit(title); - InitRender(g_window, g_fullscreen, g_msaaSamples); + RenderInitOptions options; + options.window = g_window; + options.numMsaaSamples = g_msaaSamples; + options.asyncComputeBenchmark = g_asyncComputeBenchmark; + options.defaultFontHeight = -1; + options.fullscreen = g_fullscreen; + +#if FLEX_DX + { + DemoContext* demoContext = nullptr; + + if (g_d3d12) + { + // workaround for a driver issue with D3D12 with msaa, force it to off + options.numMsaaSamples = 1; + + demoContext = CreateDemoContextD3D12(); + } + else + { + demoContext = CreateDemoContextD3D11(); + } + // Set the demo context + SetDemoContext(demoContext); + } +#endif + + InitRender(options); if (g_fullscreen) SDL_SetWindowFullscreen(g_window, SDL_WINDOW_FULLSCREEN_DESKTOP); @@ -2922,16 +3106,16 @@ int main(int argc, char* argv[]) #if !FLEX_DX - // use the PhysX GPU selected from the NVIDIA control panel + // use the PhysX GPU selected from the NVIDIA control panel if (g_device == -1) g_device = NvFlexDeviceGetSuggestedOrdinal(); - + // Create an optimized CUDA context for Flex and set it on the // calling thread. This is an optional call, it is fine to use // a regular CUDA context, although creating one through this API // is recommended for best performance. bool success = NvFlexDeviceCreateCudaContext(g_device); - + if (!success) { printf("Error creating CUDA context.\n"); @@ -2945,6 +3129,7 @@ int main(int argc, char* argv[]) desc.enableExtensions = g_extensions; desc.renderDevice = 0; desc.renderContext = 0; + desc.computeContext = 0; desc.computeType = eNvFlexCUDA; #if FLEX_DX @@ -2954,18 +3139,36 @@ int main(int argc, char* argv[]) else desc.computeType = eNvFlexD3D11; - if (g_device == -1 && !g_d3d12) + bool userSpecifiedGpuToUseForFlex = (g_device != -1); + + if (userSpecifiedGpuToUseForFlex) { - // use the renderer device - GetRenderDevice((ID3D11Device**)&desc.renderDevice, - (ID3D11DeviceContext**)&desc.renderContext); - } + // Flex doesn't currently support interop between different D3DDevices. + // If the user specifies which physical device to use, then Flex always + // creates its own D3DDevice, even if graphics is on the same physical device. + // So specified physical device always means no interop. + g_interop = false; + } else { - // disable shared resources - g_interop = false; + // Ask Flex to run on the same GPU as rendering + GetRenderDevice(&desc.renderDevice, + &desc.renderContext); } + // Shared resources are unimplemented on D3D12, + // so disable it for now. + if (g_d3d12) + g_interop = false; + + // Setting runOnRenderContext = true doesn't prevent async compute, it just + // makes Flex send compute and graphics to the GPU on the same queue. + // + // So to allow the user to toggle async compute, we set runOnRenderContext = false + // and provide a toggleable sync between compute and graphics in the app. + // + // Search for g_useAsyncCompute for details + desc.runOnRenderContext = false; #endif // Init Flex library, note that no CUDA methods should be called before this @@ -2983,14 +3186,15 @@ int main(int argc, char* argv[]) printf("Compute Device: %s\n\n", g_deviceName); if (g_benchmark) - BenchmarkInit(); - + g_scene = BenchmarkInit(); // create shadow maps g_shadowMap = ShadowCreate(); // init default scene + StartGpuWork(); Init(g_scene); + EndGpuWork(); SDLMainLoop(); @@ -3001,9 +3205,9 @@ int main(int argc, char* argv[]) DestroyDiffuseRenderBuffers(g_diffuseRenderBuffers); ShadowDestroy(g_shadowMap); - DestroyRender(); - + Shutdown(); + DestroyRender(); SDL_DestroyWindow(g_window); SDL_Quit(); diff --git a/demo/opengl/shadersGL.cpp b/demo/opengl/shadersGL.cpp index b4023db..1005be2 100644 --- a/demo/opengl/shadersGL.cpp +++ b/demo/opengl/shadersGL.cpp @@ -46,6 +46,93 @@ #define CudaCheck(x) { cudaError_t err = x; if (err != cudaSuccess) { printf("Cuda error: %d in %s at %s:%d\n", err, #x, __FILE__, __LINE__); assert(0); } } +typedef unsigned int VertexBuffer; +typedef unsigned int IndexBuffer; +typedef unsigned int Texture; + +struct FluidRenderBuffersGL +{ + FluidRenderBuffersGL(int numParticles = 0): + mPositionVBO(0), + mDensityVBO(0), + mIndices(0), + mPositionBuf(nullptr), + mDensitiesBuf(nullptr), + mIndicesBuf(nullptr) + { + mNumParticles = numParticles; + for (int i = 0; i < 3; i++) + { + mAnisotropyVBO[i] = 0; + mAnisotropyBuf[i] = nullptr; + } + } + ~FluidRenderBuffersGL() + { + glDeleteBuffers(1, &mPositionVBO); + glDeleteBuffers(3, mAnisotropyVBO); + glDeleteBuffers(1, &mDensityVBO); + glDeleteBuffers(1, &mIndices); + + NvFlexUnregisterOGLBuffer(mPositionBuf); + NvFlexUnregisterOGLBuffer(mDensitiesBuf); + NvFlexUnregisterOGLBuffer(mIndicesBuf); + + NvFlexUnregisterOGLBuffer(mAnisotropyBuf[0]); + NvFlexUnregisterOGLBuffer(mAnisotropyBuf[1]); + NvFlexUnregisterOGLBuffer(mAnisotropyBuf[2]); + } + + int mNumParticles; + VertexBuffer mPositionVBO; + VertexBuffer mDensityVBO; + VertexBuffer mAnisotropyVBO[3]; + IndexBuffer mIndices; + + // wrapper buffers that allow Flex to write directly to VBOs + NvFlexBuffer* mPositionBuf; + NvFlexBuffer* mDensitiesBuf; + NvFlexBuffer* mAnisotropyBuf[3]; + NvFlexBuffer* mIndicesBuf; +}; + +// vertex buffers for diffuse particles +struct DiffuseRenderBuffersGL +{ + DiffuseRenderBuffersGL(int numParticles = 0): + mDiffusePositionVBO(0), + mDiffuseVelocityVBO(0), + mDiffuseIndicesIBO(0), + mDiffuseIndicesBuf(nullptr), + mDiffusePositionsBuf(nullptr), + mDiffuseVelocitiesBuf(nullptr) + { + mNumParticles = numParticles; + } + ~DiffuseRenderBuffersGL() + { + if (mNumParticles > 0) + { + glDeleteBuffers(1, &mDiffusePositionVBO); + glDeleteBuffers(1, &mDiffuseVelocityVBO); + glDeleteBuffers(1, &mDiffuseIndicesIBO); + + NvFlexUnregisterOGLBuffer(mDiffuseIndicesBuf); + NvFlexUnregisterOGLBuffer(mDiffusePositionsBuf); + NvFlexUnregisterOGLBuffer(mDiffuseVelocitiesBuf); + } + } + + int mNumParticles; + VertexBuffer mDiffusePositionVBO; + VertexBuffer mDiffuseVelocityVBO; + IndexBuffer mDiffuseIndicesIBO; + + NvFlexBuffer* mDiffuseIndicesBuf; + NvFlexBuffer* mDiffusePositionsBuf; + NvFlexBuffer* mDiffuseVelocitiesBuf; +}; + namespace { @@ -59,24 +146,13 @@ int g_screenHeight; SDL_Window* g_window; -static float gSpotMin = 0.5f; -static float gSpotMax = 1.0f; -float gShadowBias = 0.05f; +static float g_spotMin = 0.5f; +static float g_spotMax = 1.0f; +float g_shadowBias = 0.05f; } // anonymous namespace -Colour gColors[] = -{ - Colour(0.0f, 0.5f, 1.0f), - Colour(0.797f, 0.354f, 0.000f), - Colour(0.092f, 0.465f, 0.820f), - Colour(0.000f, 0.349f, 0.173f), - Colour(0.875f, 0.782f, 0.051f), - Colour(0.000f, 0.170f, 0.453f), - Colour(0.673f, 0.111f, 0.000f), - Colour(0.612f, 0.194f, 0.394f) -}; - +extern Colour g_colors[]; struct ShadowMap { @@ -85,8 +161,11 @@ struct ShadowMap }; -void InitRender(SDL_Window* window, bool fullscreen, int msaaSamples) +void InitRender(const RenderInitOptions& options) { + SDL_Window* window = options.window; + int msaaSamples = options.numMsaaSamples; + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); @@ -625,7 +704,7 @@ void ShadowApply(GLint sprogram, Vec3 lightPos, Vec3 lightTarget, Matrix44 light glUniform3fv(uLightDir, 1, Normalize(lightTarget-lightPos)); GLint uBias = glGetUniformLocation(sprogram, "bias"); - glUniform1f(uBias, gShadowBias); + glUniform1f(uBias, g_shadowBias); const Vec2 taps[] = { @@ -646,8 +725,13 @@ void ShadowApply(GLint sprogram, Vec3 lightPos, Vec3 lightTarget, Matrix44 light } -void DrawPoints(GLuint positions, GLuint colors, GLuint indices, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, bool showDensity) +void DrawPoints(FluidRenderBuffers* buffersIn, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, bool showDensity) { + FluidRenderBuffersGL* buffers = reinterpret_cast(buffersIn); + GLuint positions = buffers->mPositionVBO; + GLuint colors = buffers->mDensityVBO; + GLuint indices = buffers->mIndices; + static int sprogram = -1; if (sprogram == -1) { @@ -671,10 +755,10 @@ void DrawPoints(GLuint positions, GLuint colors, GLuint indices, int n, int offs glVerify(glUseProgram(sprogram)); glVerify(glUniform1f( glGetUniformLocation(sprogram, "pointRadius"), radius)); glVerify(glUniform1f( glGetUniformLocation(sprogram, "pointScale"), screenWidth/screenAspect * (1.0f / (tanf(fov*0.5f))))); - glVerify(glUniform1f( glGetUniformLocation(sprogram, "spotMin"), gSpotMin)); - glVerify(glUniform1f( glGetUniformLocation(sprogram, "spotMax"), gSpotMax)); + glVerify(glUniform1f( glGetUniformLocation(sprogram, "spotMin"), g_spotMin)); + glVerify(glUniform1f( glGetUniformLocation(sprogram, "spotMax"), g_spotMax)); glVerify(glUniform1i( glGetUniformLocation(sprogram, "mode"), mode)); - glVerify(glUniform4fv( glGetUniformLocation(sprogram, "colors"), 8, (float*)&gColors[0].r)); + glVerify(glUniform4fv( glGetUniformLocation(sprogram, "colors"), 8, (float*)&g_colors[0].r)); // set shadow parameters ShadowApply(sprogram, lightPos, lightTarget, lightTransform, shadowMap->texture); @@ -817,8 +901,8 @@ void BindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, S glVerify(glUseProgram(s_diffuseProgram)); glVerify(glUniform1i(glGetUniformLocation(s_diffuseProgram, "grid"), 0)); - glVerify(glUniform1f( glGetUniformLocation(s_diffuseProgram, "spotMin"), gSpotMin)); - glVerify(glUniform1f( glGetUniformLocation(s_diffuseProgram, "spotMax"), gSpotMax)); + glVerify(glUniform1f( glGetUniformLocation(s_diffuseProgram, "spotMin"), g_spotMin)); + glVerify(glUniform1f( glGetUniformLocation(s_diffuseProgram, "spotMax"), g_spotMax)); glVerify(glUniform4fv( glGetUniformLocation(s_diffuseProgram, "fogColor"), 1, fogColor)); glVerify(glUniformMatrix4fv( glGetUniformLocation(s_diffuseProgram, "objectTransform"), 1, false, Matrix44::kIdentity)); @@ -858,7 +942,7 @@ void DrawPlanes(Vec4* planes, int n, float bias) } glVerify(glUniform1i(uGrid, 0)); - glVerify(glUniform1f(uBias, gShadowBias)); + glVerify(glUniform1f(uBias, g_shadowBias)); } void DrawMesh(const Mesh* m, Vec3 color) @@ -915,8 +999,8 @@ void DrawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, con } #endif - glColor3fv(gColors[colorIndex+1]*1.5f); - glSecondaryColor3fv(gColors[colorIndex]*1.5f); + glColor3fv(g_colors[colorIndex+1]*1.5f); + glSecondaryColor3fv(g_colors[colorIndex]*1.5f); glVerify(glBindBuffer(GL_ARRAY_BUFFER, 0)); glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); @@ -939,7 +1023,7 @@ void DrawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, con if (program == GLint(s_diffuseProgram)) { GLint uBias = glGetUniformLocation(s_diffuseProgram, "bias"); - glUniform1f(uBias, gShadowBias); + glUniform1f(uBias, g_shadowBias); GLint uExpand = glGetUniformLocation(s_diffuseProgram, "expand"); glUniform1f(uExpand, 0.0f); @@ -971,8 +1055,8 @@ void DrawRope(Vec4* positions, int* indices, int numIndices, float radius, int c Extrude(&curve[0], int(curve.size()), vertices, normals, triangles, radius, resolution, smoothing); glVerify(glDisable(GL_CULL_FACE)); - glVerify(glColor3fv(gColors[color%8]*1.5f)); - glVerify(glSecondaryColor3fv(gColors[color%8]*1.5f)); + glVerify(glColor3fv(g_colors[color%8]*1.5f)); + glVerify(glSecondaryColor3fv(g_colors[color%8]*1.5f)); glVerify(glBindBuffer(GL_ARRAY_BUFFER, 0)); @@ -1807,206 +1891,185 @@ void DestroyFluidRenderer(FluidRenderer* renderer) glVerify(glDeleteTextures(1, &renderer->mThicknessTex)); } -FluidRenderBuffers CreateFluidRenderBuffers(int numFluidParticles, bool enableInterop) +FluidRenderBuffers* CreateFluidRenderBuffers(int numFluidParticles, bool enableInterop) { - FluidRenderBuffers buffers = {}; - buffers.mNumFluidParticles = numFluidParticles; - + FluidRenderBuffersGL* buffers = new FluidRenderBuffersGL(numFluidParticles); + // vbos - glVerify(glGenBuffers(1, &buffers.mPositionVBO)); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mPositionVBO)); + glVerify(glGenBuffers(1, &buffers->mPositionVBO)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mPositionVBO)); glVerify(glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * numFluidParticles, 0, GL_DYNAMIC_DRAW)); // density - glVerify(glGenBuffers(1, &buffers.mDensityVBO)); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDensityVBO)); + glVerify(glGenBuffers(1, &buffers->mDensityVBO)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDensityVBO)); glVerify(glBufferData(GL_ARRAY_BUFFER, sizeof(int)*numFluidParticles, 0, GL_DYNAMIC_DRAW)); for (int i = 0; i < 3; ++i) { - glVerify(glGenBuffers(1, &buffers.mAnisotropyVBO[i])); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[i])); + glVerify(glGenBuffers(1, &buffers->mAnisotropyVBO[i])); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mAnisotropyVBO[i])); glVerify(glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * numFluidParticles, 0, GL_DYNAMIC_DRAW)); } - glVerify(glGenBuffers(1, &buffers.mIndices)); - glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers.mIndices)); + glVerify(glGenBuffers(1, &buffers->mIndices)); + glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers->mIndices)); glVerify(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int)*numFluidParticles, 0, GL_DYNAMIC_DRAW)); if (enableInterop) { extern NvFlexLibrary* g_flexLib; - buffers.mPositionBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mPositionVBO, numFluidParticles, sizeof(Vec4)); - buffers.mDensitiesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mDensityVBO, numFluidParticles, sizeof(float)); - buffers.mIndicesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mIndices, numFluidParticles, sizeof(int)); + buffers->mPositionBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mPositionVBO, numFluidParticles, sizeof(Vec4)); + buffers->mDensitiesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mDensityVBO, numFluidParticles, sizeof(float)); + buffers->mIndicesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mIndices, numFluidParticles, sizeof(int)); - buffers.mAnisotropyBuf[0] = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mAnisotropyVBO[0], numFluidParticles, sizeof(Vec4)); - buffers.mAnisotropyBuf[1] = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mAnisotropyVBO[1], numFluidParticles, sizeof(Vec4)); - buffers.mAnisotropyBuf[2] = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mAnisotropyVBO[2], numFluidParticles, sizeof(Vec4)); + buffers->mAnisotropyBuf[0] = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mAnisotropyVBO[0], numFluidParticles, sizeof(Vec4)); + buffers->mAnisotropyBuf[1] = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mAnisotropyVBO[1], numFluidParticles, sizeof(Vec4)); + buffers->mAnisotropyBuf[2] = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mAnisotropyVBO[2], numFluidParticles, sizeof(Vec4)); } - return buffers; + return reinterpret_cast(buffers); } -void DestroyFluidRenderBuffers(FluidRenderBuffers buffers) +void DestroyFluidRenderBuffers(FluidRenderBuffers* buffers) { - glDeleteBuffers(1, &buffers.mPositionVBO); - glDeleteBuffers(3, buffers.mAnisotropyVBO); - glDeleteBuffers(1, &buffers.mDensityVBO); - glDeleteBuffers(1, &buffers.mIndices); - - NvFlexUnregisterOGLBuffer(buffers.mPositionBuf); - NvFlexUnregisterOGLBuffer(buffers.mDensitiesBuf); - NvFlexUnregisterOGLBuffer(buffers.mIndicesBuf); - - NvFlexUnregisterOGLBuffer(buffers.mAnisotropyBuf[0]); - NvFlexUnregisterOGLBuffer(buffers.mAnisotropyBuf[1]); - NvFlexUnregisterOGLBuffer(buffers.mAnisotropyBuf[2]); + delete reinterpret_cast(buffers); } -void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, NvFlexSolver* solver, bool anisotropy, bool density) +void UpdateFluidRenderBuffers(FluidRenderBuffers* buffersIn, NvFlexSolver* solver, bool anisotropy, bool density) { + FluidRenderBuffersGL* buffers = reinterpret_cast(buffersIn); // use VBO buffer wrappers to allow Flex to write directly to the OpenGL buffers // Flex will take care of any CUDA interop mapping/unmapping during the get() operations if (!anisotropy) { // regular particles - NvFlexGetParticles(solver, buffers.mPositionBuf, buffers.mNumFluidParticles); + NvFlexGetParticles(solver, buffers->mPositionBuf, NULL); } else { // fluid buffers - NvFlexGetSmoothParticles(solver, buffers.mPositionBuf, buffers.mNumFluidParticles); - NvFlexGetAnisotropy(solver, buffers.mAnisotropyBuf[0], buffers.mAnisotropyBuf[1], buffers.mAnisotropyBuf[2]); + NvFlexGetSmoothParticles(solver, buffers->mPositionBuf, NULL); + NvFlexGetAnisotropy(solver, buffers->mAnisotropyBuf[0], buffers->mAnisotropyBuf[1], buffers->mAnisotropyBuf[2], NULL); } if (density) { - NvFlexGetDensities(solver, buffers.mDensitiesBuf, buffers.mNumFluidParticles); + NvFlexGetDensities(solver, buffers->mDensitiesBuf, NULL); } else { - NvFlexGetPhases(solver, buffers.mDensitiesBuf, buffers.mNumFluidParticles); + NvFlexGetPhases(solver, buffers->mDensitiesBuf, NULL); } - NvFlexGetActive(solver, buffers.mIndicesBuf); + NvFlexGetActive(solver, buffers->mIndicesBuf, NULL); } -void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) +void UpdateFluidRenderBuffers(FluidRenderBuffers* buffersIn, Vec4* particles, float* densities, Vec4* anisotropy1, Vec4* anisotropy2, Vec4* anisotropy3, int numParticles, int* indices, int numIndices) { + FluidRenderBuffersGL* buffers = reinterpret_cast(buffersIn); // regular particles - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mPositionVBO)); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumFluidParticles*sizeof(Vec4), particles)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mPositionVBO)); + glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers->mNumParticles*sizeof(Vec4), particles)); - if (anisotropy1) + Vec4*const anisotropies[] = { - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[0])); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumFluidParticles*sizeof(Vec4), anisotropy1)); - } - - if (anisotropy2) - { - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[1])); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumFluidParticles*sizeof(Vec4), anisotropy2)); - } + anisotropy1, + anisotropy2, + anisotropy3, + }; - if (anisotropy3) + for (int i = 0; i < 3; i++) { - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[2])); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumFluidParticles*sizeof(Vec4), anisotropy3)); + Vec4* anisotropy = anisotropies[i]; + if (anisotropy) + { + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mAnisotropyVBO[i])); + glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers->mNumParticles * sizeof(Vec4), anisotropy)); + } } // density /phase buffer if (densities) { - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDensityVBO)); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumFluidParticles*sizeof(float), densities)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDensityVBO)); + glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers->mNumParticles*sizeof(float), densities)); } if (indices) { - glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers.mIndices)); + glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers->mIndices)); glVerify(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, numIndices*sizeof(int), indices)); } // reset glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); glVerify(glBindBuffer(GL_ARRAY_BUFFER, 0)); - } -DiffuseRenderBuffers CreateDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop) +DiffuseRenderBuffers* CreateDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop) { - DiffuseRenderBuffers buffers = {}; - buffers.mNumDiffuseParticles = numDiffuseParticles; - + DiffuseRenderBuffersGL* buffers = new DiffuseRenderBuffersGL(numDiffuseParticles); + if (numDiffuseParticles > 0) { - glVerify(glGenBuffers(1, &buffers.mDiffusePositionVBO)); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDiffusePositionVBO)); + glVerify(glGenBuffers(1, &buffers->mDiffusePositionVBO)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDiffusePositionVBO)); glVerify(glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * numDiffuseParticles, 0, GL_DYNAMIC_DRAW)); glVerify(glBindBuffer(GL_ARRAY_BUFFER, 0)); - glVerify(glGenBuffers(1, &buffers.mDiffuseVelocityVBO)); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDiffuseVelocityVBO)); + glVerify(glGenBuffers(1, &buffers->mDiffuseVelocityVBO)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDiffuseVelocityVBO)); glVerify(glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * numDiffuseParticles, 0, GL_DYNAMIC_DRAW)); glVerify(glBindBuffer(GL_ARRAY_BUFFER, 0)); - glVerify(glGenBuffers(1, &buffers.mDiffuseIndicesIBO)); - glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers.mDiffuseIndicesIBO)); - glVerify(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int)*numDiffuseParticles, 0, GL_DYNAMIC_DRAW)); - glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); - if (enableInterop) { extern NvFlexLibrary* g_flexLib; - buffers.mDiffuseIndicesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mDiffuseIndicesIBO, numDiffuseParticles, sizeof(int)); - buffers.mDiffusePositionsBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mDiffusePositionVBO, numDiffuseParticles, sizeof(Vec4)); - buffers.mDiffuseVelocitiesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers.mDiffuseVelocityVBO, numDiffuseParticles, sizeof(Vec4)); + buffers->mDiffusePositionsBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mDiffusePositionVBO, numDiffuseParticles, sizeof(Vec4)); + buffers->mDiffuseVelocitiesBuf = NvFlexRegisterOGLBuffer(g_flexLib, buffers->mDiffuseVelocityVBO, numDiffuseParticles, sizeof(Vec4)); } } - return buffers; + return reinterpret_cast(buffers); } -void DestroyDiffuseRenderBuffers(DiffuseRenderBuffers buffers) +void DestroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffersIn) { - if (buffers.mNumDiffuseParticles > 0) + DiffuseRenderBuffersGL* buffers = reinterpret_cast(buffersIn); + if (buffers->mNumParticles > 0) { - glDeleteBuffers(1, &buffers.mDiffusePositionVBO); - glDeleteBuffers(1, &buffers.mDiffuseVelocityVBO); - glDeleteBuffers(1, &buffers.mDiffuseIndicesIBO); + glDeleteBuffers(1, &buffers->mDiffusePositionVBO); + glDeleteBuffers(1, &buffers->mDiffuseVelocityVBO); - NvFlexUnregisterOGLBuffer(buffers.mDiffuseIndicesBuf); - NvFlexUnregisterOGLBuffer(buffers.mDiffusePositionsBuf); - NvFlexUnregisterOGLBuffer(buffers.mDiffuseVelocitiesBuf); + NvFlexUnregisterOGLBuffer(buffers->mDiffusePositionsBuf); + NvFlexUnregisterOGLBuffer(buffers->mDiffuseVelocitiesBuf); } } -void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers buffers, NvFlexSolver* solver) +void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers* buffersIn, NvFlexSolver* solver) { + DiffuseRenderBuffersGL* buffers = reinterpret_cast(buffersIn); // diffuse particles - if (buffers.mNumDiffuseParticles) + if (buffers->mNumParticles) { - NvFlexGetDiffuseParticles(solver, buffers.mDiffusePositionsBuf, buffers.mDiffuseVelocitiesBuf, buffers.mDiffuseIndicesBuf); + NvFlexGetDiffuseParticles(solver, buffers->mDiffusePositionsBuf, buffers->mDiffuseVelocitiesBuf, NULL); } } -void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, int* diffuseIndices, int numDiffuseParticles) +void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers* buffersIn, Vec4* diffusePositions, Vec4* diffuseVelocities, int numDiffuseParticles) { + DiffuseRenderBuffersGL* buffers = reinterpret_cast(buffersIn); // diffuse particles - if (buffers.mNumDiffuseParticles) + if (buffers->mNumParticles) { - glVerify(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers.mDiffuseIndicesIBO)); - glVerify(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, buffers.mNumDiffuseParticles*sizeof(int), diffuseIndices)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDiffusePositionVBO)); + glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers->mNumParticles*sizeof(Vec4), diffusePositions)); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDiffusePositionVBO)); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumDiffuseParticles*sizeof(Vec4), diffusePositions)); - - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDiffuseVelocityVBO)); - glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers.mNumDiffuseParticles*sizeof(Vec4), diffuseVelocities)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDiffuseVelocityVBO)); + glVerify(glBufferSubData(GL_ARRAY_BUFFER, 0, buffers->mNumParticles*sizeof(Vec4), diffuseVelocities)); } } @@ -2033,8 +2096,10 @@ void RenderFullscreenQuad() extern Mesh* g_mesh; void DrawShapes(); -void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) +void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers* buffersIn, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, Vec4 color, float blur, float ior, bool debug) { + FluidRenderBuffersGL* buffers = reinterpret_cast(buffersIn); + #if !ENABLE_SIMPLE_FLUID // resolve msaa back buffer to texture glVerify(glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, g_msaaFbo)); @@ -2076,7 +2141,7 @@ void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers buffers, int n, glUniform1f( glGetUniformLocation(render->mPointThicknessProgram, "pointScale"), screenWidth/screenAspect * (1.0f / (tanf(fov*0.5f)))); glEnableClientState(GL_VERTEX_ARRAY); - glBindBuffer(GL_ARRAY_BUFFER, buffers.mPositionVBO); + glBindBuffer(GL_ARRAY_BUFFER, buffers->mPositionVBO); glVertexPointer(3, GL_FLOAT, sizeof(float)*4, (void*)(offset*sizeof(float)*4)); glDrawArrays(GL_POINTS, 0, n); @@ -2110,23 +2175,23 @@ void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers buffers, int n, glUniform3fv( glGetUniformLocation(render->mEllipsoidDepthProgram, "invProjection"), 1, Vec3(screenAspect*viewHeight, viewHeight, 1.0f)); glEnableClientState(GL_VERTEX_ARRAY); - glBindBuffer(GL_ARRAY_BUFFER, buffers.mPositionVBO); + glBindBuffer(GL_ARRAY_BUFFER, buffers->mPositionVBO); glVertexPointer(3, GL_FLOAT, sizeof(float)*4, 0);//(void*)(offset*sizeof(float)*4)); // ellipsoid eigenvectors int s1 = glGetAttribLocation(render->mEllipsoidDepthProgram, "q1"); glEnableVertexAttribArray(s1); - glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[0]); + glBindBuffer(GL_ARRAY_BUFFER, buffers->mAnisotropyVBO[0]); glVertexAttribPointer(s1, 4, GL_FLOAT, GL_FALSE, 0, 0);// (void*)(offset*sizeof(float)*4)); int s2 = glGetAttribLocation(render->mEllipsoidDepthProgram, "q2"); glEnableVertexAttribArray(s2); - glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[1]); + glBindBuffer(GL_ARRAY_BUFFER, buffers->mAnisotropyVBO[1]); glVertexAttribPointer(s2, 4, GL_FLOAT, GL_FALSE, 0, 0);//(void*)(offset*sizeof(float)*4)); int s3 = glGetAttribLocation(render->mEllipsoidDepthProgram, "q3"); glEnableVertexAttribArray(s3); - glBindBuffer(GL_ARRAY_BUFFER, buffers.mAnisotropyVBO[2]); + glBindBuffer(GL_ARRAY_BUFFER, buffers->mAnisotropyVBO[2]); glVertexAttribPointer(s3, 4, GL_FLOAT, GL_FALSE, 0, 0);// (void*)(offset*sizeof(float)*4)); glVerify(glDrawArrays(GL_POINTS, offset, n)); @@ -2185,8 +2250,8 @@ void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers buffers, int n, glVerify(glUniform2fv(glGetUniformLocation(render->mCompositeProgram, "clipPosToEye"), 1, Vec2(tanf(fov*0.5f)*screenAspect, tanf(fov*0.5f)))); glVerify(glUniform4fv(glGetUniformLocation(render->mCompositeProgram, "color"), 1, color)); glVerify(glUniform1f(glGetUniformLocation(render->mCompositeProgram, "ior"), ior)); - glVerify(glUniform1f(glGetUniformLocation(render->mCompositeProgram, "spotMin"), gSpotMin)); - glVerify(glUniform1f(glGetUniformLocation(render->mCompositeProgram, "spotMax"), gSpotMax)); + glVerify(glUniform1f(glGetUniformLocation(render->mCompositeProgram, "spotMin"), g_spotMin)); + glVerify(glUniform1f(glGetUniformLocation(render->mCompositeProgram, "spotMax"), g_spotMax)); glVerify(glUniform1i(glGetUniformLocation(render->mCompositeProgram, "debug"), debug)); glVerify(glUniform3fv(glGetUniformLocation(render->mCompositeProgram, "lightPos"), 1, lightPos)); @@ -2431,8 +2496,14 @@ void main() } ); -void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers buffers, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadow, bool front) +int GetNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers) { + return reinterpret_cast(buffers)->mNumParticles; +} + +void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers* buffersIn, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowMap, float motionBlur, float inscatter, float outscatter, bool shadow, bool front) +{ + DiffuseRenderBuffersGL* buffers = reinterpret_cast(buffersIn); static int sprogram = -1; if (sprogram == -1) sprogram = CompileProgram(vertexDiffuseShader, fragmentDiffuseShader, geometryDiffuseShader); @@ -2483,8 +2554,8 @@ void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers buffers, int n, f GLint uLightDir = glGetUniformLocation(sprogram, "lightDir"); glUniform3fv(uLightDir, 1, Normalize(lightTarget-lightPos)); - glUniform1f( glGetUniformLocation(sprogram, "spotMin"), gSpotMin); - glUniform1f( glGetUniformLocation(sprogram, "spotMax"), gSpotMax); + glUniform1f( glGetUniformLocation(sprogram, "spotMin"), g_spotMin); + glUniform1f( glGetUniformLocation(sprogram, "spotMax"), g_spotMax); const Vec2 taps[] = { @@ -2522,16 +2593,16 @@ void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers buffers, int n, f glClientActiveTexture(GL_TEXTURE1); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers.mDiffuseVelocityVBO)); + glVerify(glBindBuffer(GL_ARRAY_BUFFER, buffers->mDiffuseVelocityVBO)); glTexCoordPointer(4, GL_FLOAT, sizeof(float)*4, 0); glEnableClientState(GL_VERTEX_ARRAY); - glBindBuffer(GL_ARRAY_BUFFER, buffers.mDiffusePositionVBO); + glBindBuffer(GL_ARRAY_BUFFER, buffers->mDiffusePositionVBO); glVertexPointer(4, GL_FLOAT, sizeof(float)*4, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers.mDiffuseIndicesIBO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDrawElements(GL_POINTS, n, GL_UNSIGNED_INT, 0); + glDrawArrays(GL_POINTS, 0, n); glUseProgram(0); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -2770,3 +2841,31 @@ void EndPoints() glEnd(); } + + +float SyncAndGetRenderTime(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) +{ + *begin = 0; + *end = 0; + *freq = 1; + return 0.0f; +} + +float RendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq) { return 0.0f; } +void* GetGraphicsCommandQueue() { return nullptr; } +void GraphicsTimerBegin() { } +void GraphicsTimerEnd() { } + +void StartGpuWork() { } +void EndGpuWork() { } + +void GetRenderDevice(void** deviceOut, void** contextOut) +{ + *deviceOut = nullptr; + *contextOut = nullptr; +} + +void DrawImguiGraph() +{ + imguiGraphDraw(); +} \ No newline at end of file diff --git a/demo/scenes.h b/demo/scenes.h index 94e6913..331927b 100644 --- a/demo/scenes.h +++ b/demo/scenes.h @@ -93,7 +93,6 @@ public: #include "scenes/nonconvex.h" #include "scenes/parachutingbunnies.h" #include "scenes/pasta.h" -#include "scenes/plasticstack.h" #include "scenes/player.h" #include "scenes/potpourri.h" #include "scenes/rayleightaylor.h" @@ -104,6 +103,7 @@ public: #include "scenes/rockpool.h" #include "scenes/sdfcollision.h" #include "scenes/shapecollision.h" +#include "scenes/shapechannels.h" #include "scenes/softbody.h" #include "scenes/spherecloth.h" #include "scenes/surfacetension.h" diff --git a/demo/scenes/adhesion.h b/demo/scenes/adhesion.h index efbdec2..10c614a 100644 --- a/demo/scenes/adhesion.h +++ b/demo/scenes/adhesion.h @@ -11,7 +11,6 @@ public: g_params.radius = radius; - g_params.fluid = true; g_params.numIterations = 3; g_params.vorticityConfinement = 0.0f; g_params.fluidRestDistance = g_params.radius*0.55f; diff --git a/demo/scenes/armadilloshower.h b/demo/scenes/armadilloshower.h index fdbf194..0fd2cfe 100644 --- a/demo/scenes/armadilloshower.h +++ b/demo/scenes/armadilloshower.h @@ -18,7 +18,6 @@ public: g_params.radius = radius; - g_params.fluid = true; g_params.numIterations = 3; g_params.vorticityConfinement = 0.0f; g_params.fluidRestDistance = g_params.radius*0.5f; diff --git a/demo/scenes/bouyancy.h b/demo/scenes/bouyancy.h index 816146f..9f5b0d2 100644 --- a/demo/scenes/bouyancy.h +++ b/demo/scenes/bouyancy.h @@ -34,7 +34,6 @@ public: g_params.radius = radius; g_params.dynamicFriction = 0.1f; - g_params.fluid = true; g_params.viscosity = 2.0f; g_params.numIterations = 4; g_params.vorticityConfinement = 180.f; diff --git a/demo/scenes/bunnybath.h b/demo/scenes/bunnybath.h index db9e6ac..eeec5ac 100644 --- a/demo/scenes/bunnybath.h +++ b/demo/scenes/bunnybath.h @@ -37,7 +37,6 @@ public: g_params.radius = radius; g_params.dynamicFriction = 0.01f; - g_params.fluid = true; g_params.viscosity = 2.0f; g_params.numIterations = 4; g_params.vorticityConfinement = 40.0f; diff --git a/demo/scenes/ccdfluid.h b/demo/scenes/ccdfluid.h index 356eec7..9ba018e 100644 --- a/demo/scenes/ccdfluid.h +++ b/demo/scenes/ccdfluid.h @@ -50,7 +50,6 @@ public: g_numSubsteps = 2; - g_params.fluid = true; g_params.radius = radius; g_params.fluidRestDistance = restDistance; g_params.dynamicFriction = 0.1f; diff --git a/demo/scenes/dambreak.h b/demo/scenes/dambreak.h index c2f9a40..cf45c29 100644 --- a/demo/scenes/dambreak.h +++ b/demo/scenes/dambreak.h @@ -22,7 +22,6 @@ public: g_numSubsteps = 2; - g_params.fluid = true; g_params.radius = radius; g_params.fluidRestDistance = restDistance; g_params.dynamicFriction = 0.f; diff --git a/demo/scenes/debris.h b/demo/scenes/debris.h index 39013ff..5454b76 100644 --- a/demo/scenes/debris.h +++ b/demo/scenes/debris.h @@ -112,7 +112,7 @@ public: // emit new debris int numToEmit = 1;//Rand()%8; - int particleOffset = NvFlexGetActiveCount(g_flex); + int particleOffset = NvFlexGetActiveCount(g_solver); for (int i = 0; i < numToEmit; ++i) { @@ -265,7 +265,7 @@ public: virtual void Sync() { - NvFlexSetRigids(g_flex, g_buffers->rigidOffsets.buffer, g_buffers->rigidIndices.buffer, g_buffers->rigidLocalPositions.buffer, g_buffers->rigidLocalNormals.buffer, g_buffers->rigidCoefficients.buffer, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer, g_buffers->rigidOffsets.size() - 1, g_buffers->rigidIndices.size()); + NvFlexSetRigids(g_solver, g_buffers->rigidOffsets.buffer, g_buffers->rigidIndices.buffer, g_buffers->rigidLocalPositions.buffer, g_buffers->rigidLocalNormals.buffer, g_buffers->rigidCoefficients.buffer, g_buffers->rigidPlasticThresholds.buffer, g_buffers->rigidPlasticCreeps.buffer, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer, g_buffers->rigidOffsets.size() - 1, g_buffers->rigidIndices.size()); } virtual void KeyDown(int key) @@ -303,8 +303,7 @@ public: { if (mBatches[b].mInstanceTransforms.size()) { - extern Colour gColors[]; - DrawGpuMeshInstances(mBatches[b].mMesh, &mBatches[b].mInstanceTransforms[0], mBatches[b].mInstanceTransforms.size(), Vec3(gColors[b % 8])); + DrawGpuMeshInstances(mBatches[b].mMesh, &mBatches[b].mInstanceTransforms[0], mBatches[b].mInstanceTransforms.size(), Vec3(g_colors[b % 8])); } } } diff --git a/demo/scenes/envcloth.h b/demo/scenes/envcloth.h index 7405739..50a703a 100644 --- a/demo/scenes/envcloth.h +++ b/demo/scenes/envcloth.h @@ -34,7 +34,7 @@ public: int gridz = mGridZ; int clothIndex = 0; - int phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide); + int phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide | eNvFlexPhaseSelfCollideFilter); for (int x=0; x < gridx; ++x) { @@ -49,6 +49,9 @@ public: } } + // only simple collision necessary + g_solverDesc.featureMode = eNvFlexFeatureModeSimpleSolids; + g_params.radius = radius*1.05f; g_params.dynamicFriction = 0.25f; g_params.dissipation = 0.0f; diff --git a/demo/scenes/fluidblock.h b/demo/scenes/fluidblock.h index 82de2cb..abf508b 100644 --- a/demo/scenes/fluidblock.h +++ b/demo/scenes/fluidblock.h @@ -45,7 +45,6 @@ public: g_params.radius = radius; g_params.dynamicFriction = 0.0f; - g_params.fluid = true; g_params.viscosity = 0.0f; g_params.numIterations = 3; g_params.vorticityConfinement = 40.f; diff --git a/demo/scenes/fluidclothcoupling.h b/demo/scenes/fluidclothcoupling.h index 403a775..d9802b0 100644 --- a/demo/scenes/fluidclothcoupling.h +++ b/demo/scenes/fluidclothcoupling.h @@ -138,7 +138,6 @@ public: g_numExtraParticles = 64*1024; g_params.radius = radius; - g_params.fluid = true; g_params.numIterations = 5; g_params.vorticityConfinement = 0.0f; g_params.anisotropyScale = 30.0f; diff --git a/demo/scenes/forcefield.h b/demo/scenes/forcefield.h index 1ffcd12..6510e87 100644 --- a/demo/scenes/forcefield.h +++ b/demo/scenes/forcefield.h @@ -40,7 +40,7 @@ public: NvFlexExtDestroyForceFieldCallback(callback); // create new callback - callback = NvFlexExtCreateForceFieldCallback(g_flex); + callback = NvFlexExtCreateForceFieldCallback(g_solver); // expand scene bounds to include force field g_sceneLower -= Vec3(1.0f); diff --git a/demo/scenes/gamemesh.h b/demo/scenes/gamemesh.h index 6de6bd0..11824db 100644 --- a/demo/scenes/gamemesh.h +++ b/demo/scenes/gamemesh.h @@ -40,7 +40,6 @@ public: g_params.radius = radius; g_params.dynamicFriction = 0.3f; g_params.dissipation = 0.0f; - g_params.fluid = false; g_params.fluidRestDistance = g_params.radius*0.5f; g_params.viscosity = 0.05f; g_params.anisotropyScale = 20.0f; @@ -73,7 +72,6 @@ public: g_params.dissipation = 0.0f; g_params.numIterations = 4; g_params.numPlanes = 1; - g_params.fluid = false; g_params.particleCollisionMargin = g_params.radius*0.1f; g_params.restitution = 0.0f; @@ -103,7 +101,6 @@ public: g_params.numIterations = 3; g_params.anisotropyScale = 30.0f; g_params.smoothing = 0.5f; - g_params.fluid = true; g_params.relaxationFactor = 1.0f; g_params.restitution = 0.0f; g_params.smoothing = 0.5f; diff --git a/demo/scenes/googun.h b/demo/scenes/googun.h index 79ff396..71d1c51 100644 --- a/demo/scenes/googun.h +++ b/demo/scenes/googun.h @@ -17,7 +17,6 @@ public: g_params.radius = radius; - g_params.fluid = true; g_params.numIterations = 3; g_params.vorticityConfinement = 0.0f; g_params.fluidRestDistance = g_params.radius*0.55f; diff --git a/demo/scenes/granularpile.h b/demo/scenes/granularpile.h index 56a85ea..d71c7a9 100644 --- a/demo/scenes/granularpile.h +++ b/demo/scenes/granularpile.h @@ -19,7 +19,7 @@ public: CreateParticleShape(GetFilePathByPlatform("../../data/sandcastle.obj").c_str(), Vec3(-2.0f, -radius*0.15f, 0.0f), 4.0f, 0.0f, radius*1.0001f, 0.0f, 1.0f, false, 0.0f, NvFlexMakePhase(0, eNvFlexPhaseSelfCollide), false, 0.00f); g_numSubsteps = 2; - + g_params.radius = radius; g_params.staticFriction = 1.0f; g_params.dynamicFriction = 0.5f; @@ -37,9 +37,8 @@ public: g_drawPoints = true; g_warmup = false; - // hack, change the color of phase 0 particles to 'sand' - extern Colour gColors[]; - gColors[0] = Colour(0.805f, 0.702f, 0.401f); + // hack, change the color of phase 0 particles to 'sand' + g_colors[0] = Colour(0.805f, 0.702f, 0.401f); } void Update() diff --git a/demo/scenes/granularshape.h b/demo/scenes/granularshape.h index 6d21738..b07581d 100644 --- a/demo/scenes/granularshape.h +++ b/demo/scenes/granularshape.h @@ -27,8 +27,7 @@ public: g_numSubsteps = 3; - extern Colour gColors[]; - gColors[1] = Colour(0.805f, 0.702f, 0.401f); + g_colors[1] = Colour(0.805f, 0.702f, 0.401f); // draw options g_drawPoints = true; diff --git a/demo/scenes/inflatable.h b/demo/scenes/inflatable.h index 58f5f08..b3e97f6 100644 --- a/demo/scenes/inflatable.h +++ b/demo/scenes/inflatable.h @@ -135,7 +135,7 @@ public: virtual void Sync() { - NvFlexSetInflatables(g_flex, g_buffers->inflatableTriOffsets.buffer, g_buffers->inflatableTriCounts.buffer, g_buffers->inflatableVolumes.buffer, g_buffers->inflatablePressures.buffer, g_buffers->inflatableCoefficients.buffer, mCloths.size()); + NvFlexSetInflatables(g_solver, g_buffers->inflatableTriOffsets.buffer, g_buffers->inflatableTriCounts.buffer, g_buffers->inflatableVolumes.buffer, g_buffers->inflatablePressures.buffer, g_buffers->inflatableCoefficients.buffer, mCloths.size()); } virtual void Draw(int pass) diff --git a/demo/scenes/lighthouse.h b/demo/scenes/lighthouse.h index e4b410a..41e5d2f 100644 --- a/demo/scenes/lighthouse.h +++ b/demo/scenes/lighthouse.h @@ -23,7 +23,6 @@ public: g_params.radius = radius; g_params.dynamicFriction = 0.f; - g_params.fluid = true; g_params.viscosity = 0.01f; g_params.numIterations = 3; g_params.vorticityConfinement = 50.0f; diff --git a/demo/scenes/localspacecloth.h b/demo/scenes/localspacecloth.h index f28912e..1030f8b 100644 --- a/demo/scenes/localspacecloth.h +++ b/demo/scenes/localspacecloth.h @@ -65,7 +65,6 @@ public: g_numSubsteps = 2; - g_params.fluid = false; g_params.radius = radius; g_params.dynamicFriction = 0.f; g_params.restitution = 0.0f; diff --git a/demo/scenes/localspacefluid.h b/demo/scenes/localspacefluid.h index 494249a..7bcbd8b 100644 --- a/demo/scenes/localspacefluid.h +++ b/demo/scenes/localspacefluid.h @@ -46,7 +46,6 @@ public: g_numSubsteps = 2; - g_params.fluid = true; g_params.radius = radius; g_params.fluidRestDistance = restDistance; g_params.dynamicFriction = 0.f; diff --git a/demo/scenes/lowdimensionalshapes.h b/demo/scenes/lowdimensionalshapes.h index 5d32ea5..3c91394 100644 --- a/demo/scenes/lowdimensionalshapes.h +++ b/demo/scenes/lowdimensionalshapes.h @@ -21,7 +21,6 @@ public: g_params.radius = radius; g_params.dynamicFriction = 1.0f; - g_params.fluid = false; g_params.fluidRestDistance = radius; g_params.viscosity = 0.0f; g_params.numIterations = 4; diff --git a/demo/scenes/melting.h b/demo/scenes/melting.h index c7da792..f8d7083 100644 --- a/demo/scenes/melting.h +++ b/demo/scenes/melting.h @@ -13,7 +13,6 @@ public: g_params.dynamicFriction = 0.25f; g_params.dissipation = 0.0f; g_params.viscosity = 0.0f; - g_params.fluid = true; g_params.cohesion = 0.0f; g_params.fluidRestDistance = g_params.radius*0.6f; g_params.anisotropyScale = 4.0f / g_params.radius; @@ -63,7 +62,7 @@ public: virtual void Sync() { - NvFlexSetRigids(g_flex, g_buffers->rigidOffsets.buffer, g_buffers->rigidIndices.buffer, g_buffers->rigidLocalPositions.buffer, g_buffers->rigidLocalNormals.buffer, g_buffers->rigidCoefficients.buffer, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer, g_buffers->rigidOffsets.size() - 1, g_buffers->rigidIndices.size()); + NvFlexSetRigids(g_solver, g_buffers->rigidOffsets.buffer, g_buffers->rigidIndices.buffer, g_buffers->rigidLocalPositions.buffer, g_buffers->rigidLocalNormals.buffer, g_buffers->rigidCoefficients.buffer, g_buffers->rigidPlasticThresholds.buffer, g_buffers->rigidPlasticCreeps.buffer, g_buffers->rigidRotations.buffer, g_buffers->rigidTranslations.buffer, g_buffers->rigidOffsets.size() - 1, g_buffers->rigidIndices.size()); } int mFrame; diff --git a/demo/scenes/mixedpile.h b/demo/scenes/mixedpile.h index 61bc5a5..35333ff 100644 --- a/demo/scenes/mixedpile.h +++ b/demo/scenes/mixedpile.h @@ -186,7 +186,6 @@ public: g_params.shockPropagation = 0.0f; g_params.restitution = 0.0f; g_params.collisionDistance = g_params.radius*0.5f; - g_params.fluid = false; g_params.maxSpeed = 2.0f*g_params.radius*g_numSubsteps/g_dt; // separte solid particle count @@ -207,13 +206,13 @@ public: g_emitters[0].mSpeed = (g_params.radius*0.5f/g_dt); g_emitters[0].mSpeed = (g_params.radius/g_dt); - extern Colour gColors[]; - gColors[0] = Colour(0.805f, 0.702f, 0.401f); + extern Colour g_colors[]; + g_colors[0] = Colour(0.805f, 0.702f, 0.401f); } virtual void Update() { - NvFlexSetInflatables(g_flex, &mTriOffset[0], &mTriCount[0], &mRestVolume[0], &mOverPressure[0], &mConstraintScale[0], mCloths.size(), eFlexMemoryHost); + NvFlexSetInflatables(g_solver, &mTriOffset[0], &mTriCount[0], &mRestVolume[0], &mOverPressure[0], &mConstraintScale[0], mCloths.size(), eFlexMemoryHost); } int mHeight; diff --git a/demo/scenes/parachutingbunnies.h b/demo/scenes/parachutingbunnies.h index 04f2052..bfb18bb 100644 --- a/demo/scenes/parachutingbunnies.h +++ b/demo/scenes/parachutingbunnies.h @@ -124,7 +124,6 @@ public: } } - g_params.fluid = true; g_params.radius = 0.1f; g_params.fluidRestDistance = radius; g_params.numIterations = 4; diff --git a/demo/scenes/plasticstack.h b/demo/scenes/plasticstack.h deleted file mode 100644 index e1543ca..0000000 --- a/demo/scenes/plasticstack.h +++ /dev/null @@ -1,50 +0,0 @@ - -class PlasticStack : public Scene -{ -public: - - PlasticStack(const char* name) : Scene(name) {} - - virtual void Initialize() - { - g_params.radius = 0.225f; - - g_params.numIterations = 2; - g_params.dynamicFriction = 0.5f; - g_params.particleFriction = 0.15f; - g_params.dissipation = 0.0f; - g_params.viscosity = 0.0f; - - AddPlinth(); - - const float rotation = -kPi*0.5f; - const float spacing = g_params.radius*0.5f; - - // alternative box and sphere shapes - const char* mesh[] = - { - "../../data/box_high.ply", - "../../data/sphere.ply" - }; - - Vec3 lower = Vec3(4.0f, 1.0f, 0.0f); - float sizeInc = 0.0f; - float size = 1.0f; - int group = 0; - - for (int i=0; i < 8; ++i) - { - CreateParticleShape(GetFilePathByPlatform(mesh[i%2]).c_str(), lower, size + i*sizeInc, rotation, spacing, Vec3(.0f, 0.0f, 0.0f), 1.0f, true, 1.0f, NvFlexMakePhase(group++, 0), true, 0.0f, 0.0f, g_params.radius*0.5f); - - lower += Vec3(0.0f, size + i*sizeInc + 0.2f, 0.0f); - } - - g_params.plasticThreshold = 0.00025f; - g_params.plasticCreep = 0.165f; - - g_numSubsteps = 4; - - // draw options - g_drawPoints = false; - } -}; diff --git a/demo/scenes/player.h b/demo/scenes/player.h index 83407ac..46f4ca5 100644 --- a/demo/scenes/player.h +++ b/demo/scenes/player.h @@ -40,7 +40,7 @@ public: { g_buffers->activeIndices = mInitialActive; - NvFlexSetActive(g_flex, &mInitialActive[0], mInitialActive.size(), eFlexMemoryHost); + NvFlexSetActive(g_solver, &mInitialActive[0], mInitialActive.size(), eFlexMemoryHost); } virtual Matrix44 GetBasis() @@ -166,6 +166,8 @@ public: ReadArray(g_buffers->rigidLocalNormals, true); ReadArray(g_buffers->rigidCoefficients, true); + ReadArray(g_buffers->rigidPlasticThresholds, true); + ReadArray(g_buffers->rigidPlasticCreeps, true); ReadArray(g_buffers->rigidOffsets, true); ReadArray(g_buffers->rigidRotations, true); ReadArray(g_buffers->rigidTranslations, true); diff --git a/demo/scenes/rayleightaylor.h b/demo/scenes/rayleightaylor.h index f07fb46..b4f7ebd 100644 --- a/demo/scenes/rayleightaylor.h +++ b/demo/scenes/rayleightaylor.h @@ -31,7 +31,6 @@ public: g_params.gravity[1] = -9.f; g_params.radius = radius; g_params.dynamicFriction = 0.00f; - g_params.fluid = true; g_params.viscosity = 2.0f; g_params.numIterations = 10; g_params.vorticityConfinement = 0.0f; @@ -109,7 +108,6 @@ public: g_params.gravity[1] = -9.f; g_params.radius = radius; g_params.dynamicFriction = 0.00f; - g_params.fluid = true; g_params.viscosity = 0.0f; g_params.numIterations = 10; g_params.vorticityConfinement = 0.0f; diff --git a/demo/scenes/rigidfluidcoupling.h b/demo/scenes/rigidfluidcoupling.h index b978eb8..0bde7d9 100644 --- a/demo/scenes/rigidfluidcoupling.h +++ b/demo/scenes/rigidfluidcoupling.h @@ -43,13 +43,12 @@ public: g_params.radius = radius; g_params.dynamicFriction = 0.5f; - g_params.fluid = true; g_params.viscosity = 0.1f; g_params.numIterations = 3; g_params.vorticityConfinement = 0.0f; g_params.anisotropyScale = 25.0f; - g_params.fluidRestDistance = g_params.radius*0.55f; - + g_params.fluidRestDistance = g_params.radius*0.55f; + g_params.solidRestDistance = g_params.radius*0.5f; g_emitters[0].mEnabled = true; g_emitters[0].mSpeed = 2.0f*(g_params.fluidRestDistance)/g_dt; diff --git a/demo/scenes/rigidrotation.h b/demo/scenes/rigidrotation.h index 8abcb98..6d2e1d7 100644 --- a/demo/scenes/rigidrotation.h +++ b/demo/scenes/rigidrotation.h @@ -12,9 +12,9 @@ public: { float radius = 0.1f; - float dimx = 1.0f; - float dimy = 5.0f; - float dimz = 1.0f; + float dimx = 3.0f; + float dimy = 3.0f; + float dimz = 3.0f; CreateParticleShape(GetFilePathByPlatform("../../data/box.ply").c_str(), Vec3(0.0f, 1.0f, 0.0f), Vec3(dimx, dimy, dimz)*radius, 0.0f, radius, Vec3(0.0f), 1.0f, true, 1.0f, 0, true, 0.0f, 0.0f, 0.0f); @@ -22,7 +22,7 @@ public: g_params.gravity[1] = 0; g_params.numIterations = 1; - g_numSubsteps = 1; + g_numSubsteps = 3; g_pause = true; @@ -39,17 +39,19 @@ public: Vec3 center = (lower + upper)*0.5f; - Matrix44 rotation = RotationMatrix(DegToRad(95.0f), Vec3(0.0f, 0.0f, 1.0f)); + //Matrix44 rotation = RotationMatrix(DegToRad(40.0f), Vec3(0.0f, 0.0f, 1.0f)); for (int i = 0; i < int(g_buffers->positions.size()); ++i) { Vec3 delta = Vec3(g_buffers->positions[i]) - center; - delta = Vec3(rotation*Vec4(delta, 1.0f)); + //delta = Vec3(rotation*Vec4(delta, 1.0f)); - g_buffers->positions[i].x = center.x + delta.x; - g_buffers->positions[i].y = center.y + delta.y; - g_buffers->positions[i].z = center.z + delta.z; + //g_buffers->positions[i].x = center.x + delta.x; + //g_buffers->positions[i].y = center.y + delta.y; + //g_buffers->positions[i].z = center.z + delta.z; + + g_buffers->velocities[i] = Cross(delta, Vec3(0.0f, 0.0f, 1.0f))*10.0f; } } } diff --git a/demo/scenes/rockpool.h b/demo/scenes/rockpool.h index e7c0034..f596de2 100644 --- a/demo/scenes/rockpool.h +++ b/demo/scenes/rockpool.h @@ -21,11 +21,12 @@ public: CreateParticleGrid(Vec3(0.0f, radius*0.5f, -1.0f), 32, 32, 32, radius*0.55f, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhase(0, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid), 0.005f); + g_solverDesc.featureMode = eNvFlexFeatureModeSimpleFluids; + g_numSubsteps = 2; g_params.radius = radius; g_params.dynamicFriction = 0.00f; - g_params.fluid = true; g_params.viscosity = 0.01f; g_params.numIterations = 2; g_params.vorticityConfinement = 75.0f; diff --git a/demo/scenes/shapechannels.h b/demo/scenes/shapechannels.h new file mode 100644 index 0000000..22ee649 --- /dev/null +++ b/demo/scenes/shapechannels.h @@ -0,0 +1,48 @@ + + +// demonstrates how to make particles collide with +// selected collision shapes based on the channel mask +class ShapeChannels : public Scene +{ +public: + + ShapeChannels(const char* name) : Scene(name) {} + + void Initialize() + { + const float radius = 0.05f; + + Vec3 offset = Vec3(-0.25f, 6.0f, -0.25f); + + // layers of particles each set to collide with a different shape channel + int numLayers = 8; + + for (int i=0; i < numLayers; ++i) + { + CreateParticleGrid(offset + Vec3(0.0f, 2.0f*i*radius, 0.0f), 10, 1, 10, radius, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhaseWithChannels(i, eNvFlexPhaseSelfCollide, eNvFlexPhaseShapeChannel0< mInstances; + +private: + + struct RenderingInstance + { + Mesh* mMesh; + std::vector mSkinningIndices; + std::vector mSkinningWeights; + vector mRigidRestPoses; + Vec3 mColor; + int mOffset; + }; + + std::vector mRenderingInstances; + + bool plasticDeformation; + + +public: + virtual void AddInstance(Instance instance) + { + this->mInstances.push_back(instance); + } + + virtual void AddStack(Instance instance, int xStack, int yStack, int zStack, bool rotateColors = false) + { + Vec3 translation = instance.mTranslation; + for (int x = 0; x < xStack; ++x) + { + for (int y = 0; y < yStack; ++y) + { + for (int z = 0; z < zStack; ++z) + { + instance.mTranslation = translation + Vec3(x*(instance.mScale.x + 1), y*(instance.mScale.y + 1), z*(instance.mScale.z + 1))*mRadius; + if (rotateColors) { + instance.mColor = mColorPicker[(x*yStack*zStack + y*zStack + z) % 7]; + } + this->mInstances.push_back(instance); + } + } + } } virtual void Initialize() { float radius = mRadius; + // no fluids or sdf based collision + g_solverDesc.featureMode = eNvFlexFeatureModeSimpleSolids; + g_params.radius = radius; g_params.dynamicFriction = 0.35f; g_params.particleFriction = 0.25f; - g_params.dissipation = 0.0f; g_params.numIterations = 4; - g_params.viscosity = 0.0f; - g_params.drag = 0.0f; - g_params.lift = 0.0f; g_params.collisionDistance = radius*0.75f; - g_params.plasticThreshold = mPlasticThreshold; - g_params.plasticCreep = mPlasticCreep; - g_params.relaxationFactor = mRelaxationFactor; g_windStrength = 0.0f; @@ -61,14 +155,14 @@ public: g_buffers->rigidOffsets.push_back(0); - mInstances.resize(0); + mRenderingInstances.resize(0); + // build soft bodies + for (int i = 0; i < int(mInstances.size()); i++) + CreateSoftBody(mInstances[i], mRenderingInstances.size()); - CreateBodies(); - - if (mPlinth) { + if (mPlinth) AddPlinth(); - } // fix any particles below the ground plane in place for (int i = 0; i < int(g_buffers->positions.size()); ++i) @@ -81,73 +175,60 @@ public: g_lightDistance *= 1.5f; } - virtual void CreateBodies() + void CreateSoftBody(Instance instance, int group = 0) { - // build soft body - for (int x = 0; x < mStack[0]; ++x) - { - for (int y = 0; y < mStack[1]; ++y) - { - for (int z = 0; z < mStack[2]; ++z) - { - CreateSoftBody(mRadius, mOffset + Vec3(x*(mScale.x + 1), y*(mScale.y + 1), z*(mScale.z + 1))*mRadius, mClusterStiffness, mInstances.size()); - } - } - } - } - - void CreateSoftBody(float radius, Vec3 position, float clusterStiffness, int group = 0) - { - Instance instance; + RenderingInstance renderingInstance; - Mesh* mesh = ImportMesh(GetFilePathByPlatform(mFile).c_str()); + Mesh* mesh = ImportMesh(GetFilePathByPlatform(instance.mFile).c_str()); mesh->Normalize(); - mesh->Transform(TranslationMatrix(Point3(position))*ScaleMatrix(mScale*radius)); + mesh->Transform(TranslationMatrix(Point3(instance.mTranslation))*ScaleMatrix(instance.mScale*mRadius)); - instance.mMesh = mesh; - instance.mColor = Vec3(0.5f, 0.5f, 1.0f); - instance.mOffset = g_buffers->rigidTranslations.size(); + renderingInstance.mMesh = mesh; + renderingInstance.mColor = instance.mColor; + renderingInstance.mOffset = g_buffers->rigidTranslations.size(); double createStart = GetSeconds(); // create soft body definition NvFlexExtAsset* asset = NvFlexExtCreateSoftFromMesh( - (float*)&instance.mMesh->m_positions[0], - instance.mMesh->m_positions.size(), - (int*)&instance.mMesh->m_indices[0], - instance.mMesh->m_indices.size(), - radius, - mVolumeSampling, - mSurfaceSampling, - mClusterSpacing*radius, - mClusterRadius*radius, - clusterStiffness, - mLinkRadius*radius, - mLinkStiffness, - mGlobalStiffness); + (float*)&renderingInstance.mMesh->m_positions[0], + renderingInstance.mMesh->m_positions.size(), + (int*)&renderingInstance.mMesh->m_indices[0], + renderingInstance.mMesh->m_indices.size(), + mRadius, + instance.mVolumeSampling, + instance.mSurfaceSampling, + instance.mClusterSpacing*mRadius, + instance.mClusterRadius*mRadius, + instance.mClusterStiffness, + instance.mLinkRadius*mRadius, + instance.mLinkStiffness, + instance.mGlobalStiffness, + instance.mClusterPlasticThreshold, + instance.mClusterPlasticCreep); double createEnd = GetSeconds(); // create skinning const int maxWeights = 4; - instance.mSkinningIndices.resize(instance.mMesh->m_positions.size()*maxWeights); - instance.mSkinningWeights.resize(instance.mMesh->m_positions.size()*maxWeights); + renderingInstance.mSkinningIndices.resize(renderingInstance.mMesh->m_positions.size()*maxWeights); + renderingInstance.mSkinningWeights.resize(renderingInstance.mMesh->m_positions.size()*maxWeights); for (int i = 0; i < asset->numShapes; ++i) - instance.mRigidRestPoses.push_back(Vec3(&asset->shapeCenters[i * 3])); + renderingInstance.mRigidRestPoses.push_back(Vec3(&asset->shapeCenters[i * 3])); double skinStart = GetSeconds(); NvFlexExtCreateSoftMeshSkinning( - (float*)&instance.mMesh->m_positions[0], - instance.mMesh->m_positions.size(), + (float*)&renderingInstance.mMesh->m_positions[0], + renderingInstance.mMesh->m_positions.size(), asset->shapeCenters, asset->numShapes, - mSkinningFalloff, - mSkinningMaxDistance, - &instance.mSkinningWeights[0], - &instance.mSkinningIndices[0]); + instance.mSkinningFalloff, + instance.mSkinningMaxDistance, + &renderingInstance.mSkinningWeights[0], + &renderingInstance.mSkinningIndices[0]); double skinEnd = GetSeconds(); @@ -178,6 +259,52 @@ public: g_buffers->rigidCoefficients.push_back(asset->shapeCoefficients[i]); } + + // add plastic deformation data to solver, if at least one asset has non-zero plastic deformation coefficients, leave the according pointers at NULL otherwise + if (plasticDeformation) + { + if (asset->shapePlasticThresholds && asset->shapePlasticCreeps) + { + for (int i = 0; i < asset->numShapes; ++i) + { + g_buffers->rigidPlasticThresholds.push_back(asset->shapePlasticThresholds[i]); + g_buffers->rigidPlasticCreeps.push_back(asset->shapePlasticCreeps[i]); + } + } + else + { + for (int i = 0; i < asset->numShapes; ++i) + { + g_buffers->rigidPlasticThresholds.push_back(0.0f); + g_buffers->rigidPlasticCreeps.push_back(0.0f); + } + } + } + else + { + if (asset->shapePlasticThresholds && asset->shapePlasticCreeps) + { + int oldBufferSize = g_buffers->rigidCoefficients.size() - asset->numShapes; + + g_buffers->rigidPlasticThresholds.resize(oldBufferSize); + g_buffers->rigidPlasticCreeps.resize(oldBufferSize); + + for (int i = 0; i < oldBufferSize; i++) + { + g_buffers->rigidPlasticThresholds[i] = 0.0f; + g_buffers->rigidPlasticCreeps[i] = 0.0f; + } + + for (int i = 0; i < asset->numShapes; ++i) + { + g_buffers->rigidPlasticThresholds.push_back(asset->shapePlasticThresholds[i]); + g_buffers->rigidPlasticCreeps.push_back(asset->shapePlasticCreeps[i]); + } + + plasticDeformation = true; + } + } + // add link data to the solver for (int i = 0; i < asset->numSprings; ++i) { @@ -190,7 +317,7 @@ public: NvFlexExtDestroyAsset(asset); - mInstances.push_back(instance); + mRenderingInstances.push_back(renderingInstance); } virtual void Draw(int pass) @@ -198,9 +325,9 @@ public: if (!g_drawMesh) return; - for (int s = 0; s < int(mInstances.size()); ++s) + for (int s = 0; s < int(mRenderingInstances.size()); ++s) { - const Instance& instance = mInstances[s]; + const RenderingInstance& instance = mRenderingInstances[s]; Mesh m; m.m_positions.resize(instance.mMesh->m_positions.size()); @@ -239,58 +366,15 @@ public: DrawMesh(&m, instance.mColor); } } - - struct Instance - { - Mesh* mMesh; - std::vector mSkinningIndices; - std::vector mSkinningWeights; - vector mRigidRestPoses; - Vec3 mColor; - int mOffset; - }; - - std::vector mInstances; - - const char* mFile; - Vec3 mScale; - Vec3 mOffset; - - float mRadius; - - float mClusterSpacing; - float mClusterRadius; - float mClusterStiffness; - - float mLinkRadius; - float mLinkStiffness; - - float mGlobalStiffness; - - float mSurfaceSampling; - float mVolumeSampling; - - float mSkinningFalloff; - float mSkinningMaxDistance; - - float mPlasticThreshold; - float mPlasticCreep; - - float mRelaxationFactor; - - bool mPlinth; - - int mStack[3]; }; - - class SoftBodyFixed : public SoftBody { public: - SoftBodyFixed(const char* name, const char* mesh) : SoftBody(name, mesh) {} + SoftBodyFixed(const char* name) : SoftBody(name) + {} virtual void Initialize() { @@ -302,16 +386,16 @@ public: g_buffers->positions[i].w = 0.0f; } - virtual void CreateBodies() + virtual void AddStack(Instance instance, int zStack) { - int x = 0; - int y = 0; + float clusterStiffness = instance.mClusterStiffness; + Vec3 translation = instance.mTranslation; - for (int z = 0; z < 4; ++z) + for (int z = 0; z < zStack; ++z) { - float stiffness = sqr(mClusterStiffness*(z + 1)); - - CreateSoftBody(mRadius, mOffset + Vec3(x*(mScale.x + 1), y*(mScale.y + 1), -z*(mScale.z + 1))*mRadius, stiffness, mInstances.size()); + instance.mClusterStiffness = sqr(clusterStiffness*(z + 1)); + instance.mTranslation = translation + Vec3(0.0f, 0.0f, -z*(instance.mScale.z + 1))*mRadius; + this->mInstances.push_back(instance); } } @@ -322,4 +406,4 @@ public: (Vec4&)g_params.planes[1] = Vec4(1.0f, 0.0f, 0.0f, 0.0f); g_params.numPlanes = 2; } -}; +}; \ No newline at end of file diff --git a/demo/scenes/surfacetension.h b/demo/scenes/surfacetension.h index b22ad6d..60f1836 100644 --- a/demo/scenes/surfacetension.h +++ b/demo/scenes/surfacetension.h @@ -17,7 +17,6 @@ public: g_params.radius = radius; - g_params.fluid = true; g_params.numIterations = 3; g_params.vorticityConfinement = 0.0f; g_params.fluidRestDistance = restDistance; diff --git a/demo/scenes/tearing.h b/demo/scenes/tearing.h index c36ca7a..ce9dacc 100644 --- a/demo/scenes/tearing.h +++ b/demo/scenes/tearing.h @@ -123,9 +123,9 @@ public: virtual void Sync() { // update solver data not already updated in the main loop - NvFlexSetSprings(g_flex, g_buffers->springIndices.buffer, g_buffers->springLengths.buffer, g_buffers->springStiffness.buffer, g_buffers->springLengths.size()); - NvFlexSetDynamicTriangles(g_flex, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); - NvFlexSetRestParticles(g_flex, g_buffers->restPositions.buffer, g_buffers->restPositions.size()); + NvFlexSetSprings(g_solver, g_buffers->springIndices.buffer, g_buffers->springLengths.buffer, g_buffers->springStiffness.buffer, g_buffers->springLengths.size()); + NvFlexSetDynamicTriangles(g_solver, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); + NvFlexSetRestParticles(g_solver, g_buffers->restPositions.buffer, NULL); } NvFlexExtAsset* mCloth; diff --git a/demo/scenes/thinbox.h b/demo/scenes/thinbox.h index a77f258..d9005c9 100644 --- a/demo/scenes/thinbox.h +++ b/demo/scenes/thinbox.h @@ -47,7 +47,6 @@ public: g_params.gravity[1] = -9.f; g_params.radius = radius; g_params.dynamicFriction = 0.0f; - g_params.fluid = false; g_params.numIterations = 5; g_params.numPlanes = 1; g_params.restitution = 0.0f; diff --git a/demo/scenes/triggervolume.h b/demo/scenes/triggervolume.h index 0e4c1a4..8c078de 100644 --- a/demo/scenes/triggervolume.h +++ b/demo/scenes/triggervolume.h @@ -45,14 +45,14 @@ public: NvFlexVector contactIndices(g_flexLib, g_buffers->positions.size()); NvFlexVector contactCounts(g_flexLib, g_buffers->positions.size()); - NvFlexGetContacts(g_flex, contactPlanes.buffer, contactVelocities.buffer, contactIndices.buffer, contactCounts.buffer); + NvFlexGetContacts(g_solver, contactPlanes.buffer, contactVelocities.buffer, contactIndices.buffer, contactCounts.buffer); contactPlanes.map(); contactVelocities.map(); contactIndices.map(); contactCounts.map(); - int activeCount = NvFlexGetActiveCount(g_flex); + int activeCount = NvFlexGetActiveCount(g_solver); for (int i = 0; i < activeCount; ++i) { diff --git a/demo/scenes/viscosity.h b/demo/scenes/viscosity.h index 0615855..52db6d5 100644 --- a/demo/scenes/viscosity.h +++ b/demo/scenes/viscosity.h @@ -10,9 +10,10 @@ public: float radius = 0.1f; float restDistance = radius*0.5f; + g_solverDesc.featureMode = eNvFlexFeatureModeSimpleFluids; + g_params.radius = radius; - g_params.fluid = true; g_params.numIterations = 3; g_params.vorticityConfinement = 0.0f; g_params.fluidRestDistance = restDistance; diff --git a/demo/scenes/waterballoon.h b/demo/scenes/waterballoon.h index 544bf78..0e59f40 100644 --- a/demo/scenes/waterballoon.h +++ b/demo/scenes/waterballoon.h @@ -88,8 +88,6 @@ public: g_params.collisionDistance = 0.01f; g_params.solidPressure = 0.0f; - g_params.fluid = true; - g_params.fluidRestDistance = radius*0.65f; g_params.viscosity = 0.0; g_params.adhesion = 0.0f; @@ -190,11 +188,11 @@ public: virtual void Sync() { // send new particle data to the GPU - NvFlexSetRestParticles(g_flex, g_buffers->restPositions.buffer, g_buffers->restPositions.size()); + NvFlexSetRestParticles(g_solver, g_buffers->restPositions.buffer, NULL); // update solver - NvFlexSetSprings(g_flex, g_buffers->springIndices.buffer, g_buffers->springLengths.buffer, g_buffers->springStiffness.buffer, g_buffers->springLengths.size()); - NvFlexSetDynamicTriangles(g_flex, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); + NvFlexSetSprings(g_solver, g_buffers->springIndices.buffer, g_buffers->springLengths.buffer, g_buffers->springStiffness.buffer, g_buffers->springLengths.size()); + NvFlexSetDynamicTriangles(g_solver, g_buffers->triangles.buffer, g_buffers->triangleNormals.buffer, g_buffers->triangles.size() / 3); } virtual void Update() diff --git a/demo/shaders.h b/demo/shaders.h index 937c2a2..168a333 100644 --- a/demo/shaders.h +++ b/demo/shaders.h @@ -34,32 +34,41 @@ #include "../include/NvFlex.h" +void GetRenderDevice(void** device, void** context); -#if FLEX_DX - -#include -typedef ID3D11Buffer* VertexBuffer; -typedef ID3D11Buffer* IndexBuffer; - -void GetRenderDevice(ID3D11Device** device, ID3D11DeviceContext** context); - -#else - -typedef unsigned int VertexBuffer; -typedef unsigned int IndexBuffer; -typedef unsigned int Texture; - -#endif +struct DiffuseRenderBuffers; +struct FluidRenderBuffers; struct SDL_Window; -void InitRender(SDL_Window* window, bool fullscreen, int msaa); +struct RenderInitOptions +{ + RenderInitOptions(): + defaultFontHeight(-1), + asyncComputeBenchmark(false), + fullscreen(false), + numMsaaSamples(1), + window(nullptr) + {} + int defaultFontHeight; ///< Set to -1 for the default + bool asyncComputeBenchmark; ///< When set, will configure renderer to perform extra (unnecessary) rendering work to make sure async compute can take place. + bool fullscreen; + int numMsaaSamples; + SDL_Window* window; +}; + +void InitRender(const RenderInitOptions& options); void DestroyRender(); void ReshapeRender(SDL_Window* window); void StartFrame(Vec4 clearColor); void EndFrame(); +void StartGpuWork(); +void EndGpuWork(); + +void FlushGraphicsAndWait(); + // set to true to enable vsync void PresentFrame(bool fullsync); @@ -86,7 +95,7 @@ void ShadowEnd(); // primitive draw methods void DrawPlanes(Vec4* planes, int n, float bias); -void DrawPoints(VertexBuffer positions, VertexBuffer color, IndexBuffer indices, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, bool showDensity); +void DrawPoints(FluidRenderBuffers* buffer, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, bool showDensity); void DrawMesh(const Mesh*, Vec3 color); void DrawCloth(const Vec4* positions, const Vec4* normals, const float* uvs, const int* indices, int numTris, int numPositions, int colorIndex=3, float expand=0.0f, bool twosided=true, bool smooth=true); void DrawBuffer(float* buffer, Vec3 camPos, Vec3 lightPos); @@ -103,6 +112,11 @@ void DrawGpuMeshInstances(GpuMesh* m, const Matrix44* xforms, int n, const Vec3& void BindSolidShader(Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, float bias, Vec4 fogColor); void UnbindSolidShader(); +float RendererGetDeviceTimestamps(unsigned long long* begin, unsigned long long* end, unsigned long long* freq); +void* GetGraphicsCommandQueue(); +void GraphicsTimerBegin(); +void GraphicsTimerEnd(); + // new fluid renderer struct FluidRenderer; @@ -110,32 +124,14 @@ struct FluidRenderer; FluidRenderer* CreateFluidRenderer(uint32_t width, uint32_t height); void DestroyFluidRenderer(FluidRenderer*); -struct FluidRenderBuffers -{ - VertexBuffer mPositionVBO; - VertexBuffer mDensityVBO; - VertexBuffer mAnisotropyVBO[3]; - IndexBuffer mIndices; - - VertexBuffer mFluidVBO; // to be removed - - // wrapper buffers that allow Flex to write directly to VBOs - NvFlexBuffer* mPositionBuf; - NvFlexBuffer* mDensitiesBuf; - NvFlexBuffer* mAnisotropyBuf[3]; - NvFlexBuffer* mIndicesBuf; - - int mNumFluidParticles; -}; - -FluidRenderBuffers CreateFluidRenderBuffers(int numParticles, bool enableInterop); -void DestroyFluidRenderBuffers(FluidRenderBuffers buffers); +FluidRenderBuffers* CreateFluidRenderBuffers(int numParticles, bool enableInterop); +void DestroyFluidRenderBuffers(FluidRenderBuffers* buffers); // update fluid particle buffers from a FlexSovler -void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, NvFlexSolver* flex, bool anisotropy, bool density); +void UpdateFluidRenderBuffers(FluidRenderBuffers* buffers, NvFlexSolver* flex, bool anisotropy, bool density); // update fluid particle buffers from host memory -void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, +void UpdateFluidRenderBuffers(FluidRenderBuffers* buffers, Vec4* particles, float* densities, Vec4* anisotropy1, @@ -145,38 +141,26 @@ void UpdateFluidRenderBuffers(FluidRenderBuffers buffers, int* indices, int numIndices); -// vertex buffers for diffuse particles -struct DiffuseRenderBuffers -{ - VertexBuffer mDiffusePositionVBO; - VertexBuffer mDiffuseVelocityVBO; - IndexBuffer mDiffuseIndicesIBO; - - NvFlexBuffer* mDiffuseIndicesBuf; - NvFlexBuffer* mDiffusePositionsBuf; - NvFlexBuffer* mDiffuseVelocitiesBuf; - - int mNumDiffuseParticles; -}; - // owns diffuse particle vertex buffers -DiffuseRenderBuffers CreateDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop); -void DestroyDiffuseRenderBuffers(DiffuseRenderBuffers buffers); +DiffuseRenderBuffers* CreateDiffuseRenderBuffers(int numDiffuseParticles, bool& enableInterop); +void DestroyDiffuseRenderBuffers(DiffuseRenderBuffers* buffers); // update diffuse particle vertex buffers from a NvFlexSolver -void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers buffers, NvFlexSolver* solver); +void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, NvFlexSolver* solver); // update diffuse particle vertex buffers from host memory -void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers buffers, +void UpdateDiffuseRenderBuffers(DiffuseRenderBuffers* buffers, Vec4* diffusePositions, Vec4* diffuseVelocities, - int* diffuseIndices, int numDiffuseParticles); +// Returns the number of particles in the diffuse buffers +int GetNumDiffuseRenderParticles(DiffuseRenderBuffers* buffers); + // screen space fluid rendering -void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, Vec4 color, float blur, float ior, bool debug); -void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers buffer, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, float motionBlur, float inscatter, float outscatter, bool shadow, bool front); +void RenderEllipsoids(FluidRenderer* render, FluidRenderBuffers* buffers, int n, int offset, float radius, float screenWidth, float screenAspect, float fov, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, Vec4 color, float blur, float ior, bool debug); +void RenderDiffuse(FluidRenderer* render, DiffuseRenderBuffers* buffer, int n, float radius, float screenWidth, float screenAspect, float fov, Vec4 color, Vec3 lightPos, Vec3 lightTarget, Matrix44 lightTransform, ShadowMap* shadowTex, float motionBlur, float inscatter, float outscatter, bool shadow, bool front); // UI rendering -void imguiGraphDraw(); -void imguiGraphInit(const char* fontpath); \ No newline at end of file + +void DrawImguiGraph(); diff --git a/doc/.buildinfo b/doc/.buildinfo index 52b7d53..796e70f 100644 --- a/doc/.buildinfo +++ b/doc/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 6cf9db66665815d32ac02a4ae6d96335 +config: 39b9edc0aafd74c178215254aff93032 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/doc/_sources/manual.txt b/doc/_sources/manual.txt index 08f61af..d4d916b 100644 --- a/doc/_sources/manual.txt +++ b/doc/_sources/manual.txt @@ -38,21 +38,26 @@ Quick Start The example code below shows how to initialize the library, create a new solver (similar to a scene in PhysX), and how to tick the solver:: - #include - NvFlexLibrary* library = NvFlexInit(); - NvFlexSolver* solver = NvFlexCreateSolver(library); - NvFlexBuffer* particleBuffer = NvlexAllocBuffer(library, n, sizeof(Vec4), eNvFlexBufferHost); - NvFlexBuffer* velocityBuffer = NvlexAllocBuffer(library, n, sizeof(Vec4), eNvFlexBufferHost); - NvFlexBuffer* phaseBuffer = NvlexAllocBuffer(library, n, sizeof(int), eNvFlexBufferHost); + // create new solver + NvFlexSolverDesc solverDesc; + NvFlexSetSolverDescDefaults(&solverDesc); + solverDesc.maxParticles = n; + solverDesc.maxDiffuseParticles = 0; + + NvFlexSolver* solver = NvFlexCreateSolver(library, &solverDesc); + + NvFlexBuffer* particleBuffer = NvFlexAllocBuffer(library, n, sizeof(float4), eNvFlexBufferHost); + NvFlexBuffer* velocityBuffer = NvFlexAllocBuffer(library, n, sizeof(float4), eNvFlexBufferHost); + NvFlexBuffer* phaseBuffer = NvFlexAllocBuffer(library, n, sizeof(int), eNvFlexBufferHost); while(!done) { // map buffers for reading / writing - float4* particles = (float4*)NvlexMap(particles, eNvFlexMapWait); - float3* velocities = (float3*)NvFlexMap(velocities, eNvFlexMapWait); - int* phases = (int*)NvFlexMap(phases, eNvFlexMapWait); + float4* particles = (float4*)NvFlexMap(particleBuffer, eNvFlexMapWait); + float3* velocities = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait); + int* phases = (int*)NvFlexMap(phaseBuffer, eNvFlexMapWait); // spawn (user method) SpawnParticles(particles, velocities, phases); @@ -66,17 +71,17 @@ The example code below shows how to initialize the library, create a new solver NvFlexUnmap(phaseBuffer); // write to device (async) - NvFlexSetParticles(particleBuffer, n); - NvFlexSetVelocities(velocityBuffer, n); - NvFlexSetPhases(phaseBuffer, n); + NvFlexSetParticles(solver, particleBuffer, NULL); + NvFlexSetVelocities(solver, velocityBuffer, NULL); + NvFlexSetPhases(solver, phaseBuffer, NULL); // tick NvFlexUpdateSolver(solver, dt, 1, false); // read back (async) - NvFlexGetParticles(particleBuffer, n); - NvFlexGetVelocities(velocityBuffer, n); - NvFlexGetPhases(phaseBuffer, n); + NvFlexGetParticles(solver, particleBuffer, NULL); + NvFlexGetVelocities(solver, velocityBuffer, NULL); + NvFlexGetPhases(solver, phaseBuffer, NULL); } NvFlexFreeBuffer(particleBuffer); @@ -119,9 +124,9 @@ Particles are the fundamental building-block in Flex. For each particle the basi NvFlexBuffer* phaseBuffer = NvFlexAllocBuffer(library, n, sizeof(int), eNvFlexBufferHost); // map buffers for reading / writing - float4* particles = (float4*)NvFlexMap(particles, eNvFlexMapWait); - float3* velocities = (float3*)NvFlexMap(velocities, eNvFlexMapWait); - int* phases = (int*)NvFlexMap(phases, eFlexMapWait); + float4* particles = (float4*)NvFlexMap(particlesBuffer, eNvFlexMapWait); + float3* velocities = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait); + int* phases = (int*)NvFlexMap(phaseBuffer, eFlexMapWait); // spawn particles for (int i=0; i < n; ++i) @@ -137,9 +142,9 @@ Particles are the fundamental building-block in Flex. For each particle the basi NvFlexUnmap(phaseBuffer); // write to device (async) - NvFlexSetParticles(particleBuffer, n); - NvFlexSetVelocities(velocityBuffer, n); - NvFlexSetPhases(phaseBuffer, n); + NvFlexSetParticles(solver, particleBuffer, NULL); + NvFlexSetVelocities(solver, velocityBuffer, NULL); + NvFlexSetPhases(solver, phaseBuffer, NULL); .. _Radius: @@ -187,7 +192,9 @@ The example code below shows how to create an active set which enables simulatio activeIndices[i] = i; NvFlexUnmap(activeBuffer); - NvFlexSetActive(solver, activeBuffer, 10) + + NvFlexSetActive(solver, activeBuffer, NULL) + NvFlexSetActiveCount(solver, 10); **Note:** constraints referencing inactive particles may behave unexpectedly. @@ -581,34 +588,34 @@ Synchronization occurs when you call **NvFlexMap()** on a simulation buffer. To while (!done) { - // map buffers for reading / writing (synchronizes with GPU) - float4* particles = (float4*)NvFlexMap(particleBuffer, eNvFlexMapWait); - float3* velocities = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait); - int* phases = (int*)NvFlexMap(phaseBuffer, eNvFlexMapWait); - - // application CPU-side particle update - UpdateBuffers(particles, velocities, phases); - - // unmap buffers - NvFlexUnmap(particleBuffer); - NvFlexUnmap(velocityBuffer); - NvFlexUnmap(phaseBuffer); - - // write to device (async) - NvFlexSetParticles(particleBuffer, n); - NvFlexSetVelocities(velocityBuffer, n); - NvFlexSetPhases(phaseBuffer, n); - - // tick (async) - NvFlexUpdateSolver(solver, dt, 1, NULL); - - // read back (async) - NvFlexGetParticles(particleBuffer, n); - NvFlexGetVelocities(velocityBuffer, n); - NvFlexGetPhases(phaseBuffer, n); - - // Perform CPU work here while update and transfer are in flight - TickGame() + // map buffers for reading / writing (synchronizes with GPU) + float4* particles = (float4*)NvFlexMap(particleBuffer, eNvFlexMapWait); + float3* velocities = (float3*)NvFlexMap(velocityBuffer, eNvFlexMapWait); + int* phases = (int*)NvFlexMap(phaseBuffer, eNvFlexMapWait); + + // application CPU-side particle update + UpdateBuffers(particles, velocities, phases); + + // unmap buffers + NvFlexUnmap(particleBuffer); + NvFlexUnmap(velocityBuffer); + NvFlexUnmap(phaseBuffer); + + // write to device (async) + NvFlexSetParticles(solver, particleBuffer, NULL); + NvFlexSetVelocities(solver, velocityBuffer, NULL); + NvFlexSetPhases(solver, phaseBuffer, NULL); + + // tick (async) + NvFlexUpdateSolver(solver, dt, 1, NULL); + + // read back (async) + NvFlexGetParticles(solver, particleBuffer, NULL); + NvFlexGetVelocities(solver, velocityBuffer, NULL); + NvFlexGetPhases(solver, phaseBuffer, NULL); + + // Perform CPU work here while update and transfer are in flight + TickGame() } diff --git a/doc/_static/api/_nv_flex_8h.html b/doc/_static/api/_nv_flex_8h.html index 837b040..ca04c36 100644 --- a/doc/_static/api/_nv_flex_8h.html +++ b/doc/_static/api/_nv_flex_8h.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -55,10 +55,14 @@ Data Structures   struct  NvFlexSolverCallbackParams   -struct  NvFlexInitDesc -  struct  NvFlexSolverCallback   +struct  NvFlexInitDesc +  +struct  NvFlexSolverDesc +  +struct  NvFlexCopyDesc +  struct  NvFlexSphereGeometry   struct  NvFlexCapsuleGeometry @@ -98,9 +102,7 @@ Enumerations enum  NvFlexMapFlags {
  eNvFlexMapWait = 0,
-  eNvFlexMapDoNotWait = 1, -
-  eNvFlexMapDiscard = 2 +  eNvFlexMapDoNotWait = 1
}   @@ -119,13 +121,35 @@ Enumerations }   enum  NvFlexPhase {
-  eNvFlexPhaseGroupMask = 0x00ffffff, +  eNvFlexPhaseGroupMask = 0x000fffff, +
+  eNvFlexPhaseFlagsMask = 0x00f00000, +
+  eNvFlexPhaseShapeChannelMask = 0xff000000, +
+  eNvFlexPhaseSelfCollide = 1 << 20, +
+  eNvFlexPhaseSelfCollideFilter = 1 << 21, +
+  eNvFlexPhaseFluid = 1 << 22, +
+  eNvFlexPhaseUnused = 1 << 23, +
+  eNvFlexPhaseShapeChannel0 = 1 << 24, +
+  eNvFlexPhaseShapeChannel1 = 1 << 25, +
+  eNvFlexPhaseShapeChannel2 = 1 << 26, +
+  eNvFlexPhaseShapeChannel3 = 1 << 27,
-  eNvFlexPhaseSelfCollide = 1 << 24, +  eNvFlexPhaseShapeChannel4 = 1 << 28,
-  eNvFlexPhaseSelfCollideFilter = 1 << 25, +  eNvFlexPhaseShapeChannel5 = 1 << 29,
-  eNvFlexPhaseFluid = 1 << 26 +  eNvFlexPhaseShapeChannel6 = 1 << 30, +
+  eNvFlexPhaseShapeChannel7 = 1 << 31
}   @@ -166,6 +190,15 @@ Enumerations
}   +enum  NvFlexFeatureMode {
+  eNvFlexFeatureModeDefault = 0, +
+  eNvFlexFeatureModeSimpleSolids = 1, +
+  eNvFlexFeatureModeSimpleFluids = 2 +
+ } +  enum  NvFlexCollisionShapeType {
  eNvFlexShapeSphere = 0,
@@ -184,9 +217,9 @@ Enumerations enum  NvFlexCollisionShapeFlags {
  eNvFlexShapeFlagTypeMask = 0x7,
-  eNvFlexShapeFlagDynamic = 8, +  eNvFlexShapeFlagDynamic = 0x8,
-  eNvFlexShapeFlagTrigger = 16, +  eNvFlexShapeFlagTrigger = 0x10,
  eNvFlexShapeFlagReserved = 0xffffff00
@@ -195,20 +228,26 @@ Enumerations - - + + + + - - + + + + + + @@ -217,42 +256,44 @@ Functions - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + @@ -271,10 +312,12 @@ Functions - - + + + + @@ -285,20 +328,22 @@ Functions - - - - - - + + + + + + + + - - + + @@ -329,6 +374,8 @@ Functions + +

Functions

NV_FLEX_API int NvFlexMakePhase (int group, int flags)
 
NV_FLEX_API int NvFlexMakePhaseWithChannels (int group, int particleFlags, int shapeChannels)
 
NV_FLEX_API int NvFlexMakePhase (int group, int particleFlags)
 
NV_FLEX_API NvFlexLibraryNvFlexInit (int version=NV_FLEX_VERSION, NvFlexErrorCallback errorFunc=0, NvFlexInitDesc *desc=0)
 
NV_FLEX_API void NvFlexShutdown (NvFlexLibrary *lib)
 
NV_FLEX_API int NvFlexGetVersion ()
 
NV_FLEX_API NvFlexSolverNvFlexCreateSolver (NvFlexLibrary *lib, int maxParticles, int maxDiffuseParticles, int maxNeighborsPerParticle=96)
 
NV_FLEX_API void NvFlexSetSolverDescDefaults (NvFlexSolverDesc *desc)
 
NV_FLEX_API NvFlexSolverNvFlexCreateSolver (NvFlexLibrary *lib, const NvFlexSolverDesc *desc)
 
NV_FLEX_API void NvFlexDestroySolver (NvFlexSolver *solver)
 
NV_FLEX_API NvFlexLibraryNvFlexGetSolverLibrary (NvFlexSolver *solver)
 
NV_FLEX_API void NvFlexGetSolverDesc (NvFlexSolver *solver, NvFlexSolverDesc *desc)
 
NV_FLEX_API NvFlexSolverCallback NvFlexRegisterSolverCallback (NvFlexSolver *solver, NvFlexSolverCallback function, NvFlexSolverCallbackStage stage)
 
NV_FLEX_API void NvFlexUpdateSolver (NvFlexSolver *solver, float dt, int substeps, bool enableTimers)
 
NV_FLEX_API void NvFlexGetParams (NvFlexSolver *solver, NvFlexParams *params)
 
NV_FLEX_API void NvFlexSetActive (NvFlexSolver *solver, NvFlexBuffer *indices, int n)
 
NV_FLEX_API void NvFlexGetActive (NvFlexSolver *solver, NvFlexBuffer *indices)
 
NV_FLEX_API void NvFlexSetActive (NvFlexSolver *solver, NvFlexBuffer *indices, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetActive (NvFlexSolver *solver, NvFlexBuffer *indices, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexSetActiveCount (NvFlexSolver *solver, int n)
 
NV_FLEX_API int NvFlexGetActiveCount (NvFlexSolver *solver)
 
NV_FLEX_API void NvFlexSetParticles (NvFlexSolver *solver, NvFlexBuffer *p, int n)
 
NV_FLEX_API void NvFlexGetParticles (NvFlexSolver *solver, NvFlexBuffer *p, int n)
 
NV_FLEX_API void NvFlexSetRestParticles (NvFlexSolver *solver, NvFlexBuffer *p, int n)
 
NV_FLEX_API void NvFlexGetRestParticles (NvFlexSolver *solver, NvFlexBuffer *p, int n)
 
NV_FLEX_API void NvFlexGetSmoothParticles (NvFlexSolver *solver, NvFlexBuffer *p, int n)
 
NV_FLEX_API void NvFlexSetVelocities (NvFlexSolver *solver, NvFlexBuffer *v, int n)
 
NV_FLEX_API void NvFlexGetVelocities (NvFlexSolver *solver, NvFlexBuffer *v, int n)
 
NV_FLEX_API void NvFlexSetPhases (NvFlexSolver *solver, NvFlexBuffer *phases, int n)
 
NV_FLEX_API void NvFlexGetPhases (NvFlexSolver *solver, NvFlexBuffer *phases, int n)
 
NV_FLEX_API void NvFlexSetNormals (NvFlexSolver *solver, NvFlexBuffer *normals, int n)
 
NV_FLEX_API void NvFlexGetNormals (NvFlexSolver *solver, NvFlexBuffer *normals, int n)
 
NV_FLEX_API void NvFlexSetParticles (NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetParticles (NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexSetRestParticles (NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetRestParticles (NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetSmoothParticles (NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexSetVelocities (NvFlexSolver *solver, NvFlexBuffer *v, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetVelocities (NvFlexSolver *solver, NvFlexBuffer *v, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexSetPhases (NvFlexSolver *solver, NvFlexBuffer *phases, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetPhases (NvFlexSolver *solver, NvFlexBuffer *phases, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexSetNormals (NvFlexSolver *solver, NvFlexBuffer *normals, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetNormals (NvFlexSolver *solver, NvFlexBuffer *normals, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexSetSprings (NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
 
NV_FLEX_API void NvFlexGetSprings (NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
 
NV_FLEX_API void NvFlexSetRigids (NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *rotations, NvFlexBuffer *translations, int numRigids, int numIndices)
 
NV_FLEX_API void NvFlexGetRigidTransforms (NvFlexSolver *solver, NvFlexBuffer *rotations, NvFlexBuffer *translations)
 
NV_FLEX_API void NvFlexSetRigids (NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *thresholds, NvFlexBuffer *creeps, NvFlexBuffer *rotations, NvFlexBuffer *translations, int numRigids, int numIndices)
 
NV_FLEX_API void NvFlexGetRigids (NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *thresholds, NvFlexBuffer *creeps, NvFlexBuffer *rotations, NvFlexBuffer *translations)
 
NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh (NvFlexLibrary *lib)
 
NV_FLEX_API void NvFlexDestroyTriangleMesh (NvFlexLibrary *lib, NvFlexTriangleMeshId mesh)
 
NV_FLEX_API void NvFlexDestroyConvexMesh (NvFlexLibrary *lib, NvFlexConvexMeshId convex)
 
NV_FLEX_API void NvFlexUpdateConvexMesh (NvFlexLibrary *lib, NvFlexConvexMeshId convex, NvFlexBuffer *planes, int numPlanes, float *lower, float *upper)
 
NV_FLEX_API void NvFlexUpdateConvexMesh (NvFlexLibrary *lib, NvFlexConvexMeshId convex, NvFlexBuffer *planes, int numPlanes, const float *lower, const float *upper)
 
NV_FLEX_API void NvFlexGetConvexMeshBounds (NvFlexLibrary *lib, NvFlexConvexMeshId mesh, float *lower, float *upper)
 
NV_FLEX_API int NvFlexMakeShapeFlagsWithChannels (NvFlexCollisionShapeType type, bool dynamic, int shapeChannels)
 
NV_FLEX_API int NvFlexMakeShapeFlags (NvFlexCollisionShapeType type, bool dynamic)
 
NV_FLEX_API void NvFlexSetShapes (NvFlexSolver *solver, NvFlexBuffer *geometry, NvFlexBuffer *shapePositions, NvFlexBuffer *shapeRotations, NvFlexBuffer *shapePrevPositions, NvFlexBuffer *shapePrevRotations, NvFlexBuffer *shapeFlags, int numShapes)
 
NV_FLEX_API void NvFlexSetInflatables (NvFlexSolver *solver, NvFlexBuffer *startTris, NvFlexBuffer *numTris, NvFlexBuffer *restVolumes, NvFlexBuffer *overPressures, NvFlexBuffer *constraintScales, int numInflatables)
 
NV_FLEX_API void NvFlexGetDensities (NvFlexSolver *solver, NvFlexBuffer *densities, int n)
 
NV_FLEX_API void NvFlexGetAnisotropy (NvFlexSolver *solver, NvFlexBuffer *q1, NvFlexBuffer *q2, NvFlexBuffer *q3)
 
NV_FLEX_API int NvFlexGetDiffuseParticles (NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, NvFlexBuffer *indices)
 
NV_FLEX_API void NvFlexGetDensities (NvFlexSolver *solver, NvFlexBuffer *densities, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetAnisotropy (NvFlexSolver *solver, NvFlexBuffer *q1, NvFlexBuffer *q2, NvFlexBuffer *q3, const NvFlexCopyDesc *desc)
 
NV_FLEX_API void NvFlexGetDiffuseParticles (NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, NvFlexBuffer *count)
 
NV_FLEX_API void NvFlexSetDiffuseParticles (NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, int n)
 
NV_FLEX_API void NvFlexGetContacts (NvFlexSolver *solver, NvFlexBuffer *planes, NvFlexBuffer *velocities, NvFlexBuffer *indices, NvFlexBuffer *counts)
 
NV_FLEX_API void NvFlexGetNeighbors (NvFlexSolver *solver, NvFlexBuffer *neighbors, NvFlexBuffer *counts, NvFlexBuffer *remap)
 
NV_FLEX_API void NvFlexGetBounds (NvFlexSolver *solver, NvFlexBuffer *lower, NvFlexBuffer *upper)
 
NV_FLEX_API float NvFlexGetDeviceLatency (NvFlexSolver *solver)
 
NV_FLEX_API float NvFlexGetDeviceLatency (NvFlexSolver *solver, unsigned long long *begin, unsigned long long *end, unsigned long long *frequency)
 
NV_FLEX_API void NvFlexGetTimers (NvFlexSolver *solver, NvFlexTimers *timers)
 
NV_FLEX_API int NvFlexGetDetailTimers (NvFlexSolver *solver, NvFlexDetailTimer **timers)
 
NV_FLEX_API void NvFlexFlush (NvFlexLibrary *lib)
 
NV_FLEX_API void NvFlexWait (NvFlexLibrary *lib)
 

Detailed Description

The main include file for the core Flex solver.

@@ -460,12 +507,6 @@ lift Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in the direction perpendicular to velocity and (if possible), parallel to the plane normal. -bool - -fluid - -If true then particles with phase 0 are considered fluid particles and interact using the position based fluids method. - float cohesion @@ -494,7 +535,7 @@ Increases vorticity by applying rotational forces to particles. anisotropyScale -Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy will not be calculated, see NvFlexGetAnisotropy() +Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy will not be calculated, see NvFlexGetAnisotropy() float @@ -512,7 +553,7 @@ Clamp the anisotropy scale to this fraction of the radius. smoothing -Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positions will not be calculated, see NvFlexGetSmoothParticles() +Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positions will not be calculated, see NvFlexGetSmoothParticles() float @@ -556,30 +597,12 @@ diffuseBallistic The number of neighbors below which a diffuse particle is considered ballistic. -float - -diffuseSortAxis[3] - -Diffuse particles will be sorted by depth along this axis if non-zero. - float diffuseLifetime Time in seconds that a diffuse particle will live for after being spawned, particles will be spawned with a random lifetime in the range [0, diffuseLifetime]. -float - -plasticThreshold - -Particles belonging to rigid shapes that move with a position delta magnitude > threshold will be permanently deformed in the rest pose. - -float - -plasticCreep - -Controls the rate at which particles in the rest pose are deformed for particles passing the deformation threshold. - float collisionDistance @@ -895,8 +918,20 @@ Direct3D device to use for simulation, if none is specified a new device and con renderContext +Direct3D context that the app is using for rendering. In DirectX 12 this should be a ID3D12CommandQueue pointer. + +void * + +computeContext + Direct3D context to use for simulation, if none is specified a new context will be created, in DirectX 12 this should be a pointer to the ID3D12CommandQueue where compute operations will take place. +bool + +useComputeQueue + +If true, run Flex on a D3D12 compute queue, or vendor specific D3D11 compute queue. This allows compute and graphics to run in parallel on some GPUs. + NvFlexComputeType computeType @@ -904,6 +939,80 @@ computeType Set to eNvFlexD3D11 if DirectX 11 should be used, eNvFlexD3D12 for DirectX 12, this must match the libraries used to link the application. +
+ + +
+
+ + + + +
struct NvFlexSolverDesc
+
+

Describes the creation time parameters for the solver

+
+ + + + + + + + + + + + + +
Data Fields
+NvFlexFeatureMode +featureMode +Control which features are enabled.
+int +maxParticles +Maximum number of regular particles in the solver.
+int +maxDiffuseParticles +Maximum number of diffuse particles in the solver.
+int +maxNeighborsPerParticle +Maximum number of neighbors per-particle, for solids this can be around 32, for fluids up to 128 may be necessary depending on smoothing radius.
+ +
+
+ +
+
+ + + + +
struct NvFlexCopyDesc
+
+

Describes a source and destination buffer region for performing a copy operation.

+
+ + + + + + + + + + +
Data Fields
+int +srcOffset +
+int +dstOffset +
+int +elementCount +
+
@@ -1252,9 +1361,6 @@ time eNvFlexMapDoNotWait 

Calling thread will check if buffer is ready for access, if not ready then the method will return NULL immediately.

-eNvFlexMapDiscard  -

Buffer contents will be discarded, this allows for efficent buffer reuse.

- @@ -1271,10 +1377,10 @@ time

Controls memory space of a NvFlexBuffer, see NvFlexAllocBuffer()

Enumerator
eNvFlexBufferHost  -

Host mappable buffer, pinned memory on CUDA, staging buffer on DX.

+

A host mappable buffer, pinned memory on CUDA, staging buffer on DX.

eNvFlexBufferDevice  -

Device memory buffer, mapping this on CUDA will return a device memory pointer, and will return a buffer pointer on DX.

+

A device memory buffer, mapping this on CUDA will return a device memory pointer, and will return a buffer pointer on DX.

@@ -1310,20 +1416,53 @@ time
-

Flags that control the a particle's behavior and grouping, use NvFlexMakePhase() to construct a valid 32bit phase identifier

+

Flags that control a particle's behavior and grouping, use NvFlexMakePhase() to construct a valid 32bit phase identifier

+ + + + + + + + + + +
Enumerator
eNvFlexPhaseGroupMask  -

Low 24 bits represent the particle group for controlling collisions.

+

Bits [ 0, 19] represent the particle group for controlling collisions.

+
eNvFlexPhaseFlagsMask  +

Bits [20, 23] hold flags about how the particle behave.

+
eNvFlexPhaseShapeChannelMask  +

Bits [24, 31] hold flags representing what shape collision channels particles will collide with, see NvFlexMakeShapeFlags()

eNvFlexPhaseSelfCollide 

If set this particle will interact with particles of the same group.

eNvFlexPhaseSelfCollideFilter  -

If set this particle will ignore collisions with particles closer than the radius in the rest pose, this flag should not be specified unless valid rest positions have been specified using NvFlexSetRestParticles()

+

If set this particle will ignore collisions with particles closer than the radius in the rest pose, this flag should not be specified unless valid rest positions have been specified using NvFlexSetRestParticles()

eNvFlexPhaseFluid 

If set this particle will generate fluid density constraints for its overlapping neighbors.

eNvFlexPhaseUnused  +

Reserved.

+
eNvFlexPhaseShapeChannel0  +

Particle will collide with shapes with channel 0 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel1  +

Particle will collide with shapes with channel 1 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel2  +

Particle will collide with shapes with channel 2 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel3  +

Particle will collide with shapes with channel 3 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel4  +

Particle will collide with shapes with channel 4 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel5  +

Particle will collide with shapes with channel 5 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel6  +

Particle will collide with shapes with channel 6 set (see NvFlexMakeShapeFlags())

+
eNvFlexPhaseShapeChannel7  +

Particle will collide with shapes with channel 7 set (see NvFlexMakeShapeFlags())

+
@@ -1400,7 +1539,7 @@ time
-

Defines the different DirectX compute modes that Flex can use

+

Defines the different compute backends that Flex can use

Enumerator
eNvFlexCUDA 

Use CUDA compute for Flex, the application must link against the CUDA libraries.

@@ -1413,6 +1552,30 @@ time
+
+ + +
+
+ + + + +
enum NvFlexFeatureMode
+
+

Controls which features are enabled, choosing a simple option will disable features and can lead to better performance and reduced memory usage

+ + + + +
Enumerator
eNvFlexFeatureModeDefault  +

All features enabled.

+
eNvFlexFeatureModeSimpleSolids  +

Simple per-particle collision (no per-particle SDF normals, no fluids)

+
eNvFlexFeatureModeSimpleFluids  +

Simple single phase fluid-only particles (no solids)

+
+
@@ -1458,7 +1621,7 @@ time

Function Documentation

- + +
+
+
Enumerator
eNvFlexShapeFlagTypeMask  -

Lower 3 bits holds the type of the collision shape.

+

Lower 3 bits holds the type of the collision shape given by the NvFlexCollisionShapeType enum.

eNvFlexShapeFlagDynamic 

Indicates the shape is dynamic and should have lower priority over static collision shapes.

@@ -1473,7 +1636,56 @@ time
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
NV_FLEX_API int NvFlexMakePhaseWithChannels (int group,
int particleFlags,
int shapeChannels 
)
+
+inline
+
+

Generate a bit set for the particle phase, this is a helper method to simply combine the group id and bit flags into a single integer.

+
Parameters
+ + + + +
[in]groupThe index of the group for this particle, should be an integer < 2^20
[in]particleFlagsA combination of the phase flags which should be a combination of eNvFlexPhaseSelfCollide, eNvFlexPhaseSelfCollideFilter, and eNvFlexPhaseFluid
[in]shapeChannelsA combination of eNvFlexPhaseShapeChannel* flags that control which shapes will be collided against, particles will only collide against shapes that share at least one set channel, see NvFlexMakeShapeFlagsWithChannels()
+
+
+ +
+ +
@@ -1490,7 +1702,7 @@ time - + @@ -1504,7 +1716,7 @@ time
int flags particleFlags 
-

Generate a bit set for the particle phase, the group should be an integer < 2^24, and the flags should be a combination of FlexPhase enum values

+

Deprecated helper method to generates a phase with all shape channels set

@@ -1589,33 +1801,43 @@ time - +
- + - - - - - + + - - +
NV_FLEX_API NvFlexSolver* NvFlexCreateSolver NV_FLEX_API void NvFlexSetSolverDescDefaults (NvFlexLibrarylib,
NvFlexSolverDescdesc) int maxParticles,
+
+

Initialize the solver desc to its default values

Parameters
+ + +
[in]descPointer to a description structure that will be initialized to default values
+
+
+ +
+
+ +
+
+ - - - - + + + + - - + + @@ -1628,9 +1850,7 @@ time
Parameters
int maxDiffuseParticles, NV_FLEX_API NvFlexSolver* NvFlexCreateSolver (NvFlexLibrarylib,
int maxNeighborsPerParticle = 96 const NvFlexSolverDescdesc 
- - - +
[in]libThe library instance to use
[in]maxParticlesMaximum number of simulation particles possible for this solver
[in]maxDiffuseParticlesMaximum number of diffuse (non-simulation) particles possible for this solver
[in]maxNeighborsPerParticleMaximum number of neighbors per particle possible for this solver
[in]descPointer to a solver description structure used to create the solver
@@ -1653,7 +1873,7 @@ time

Delete a particle solver

Parameters
- +
[in]solverA valid solver pointer created from NvFlexCreateSolver()
[in]solverA valid solver pointer created from NvFlexCreateSolver()
@@ -1676,12 +1896,46 @@ time

Return the library associated with a solver

Parameters
- +
[in]solverA valid solver created with NvFlexCreateSolver()
[in]solverA valid solver created with NvFlexCreateSolver()
Returns
A library pointer
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
NV_FLEX_API void NvFlexGetSolverDesc (NvFlexSolversolver,
NvFlexSolverDescdesc 
)
+
+

Return the solver desc that was used to create a solver

+
Parameters
+ + + +
[in]solverPointer to a valid Flex solver
[in]descPointer to a desc structure
+
+
+
@@ -1763,7 +2017,7 @@ time

Integrate particle solver forward in time. Below is an example of how to step Flex in the context of a simple game loop:

-
NvFlexSolver* solver = NvFlexCreateSolver(library);
+
NvFlexSolver* solver = NvFlexCreateSolver(library);
NvFlexBuffer* particleBuffer = NvFlexAllocBuffer(library, n, sizeof(Vec4), eNvFlexBufferHost);
NvFlexBuffer* velocityBuffer = NvFlexAllocBuffer(library, n, sizeof(Vec4), eNvFlexBufferHost);
@@ -1788,17 +2042,17 @@ time
NvFlexUnmap(phaseBuffer);
// write to device (async)
-
NvFlexSetParticles(particleBuffer, n);
-
NvFlexSetVelocities(velocityBuffer, n);
-
NvFlexSetPhases(phaseBuffer, n);
+
NvFlexSetParticles(particleBuffer, n);
+
NvFlexSetVelocities(velocityBuffer, n);
+
NvFlexSetPhases(phaseBuffer, n);
// tick
NvFlexUpdateSolver(solver, dt, 1, NULL);
// read back (async)
-
NvFlexGetParticles(particleBuffer, n);
-
NvFlexGetVelocities(velocityBuffer, n);
-
NvFlexGetPhases(phaseBuffer, n);
+
NvFlexGetParticles(particleBuffer, n);
+
NvFlexGetVelocities(velocityBuffer, n);
+
NvFlexGetPhases(phaseBuffer, n);
}
NvFlexFreeBuffer(particleBuffer);
@@ -1887,7 +2141,7 @@ time
- +
@@ -1906,8 +2160,8 @@ time - - + + @@ -1921,14 +2175,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]indicesHolds the indices of particles that have been made active
[in]nNumber of particles to allocate
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -1942,7 +2196,13 @@ time - + + + + + + + @@ -1956,6 +2216,41 @@ time
NvFlexBufferindices indices,
const NvFlexCopyDescdesc 
+ +
[in]solverA valid solver
[out]indicesa buffer of indices at least activeCount in length
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
+ + + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
NV_FLEX_API void NvFlexSetActiveCount (NvFlexSolversolver,
int n 
)
+
+

Set the total number of active particles

+
Parameters
+ + +
[in]solverA valid solver
[in]nThe number of active particles, the first n indices in the active particles array will be used as the active count
@@ -1986,7 +2281,7 @@ time
- +
@@ -2005,8 +2300,8 @@ time - - + + @@ -2020,14 +2315,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]pPointer to a buffer of particle data, should be 4*n in length
[in]nThe number of particles to set
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2046,8 +2341,8 @@ time - - + + @@ -2061,14 +2356,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[out]pPointer to a buffer of 4*n floats that will be filled out with the particle data, can be either a host or device pointer
[in]nThe number of particles to get, must be less than max particles passed to NvFlexCreateSolver
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2087,8 +2382,8 @@ time - - + + @@ -2102,14 +2397,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]pPointer to a buffer of particle data, should be 4*n in length
[in]nThe number of particles to set
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2128,8 +2423,8 @@ time - - + + @@ -2143,14 +2438,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]pPointer to a buffer of particle data, should be 4*n in length
[in]nThe number of particles to set
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2169,8 +2464,8 @@ time - - + + @@ -2184,14 +2479,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[out]pPointer to a buffer of 4*n floats that will be filled out with the data, can be either a host or device pointer
[in]nThe number of smooth particles to return
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2210,8 +2505,8 @@ time - - + + @@ -2225,14 +2520,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]vPointer to a buffer of 3*n floats
[in]nThe number of velocities to set
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2251,8 +2546,8 @@ time - - + + @@ -2266,14 +2561,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[out]vPointer to a buffer of 3*n floats that will be filled out with the data, can be either a host or device pointer
[in]nThe number of velocities to get
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2292,8 +2587,8 @@ time - - + + @@ -2309,14 +2604,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]phasesPointer to a buffer of n integers containing the phases
[in]nThe number of phases to set
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2335,8 +2630,8 @@ time - - + + @@ -2350,14 +2645,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[out]phasesPointer to a buffer of n integers that will be filled with the phase data, can be either a host or device pointer
[in]nThe number of phases to get
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2376,8 +2671,8 @@ time - - + + @@ -2391,14 +2686,14 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]normalsPointer to a buffer of normals, should be 4*n in length
[in]nThe number of normals to set
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
- +
@@ -2417,8 +2712,8 @@ time - - + + @@ -2432,7 +2727,7 @@ time
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[out]normalsPointer to a buffer of normals, should be 4*n in length
[in]nThe number of normals to get
[in]descDescribes the copy region, if NULL the solver will try to access the entire buffer (maxParticles length)
@@ -2549,7 +2844,7 @@ time
- +
@@ -2589,6 +2884,18 @@ time + + + + + + + + + + + + @@ -2629,6 +2936,8 @@ time + + @@ -2639,16 +2948,58 @@ time - +
NvFlexBuffer stiffness,
NvFlexBufferthresholds,
NvFlexBuffercreeps,
[in]restPositionsPointer to a buffer of local space positions relative to the rigid's center of mass (average position), this should be at least 3*numIndices in length in the format x,y,z
[in]restNormalsPointer to a buffer of local space normals, this should be at least 4*numIndices in length in the format x,y,z,w where w is the (negative) signed distance of the particle inside its shape
[in]stiffnessPointer to a buffer of rigid stiffness coefficents, should be numRigids in length, valid values in range [0, 1]
[in]thresholdsPointer to a buffer of plastic deformation threshold coefficients, should be numRigids in length
[in]creepsPointer to a buffer of plastic deformation creep coefficients, should be numRigids in length, valid values in range [0, 1]
[in]rotationsPointer to a buffer of quaternions (4*numRigids in length)
[in]translationsPointer to a buffer of translations of the center of mass (3*numRigids in length)
[in]numRigidsThe number of rigid bodies to set
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2668,12 +3019,19 @@ time
NV_FLEX_API void NvFlexGetRigidTransforms NV_FLEX_API void NvFlexGetRigids ( NvFlexSolver solver,
NvFlexBufferoffsets,
NvFlexBufferindices,
NvFlexBufferrestPositions,
NvFlexBufferrestNormals,
NvFlexBufferstiffness,
NvFlexBufferthresholds,
NvFlexBuffercreeps,
-

Get the rotation matrices for the rigid bodies in the solver

+

Retrive the rigid body shape matching constraints and transforms, if any buffer pointers are NULL then they will be ignored This method supersedes the previous NvFlexGetRigidTransforms method and can be used to retrieve modified rest positions from plastic deformation.

Parameters
- - + + + + + + + + +
[in]solverA valid solver
[out]rotationsPointer to a buffer of quaternions, should be 4*numRigids floats in length
[out]translationsPointer to a buffer of vectors to hold the rigid translations, should be 3*numRigids floats in length
[in]offsetsPointer to a buffer of start offsets for a rigid in the indices array, should be numRigids+1 in length, the first entry must be 0
[in]indicesPointer to a buffer of indices for the rigid bodies, the indices for the jth rigid body start at indices[offsets[j]] and run to indices[offsets[j+1]] exclusive
[in]restPositionsPointer to a buffer of local space positions relative to the rigid's center of mass (average position), this should be at least 3*numIndices in length in the format x,y,z
[in]restNormalsPointer to a buffer of local space normals, this should be at least 4*numIndices in length in the format x,y,z,w where w is the (negative) signed distance of the particle inside its shape
[in]stiffnessPointer to a buffer of rigid stiffness coefficents, should be numRigids in length, valid values in range [0, 1]
[in]thresholdsPointer to a buffer of plastic deformation threshold coefficients, should be numRigids in length
[in]creepsPointer to a buffer of plastic deformation creep coefficients, should be numRigids in length, valid values in range [0, 1]
[in]rotationsPointer to a buffer of quaternions (4*numRigids in length with the imaginary elements in the x,y,z components)
[in]translationsPointer to a buffer of translations of the center of mass (3*numRigids in length)
@@ -2995,7 +3353,7 @@ time
-

Create a convex mesh collision shapes, see NvFlexConvexMeshId for details.

+

Create a convex mesh collision shape, see NvFlexConvexMeshId for details.

Parameters
@@ -3040,7 +3398,7 @@ time - +
[in]libThe library instance to use
@@ -3071,13 +3429,13 @@ time - + - + @@ -3093,7 +3451,7 @@ time - +
float * const float *  lower,
float * const float *  upper 
[in]libThe library instance to use
[in]convexA valid convex mesh shape created from NvFlexCreateConvexMesh()
[in]planesAn array of planes, each plane consists of 4 floats in the form a*x + b*y + c*z + d = 0
[in]numPlanesThe number of planes in the convex
[in]numPlanesThe number of planes in the convex, must be less than 64 planes per-convex
[in]lowerThe local space lower bound of the convex shape
[in]upperThe local space upper bound of the convex shape
@@ -3137,7 +3495,7 @@ time
-

Retrieve the local space bounds of the mesh, these are the same values specified to NvFlexUpdateConvexMesh()

+

Retrieve the local space bounds of the mesh, these are the same values specified to NvFlexUpdateConvexMesh()

Parameters
@@ -3148,6 +3506,55 @@ time + + + +
+
+
[in]libThe library instance to use
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
NV_FLEX_API int NvFlexMakeShapeFlagsWithChannels (NvFlexCollisionShapeType type,
bool dynamic,
int shapeChannels 
)
+
+inline
+
+

Helper function to combine shape type, flags, and phase/shape collision channels into a 32bit value

+
Parameters
+ + + + +
[in]typeThe type of the shape, see NvFlexCollisionShapeType
[in]dynamicSee eNvFlexShapeFlagDynamic
[in]shapeChannelsA combination of the eNvFlexPhaseShapeChannel* flags, collisions will only be processed between a particle and a shape if a channel is set on both the particle and shape, see NvFlexMakePhaseWithChannels()
+
+
+
@@ -3181,7 +3588,7 @@ time
-

Combines geometry type and static/dynamic flags

+

Deprecrated helper method that creates shape flags that by default have all collision channels enabled

@@ -3426,7 +3833,7 @@ time - +
@@ -3445,8 +3852,8 @@ time - - + + @@ -3459,15 +3866,15 @@ time
Parameters
int n const NvFlexCopyDescdesc 
- +
[in]solverA valid solver
[in]nThe number of particle densities to return
[out]densitiesPointer to a buffer of floats, should be maxParticles in length, density values are normalized between [0, 1] where 1 represents the rest density
[in]descPointer to a descriptor specifying the contents to read back
- +
@@ -3493,7 +3900,13 @@ time - + + + + + + + @@ -3510,18 +3923,19 @@ time +
NvFlexBufferq3 q3,
const NvFlexCopyDescdesc 
[out]q1Pointer to a buffer of floats that receive the first basis vector and scale, should be 4*maxParticles in length
[out]q2Pointer to a buffer of floats that receive the second basis vector and scale, should be 4*maxParticles in length
[out]q3Pointer to a buffer of floats that receive the third basis vector and scale, should be 4*maxParticles in length
[in]descPointer to a descriptor specifying the contents to read back
- +
- + @@ -3542,7 +3956,7 @@ time - + @@ -3557,7 +3971,7 @@ time - +
NV_FLEX_API int NvFlexGetDiffuseParticles NV_FLEX_API void NvFlexGetDiffuseParticles ( NvFlexSolver solver, NvFlexBufferindices count 
[in]solverA valid solver
[out]pPointer to a buffer of floats, should be 4*maxParticles in length, the w component represents the particles lifetime with 1 representing a new particle, and 0 representing an inactive particle
[out]vPointer to a buffer of floats, should be 4*maxParticles in length, the w component is not used
[out]indicesPointer to a buffer of ints that specify particle indices in depth sorted order, should be maxParticles in length, see NvFlexParams::mDiffuseSortDir
[out]countPointer to a buffer of a single int that holds the current particle count (this may be updated by the GPU which is why it is passed back in a buffer)
@@ -3605,7 +4019,7 @@ time [in]solverA valid solver [in]pPointer to a buffer of floats, should be 4*n in length, the w component represents the particles lifetime with 1 representing a new particle, and 0 representing an inactive particle [in]vPointer to a buffer of floats, should be 4*n in length, the w component is not used - [in]nNumber of diffuse particles to set + [in]nThe number of active diffuse particles @@ -3657,13 +4071,90 @@ time
Parameters
- - - - + + + + +
[in]solverA valid solver
[out]planesPointer to a destination buffer containing the contact planes for the particle, each particle can have up to 4 contact planes so this buffer should be 16*maxParticles in length
[out]velocitiesPointer to a destination buffer containing the velocity of the contact point on the shape in world space, the index of the shape (corresponding to the shape in NvFlexSetShapes() is stored in the w component), each particle can have up to 4 contact planes so this buffer should be 16*maxParticles in length
[out]indicesPointer to a buffer of indices into the contacts buffer, the first contact plane for the i'th particle is given by planes[indices[i]*sizeof(float)*4] and subsequent contacts for that particle are stored sequentially, this array should be maxParticles in length
[out]countsPointer to a buffer of contact counts for each particle (will be <= 4), this buffer should be maxParticles in length
[out]planesPointer to a destination buffer containing the contact planes for the particle, each particle can have up to 6 contact planes so this buffer should be 4*6*maxParticles floats in length
[out]velocitiesPointer to a destination buffer containing the velocity of the contact point on the shape in world space, the index of the shape (corresponding to the shape in NvFlexSetShapes() is stored in the w component), each particle can have up to 6 contact planes so this buffer should be 4*6*maxParticles floats in length
[out]indicesPointer to a buffer of indices into the contacts buffer, the first contact plane for the i'th particle is given by planes[indices[i]*sizeof(float)*4*6] and subsequent contact planes for that particle are stored sequentially, this array should be maxParticles in length
[out]countsPointer to a buffer of contact counts for each particle (will be <= 6), this buffer should be maxParticles in length
+
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NV_FLEX_API void NvFlexGetNeighbors (NvFlexSolversolver,
NvFlexBufferneighbors,
NvFlexBuffercounts,
NvFlexBufferremap 
)
+
+

Get the particle neighbor lists, these are stored in a strided format, and can be iterated in the following manner:

+
NvFlexGetNeighbors(solver, neighborsBuffer, countsBuffer, indicesBuffer);
+
+
int* neighbors = (int*)NvFlexMap(neighborsBuffer, 0);
+
int* counts = (int*)NvFlexMap(countsBuffer, 0);
+
int* remap = (int*)NvFlexMap(remapBuffer, 0);
+
+
// neighbors are stored in a strided format so that the first neighbor
+
// of each particle is stored sequentially, then the second, and so on
+
+
int stride = maxParticles;
+
+
for (int i=0; i < maxParticles; ++i)
+
{
+
// find offset in the neighbors buffer
+
int offset = remap[i];
+
int count = counts[offset];
+
+
for (int c=0; c < count; ++c)
+
{
+
int neighbor = remap[neighbors[c*stride + offset]];
+
+
printf("Particle %d's neighbor %d is particle %d\n", i, c, neighbor);
+
}
+
}
+
+
NvFlexUnmap(neighborsBuffer);
+
NvFlexUnmap(countsBuffer);
+
NvFlexUnmap(remapBuffer);
+
Parameters
+ + + + +
[in]solverA valid solver
[out]neighborsPointer to a destination buffer containing the the neighbors for all particles, this should be maxParticles*maxParticleNeighbors ints (passed to NvFlexInit() in length)
[out]countsPointer to a buffer of neighbor counts per-particle, should be maxParticles ints in length
[out]remapPointer to a buffer of indices, because Flex internally re-orders particles these are used to map from an API particle index to it internal index
+
Note
Neighbors are only valid after a call to NvFlexUpdateSolver() has completed, the returned neighbors correspond to the last substep of the last update
@@ -3708,7 +4199,7 @@ time - +
@@ -3716,14 +4207,39 @@ time - + + + + + + + + + + + + + + + + + + + + + + +
NV_FLEX_API float NvFlexGetDeviceLatency ( NvFlexSolversolver)solver,
unsigned long long * begin,
unsigned long long * end,
unsigned long long * frequency 
)
Parameters
+ + +
[in]solverA valid solver
[out]beginOptional pointer to a 64 bit unsigned to receive the value of the GPU clock when Flex update began (in cycles)
[out]endOptional pointer to a 64 bit unsigned to receive the value of the GPU clock when Flex update ended (in cycles)
[out]frequencyOptional pointer to a 64 bit unsigned to receive the frequency of the clock used to measure begin and end
@@ -3898,7 +4414,7 @@ time
-

Maps a buffer for reading and writing. When the buffer is created with NvFlexBufferType::eHost, then the returned pointer will be a host memory address that can be read/written. Mapping a buffer implicitly synchronizes with the GPU to ensure that any reads or writes from the buffer (e.g.: from the NvFlexGet*() or NvFlexSet*()) methods have completed.

+

Maps a buffer for reading and writing. When the buffer is created with NvFlexBufferType::eHost, then the returned pointer will be a host memory address that can be read/written. Mapping a buffer implicitly synchronizes with the GPU to ensure that any reads or writes from the buffer (e.g.: from the NvFlexGet*() or NvFlexSet*() methods) have completed.

Parameters
@@ -3980,7 +4496,7 @@ time
...
// copy directly from Flex into render buffer
-
NvFlexGetParticles(vboBuffer, n);
+
NvFlexGetParticles(vboBuffer, n);
// render
...
@@ -4217,12 +4733,28 @@ time + + + +
+
+
[in]bufferA buffer allocated with NvFlexAllocBuffer()
+ + + + + + + +
NV_FLEX_API void NvFlexWait (NvFlexLibrarylib)
+
+
diff --git a/doc/_static/api/_nv_flex_8h_source.html b/doc/_static/api/_nv_flex_8h_source.html index 434a362..c4cd011 100644 --- a/doc/_static/api/_nv_flex_8h_source.html +++ b/doc/_static/api/_nv_flex_8h_source.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -76,7 +76,7 @@
36 #endif
37 
38 // least 2 significant digits define minor version, eg: 10 -> version 0.10
-
39 #define NV_FLEX_VERSION 110
+
39 #define NV_FLEX_VERSION 120
40 
42 
47 extern "C" {
@@ -91,644 +91,725 @@
68 {
- -
72 };
-
73 
- -
78 {
- - -
81 };
-
82 
- -
87 {
- - -
90 };
+
71 };
+
72 
+ +
77 {
+ + +
80 };
+
81 
+ +
86 {
+ + +
89 };
+
90 
91 
-
92 
- -
97 {
- -
99 
-
100  float gravity[3];
-
101  float radius;
- - -
104 
-
105  // common params
- - - -
109  float restitution;
-
110  float adhesion;
- -
112 
-
113  float maxSpeed;
- -
115 
- -
117  float dissipation;
-
118  float damping;
-
119 
-
120  // cloth params
-
121  float wind[3];
-
122  float drag;
-
123  float lift;
-
124 
-
125  // fluid params
-
126  bool fluid;
-
127  float cohesion;
- -
129  float viscosity;
- - - - -
134  float smoothing;
- - -
137  float buoyancy;
-
138 
-
139  // diffuse params
- - -
142  float diffuseDrag;
- -
144  float diffuseSortAxis[3];
- -
146 
-
147  // rigid params
- -
149  float plasticCreep;
-
150 
-
151  // collision params
- - - + +
96 {
+ +
98 
+
99  float gravity[3];
+
100  float radius;
+ + +
103 
+
104  // common params
+ + + +
108  float restitution;
+
109  float adhesion;
+ +
111 
+
112  float maxSpeed;
+ +
114 
+ +
116  float dissipation;
+
117  float damping;
+
118 
+
119  // cloth params
+
120  float wind[3];
+
121  float drag;
+
122  float lift;
+
123 
+
124  // fluid params
+
125  float cohesion;
+ +
127  float viscosity;
+ + + + +
132  float smoothing;
+ + +
135  float buoyancy;
+
136 
+
137  // diffuse params
+ + +
140  float diffuseDrag;
+ + +
143 
+
144  // collision params
+ + + +
148 
+
149  float planes[8][4];
+
150  int numPlanes;
+
151 
+ + +
154 };
155 
-
156  float planes[8][4];
-
157  int numPlanes;
-
158 
- - -
161 };
-
162 
- -
167 {
-
168  eNvFlexPhaseGroupMask = 0x00ffffff,
-
169 
- - -
172  eNvFlexPhaseFluid = 1 << 26,
-
173 };
-
174 
-
178 NV_FLEX_API inline int NvFlexMakePhase(int group, int flags) { return (group & eNvFlexPhaseGroupMask) | flags; }
-
179 
+
156 
+ +
161 {
+
162  eNvFlexPhaseGroupMask = 0x000fffff,
+
163  eNvFlexPhaseFlagsMask = 0x00f00000,
+ +
165 
+ + +
168  eNvFlexPhaseFluid = 1 << 22,
+
169  eNvFlexPhaseUnused = 1 << 23,
+
170 
+ + + + + + + + +
179 };
180 
- -
185 {
-
186  float predict;
- - -
189  float createGrid;
-
190  float reorder;
- - - - - - - -
198  float solveShapes;
-
199  float solveSprings;
- - -
202  float applyDeltas;
- - - - -
207  float finalize;
-
208  float updateBounds;
-
209  float total;
-
210 };
-
211 
- -
216 {
- - - - - -
222 };
-
223 
-
224 
- -
228 {
- - - - - - -
235 };
-
236 
- -
240 {
- - - -
244 };
-
245 
- -
259 {
- -
261  void* userData;
-
262 
-
263  float* particles;
-
264  float* velocities;
-
265  int* phases;
-
266 
-
267  int numActive;
-
268 
-
269  float dt;
-
270 
-
271  const int* originalToSortedMap;
-
272  const int* sortedToOriginalMap;
-
273 };
-
274 
- -
278 {
- - -
281  void* renderDevice;
- -
283 
- -
285 };
-
286 
- -
290 {
-
292  void* userData;
-
293 
-
295  void (*function)(NvFlexSolverCallbackParams params);
-
296 };
-
297 
-
301 typedef void (*NvFlexErrorCallback)(NvFlexErrorSeverity type, const char* msg, const char* file, int line);
+
181 
+
190 NV_FLEX_API inline int NvFlexMakePhaseWithChannels(int group, int particleFlags, int shapeChannels) { return (group & eNvFlexPhaseGroupMask) | (particleFlags & eNvFlexPhaseFlagsMask) | (shapeChannels & eNvFlexPhaseShapeChannelMask); }
+
191 
+
195 NV_FLEX_API inline int NvFlexMakePhase(int group, int particleFlags) { return NvFlexMakePhaseWithChannels(group, particleFlags, eNvFlexPhaseShapeChannelMask); }
+
196 
+
197 
+ +
202 {
+
203  float predict;
+ + +
206  float createGrid;
+
207  float reorder;
+ + + + + + + +
215  float solveShapes;
+
216  float solveSprings;
+ + +
219  float applyDeltas;
+ + + + +
224  float finalize;
+
225  float updateBounds;
+
226  float total;
+
227 };
+
228 
+ +
233 {
+ + + + + +
239 };
+
240 
+
241 
+ +
245 {
+ + + + + + +
252 };
+
253 
+
254 
+ +
268 {
+ +
270  void* userData;
+
271 
+
272  float* particles;
+
273  float* velocities;
+
274  int* phases;
+
275 
+
276  int numActive;
+
277 
+
278  float dt;
+
279 
+
280  const int* originalToSortedMap;
+
281  const int* sortedToOriginalMap;
+
282 };
+
283 
+ +
287 {
+
289  void* userData;
+
290 
+
292  void (*function)(NvFlexSolverCallbackParams params);
+
293 };
+
294 
+
298 typedef void (*NvFlexErrorCallback)(NvFlexErrorSeverity type, const char* msg, const char* file, int line);
+
299 
+
300 
+
301 
302 
-
312 NV_FLEX_API NvFlexLibrary* NvFlexInit(int version = NV_FLEX_VERSION, NvFlexErrorCallback errorFunc = 0, NvFlexInitDesc * desc = 0);
-
313 
-
320 NV_FLEX_API void NvFlexShutdown(NvFlexLibrary* lib);
-
321 
-
325 NV_FLEX_API int NvFlexGetVersion();
+ +
306 {
+ + + +
310 };
+
311 
+
312 
+ +
316 {
+ + +
319  void* renderDevice;
+ + + +
323 
+ +
325 };
326 
-
335 NV_FLEX_API NvFlexSolver* NvFlexCreateSolver(NvFlexLibrary* lib, int maxParticles, int maxDiffuseParticles, int maxNeighborsPerParticle = 96);
-
341 NV_FLEX_API void NvFlexDestroySolver(NvFlexSolver* solver);
-
342 
- +
336 NV_FLEX_API NvFlexLibrary* NvFlexInit(int version = NV_FLEX_VERSION, NvFlexErrorCallback errorFunc = 0, NvFlexInitDesc* desc = 0);
+
337 
+
344 NV_FLEX_API void NvFlexShutdown(NvFlexLibrary* lib);
+
345 
+
349 NV_FLEX_API int NvFlexGetVersion();
350 
- + +
355 {
+ + + +
359 };
360 
-
420 NV_FLEX_API void NvFlexUpdateSolver(NvFlexSolver* solver, float dt, int substeps, bool enableTimers);
-
421 
-
428 NV_FLEX_API void NvFlexSetParams(NvFlexSolver* solver, const NvFlexParams* params);
-
429 
-
437 NV_FLEX_API void NvFlexGetParams(NvFlexSolver* solver, NvFlexParams* params);
-
438 
-
446 NV_FLEX_API void NvFlexSetActive(NvFlexSolver* solver, NvFlexBuffer* indices, int n);
-
447 
-
454 NV_FLEX_API void NvFlexGetActive(NvFlexSolver* solver, NvFlexBuffer* indices);
-
455 
-
462 NV_FLEX_API int NvFlexGetActiveCount(NvFlexSolver* solver);
-
463 
-
472 NV_FLEX_API void NvFlexSetParticles(NvFlexSolver* solver, NvFlexBuffer* p, int n);
-
473 
-
481 NV_FLEX_API void NvFlexGetParticles(NvFlexSolver* solver, NvFlexBuffer* p, int n);
-
482 
-
492 NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver* solver, NvFlexBuffer* p, int n);
-
493 
-
502 NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver* solver, NvFlexBuffer* p, int n);
-
503 
-
504 
-
512 NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver* solver, NvFlexBuffer* p, int n);
-
513 
-
522 NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver* solver, NvFlexBuffer* v, int n);
-
530 NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver* solver, NvFlexBuffer* v, int n);
-
531 
-
548 NV_FLEX_API void NvFlexSetPhases(NvFlexSolver* solver, NvFlexBuffer* phases, int n);
-
556 NV_FLEX_API void NvFlexGetPhases(NvFlexSolver* solver, NvFlexBuffer* phases, int n);
-
557 
-
566 NV_FLEX_API void NvFlexSetNormals(NvFlexSolver* solver, NvFlexBuffer* normals, int n);
-
567 
-
575 NV_FLEX_API void NvFlexGetNormals(NvFlexSolver* solver, NvFlexBuffer* normals, int n);
-
576 
-
577 
-
590 NV_FLEX_API void NvFlexSetSprings(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* restLengths, NvFlexBuffer* stiffness, int numSprings);
-
600 NV_FLEX_API void NvFlexGetSprings(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* restLengths, NvFlexBuffer* stiffness, int numSprings);
-
601 
-
618 NV_FLEX_API void NvFlexSetRigids(NvFlexSolver* solver, NvFlexBuffer* offsets, NvFlexBuffer* indices, NvFlexBuffer* restPositions, NvFlexBuffer* restNormals, NvFlexBuffer* stiffness, NvFlexBuffer* rotations, NvFlexBuffer* translations, int numRigids, int numIndices);
-
619 
-
620 
-
628 NV_FLEX_API void NvFlexGetRigidTransforms(NvFlexSolver* solver, NvFlexBuffer* rotations, NvFlexBuffer* translations);
-
629 
-
633 typedef unsigned int NvFlexTriangleMeshId;
+ +
365 {
+ +
367 
+ + + +
371 };
+
372 
+
377 NV_FLEX_API void NvFlexSetSolverDescDefaults(NvFlexSolverDesc* desc);
+
378 
+
385 NV_FLEX_API NvFlexSolver* NvFlexCreateSolver(NvFlexLibrary* lib, const NvFlexSolverDesc* desc);
+
391 NV_FLEX_API void NvFlexDestroySolver(NvFlexSolver* solver);
+
392 
+ +
400 
+
407 NV_FLEX_API void NvFlexGetSolverDesc(NvFlexSolver* solver, NvFlexSolverDesc* desc);
+
408 
+ +
418 
+
478 NV_FLEX_API void NvFlexUpdateSolver(NvFlexSolver* solver, float dt, int substeps, bool enableTimers);
+
479 
+
486 NV_FLEX_API void NvFlexSetParams(NvFlexSolver* solver, const NvFlexParams* params);
+
487 
+
495 NV_FLEX_API void NvFlexGetParams(NvFlexSolver* solver, NvFlexParams* params);
+
496 
+ +
501 {
+
502  int srcOffset; //<! Offset in elements from the start of the source buffer to begin reading from
+
503  int dstOffset; //<! Offset in elements from the start of the destination buffer to being writing to
+
504  int elementCount; //<! Number of elements to copy
+
505 };
+
506 
+
514 NV_FLEX_API void NvFlexSetActive(NvFlexSolver* solver, NvFlexBuffer* indices, const NvFlexCopyDesc* desc);
+
515 
+
523 NV_FLEX_API void NvFlexGetActive(NvFlexSolver* solver, NvFlexBuffer* indices, const NvFlexCopyDesc* desc);
+
524 
+
531 NV_FLEX_API void NvFlexSetActiveCount(NvFlexSolver* solver, int n);
+
532 
+
539 NV_FLEX_API int NvFlexGetActiveCount(NvFlexSolver* solver);
+
540 
+
549 NV_FLEX_API void NvFlexSetParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
+
550 
+
558 NV_FLEX_API void NvFlexGetParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
+
559 
+
569 NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
+
570 
+
579 NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
+
580 
+
581 
+
589 NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
+
590 
+
599 NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver* solver, NvFlexBuffer* v, const NvFlexCopyDesc* desc);
+
607 NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver* solver, NvFlexBuffer* v, const NvFlexCopyDesc* desc);
+
608 
+
625 NV_FLEX_API void NvFlexSetPhases(NvFlexSolver* solver, NvFlexBuffer* phases, const NvFlexCopyDesc* desc);
+
633 NV_FLEX_API void NvFlexGetPhases(NvFlexSolver* solver, NvFlexBuffer* phases, const NvFlexCopyDesc* desc);
634 
-
638 typedef unsigned int NvFlexDistanceFieldId;
-
639 
-
645 typedef unsigned int NvFlexConvexMeshId;
-
646 
-
653 NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh(NvFlexLibrary* lib);
-
654 
-
661 NV_FLEX_API void NvFlexDestroyTriangleMesh(NvFlexLibrary* lib, NvFlexTriangleMeshId mesh);
-
662 
-
676 NV_FLEX_API void NvFlexUpdateTriangleMesh(NvFlexLibrary* lib, NvFlexTriangleMeshId mesh, NvFlexBuffer* vertices, NvFlexBuffer* indices, int numVertices, int numTriangles, const float* lower, const float* upper);
+
642 NV_FLEX_API void NvFlexSetNormals(NvFlexSolver* solver, NvFlexBuffer* normals, const NvFlexCopyDesc* desc);
+
643 
+
651 NV_FLEX_API void NvFlexGetNormals(NvFlexSolver* solver, NvFlexBuffer* normals, const NvFlexCopyDesc* desc);
+
652 
+
653 
+
666 NV_FLEX_API void NvFlexSetSprings(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* restLengths, NvFlexBuffer* stiffness, int numSprings);
+
676 NV_FLEX_API void NvFlexGetSprings(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* restLengths, NvFlexBuffer* stiffness, int numSprings);
677 
-
686 NV_FLEX_API void NvFlexGetTriangleMeshBounds(NvFlexLibrary* lib, const NvFlexTriangleMeshId mesh, float* lower, float* upper);
-
687 
-
694 NV_FLEX_API NvFlexDistanceFieldId NvFlexCreateDistanceField(NvFlexLibrary* lib);
-
695 
-
702 NV_FLEX_API void NvFlexDestroyDistanceField(NvFlexLibrary* lib, NvFlexDistanceFieldId sdf);
-
703 
-
715 NV_FLEX_API void NvFlexUpdateDistanceField(NvFlexLibrary* lib, NvFlexDistanceFieldId sdf, int dimx, int dimy, int dimz, NvFlexBuffer* field);
-
716 
-
723 NV_FLEX_API NvFlexConvexMeshId NvFlexCreateConvexMesh(NvFlexLibrary* lib);
+
696 NV_FLEX_API void NvFlexSetRigids(NvFlexSolver* solver, NvFlexBuffer* offsets, NvFlexBuffer* indices, NvFlexBuffer* restPositions, NvFlexBuffer* restNormals, NvFlexBuffer* stiffness, NvFlexBuffer* thresholds, NvFlexBuffer* creeps, NvFlexBuffer* rotations, NvFlexBuffer* translations, int numRigids, int numIndices);
+
697 
+
713 NV_FLEX_API void NvFlexGetRigids(NvFlexSolver* solver, NvFlexBuffer* offsets, NvFlexBuffer* indices, NvFlexBuffer* restPositions, NvFlexBuffer* restNormals, NvFlexBuffer* stiffness, NvFlexBuffer* thresholds, NvFlexBuffer* creeps, NvFlexBuffer* rotations, NvFlexBuffer* translations);
+
714 
+
718 typedef unsigned int NvFlexTriangleMeshId;
+
719 
+
723 typedef unsigned int NvFlexDistanceFieldId;
724 
-
731 NV_FLEX_API void NvFlexDestroyConvexMesh(NvFlexLibrary* lib, NvFlexConvexMeshId convex);
-
732 
-
743 NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary* lib, NvFlexConvexMeshId convex, NvFlexBuffer* planes, int numPlanes, float* lower, float* upper);
-
744 
-
753 NV_FLEX_API void NvFlexGetConvexMeshBounds(NvFlexLibrary* lib, NvFlexConvexMeshId mesh, float* lower, float* upper);
-
754 
- -
759 {
-
760  float radius;
-
761 };
+
730 typedef unsigned int NvFlexConvexMeshId;
+
731 
+
738 NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh(NvFlexLibrary* lib);
+
739 
+
746 NV_FLEX_API void NvFlexDestroyTriangleMesh(NvFlexLibrary* lib, NvFlexTriangleMeshId mesh);
+
747 
+
761 NV_FLEX_API void NvFlexUpdateTriangleMesh(NvFlexLibrary* lib, NvFlexTriangleMeshId mesh, NvFlexBuffer* vertices, NvFlexBuffer* indices, int numVertices, int numTriangles, const float* lower, const float* upper);
762 
- -
767 {
-
768  float radius;
-
769  float halfHeight;
-
770 };
-
771 
- -
776 {
-
777  float halfExtents[3];
-
778 };
-
779 
- -
784 {
-
785  float scale[3];
-
786  NvFlexConvexMeshId mesh;
-
787 };
+
771 NV_FLEX_API void NvFlexGetTriangleMeshBounds(NvFlexLibrary* lib, const NvFlexTriangleMeshId mesh, float* lower, float* upper);
+
772 
+
779 NV_FLEX_API NvFlexDistanceFieldId NvFlexCreateDistanceField(NvFlexLibrary* lib);
+
780 
+
787 NV_FLEX_API void NvFlexDestroyDistanceField(NvFlexLibrary* lib, NvFlexDistanceFieldId sdf);
788 
- -
793 {
-
794  float scale[3];
-
795  NvFlexTriangleMeshId mesh;
-
796 };
-
797 
- -
803 {
-
804  float scale;
-
805  NvFlexDistanceFieldId field;
-
806 };
-
807 
- -
813 {
- - - - - - -
820 };
-
821 
- -
823 {
- - - - - - -
830 };
-
831 
- -
833 {
- - - -
837 
- -
839 };
-
840 
-
844 NV_FLEX_API inline int NvFlexMakeShapeFlags(NvFlexCollisionShapeType type, bool dynamic) { return type | (dynamic?eNvFlexShapeFlagDynamic:0); }
-
845 
-
859 NV_FLEX_API void NvFlexSetShapes(NvFlexSolver* solver, NvFlexBuffer* geometry, NvFlexBuffer* shapePositions, NvFlexBuffer* shapeRotations, NvFlexBuffer* shapePrevPositions, NvFlexBuffer* shapePrevRotations, NvFlexBuffer* shapeFlags, int numShapes);
-
860 
-
871 NV_FLEX_API void NvFlexSetDynamicTriangles(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* normals, int numTris);
-
880 NV_FLEX_API void NvFlexGetDynamicTriangles(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* normals, int numTris);
-
881 
-
896 NV_FLEX_API void NvFlexSetInflatables(NvFlexSolver* solver, NvFlexBuffer* startTris, NvFlexBuffer* numTris, NvFlexBuffer* restVolumes, NvFlexBuffer* overPressures, NvFlexBuffer* constraintScales, int numInflatables);
-
897 
-
905 NV_FLEX_API void NvFlexGetDensities(NvFlexSolver* solver, NvFlexBuffer* densities, int n);
+
800 NV_FLEX_API void NvFlexUpdateDistanceField(NvFlexLibrary* lib, NvFlexDistanceFieldId sdf, int dimx, int dimy, int dimz, NvFlexBuffer* field);
+
801 
+
808 NV_FLEX_API NvFlexConvexMeshId NvFlexCreateConvexMesh(NvFlexLibrary* lib);
+
809 
+
816 NV_FLEX_API void NvFlexDestroyConvexMesh(NvFlexLibrary* lib, NvFlexConvexMeshId convex);
+
817 
+
828 NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary* lib, NvFlexConvexMeshId convex, NvFlexBuffer* planes, int numPlanes, const float* lower, const float* upper);
+
829 
+
838 NV_FLEX_API void NvFlexGetConvexMeshBounds(NvFlexLibrary* lib, NvFlexConvexMeshId mesh, float* lower, float* upper);
+
839 
+ +
844 {
+
845  float radius;
+
846 };
+
847 
+ +
852 {
+
853  float radius;
+
854  float halfHeight;
+
855 };
+
856 
+ +
861 {
+
862  float halfExtents[3];
+
863 };
+
864 
+ +
869 {
+
870  float scale[3];
+
871  NvFlexConvexMeshId mesh;
+
872 };
+
873 
+ +
878 {
+
879  float scale[3];
+
880  NvFlexTriangleMeshId mesh;
+
881 };
+
882 
+ +
888 {
+
889  float scale;
+
890  NvFlexDistanceFieldId field;
+
891 };
+
892 
+ +
898 {
+ + + + + + +
905 };
906 
-
920 NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver* solver, NvFlexBuffer* q1, NvFlexBuffer* q2, NvFlexBuffer* q3);
-
930 NV_FLEX_API int NvFlexGetDiffuseParticles(NvFlexSolver* solver, NvFlexBuffer* p, NvFlexBuffer* v, NvFlexBuffer* indices);
-
931 
-
942 NV_FLEX_API void NvFlexSetDiffuseParticles(NvFlexSolver* solver, NvFlexBuffer* p, NvFlexBuffer* v, int n);
-
943 
-
953 NV_FLEX_API void NvFlexGetContacts(NvFlexSolver* solver, NvFlexBuffer* planes, NvFlexBuffer* velocities, NvFlexBuffer* indices, NvFlexBuffer* counts);
-
954 
-
963 NV_FLEX_API void NvFlexGetBounds(NvFlexSolver* solver, NvFlexBuffer* lower, NvFlexBuffer* upper);
-
964 
-
973 NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver* solver);
-
974 
-
985 NV_FLEX_API void NvFlexGetTimers(NvFlexSolver* solver, NvFlexTimers* timers);
-
986 
- -
991 {
-
992  char* name;
-
993  float time;
-
994 };
-
995 
-
1008 NV_FLEX_API int NvFlexGetDetailTimers(NvFlexSolver* solver, NvFlexDetailTimer** timers);
-
1009 
-
1019 NV_FLEX_API NvFlexBuffer* NvFlexAllocBuffer(NvFlexLibrary* lib, int elementCount, int elementByteStride, NvFlexBufferType type);
-
1020 
-
1026 NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer* buf);
+ +
908 {
+ + + + + + +
915 };
+
916 
+ +
918 {
+ + + +
922 
+ +
924 };
+
925 
+
933 NV_FLEX_API inline int NvFlexMakeShapeFlagsWithChannels(NvFlexCollisionShapeType type, bool dynamic, int shapeChannels) { return type | (dynamic?eNvFlexShapeFlagDynamic:0) | shapeChannels; }
+
934 
+
938 NV_FLEX_API inline int NvFlexMakeShapeFlags(NvFlexCollisionShapeType type, bool dynamic) { return NvFlexMakeShapeFlagsWithChannels(type, dynamic, eNvFlexPhaseShapeChannelMask); }
+
939 
+
940 
+
954 NV_FLEX_API void NvFlexSetShapes(NvFlexSolver* solver, NvFlexBuffer* geometry, NvFlexBuffer* shapePositions, NvFlexBuffer* shapeRotations, NvFlexBuffer* shapePrevPositions, NvFlexBuffer* shapePrevRotations, NvFlexBuffer* shapeFlags, int numShapes);
+
955 
+
966 NV_FLEX_API void NvFlexSetDynamicTriangles(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* normals, int numTris);
+
975 NV_FLEX_API void NvFlexGetDynamicTriangles(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* normals, int numTris);
+
976 
+
991 NV_FLEX_API void NvFlexSetInflatables(NvFlexSolver* solver, NvFlexBuffer* startTris, NvFlexBuffer* numTris, NvFlexBuffer* restVolumes, NvFlexBuffer* overPressures, NvFlexBuffer* constraintScales, int numInflatables);
+
992 
+
1000 NV_FLEX_API void NvFlexGetDensities(NvFlexSolver* solver, NvFlexBuffer* densities, const NvFlexCopyDesc* desc);
+
1001 
+
1016 NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver* solver, NvFlexBuffer* q1, NvFlexBuffer* q2, NvFlexBuffer* q3, const NvFlexCopyDesc* desc);
+
1026 NV_FLEX_API void NvFlexGetDiffuseParticles(NvFlexSolver* solver, NvFlexBuffer* p, NvFlexBuffer* v, NvFlexBuffer* count);
1027 
-
1037 NV_FLEX_API void* NvFlexMap(NvFlexBuffer* buffer, int flags);
-
1038 
-
1044 NV_FLEX_API void NvFlexUnmap(NvFlexBuffer* buffer);
-
1045 
-
1075 NV_FLEX_API NvFlexBuffer* NvFlexRegisterOGLBuffer(NvFlexLibrary* lib, int buf, int elementCount, int elementByteStride);
-
1076 
-
1082 NV_FLEX_API void NvFlexUnregisterOGLBuffer(NvFlexBuffer* buf);
-
1083 
-
1093 NV_FLEX_API NvFlexBuffer* NvFlexRegisterD3DBuffer(NvFlexLibrary* lib, void* buffer, int elementCount, int elementByteStride);
-
1094 
-
1100 NV_FLEX_API void NvFlexUnregisterD3DBuffer(NvFlexBuffer* buf);
-
1101 
-
1107 NV_FLEX_API void NvFlexAcquireContext(NvFlexLibrary* lib);
-
1108 
-
1113 NV_FLEX_API void NvFlexRestoreContext(NvFlexLibrary* lib);
-
1114 
-
1120 NV_FLEX_API const char* NvFlexGetDeviceName(NvFlexLibrary* lib);
-
1121 
-
1131 NV_FLEX_API void NvFlexGetDeviceAndContext(NvFlexLibrary* lib, void** device, void** context);
-
1132 
-
1133 
-
1139 NV_FLEX_API void NvFlexFlush(NvFlexLibrary* lib);
-
1140 
-
1142 
-
1147 NV_FLEX_API void NvFlexSetDebug(NvFlexSolver* solver, bool enable);
-
1148 NV_FLEX_API void NvFlexGetShapeBVH(NvFlexSolver* solver, void* bvh);
-
1149 NV_FLEX_API void NvFlexCopySolver(NvFlexSolver* dst, NvFlexSolver* src);
-
1150 
-
1152 
-
1153 } // extern "C"
-
1154 
-
1155 #endif // NV_FLEX_H
+
1038 NV_FLEX_API void NvFlexSetDiffuseParticles(NvFlexSolver* solver, NvFlexBuffer* p, NvFlexBuffer* v, int n);
+
1039 
+
1049 NV_FLEX_API void NvFlexGetContacts(NvFlexSolver* solver, NvFlexBuffer* planes, NvFlexBuffer* velocities, NvFlexBuffer* indices, NvFlexBuffer* counts);
+
1050 
+
1094 NV_FLEX_API void NvFlexGetNeighbors(NvFlexSolver* solver, NvFlexBuffer* neighbors, NvFlexBuffer* counts, NvFlexBuffer* remap);
+
1095 
+
1104 NV_FLEX_API void NvFlexGetBounds(NvFlexSolver* solver, NvFlexBuffer* lower, NvFlexBuffer* upper);
+
1105 
+
1117 NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver* solver, unsigned long long* begin, unsigned long long* end, unsigned long long* frequency);
+
1118 
+
1129 NV_FLEX_API void NvFlexGetTimers(NvFlexSolver* solver, NvFlexTimers* timers);
+
1130 
+ +
1135 {
+
1136  char* name;
+
1137  float time;
+
1138 };
+
1139 
+
1152 NV_FLEX_API int NvFlexGetDetailTimers(NvFlexSolver* solver, NvFlexDetailTimer** timers);
+
1153 
+
1163 NV_FLEX_API NvFlexBuffer* NvFlexAllocBuffer(NvFlexLibrary* lib, int elementCount, int elementByteStride, NvFlexBufferType type);
+
1164 
+
1170 NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer* buf);
+
1171 
+
1181 NV_FLEX_API void* NvFlexMap(NvFlexBuffer* buffer, int flags);
+
1182 
+
1188 NV_FLEX_API void NvFlexUnmap(NvFlexBuffer* buffer);
+
1189 
+
1219 NV_FLEX_API NvFlexBuffer* NvFlexRegisterOGLBuffer(NvFlexLibrary* lib, int buf, int elementCount, int elementByteStride);
+
1220 
+
1226 NV_FLEX_API void NvFlexUnregisterOGLBuffer(NvFlexBuffer* buf);
+
1227 
+
1237 NV_FLEX_API NvFlexBuffer* NvFlexRegisterD3DBuffer(NvFlexLibrary* lib, void* buffer, int elementCount, int elementByteStride);
+
1238 
+
1244 NV_FLEX_API void NvFlexUnregisterD3DBuffer(NvFlexBuffer* buf);
+
1245 
+
1251 NV_FLEX_API void NvFlexAcquireContext(NvFlexLibrary* lib);
+
1252 
+
1257 NV_FLEX_API void NvFlexRestoreContext(NvFlexLibrary* lib);
+
1258 
+
1264 NV_FLEX_API const char* NvFlexGetDeviceName(NvFlexLibrary* lib);
+
1265 
+
1275 NV_FLEX_API void NvFlexGetDeviceAndContext(NvFlexLibrary* lib, void** device, void** context);
+
1276 
+
1277 
+
1283 NV_FLEX_API void NvFlexFlush(NvFlexLibrary* lib);
+
1284 
+
1285 NV_FLEX_API void NvFlexWait(NvFlexLibrary* lib);
+
1286 
+
1288 
+
1293 NV_FLEX_API void NvFlexSetDebug(NvFlexSolver* solver, bool enable);
+
1294 NV_FLEX_API void NvFlexGetShapeBVH(NvFlexSolver* solver, void* bvh);
+
1295 NV_FLEX_API void NvFlexCopySolver(NvFlexSolver* dst, NvFlexSolver* src);
+
1296 NV_FLEX_API void NvFlexCopyDeviceToHost(NvFlexSolver* solver, NvFlexBuffer* pDevice, void* pHost, int size, int stride);
+
1297 NV_FLEX_API void NvFlexComputeWaitForGraphics(NvFlexLibrary* lib);
+
1298 
+
1300 
+
1301 } // extern "C"
+
1302 
+
1303 #endif // NV_FLEX_H
NV_FLEX_API int NvFlexGetActiveCount(NvFlexSolver *solver)
-
float solveShapes
Time spent solving rigid body constraints.
Definition: NvFlex.h:198
+
Reserved.
Definition: NvFlex.h:169
+
float solveShapes
Time spent solving rigid body constraints.
Definition: NvFlex.h:215
NV_FLEX_API NvFlexSolverCallback NvFlexRegisterSolverCallback(NvFlexSolver *solver, NvFlexSolverCallback function, NvFlexSolverCallbackStage stage)
-
float radius
Definition: NvFlex.h:760
-
Warning messages.
Definition: NvFlex.h:219
-
float solveSprings
Time spent solving distance constraints.
Definition: NvFlex.h:199
+
NV_FLEX_API void NvFlexGetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, const NvFlexCopyDesc *desc)
+
float radius
Definition: NvFlex.h:845
+
Warning messages.
Definition: NvFlex.h:236
+
float solveSprings
Time spent solving distance constraints.
Definition: NvFlex.h:216
NvFlexMapFlags
Definition: NvFlex.h:67
-
NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
-
void(* NvFlexErrorCallback)(NvFlexErrorSeverity type, const char *msg, const char *file, int line)
Definition: NvFlex.h:301
-
Information messages.
Definition: NvFlex.h:218
-
float smoothing
Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positio...
Definition: NvFlex.h:134
+
int maxDiffuseParticles
Maximum number of diffuse particles in the solver.
Definition: NvFlex.h:369
+
void(* NvFlexErrorCallback)(NvFlexErrorSeverity type, const char *msg, const char *file, int line)
Definition: NvFlex.h:298
+
Information messages.
Definition: NvFlex.h:235
+
float smoothing
Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positio...
Definition: NvFlex.h:132
NV_FLEX_API void NvFlexSetParams(NvFlexSolver *solver, const NvFlexParams *params)
-
Called at the end of solver update after the final substep has completed.
Definition: NvFlex.h:233
-
NV_FLEX_API void NvFlexSetRigids(NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *rotations, NvFlexBuffer *translations, int numRigids, int numIndices)
-
NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
+
Called at the end of solver update after the final substep has completed.
Definition: NvFlex.h:250
+
Particle will collide with shapes with channel 3 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:174
NV_FLEX_API void NvFlexUpdateTriangleMesh(NvFlexLibrary *lib, NvFlexTriangleMeshId mesh, NvFlexBuffer *vertices, NvFlexBuffer *indices, int numVertices, int numTriangles, const float *lower, const float *upper)
NV_FLEX_API void NvFlexUnmap(NvFlexBuffer *buffer)
-
If set this particle will interact with particles of the same group.
Definition: NvFlex.h:170
-
float createCellIndices
Time spent creating grid indices.
Definition: NvFlex.h:187
-
float shapeCollisionMargin
Increases the radius used during contact finding against kinematic shapes.
Definition: NvFlex.h:154
-
float scale
Uniform scale of SDF, this corresponds to the world space width of the shape.
Definition: NvFlex.h:804
-
NV_FLEX_API void NvFlexGetActive(NvFlexSolver *solver, NvFlexBuffer *indices)
-
int diffuseBallistic
The number of neighbors below which a diffuse particle is considered ballistic.
Definition: NvFlex.h:143
-
NvFlexRelaxationMode
Definition: NvFlex.h:86
-
float drag
Drag force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:122
-
NvFlexErrorSeverity
Definition: NvFlex.h:215
-
float maxSpeed
The magnitude of particle velocity will be clamped to this value at the end of each step...
Definition: NvFlex.h:113
-
float planes[8][4]
Collision planes in the form ax + by + cz + d = 0.
Definition: NvFlex.h:156
-
float cohesion
Control how strongly particles hold each other together, default: 0.025, range [0.0, +inf].
Definition: NvFlex.h:127
-
float staticFriction
Coefficient of static friction used when colliding against shapes.
Definition: NvFlex.h:107
-
float collideParticles
Time spent finding particle neighbors.
Definition: NvFlex.h:191
-
NvFlexCapsuleGeometry capsule
Definition: NvFlex.h:815
-
float predict
Time spent in prediction.
Definition: NvFlex.h:186
-
Definition: NvFlex.h:783
-
float updateDiffuse
Time spent updating diffuse particles.
Definition: NvFlex.h:204
-
NvFlexSphereGeometry sphere
Definition: NvFlex.h:814
-
float collisionDistance
Distance particles maintain against shapes, note that for robust collision against triangle meshes th...
Definition: NvFlex.h:152
-
NvFlexTriangleMeshGeometry triMesh
Definition: NvFlex.h:818
-
float solveContacts
Time spent solving contact constraints.
Definition: NvFlex.h:200
-
Definition: NvFlex.h:838
-
NvFlexComputeType computeType
Set to eNvFlexD3D11 if DirectX 11 should be used, eNvFlexD3D12 for DirectX 12, this must match the li...
Definition: NvFlex.h:284
+
If set this particle will interact with particles of the same group.
Definition: NvFlex.h:166
+
float createCellIndices
Time spent creating grid indices.
Definition: NvFlex.h:204
+
Particle will collide with shapes with channel 4 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:175
+
float shapeCollisionMargin
Increases the radius used during contact finding against kinematic shapes.
Definition: NvFlex.h:147
+
float scale
Uniform scale of SDF, this corresponds to the world space width of the shape.
Definition: NvFlex.h:889
+
int diffuseBallistic
The number of neighbors below which a diffuse particle is considered ballistic.
Definition: NvFlex.h:141
+
NV_FLEX_API void NvFlexSetRigids(NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *thresholds, NvFlexBuffer *creeps, NvFlexBuffer *rotations, NvFlexBuffer *translations, int numRigids, int numIndices)
+
NvFlexRelaxationMode
Definition: NvFlex.h:85
+
float drag
Drag force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:121
+
NvFlexErrorSeverity
Definition: NvFlex.h:232
+
NV_FLEX_API void NvFlexSetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, const NvFlexCopyDesc *desc)
+
float maxSpeed
The magnitude of particle velocity will be clamped to this value at the end of each step...
Definition: NvFlex.h:112
+
All features enabled.
Definition: NvFlex.h:356
+
float planes[8][4]
Collision planes in the form ax + by + cz + d = 0.
Definition: NvFlex.h:149
+
float cohesion
Control how strongly particles hold each other together, default: 0.025, range [0.0, +inf].
Definition: NvFlex.h:125
+
float staticFriction
Coefficient of static friction used when colliding against shapes.
Definition: NvFlex.h:106
+
float collideParticles
Time spent finding particle neighbors.
Definition: NvFlex.h:208
+
NV_FLEX_API void NvFlexGetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, const NvFlexCopyDesc *desc)
+
NvFlexCapsuleGeometry capsule
Definition: NvFlex.h:900
+
float predict
Time spent in prediction.
Definition: NvFlex.h:203
+
NV_FLEX_API void NvFlexGetDiffuseParticles(NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, NvFlexBuffer *count)
+
Definition: NvFlex.h:868
+
int maxNeighborsPerParticle
Maximum number of neighbors per-particle, for solids this can be around 32, for fluids up to 128 may ...
Definition: NvFlex.h:370
+
float updateDiffuse
Time spent updating diffuse particles.
Definition: NvFlex.h:221
+
NvFlexSphereGeometry sphere
Definition: NvFlex.h:899
+
float collisionDistance
Distance particles maintain against shapes, note that for robust collision against triangle meshes th...
Definition: NvFlex.h:145
+
NvFlexTriangleMeshGeometry triMesh
Definition: NvFlex.h:903
+
float solveContacts
Time spent solving contact constraints.
Definition: NvFlex.h:217
+
NV_FLEX_API void NvFlexSetActiveCount(NvFlexSolver *solver, int n)
+
Bits [20, 23] hold flags about how the particle behave.
Definition: NvFlex.h:163
+
Definition: NvFlex.h:923
+
NvFlexComputeType computeType
Set to eNvFlexD3D11 if DirectX 11 should be used, eNvFlexD3D12 for DirectX 12, this must match the li...
Definition: NvFlex.h:324
NV_FLEX_API void NvFlexDestroyDistanceField(NvFlexLibrary *lib, NvFlexDistanceFieldId sdf)
-
Use DirectX 11 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:242
+
Use DirectX 11 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:308
+
NV_FLEX_API void NvFlexGetNeighbors(NvFlexSolver *solver, NvFlexBuffer *neighbors, NvFlexBuffer *counts, NvFlexBuffer *remap)
NV_FLEX_API void NvFlexDestroySolver(NvFlexSolver *solver)
-
Lower 3 bits holds the type of the collision shape.
Definition: NvFlex.h:834
-
const int * originalToSortedMap
Device pointer that maps the sorted callback data to the original position given by SetParticles() ...
Definition: NvFlex.h:271
-
float halfHeight
Definition: NvFlex.h:769
+
Lower 3 bits holds the type of the collision shape given by the NvFlexCollisionShapeType enum...
Definition: NvFlex.h:919
+
const int * originalToSortedMap
Device pointer that maps the sorted callback data to the original position given by SetParticles() ...
Definition: NvFlex.h:280
+
float halfHeight
Definition: NvFlex.h:854
Calling thread will be blocked until buffer is ready for access, default.
Definition: NvFlex.h:69
NV_FLEX_API void NvFlexSetDiffuseParticles(NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, int n)
struct NvFlexSolver NvFlexSolver
Definition: NvFlex.h:57
-
Called at the end of each substep after the velocity has been updated by the constraints.
Definition: NvFlex.h:232
-
float * particles
Device pointer to the active particle basic data in the form x,y,z,1/m.
Definition: NvFlex.h:263
+
Called at the end of each substep after the velocity has been updated by the constraints.
Definition: NvFlex.h:249
+
float * particles
Device pointer to the active particle basic data in the form x,y,z,1/m.
Definition: NvFlex.h:272
+
NV_FLEX_API void NvFlexGetActive(NvFlexSolver *solver, NvFlexBuffer *indices, const NvFlexCopyDesc *desc)
NV_FLEX_API void NvFlexSetInflatables(NvFlexSolver *solver, NvFlexBuffer *startTris, NvFlexBuffer *numTris, NvFlexBuffer *restVolumes, NvFlexBuffer *overPressures, NvFlexBuffer *constraintScales, int numInflatables)
-
Definition: NvFlex.h:758
-
Called at the beginning of each constraint iteration.
Definition: NvFlex.h:229
+
NV_FLEX_API void NvFlexWait(NvFlexLibrary *lib)
+
NV_FLEX_API void NvFlexSetParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
+
Definition: NvFlex.h:843
+
Definition: NvFlex.h:364
+
int dstOffset
Definition: NvFlex.h:503
+
Called at the beginning of each constraint iteration.
Definition: NvFlex.h:246
NV_FLEX_API void NvFlexGetTriangleMeshBounds(NvFlexLibrary *lib, const NvFlexTriangleMeshId mesh, float *lower, float *upper)
-
Definition: NvFlex.h:258
+
NV_FLEX_API int NvFlexMakeShapeFlagsWithChannels(NvFlexCollisionShapeType type, bool dynamic, int shapeChannels)
Definition: NvFlex.h:933
+
Definition: NvFlex.h:267
NV_FLEX_API NvFlexConvexMeshId NvFlexCreateConvexMesh(NvFlexLibrary *lib)
NV_FLEX_API void * NvFlexMap(NvFlexBuffer *buffer, int flags)
-
float time
Definition: NvFlex.h:993
-
Definition: NvFlex.h:812
-
float updateNormals
Time spent updating vertex normals.
Definition: NvFlex.h:206
-
unsigned int NvFlexTriangleMeshId
Definition: NvFlex.h:633
-
The relaxation factor is a fixed multiplier on each constraint's delta divided by the particle's cons...
Definition: NvFlex.h:89
+
float time
Definition: NvFlex.h:1137
+
Definition: NvFlex.h:897
+
float updateNormals
Time spent updating vertex normals.
Definition: NvFlex.h:223
+
unsigned int NvFlexTriangleMeshId
Definition: NvFlex.h:718
+
The relaxation factor is a fixed multiplier on each constraint's delta divided by the particle's cons...
Definition: NvFlex.h:88
NV_FLEX_API NvFlexBuffer * NvFlexRegisterD3DBuffer(NvFlexLibrary *lib, void *buffer, int elementCount, int elementByteStride)
-
Buffer contents will be discarded, this allows for efficent buffer reuse.
Definition: NvFlex.h:71
-
Indicates that the shape is a trigger volume, this means it will not perform any collision response...
Definition: NvFlex.h:836
-
A sphere shape, see FlexSphereGeometry.
Definition: NvFlex.h:824
-
A signed distance field shape, see FlexSDFGeometry.
Definition: NvFlex.h:829
-
int deviceIndex
The GPU device index that should be used, if there is already a CUDA context on the calling thread th...
Definition: NvFlex.h:279
-
bool fluid
If true then particles with phase 0 are considered fluid particles and interact using the position ba...
Definition: NvFlex.h:126
-
float viscosity
Smoothes particle velocities using XSPH viscosity.
Definition: NvFlex.h:129
-
NvFlexTriangleMeshId mesh
A triangle mesh pointer created by NvFlexCreateTriangleMesh()
Definition: NvFlex.h:795
-
NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, int n)
-
NV_FLEX_API int NvFlexMakePhase(int group, int flags)
Definition: NvFlex.h:178
-
float adhesion
Controls how strongly particles stick to surfaces they hit, default 0.0, range [0.0, +inf].
Definition: NvFlex.h:110
+
Indicates that the shape is a trigger volume, this means it will not perform any collision response...
Definition: NvFlex.h:921
+
Simple single phase fluid-only particles (no solids)
Definition: NvFlex.h:358
+
A sphere shape, see FlexSphereGeometry.
Definition: NvFlex.h:909
+
A signed distance field shape, see FlexSDFGeometry.
Definition: NvFlex.h:914
+
int deviceIndex
The GPU device index that should be used, if there is already a CUDA context on the calling thread th...
Definition: NvFlex.h:317
+
float viscosity
Smoothes particle velocities using XSPH viscosity.
Definition: NvFlex.h:127
+
NvFlexTriangleMeshId mesh
A triangle mesh pointer created by NvFlexCreateTriangleMesh()
Definition: NvFlex.h:880
+
float adhesion
Controls how strongly particles stick to surfaces they hit, default 0.0, range [0.0, +inf].
Definition: NvFlex.h:109
NV_FLEX_API void NvFlexUnregisterOGLBuffer(NvFlexBuffer *buf)
-
float halfExtents[3]
Definition: NvFlex.h:777
-
Definition: NvFlex.h:775
-
NV_FLEX_API void NvFlexGetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, int n)
+
float halfExtents[3]
Definition: NvFlex.h:862
+
Definition: NvFlex.h:860
NV_FLEX_API NvFlexDistanceFieldId NvFlexCreateDistanceField(NvFlexLibrary *lib)
-
int * phases
Device pointer to the active particle phase data.
Definition: NvFlex.h:265
+
int * phases
Device pointer to the active particle phase data.
Definition: NvFlex.h:274
NV_FLEX_API void NvFlexFlush(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexGetBounds(NvFlexSolver *solver, NvFlexBuffer *lower, NvFlexBuffer *upper)
-
Host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:79
-
int numActive
The number of active particles returned, the callback data only return pointers to active particle da...
Definition: NvFlex.h:267
+
A host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:78
+
int numActive
The number of active particles returned, the callback data only return pointers to active particle da...
Definition: NvFlex.h:276
NV_FLEX_API NvFlexLibrary * NvFlexGetSolverLibrary(NvFlexSolver *solver)
+
Particle will collide with shapes with channel 7 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:178
struct NvFlexBuffer NvFlexBuffer
Definition: NvFlex.h:62
-
float sortCellIndices
Time spent sorting grid indices.
Definition: NvFlex.h:188
-
float radius
The maximum interaction radius for particles.
Definition: NvFlex.h:101
+
float sortCellIndices
Time spent sorting grid indices.
Definition: NvFlex.h:205
+
int srcOffset
Definition: NvFlex.h:502
+
int maxParticles
Maximum number of regular particles in the solver.
Definition: NvFlex.h:368
+
NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
+
void * computeContext
Direct3D context to use for simulation, if none is specified a new context will be created...
Definition: NvFlex.h:321
+
float radius
The maximum interaction radius for particles.
Definition: NvFlex.h:100
NV_FLEX_API void NvFlexGetContacts(NvFlexSolver *solver, NvFlexBuffer *planes, NvFlexBuffer *velocities, NvFlexBuffer *indices, NvFlexBuffer *counts)
-
NvFlexBoxGeometry box
Definition: NvFlex.h:816
-
float * velocities
Device pointer to the active particle velocity data in the form x,y,z,w (last component is not used) ...
Definition: NvFlex.h:264
-
float anisotropyMin
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:132
-
float applyDeltas
Time spent adding position deltas to particles.
Definition: NvFlex.h:202
-
NvFlexDistanceFieldId field
A signed distance field pointer created by NvFlexCreateDistanceField()
Definition: NvFlex.h:805
-
float calculateDensity
Time spent calculating fluid density.
Definition: NvFlex.h:195
-
void * userData
Definition: NvFlex.h:292
-
A capsule shape, see FlexCapsuleGeometry.
Definition: NvFlex.h:825
+
NvFlexBoxGeometry box
Definition: NvFlex.h:901
+
float * velocities
Device pointer to the active particle velocity data in the form x,y,z,w (last component is not used) ...
Definition: NvFlex.h:273
+
Particle will collide with shapes with channel 1 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:172
+
NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver *solver, unsigned long long *begin, unsigned long long *end, unsigned long long *frequency)
+
float anisotropyMin
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:130
+
float applyDeltas
Time spent adding position deltas to particles.
Definition: NvFlex.h:219
+
NvFlexDistanceFieldId field
A signed distance field pointer created by NvFlexCreateDistanceField()
Definition: NvFlex.h:890
+
float calculateDensity
Time spent calculating fluid density.
Definition: NvFlex.h:212
+
void * userData
Definition: NvFlex.h:289
+
A capsule shape, see FlexCapsuleGeometry.
Definition: NvFlex.h:910
NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh(NvFlexLibrary *lib)
-
NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
+
NvFlexFeatureMode featureMode
Control which features are enabled.
Definition: NvFlex.h:366
NV_FLEX_API void NvFlexShutdown(NvFlexLibrary *lib)
-
NvFlexSolver * solver
Pointer to the solver that the callback is registered to.
Definition: NvFlex.h:260
-
If set this particle will generate fluid density constraints for its overlapping neighbors.
Definition: NvFlex.h:172
-
NvFlexPhase
Definition: NvFlex.h:166
+
NvFlexSolver * solver
Pointer to the solver that the callback is registered to.
Definition: NvFlex.h:269
+
If set this particle will generate fluid density constraints for its overlapping neighbors.
Definition: NvFlex.h:168
+
NvFlexFeatureMode
Definition: NvFlex.h:354
+
NvFlexPhase
Definition: NvFlex.h:160
NV_FLEX_API void NvFlexUnregisterD3DBuffer(NvFlexBuffer *buf)
-
float sleepThreshold
Particles with a velocity magnitude < this threshold will be considered fixed.
Definition: NvFlex.h:111
-
NV_FLEX_API void NvFlexGetDensities(NvFlexSolver *solver, NvFlexBuffer *densities, int n)
+
bool useComputeQueue
If true, run Flex on a D3D12 compute queue, or vendor specific D3D11 compute queue. This allows compute and graphics to run in parallel on some GPUs.
Definition: NvFlex.h:322
+
float sleepThreshold
Particles with a velocity magnitude < this threshold will be considered fixed.
Definition: NvFlex.h:110
NV_FLEX_API int NvFlexGetVersion()
-
float anisotropyMax
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:133
-
float collideTriangles
Time spent colliding triangle shapes.
Definition: NvFlex.h:193
+
float anisotropyMax
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:131
+
float collideTriangles
Time spent colliding triangle shapes.
Definition: NvFlex.h:210
NV_FLEX_API int NvFlexGetDetailTimers(NvFlexSolver *solver, NvFlexDetailTimer **timers)
-
NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, int n)
NV_FLEX_API void NvFlexGetConvexMeshBounds(NvFlexLibrary *lib, NvFlexConvexMeshId mesh, float *lower, float *upper)
-
Indicates the shape is dynamic and should have lower priority over static collision shapes...
Definition: NvFlex.h:835
+
Indicates the shape is dynamic and should have lower priority over static collision shapes...
Definition: NvFlex.h:920
Calling thread will check if buffer is ready for access, if not ready then the method will return NUL...
Definition: NvFlex.h:70
-
NV_FLEX_API void NvFlexGetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, int n)
-
float shockPropagation
Artificially decrease the mass of particles based on height from a fixed reference point...
Definition: NvFlex.h:116
+
NV_FLEX_API int NvFlexMakePhaseWithChannels(int group, int particleFlags, int shapeChannels)
Definition: NvFlex.h:190
+
NV_FLEX_API int NvFlexMakePhase(int group, int particleFlags)
Definition: NvFlex.h:195
+
NV_FLEX_API void NvFlexSetActive(NvFlexSolver *solver, NvFlexBuffer *indices, const NvFlexCopyDesc *desc)
+
float shockPropagation
Artificially decrease the mass of particles based on height from a fixed reference point...
Definition: NvFlex.h:115
NV_FLEX_API const char * NvFlexGetDeviceName(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexDestroyConvexMesh(NvFlexLibrary *lib, NvFlexConvexMeshId convex)
-
float collideFields
Time spent colliding signed distance field shapes.
Definition: NvFlex.h:194
-
float calculateAnisotropy
Time spent calculating particle anisotropy for fluid.
Definition: NvFlex.h:203
-
void * renderContext
Direct3D context to use for simulation, if none is specified a new context will be created...
Definition: NvFlex.h:282
+
float collideFields
Time spent colliding signed distance field shapes.
Definition: NvFlex.h:211
+
float calculateAnisotropy
Time spent calculating particle anisotropy for fluid.
Definition: NvFlex.h:220
+
Particle will collide with shapes with channel 6 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:177
+
NV_FLEX_API void NvFlexGetParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
+
void * renderContext
Direct3D context that the app is using for rendering. In DirectX 12 this should be a ID3D12CommandQue...
Definition: NvFlex.h:320
struct NvFlexLibrary NvFlexLibrary
Definition: NvFlex.h:52
NV_FLEX_API void NvFlexAcquireContext(NvFlexLibrary *lib)
NV_FLEX_API NvFlexLibrary * NvFlexInit(int version=NV_FLEX_VERSION, NvFlexErrorCallback errorFunc=0, NvFlexInitDesc *desc=0)
-
float freeSurfaceDrag
Drag force applied to boundary fluid particles.
Definition: NvFlex.h:136
-
NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver *solver)
-
NvFlexSDFGeometry sdf
Definition: NvFlex.h:819
-
float maxAcceleration
The magnitude of particle acceleration will be clamped to this value at the end of each step (limits ...
Definition: NvFlex.h:114
-
float wind[3]
Constant acceleration applied to particles that belong to dynamic triangles, drag needs to be > 0 for...
Definition: NvFlex.h:121
+
float freeSurfaceDrag
Drag force applied to boundary fluid particles.
Definition: NvFlex.h:134
+
NV_FLEX_API void NvFlexSetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, const NvFlexCopyDesc *desc)
+
NvFlexSDFGeometry sdf
Definition: NvFlex.h:904
+
float maxAcceleration
The magnitude of particle acceleration will be clamped to this value at the end of each step (limits ...
Definition: NvFlex.h:113
+
float wind[3]
Constant acceleration applied to particles that belong to dynamic triangles, drag needs to be > 0 for...
Definition: NvFlex.h:120
+
Particle will collide with shapes with channel 5 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:176
+
NV_FLEX_API NvFlexSolver * NvFlexCreateSolver(NvFlexLibrary *lib, const NvFlexSolverDesc *desc)
NV_FLEX_API void NvFlexUpdateDistanceField(NvFlexLibrary *lib, NvFlexDistanceFieldId sdf, int dimx, int dimy, int dimz, NvFlexBuffer *field)
-
Definition: NvFlex.h:184
-
float surfaceTension
Controls how strongly particles attempt to minimize surface area, default: 0.0, range: [0...
Definition: NvFlex.h:128
-
float dt
The per-update time-step, this is the value passed to NvFlexUpdateSolver()
Definition: NvFlex.h:269
-
float diffuseSortAxis[3]
Diffuse particles will be sorted by depth along this axis if non-zero.
Definition: NvFlex.h:144
-
float fluidRestDistance
The distance fluid particles are spaced at the rest density, must be in the range (0...
Definition: NvFlex.h:103
-
float reorder
Time spent reordering particles.
Definition: NvFlex.h:190
-
unsigned int NvFlexDistanceFieldId
Definition: NvFlex.h:638
-
A triangle mesh shape, see FlexTriangleMeshGeometry.
Definition: NvFlex.h:828
-
If set this particle will ignore collisions with particles closer than the radius in the rest pose...
Definition: NvFlex.h:171
-
NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver *solver, NvFlexBuffer *q1, NvFlexBuffer *q2, NvFlexBuffer *q3)
+
Definition: NvFlex.h:201
+
float surfaceTension
Controls how strongly particles attempt to minimize surface area, default: 0.0, range: [0...
Definition: NvFlex.h:126
+
Particle will collide with shapes with channel 0 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:171
+
float dt
The per-update time-step, this is the value passed to NvFlexUpdateSolver()
Definition: NvFlex.h:278
+
float fluidRestDistance
The distance fluid particles are spaced at the rest density, must be in the range (0...
Definition: NvFlex.h:102
+
float reorder
Time spent reordering particles.
Definition: NvFlex.h:207
+
unsigned int NvFlexDistanceFieldId
Definition: NvFlex.h:723
+
A triangle mesh shape, see FlexTriangleMeshGeometry.
Definition: NvFlex.h:913
+
If set this particle will ignore collisions with particles closer than the radius in the rest pose...
Definition: NvFlex.h:167
NV_FLEX_API void NvFlexGetTimers(NvFlexSolver *solver, NvFlexTimers *timers)
-
NvFlexConvexMeshId mesh
Definition: NvFlex.h:786
-
NvFlexConvexMeshGeometry convexMesh
Definition: NvFlex.h:817
-
NvFlexSolverCallbackStage
Definition: NvFlex.h:227
-
float dissipation
Damps particle velocity based on how many particle contacts it has.
Definition: NvFlex.h:117
-
NvFlexCollisionShapeType
Definition: NvFlex.h:822
-
Used only in debug version of dll.
Definition: NvFlex.h:220
-
Use CUDA compute for Flex, the application must link against the CUDA libraries.
Definition: NvFlex.h:241
-
NvFlexRelaxationMode relaxationMode
How the relaxation is applied inside the solver.
Definition: NvFlex.h:159
-
float lift
Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:123
+
NvFlexConvexMeshId mesh
Definition: NvFlex.h:871
+
NV_FLEX_API void NvFlexGetRigids(NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *thresholds, NvFlexBuffer *creeps, NvFlexBuffer *rotations, NvFlexBuffer *translations)
+
NvFlexConvexMeshGeometry convexMesh
Definition: NvFlex.h:902
+
NvFlexSolverCallbackStage
Definition: NvFlex.h:244
+
float dissipation
Damps particle velocity based on how many particle contacts it has.
Definition: NvFlex.h:116
+
NvFlexCollisionShapeType
Definition: NvFlex.h:907
+
Used only in debug version of dll.
Definition: NvFlex.h:237
+
Use CUDA compute for Flex, the application must link against the CUDA libraries.
Definition: NvFlex.h:307
+
NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary *lib, NvFlexConvexMeshId convex, NvFlexBuffer *planes, int numPlanes, const float *lower, const float *upper)
+
NvFlexRelaxationMode relaxationMode
How the relaxation is applied inside the solver.
Definition: NvFlex.h:152
+
float lift
Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:122
NV_FLEX_API void NvFlexGetDeviceAndContext(NvFlexLibrary *lib, void **device, void **context)
-
void * renderDevice
Direct3D device to use for simulation, if none is specified a new device and context will be created...
Definition: NvFlex.h:281
-
A box shape, see FlexBoxGeometry.
Definition: NvFlex.h:826
-
float damping
Viscous drag force, applies a force proportional, and opposite to the particle velocity.
Definition: NvFlex.h:118
+
void * renderDevice
Direct3D device to use for simulation, if none is specified a new device and context will be created...
Definition: NvFlex.h:319
+
A box shape, see FlexBoxGeometry.
Definition: NvFlex.h:911
+
float damping
Viscous drag force, applies a force proportional, and opposite to the particle velocity.
Definition: NvFlex.h:117
NV_FLEX_API void NvFlexSetDynamicTriangles(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *normals, int numTris)
-
NvFlexCollisionShapeFlags
Definition: NvFlex.h:832
-
int numPlanes
Num collision planes.
Definition: NvFlex.h:157
-
NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary *lib, NvFlexConvexMeshId convex, NvFlexBuffer *planes, int numPlanes, float *lower, float *upper)
+
NvFlexCollisionShapeFlags
Definition: NvFlex.h:917
+
int numPlanes
Num collision planes.
Definition: NvFlex.h:150
NV_FLEX_API NvFlexBuffer * NvFlexAllocBuffer(NvFlexLibrary *lib, int elementCount, int elementByteStride, NvFlexBufferType type)
-
Definition: NvFlex.h:96
-
float collideShapes
Time spent colliding convex shapes.
Definition: NvFlex.h:192
-
float particleFriction
Coefficient of friction used when colliding particles.
Definition: NvFlex.h:108
+
Definition: NvFlex.h:95
+
float collideShapes
Time spent colliding convex shapes.
Definition: NvFlex.h:209
+
float particleFriction
Coefficient of friction used when colliding particles.
Definition: NvFlex.h:107
NV_FLEX_API void NvFlexUpdateSolver(NvFlexSolver *solver, float dt, int substeps, bool enableTimers)
-
NV_FLEX_API void NvFlexSetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, int n)
-
NV_FLEX_API void NvFlexGetRigidTransforms(NvFlexSolver *solver, NvFlexBuffer *rotations, NvFlexBuffer *translations)
-
float createGrid
Time spent creating grid.
Definition: NvFlex.h:189
-
Low 24 bits represent the particle group for controlling collisions.
Definition: NvFlex.h:168
-
NV_FLEX_API void NvFlexGetParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
-
float buoyancy
Gravity is scaled by this value for fluid particles.
Definition: NvFlex.h:137
-
All log types.
Definition: NvFlex.h:221
+
float createGrid
Time spent creating grid.
Definition: NvFlex.h:206
+
Bits [ 0, 19] represent the particle group for controlling collisions.
Definition: NvFlex.h:162
+
float buoyancy
Gravity is scaled by this value for fluid particles.
Definition: NvFlex.h:135
+
All log types.
Definition: NvFlex.h:238
NV_FLEX_API void NvFlexSetShapes(NvFlexSolver *solver, NvFlexBuffer *geometry, NvFlexBuffer *shapePositions, NvFlexBuffer *shapeRotations, NvFlexBuffer *shapePrevPositions, NvFlexBuffer *shapePrevRotations, NvFlexBuffer *shapeFlags, int numShapes)
-
NV_FLEX_API void NvFlexSetParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
-
Use DirectX 12 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:243
-
float scale[3]
The scale of the object from local space to world space.
Definition: NvFlex.h:794
-
float solveDensities
Time spent solving density constraints.
Definition: NvFlex.h:196
-
float plasticThreshold
Particles belonging to rigid shapes that move with a position delta magnitude > threshold will be per...
Definition: NvFlex.h:148
+
Use DirectX 12 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:309
+
float scale[3]
The scale of the object from local space to world space.
Definition: NvFlex.h:879
+
float solveDensities
Time spent solving density constraints.
Definition: NvFlex.h:213
+
NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
+
NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver *solver, NvFlexBuffer *q1, NvFlexBuffer *q2, NvFlexBuffer *q3, const NvFlexCopyDesc *desc)
NV_FLEX_API void NvFlexDestroyTriangleMesh(NvFlexLibrary *lib, NvFlexTriangleMeshId mesh)
-
float gravity[3]
Constant acceleration applied to all particles.
Definition: NvFlex.h:100
-
Called at the end of each constraint iteration.
Definition: NvFlex.h:230
-
Error messages.
Definition: NvFlex.h:217
+
float gravity[3]
Constant acceleration applied to all particles.
Definition: NvFlex.h:99
+
Called at the end of each constraint iteration.
Definition: NvFlex.h:247
+
Error messages.
Definition: NvFlex.h:234
NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer *buf)
-
float solveInflatables
Time spent solving pressure constraints.
Definition: NvFlex.h:201
-
Called at the beginning of each substep after the prediction step has been completed.
Definition: NvFlex.h:231
-
NV_FLEX_API void NvFlexSetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, int n)
-
Definition: NvFlex.h:277
-
The relaxation factor is a fixed multiplier on each constraint's position delta.
Definition: NvFlex.h:88
-
Definition: NvFlex.h:766
-
float total
Sum of all timers above.
Definition: NvFlex.h:209
-
void * userData
Pointer to the user data provided to NvFlexRegisterSolverCallback()
Definition: NvFlex.h:261
-
float radius
Definition: NvFlex.h:768
+
Bits [24, 31] hold flags representing what shape collision channels particles will collide with...
Definition: NvFlex.h:164
+
float solveInflatables
Time spent solving pressure constraints.
Definition: NvFlex.h:218
+
Called at the beginning of each substep after the prediction step has been completed.
Definition: NvFlex.h:248
+
Simple per-particle collision (no per-particle SDF normals, no fluids)
Definition: NvFlex.h:357
+
Definition: NvFlex.h:315
+
The relaxation factor is a fixed multiplier on each constraint's position delta.
Definition: NvFlex.h:87
+
NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, const NvFlexCopyDesc *desc)
+
Definition: NvFlex.h:851
+
float total
Sum of all timers above.
Definition: NvFlex.h:226
+
void * userData
Pointer to the user data provided to NvFlexRegisterSolverCallback()
Definition: NvFlex.h:270
+
NV_FLEX_API void NvFlexGetDensities(NvFlexSolver *solver, NvFlexBuffer *densities, const NvFlexCopyDesc *desc)
+
float radius
Definition: NvFlex.h:853
NV_FLEX_API void NvFlexGetDynamicTriangles(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *normals, int numTris)
-
NV_FLEX_API int NvFlexMakeShapeFlags(NvFlexCollisionShapeType type, bool dynamic)
Definition: NvFlex.h:844
+
NV_FLEX_API int NvFlexMakeShapeFlags(NvFlexCollisionShapeType type, bool dynamic)
Definition: NvFlex.h:938
NV_FLEX_API NvFlexBuffer * NvFlexRegisterOGLBuffer(NvFlexLibrary *lib, int buf, int elementCount, int elementByteStride)
-
Definition: NvFlex.h:990
-
float relaxationFactor
Control the convergence rate of the parallel solver, default: 1, values greater than 1 may lead to in...
Definition: NvFlex.h:160
+
Definition: NvFlex.h:1134
+
Particle will collide with shapes with channel 2 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:173
+
float relaxationFactor
Control the convergence rate of the parallel solver, default: 1, values greater than 1 may lead to in...
Definition: NvFlex.h:153
NV_FLEX_API void NvFlexSetSprings(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
-
float finalize
Time spent finalizing state.
Definition: NvFlex.h:207
-
const int * sortedToOriginalMap
Device pointer that maps the original particle index to the index in the callback data structure...
Definition: NvFlex.h:272
-
NvFlexComputeType
Definition: NvFlex.h:239
-
NV_FLEX_API void NvFlexSetActive(NvFlexSolver *solver, NvFlexBuffer *indices, int n)
-
float dynamicFriction
Coefficient of friction used when colliding against shapes.
Definition: NvFlex.h:106
-
float plasticCreep
Controls the rate at which particles in the rest pose are deformed for particles passing the deformat...
Definition: NvFlex.h:149
-
Definition: NvFlex.h:802
-
float scale[3]
Definition: NvFlex.h:785
-
Definition: NvFlex.h:289
-
float diffuseBuoyancy
Scales force opposing gravity that diffuse particles receive.
Definition: NvFlex.h:141
-
float updateBounds
Time spent updating particle bounds.
Definition: NvFlex.h:208
-
char * name
Definition: NvFlex.h:992
-
float solidRestDistance
The distance non-fluid particles attempt to maintain from each other, must be in the range (0...
Definition: NvFlex.h:102
-
float solidPressure
Add pressure from solid surfaces to particles.
Definition: NvFlex.h:135
-
float solveVelocities
Time spent solving velocity constraints.
Definition: NvFlex.h:197
-
Number of stages.
Definition: NvFlex.h:234
-
float restitution
Coefficient of restitution used when colliding against shapes, particle collisions are always inelast...
Definition: NvFlex.h:109
-
Definition: NvFlex.h:792
-
int numIterations
Number of solver iterations to perform per-substep.
Definition: NvFlex.h:98
+
float finalize
Time spent finalizing state.
Definition: NvFlex.h:224
+
const int * sortedToOriginalMap
Device pointer that maps the original particle index to the index in the callback data structure...
Definition: NvFlex.h:281
+
NvFlexComputeType
Definition: NvFlex.h:305
+
float dynamicFriction
Coefficient of friction used when colliding against shapes.
Definition: NvFlex.h:105
+
Definition: NvFlex.h:887
+
float scale[3]
Definition: NvFlex.h:870
+
Definition: NvFlex.h:286
+
float diffuseBuoyancy
Scales force opposing gravity that diffuse particles receive.
Definition: NvFlex.h:139
+
float updateBounds
Time spent updating particle bounds.
Definition: NvFlex.h:225
+
char * name
Definition: NvFlex.h:1136
+
float solidRestDistance
The distance non-fluid particles attempt to maintain from each other, must be in the range (0...
Definition: NvFlex.h:101
+
NV_FLEX_API void NvFlexSetSolverDescDefaults(NvFlexSolverDesc *desc)
+
float solidPressure
Add pressure from solid surfaces to particles.
Definition: NvFlex.h:133
+
float solveVelocities
Time spent solving velocity constraints.
Definition: NvFlex.h:214
+
Number of stages.
Definition: NvFlex.h:251
+
float restitution
Coefficient of restitution used when colliding against shapes, particle collisions are always inelast...
Definition: NvFlex.h:108
+
Definition: NvFlex.h:877
+
int numIterations
Number of solver iterations to perform per-substep.
Definition: NvFlex.h:97
NV_FLEX_API void NvFlexRestoreContext(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexGetParams(NvFlexSolver *solver, NvFlexParams *params)
-
NV_FLEX_API NvFlexSolver * NvFlexCreateSolver(NvFlexLibrary *lib, int maxParticles, int maxDiffuseParticles, int maxNeighborsPerParticle=96)
-
float anisotropyScale
Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy...
Definition: NvFlex.h:131
-
float vorticityConfinement
Increases vorticity by applying rotational forces to particles.
Definition: NvFlex.h:130
-
NV_FLEX_API int NvFlexGetDiffuseParticles(NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, NvFlexBuffer *indices)
-
float diffuseLifetime
Time in seconds that a diffuse particle will live for after being spawned, particles will be spawned ...
Definition: NvFlex.h:145
-
float diffuseDrag
Scales force diffuse particles receive in direction of neighbor fluid particles.
Definition: NvFlex.h:142
-
float particleCollisionMargin
Increases the radius used during neighbor finding, this is useful if particles are expected to move s...
Definition: NvFlex.h:153
-
float diffuseThreshold
Particles with kinetic energy + divergence above this threshold will spawn new diffuse particles...
Definition: NvFlex.h:140
-
Device memory buffer, mapping this on CUDA will return a device memory pointer, and will return a buf...
Definition: NvFlex.h:80
+
float anisotropyScale
Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy...
Definition: NvFlex.h:129
+
float vorticityConfinement
Increases vorticity by applying rotational forces to particles.
Definition: NvFlex.h:128
+
float diffuseLifetime
Time in seconds that a diffuse particle will live for after being spawned, particles will be spawned ...
Definition: NvFlex.h:142
+
float diffuseDrag
Scales force diffuse particles receive in direction of neighbor fluid particles.
Definition: NvFlex.h:140
+
NV_FLEX_API void NvFlexGetSolverDesc(NvFlexSolver *solver, NvFlexSolverDesc *desc)
+
float particleCollisionMargin
Increases the radius used during neighbor finding, this is useful if particles are expected to move s...
Definition: NvFlex.h:146
+
float diffuseThreshold
Particles with kinetic energy + divergence above this threshold will spawn new diffuse particles...
Definition: NvFlex.h:138
+
int elementCount
Definition: NvFlex.h:504
+
A device memory buffer, mapping this on CUDA will return a device memory pointer, and will return a b...
Definition: NvFlex.h:79
NV_FLEX_API void NvFlexGetSprings(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
-
A convex mesh shape, see FlexConvexMeshGeometry.
Definition: NvFlex.h:827
-
float updateTriangles
Time spent updating dynamic triangles.
Definition: NvFlex.h:205
-
NvFlexBufferType
Definition: NvFlex.h:77
-
bool enableExtensions
Enable or disable NVIDIA/AMD extensions in DirectX, can lead to improved performance.
Definition: NvFlex.h:280
-
unsigned int NvFlexConvexMeshId
Definition: NvFlex.h:645
+
NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
+
NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, const NvFlexCopyDesc *desc)
+
A convex mesh shape, see FlexConvexMeshGeometry.
Definition: NvFlex.h:912
+
float updateTriangles
Time spent updating dynamic triangles.
Definition: NvFlex.h:222
+
Definition: NvFlex.h:500
+
NvFlexBufferType
Definition: NvFlex.h:76
+
bool enableExtensions
Enable or disable NVIDIA/AMD extensions in DirectX, can lead to improved performance.
Definition: NvFlex.h:318
+
unsigned int NvFlexConvexMeshId
Definition: NvFlex.h:730
diff --git a/doc/_static/api/_nv_flex_device_8h.html b/doc/_static/api/_nv_flex_device_8h.html index 20f041b..9f0be26 100644 --- a/doc/_static/api/_nv_flex_device_8h.html +++ b/doc/_static/api/_nv_flex_device_8h.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -115,7 +115,7 @@ Functions diff --git a/doc/_static/api/_nv_flex_device_8h_source.html b/doc/_static/api/_nv_flex_device_8h_source.html index 42e8d54..8986294 100644 --- a/doc/_static/api/_nv_flex_device_8h_source.html +++ b/doc/_static/api/_nv_flex_device_8h_source.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -91,7 +91,7 @@ diff --git a/doc/_static/api/_nv_flex_ext_8h.html b/doc/_static/api/_nv_flex_ext_8h.html index fc0433a..8b89124 100644 --- a/doc/_static/api/_nv_flex_ext_8h.html +++ b/doc/_static/api/_nv_flex_ext_8h.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -109,8 +109,8 @@ Functions   NV_FLEX_API NvFlexExtAssetNvFlexExtCreateRigidFromMesh (const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float radius, float expand)   -NV_FLEX_API NvFlexExtAssetNvFlexExtCreateSoftFromMesh (const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness) -  +NV_FLEX_API NvFlexExtAssetNvFlexExtCreateSoftFromMesh (const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness, float clusterPlasticThreshold, float clusterPlasticCreep) +  NV_FLEX_API void NvFlexExtDestroyAsset (NvFlexExtAsset *asset)   NV_FLEX_API void NvFlexExtCreateSoftMeshSkinning (const float *vertices, int numVertices, const float *bones, int numBones, float falloff, float maxDistance, float *skinningWeights, int *skinningIndices) @@ -310,6 +310,18 @@ numShapes The number of shape matching constraints. +float * + +shapePlasticThresholds + +The plastic threshold coefficient for each shape. + +float * + +shapePlasticCreeps + +The plastic creep coefficient for each shape. + int * triangleIndices @@ -1232,7 +1244,7 @@ Linear or no falloff. - +
@@ -1312,7 +1324,19 @@ Linear or no falloff. - + + + + + + + + + + + + + @@ -1337,6 +1361,8 @@ Linear or no falloff. + +
float globalStiffness globalStiffness,
float clusterPlasticThreshold,
float clusterPlasticCreep 
[in]linkRadiusAny particles below this distance will have additional distance constraints created between them
[in]linkStiffnessThe stiffness of distance links
[in]globalStiffnessIf this parameter is > 0.0f, adds an additional global cluster that consists of all particles in the shape. The stiffness of this cluster is the globalStiffness.
[in]clusterPlasticThresholdParticles belonging to rigid shapes that move with a position delta magnitude > threshold will be permanently deformed in the rest pose, if clusterPlasticCreep > 0.0f
[in]clusterPlasticCreepControls the rate at which particles in the rest pose are deformed for particles passing the deformation threshold
@@ -1879,7 +1905,7 @@ Linear or no falloff.
-

Notifies the container that asset data has changed and needs to be sent to the GPU this should be called if the constrains for an existing asset are modified by the user

+

Notifies the container that asset data has changed and needs to be sent to the GPU this should be called if the constraints for an existing asset are modified by the user

Parameters
@@ -2038,7 +2064,7 @@ Linear or no falloff.

Create a NvFlexExtForceFieldCallback structure, each callback is associated with the passed in solver once the NvFlexExtSetForceFields() is called.

Parameters
[in]containerThe container the instance referencing the asset belongs to
- +
[in]solverA valid solver created with NvFlexCreateSolver()
[in]solverA valid solver created with NvFlexCreateSolver()
@@ -2113,7 +2139,7 @@ Linear or no falloff.
diff --git a/doc/_static/api/_nv_flex_ext_8h_source.html b/doc/_static/api/_nv_flex_ext_8h_source.html index d704ded..18c994b 100644 --- a/doc/_static/api/_nv_flex_ext_8h_source.html +++ b/doc/_static/api/_nv_flex_ext_8h_source.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -80,7 +80,7 @@
44 template <typename T>
46 {
-
47  NvFlexVector(NvFlexLibrary* l, int size=0) : lib(l), buffer(NULL), mappedPtr(NULL), count(0), capacity(0)
+
48  {
49  if (size)
50  {
@@ -91,7 +91,7 @@
55  }
56  }
57 
-
58  NvFlexVector(NvFlexLibrary* l, const T* ptr, int size) : lib(l), buffer(NULL), mappedPtr(NULL), count(0), capacity(0)
+
59  {
60  assign(ptr, size);
61  unmap();
@@ -109,515 +109,524 @@
74  int count;
75  int capacity;
-
76 
-
77  // reinitialize the vector leaving it unmapped
-
78  void init(int size)
-
79  {
-
80  destroy();
-
81  resize(size);
-
82  unmap();
-
83  }
-
84 
-
85  void destroy()
-
86  {
-
87  if (mappedPtr)
-
88  NvFlexUnmap(buffer);
-
89 
-
90  if (buffer)
-
91  NvFlexFreeBuffer(buffer);
-
92 
-
93  mappedPtr = NULL;
-
94  buffer = NULL;
-
95  capacity = 0;
-
96  count = 0;
-
97  }
-
98 
-
99  void map(int flags=eNvFlexMapWait)
-
100  {
-
101  if (!buffer)
-
102  return;
-
103 
-
104  assert(!mappedPtr);
-
105  mappedPtr = (T*)NvFlexMap(buffer, flags);
-
106  }
-
107 
-
108  void unmap()
-
109  {
-
110  if (!buffer)
-
111  return;
-
112 
-
113  assert(mappedPtr);
-
114 
-
115  NvFlexUnmap(buffer);
-
116  mappedPtr = 0;
-
117  }
-
118 
-
119  const T& operator[](int index) const
-
120  {
-
121  assert(mappedPtr);
-
122  assert(index < count);
-
123 
-
124  return mappedPtr[index];
-
125  }
-
126 
-
127  T& operator[](int index)
-
128  {
-
129  assert(mappedPtr);
-
130  assert(index < count);
-
131 
-
132  return mappedPtr[index];
-
133  }
-
134 
-
135  void push_back(const T& t)
-
136  {
-
137  assert(mappedPtr || !buffer);
-
138 
-
139  reserve(count+1);
-
140 
-
141  // copy element
-
142  mappedPtr[count++] = t;
-
143  }
-
144 
-
145  void assign(const T* srcPtr, int newCount)
-
146  {
-
147  assert(mappedPtr || !buffer);
-
148 
-
149  resize(newCount);
-
150 
-
151  memcpy(mappedPtr, srcPtr, newCount*sizeof(T));
-
152  }
-
153 
-
154  void copyto(T* dest, int count)
-
155  {
-
156  assert(mappedPtr);
-
157 
-
158  memcpy(dest, mappedPtr, sizeof(T)*count);
-
159  }
-
160 
-
161  int size() const { return count; }
-
162 
-
163  bool empty() const { return size() == 0; }
-
164 
-
165  const T& back() const
-
166  {
-
167  assert(mappedPtr);
-
168  assert(!empty());
-
169 
-
170  return mappedPtr[count-1];
-
171  }
-
172 
-
173  void reserve(int minCapacity)
-
174  {
-
175  if (minCapacity > capacity)
-
176  {
-
177  // growth factor of 1.5
-
178  const int newCapacity = minCapacity*3/2;
-
179 
-
180  NvFlexBuffer* newBuf = NvFlexAllocBuffer(lib, newCapacity, sizeof(T), eNvFlexBufferHost);
-
181 
-
182  // copy contents to new buffer
-
183  void* newPtr = NvFlexMap(newBuf, eNvFlexMapWait);
-
184  memcpy(newPtr, mappedPtr, count*sizeof(T));
-
185 
-
186  // unmap old buffer, but leave new buffer mapped
-
187  unmap();
-
188 
-
189  if (buffer)
-
190  NvFlexFreeBuffer(buffer);
-
191 
-
192  // swap
-
193  buffer = newBuf;
-
194  mappedPtr = (T*)newPtr;
-
195  capacity = newCapacity;
-
196  }
-
197  }
-
198 
-
199  // resizes mapped buffer and leaves new buffer mapped
-
200  void resize(int newCount)
-
201  {
-
202  assert(mappedPtr || !buffer);
-
203 
-
204  reserve(newCount);
-
205 
-
206  // resize but do not initialize new entries
-
207  count = newCount;
-
208  }
-
209 
-
210  void resize(int newCount, const T& val)
-
211  {
-
212  assert(mappedPtr || !buffer);
-
213 
-
214  const int startInit = count;
-
215  const int endInit = newCount;
-
216 
-
217  resize(newCount);
-
218 
-
219  // init any new entries
-
220  for (int i=startInit; i < endInit; ++i)
-
221  mappedPtr[i] = val;
-
222  }
-
223 };
-
224 
-
225 extern "C" {
-
226 
- -
231 {
-
232  float position[3];
-
233  float rotation[4];
-
234 
-
235  float velocity[3];
-
236  float omega[3];
-
237 
-
238  float acceleration[3];
-
239  float tau[3];
-
240 
-
241  float delta[4][4];
-
242 };
-
243 
-
280 NV_FLEX_API void NvFlexExtMovingFrameInit(NvFlexExtMovingFrame* frame, const float* worldTranslation, const float* worldRotation);
-
281 
-
282 /* Update a frame to a new position, this will automatically update the velocity and acceleration of
-
283  * the frame, which can then be used to calculate inertial forces. This should be called once per-frame
-
284  * with the new position and time-step used when moving the frame.
-
285  *
-
286  * @param[in] frame A pointer to a user-allocated NvFlexExtMovingFrame struct
-
287  * @param[in] worldTranslation A pointer to a vec3 storing the frame's initial translation in world space
-
288  * @param[in] worldRotation A pointer to a quaternion storing the frame's initial rotation in world space
-
289  * @param[in] dt The time that elapsed since the last call to the frame update
-
290  */
-
291 NV_FLEX_API void NvFlexExtMovingFrameUpdate(NvFlexExtMovingFrame* frame, const float* worldTranslation, const float* worldRotation, float dt);
-
292 
-
293 /* Teleport particles to the frame's new position and apply the inertial forces
-
294  *
-
295  * @param[in] frame A pointer to a user-allocated NvFlexExtMovingFrame struct
-
296  * @param[in] positions A pointer to an array of particle positions in (x, y, z, 1/m) format
-
297  * @param[in] velocities A pointer to an array of particle velocities in (vx, vy, vz) format
-
298  * @param[in] numParticles The number of particles to update
-
299  * @param[in] linearScale How strongly the translational inertial forces should be applied, 0.0 corresponds to a purely local space simulation removing all inertial forces, 1.0 corresponds to no inertial damping and has no benefit over regular world space simulation
-
300  * @param[in] angularScale How strongly the angular inertial forces should be applied, 0.0 corresponds to a purely local space simulation, 1.0 corresponds to no inertial damping
-
301  * @param[in] dt The time that elapsed since the last call to the frame update, should match the value passed to NvFlexExtMovingFrameUpdate()
-
302  */
-
303 NV_FLEX_API void NvFlexExtMovingFrameApply(NvFlexExtMovingFrame* frame, float* positions, float* velocities, int numParticles, float linearScale, float angularScale, float dt);
-
304 
+ +
77 
+
78  // reinitialize the vector leaving it unmapped
+
79  void init(int size)
+
80  {
+
81  destroy();
+
82  resize(size);
+
83  unmap();
+
84  }
+
85 
+
86  void destroy()
+
87  {
+
88  if (mappedPtr)
+
89  NvFlexUnmap(buffer);
+
90 
+
91  if (buffer)
+
92  NvFlexFreeBuffer(buffer);
+
93 
+
94  mappedPtr = NULL;
+
95  buffer = NULL;
+
96  capacity = 0;
+
97  count = 0;
+
98  }
+
99 
+
100  void map(int flags=eNvFlexMapWait)
+
101  {
+
102  if (!buffer)
+
103  return;
+
104 
+
105  assert(!mappedPtr);
+
106  mappedPtr = (T*)NvFlexMap(buffer, flags);
+
107  }
+
108 
+
109  void unmap()
+
110  {
+
111  if (!buffer)
+
112  return;
+
113 
+
114  assert(mappedPtr);
+
115 
+
116  NvFlexUnmap(buffer);
+
117  mappedPtr = 0;
+
118  }
+
119 
+
120  const T& operator[](int index) const
+
121  {
+
122  assert(mappedPtr);
+
123  assert(index < count);
+
124 
+
125  return mappedPtr[index];
+
126  }
+
127 
+
128  T& operator[](int index)
+
129  {
+
130  assert(mappedPtr);
+
131  assert(index < count);
+
132 
+
133  return mappedPtr[index];
+
134  }
+
135 
+
136  void push_back(const T& t)
+
137  {
+
138  assert(mappedPtr || !buffer);
+
139 
+
140  reserve(count+1);
+
141 
+
142  // copy element
+
143  mappedPtr[count++] = t;
+
144  }
+
145 
+
146  void assign(const T* srcPtr, int newCount)
+
147  {
+
148  assert(mappedPtr || !buffer);
+
149 
+
150  resize(newCount);
+
151 
+
152  memcpy(mappedPtr, srcPtr, newCount*sizeof(T));
+
153  }
+
154 
+
155  void copyto(T* dest, int count)
+
156  {
+
157  assert(mappedPtr);
+
158 
+
159  memcpy(dest, mappedPtr, sizeof(T)*count);
+
160  }
+
161 
+
162  int size() const { return count; }
+
163 
+
164  bool empty() const { return size() == 0; }
+
165 
+
166  const T& back() const
+
167  {
+
168  assert(mappedPtr);
+
169  assert(!empty());
+
170 
+
171  return mappedPtr[count-1];
+
172  }
+
173 
+
174  void reserve(int minCapacity)
+
175  {
+
176  if (minCapacity > capacity)
+
177  {
+
178  // growth factor of 1.5
+
179  const int newCapacity = minCapacity*3/2;
+
180 
+
181  NvFlexBuffer* newBuf = NvFlexAllocBuffer(lib, newCapacity, sizeof(T), type);
+
182 
+
183  // copy contents to new buffer
+
184  void* newPtr = NvFlexMap(newBuf, eNvFlexMapWait);
+
185  memcpy(newPtr, mappedPtr, count*sizeof(T));
+
186 
+
187  // unmap old buffer, but leave new buffer mapped
+
188  unmap();
+
189 
+
190  if (buffer)
+
191  NvFlexFreeBuffer(buffer);
+
192 
+
193  // swap
+
194  buffer = newBuf;
+
195  mappedPtr = (T*)newPtr;
+
196  capacity = newCapacity;
+
197  }
+
198  }
+
199 
+
200  // resizes mapped buffer and leaves new buffer mapped
+
201  void resize(int newCount)
+
202  {
+
203  assert(mappedPtr || !buffer);
+
204 
+
205  reserve(newCount);
+
206 
+
207  // resize but do not initialize new entries
+
208  count = newCount;
+
209  }
+
210 
+
211  void resize(int newCount, const T& val)
+
212  {
+
213  assert(mappedPtr || !buffer);
+
214 
+
215  const int startInit = count;
+
216  const int endInit = newCount;
+
217 
+
218  resize(newCount);
+
219 
+
220  // init any new entries
+
221  for (int i=startInit; i < endInit; ++i)
+
222  mappedPtr[i] = val;
+
223  }
+
224 };
+
225 
+
226 extern "C" {
+
227 
+ +
232 {
+
233  float position[3];
+
234  float rotation[4];
+
235 
+
236  float velocity[3];
+
237  float omega[3];
+
238 
+
239  float acceleration[3];
+
240  float tau[3];
+
241 
+
242  float delta[4][4];
+
243 };
+
244 
+
281 NV_FLEX_API void NvFlexExtMovingFrameInit(NvFlexExtMovingFrame* frame, const float* worldTranslation, const float* worldRotation);
+
282 
+
283 /* Update a frame to a new position, this will automatically update the velocity and acceleration of
+
284  * the frame, which can then be used to calculate inertial forces. This should be called once per-frame
+
285  * with the new position and time-step used when moving the frame.
+
286  *
+
287  * @param[in] frame A pointer to a user-allocated NvFlexExtMovingFrame struct
+
288  * @param[in] worldTranslation A pointer to a vec3 storing the frame's initial translation in world space
+
289  * @param[in] worldRotation A pointer to a quaternion storing the frame's initial rotation in world space
+
290  * @param[in] dt The time that elapsed since the last call to the frame update
+
291  */
+
292 NV_FLEX_API void NvFlexExtMovingFrameUpdate(NvFlexExtMovingFrame* frame, const float* worldTranslation, const float* worldRotation, float dt);
+
293 
+
294 /* Teleport particles to the frame's new position and apply the inertial forces
+
295  *
+
296  * @param[in] frame A pointer to a user-allocated NvFlexExtMovingFrame struct
+
297  * @param[in] positions A pointer to an array of particle positions in (x, y, z, 1/m) format
+
298  * @param[in] velocities A pointer to an array of particle velocities in (vx, vy, vz) format
+
299  * @param[in] numParticles The number of particles to update
+
300  * @param[in] linearScale How strongly the translational inertial forces should be applied, 0.0 corresponds to a purely local space simulation removing all inertial forces, 1.0 corresponds to no inertial damping and has no benefit over regular world space simulation
+
301  * @param[in] angularScale How strongly the angular inertial forces should be applied, 0.0 corresponds to a purely local space simulation, 1.0 corresponds to no inertial damping
+
302  * @param[in] dt The time that elapsed since the last call to the frame update, should match the value passed to NvFlexExtMovingFrameUpdate()
+
303  */
+
304 NV_FLEX_API void NvFlexExtMovingFrameApply(NvFlexExtMovingFrame* frame, float* positions, float* velocities, int numParticles, float linearScale, float angularScale, float dt);
305 
- -
311 {
-
312  // particles
-
313  float* particles;
- - -
316 
-
317  // springs
- - - - -
322 
-
323  // shapes
- - - - -
328  float* shapeCenters;
-
329  int numShapes;
-
330 
-
331  // faces for cloth
- - -
334 
-
335  // inflatable params
-
336  bool inflatable;
- - - -
340 };
-
341 
- -
346 {
- - -
349 
- - - -
353 
- -
355  float* shapeRotations;
-
356 
- -
358 
-
359  void* userData;
-
360 };
+
306 
+ +
312 {
+
313  // particles
+
314  float* particles;
+ + +
317 
+
318  // springs
+ + + + +
323 
+
324  // shapes
+ + + + +
329  float* shapeCenters;
+
330  int numShapes;
+
331 
+
332  // plastic deformation
+ + +
335 
+
336  // faces for cloth
+ + +
339 
+
340  // inflatable params
+
341  bool inflatable;
+ + + +
345 };
+
346 
+ +
351 {
+ + +
354 
+ + + +
358 
+ +
360  float* shapeRotations;
361 
- + +
363 
+
364  void* userData;
+
365 };
366 
-
378 NV_FLEX_API int NvFlexExtCreateWeldedMeshIndices(const float* vertices, int numVertices, int* uniqueVerts, int* originalToUniqueMap, float threshold);
-
379 
-
395 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateClothFromMesh(const float* particles, int numParticles, const int* indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure);
-
396 
-
415 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateTearingClothFromMesh(const float* particles, int numParticles, int maxParticles, const int* indices, int numTriangles, float stretchStiffness, float bendStiffness, float pressure);
-
416 
-
421 NV_FLEX_API void NvFlexExtDestroyTearingCloth(NvFlexExtAsset* asset);
-
422 
- -
429 {
-
430  int srcIndex;
- -
432 };
-
433 
- -
442 {
-
443  int triIndex; // index into the triangle indices array to update
-
444  int newParticleIndex; // new value for the index
-
445 };
-
446 
-
461 NV_FLEX_API void NvFlexExtTearClothMesh(NvFlexExtAsset* asset, float maxStrain, int maxSplits, NvFlexExtTearingParticleClone* particleCopies, int* numParticleCopies, int maxCopies, NvFlexExtTearingMeshEdit* triangleEdits, int* numTriangleEdits, int maxEdits);
-
462 
-
474 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateRigidFromMesh(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, float radius, float expand);
-
475 
-
494 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateSoftFromMesh(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness);
-
495 
-
500 NV_FLEX_API void NvFlexExtDestroyAsset(NvFlexExtAsset* asset);
-
501 
-
514 NV_FLEX_API void NvFlexExtCreateSoftMeshSkinning(const float* vertices, int numVertices, const float* bones, int numBones, float falloff, float maxDistance, float* skinningWeights, int* skinningIndices);
-
515 
-
524 NV_FLEX_API NvFlexExtContainer* NvFlexExtCreateContainer(NvFlexLibrary* lib, NvFlexSolver* solver, int maxParticles);
-
525 
-
531 NV_FLEX_API void NvFlexExtDestroyContainer(NvFlexExtContainer* container);
+ +
371 
+
383 NV_FLEX_API int NvFlexExtCreateWeldedMeshIndices(const float* vertices, int numVertices, int* uniqueVerts, int* originalToUniqueMap, float threshold);
+
384 
+
400 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateClothFromMesh(const float* particles, int numParticles, const int* indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure);
+
401 
+
420 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateTearingClothFromMesh(const float* particles, int numParticles, int maxParticles, const int* indices, int numTriangles, float stretchStiffness, float bendStiffness, float pressure);
+
421 
+
426 NV_FLEX_API void NvFlexExtDestroyTearingCloth(NvFlexExtAsset* asset);
+
427 
+ +
434 {
+
435  int srcIndex;
+ +
437 };
+
438 
+ +
447 {
+
448  int triIndex; // index into the triangle indices array to update
+
449  int newParticleIndex; // new value for the index
+
450 };
+
451 
+
466 NV_FLEX_API void NvFlexExtTearClothMesh(NvFlexExtAsset* asset, float maxStrain, int maxSplits, NvFlexExtTearingParticleClone* particleCopies, int* numParticleCopies, int maxCopies, NvFlexExtTearingMeshEdit* triangleEdits, int* numTriangleEdits, int maxEdits);
+
467 
+
479 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateRigidFromMesh(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, float radius, float expand);
+
480 
+
501 NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateSoftFromMesh(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness, float clusterPlasticThreshold, float clusterPlasticCreep);
+
502 
+
507 NV_FLEX_API void NvFlexExtDestroyAsset(NvFlexExtAsset* asset);
+
508 
+
521 NV_FLEX_API void NvFlexExtCreateSoftMeshSkinning(const float* vertices, int numVertices, const float* bones, int numBones, float falloff, float maxDistance, float* skinningWeights, int* skinningIndices);
+
522 
+
531 NV_FLEX_API NvFlexExtContainer* NvFlexExtCreateContainer(NvFlexLibrary* lib, NvFlexSolver* solver, int maxParticles);
532 
-
540 NV_FLEX_API int NvFlexExtAllocParticles(NvFlexExtContainer* container, int n, int* indices);
-
541 
-
549 NV_FLEX_API void NvFlexExtFreeParticles(NvFlexExtContainer* container, int n, const int* indices);
-
550 
-
551 
-
559 NV_FLEX_API int NvFlexExtGetActiveList(NvFlexExtContainer* container, int* indices);
-
560 
-
561 
- -
563 {
-
564  float* particles;
-
565  float* restParticles;
-
566  float* velocities;
-
567  int* phases;
-
568  float* normals;
-
569 
-
570  const float* lower;
-
571  const float* upper;
-
572 };
-
573 
- -
581 NV_FLEX_API void NvFlexExtUnmapParticleData(NvFlexExtContainer* container);
-
582 
- -
584 {
-
585  int* indices;
-
586  float* normals;
-
587 };
-
588 
- +
538 NV_FLEX_API void NvFlexExtDestroyContainer(NvFlexExtContainer* container);
+
539 
+
547 NV_FLEX_API int NvFlexExtAllocParticles(NvFlexExtContainer* container, int n, int* indices);
+
548 
+
556 NV_FLEX_API void NvFlexExtFreeParticles(NvFlexExtContainer* container, int n, const int* indices);
+
557 
+
558 
+
566 NV_FLEX_API int NvFlexExtGetActiveList(NvFlexExtContainer* container, int* indices);
+
567 
+
568 
+ +
570 {
+
571  float* particles;
+
572  float* restParticles;
+
573  float* velocities;
+
574  int* phases;
+
575  float* normals;
+
576 
+
577  const float* lower;
+
578  const float* upper;
+
579 };
+
580 
+ +
588 NV_FLEX_API void NvFlexExtUnmapParticleData(NvFlexExtContainer* container);
+
589 
+ +
591 {
+
592  int* indices;
+
593  float* normals;
+
594 };
595 
-
599 NV_FLEX_API void NvFlexExtUnmapTriangleData(NvFlexExtContainer* container);
-
600 
- -
602 {
-
603  float* rotations;
-
604  float* positions;
-
605  int n;
-
606 };
+ +
602 
+
606 NV_FLEX_API void NvFlexExtUnmapTriangleData(NvFlexExtContainer* container);
607 
- + +
609 {
+
610  float* rotations;
+
611  float* positions;
+
612  int n;
+
613 };
614 
-
618 NV_FLEX_API void NvFlexExtUnmapShapeData(NvFlexExtContainer* container);
-
619 
-
635 NV_FLEX_API NvFlexExtInstance* NvFlexExtCreateInstance(NvFlexExtContainer* container, NvFlexExtParticleData* particleData, const NvFlexExtAsset* asset, const float* transform, float vx, float vy, float vz, int phase, float invMassScale);
-
636 
-
642 NV_FLEX_API void NvFlexExtDestroyInstance(NvFlexExtContainer* container, const NvFlexExtInstance* instance);
+ +
621 
+
625 NV_FLEX_API void NvFlexExtUnmapShapeData(NvFlexExtContainer* container);
+
626 
+
642 NV_FLEX_API NvFlexExtInstance* NvFlexExtCreateInstance(NvFlexExtContainer* container, NvFlexExtParticleData* particleData, const NvFlexExtAsset* asset, const float* transform, float vx, float vy, float vz, int phase, float invMassScale);
643 
-
650 NV_FLEX_API void NvFlexExtNotifyAssetChanged(NvFlexExtContainer* container, const NvFlexExtAsset* asset);
-
651 
-
681 NV_FLEX_API void NvFlexExtTickContainer(NvFlexExtContainer* container, float dt, int numSubsteps, bool enableTimers=false);
-
682 
-
688 NV_FLEX_API void NvFlexExtPushToDevice(NvFlexExtContainer* container);
+
649 NV_FLEX_API void NvFlexExtDestroyInstance(NvFlexExtContainer* container, const NvFlexExtInstance* instance);
+
650 
+
657 NV_FLEX_API void NvFlexExtNotifyAssetChanged(NvFlexExtContainer* container, const NvFlexExtAsset* asset);
+
658 
+
688 NV_FLEX_API void NvFlexExtTickContainer(NvFlexExtContainer* container, float dt, int numSubsteps, bool enableTimers=false);
689 
-
695 NV_FLEX_API void NvFlexExtPullFromDevice(NvFlexExtContainer* container);
+
695 NV_FLEX_API void NvFlexExtPushToDevice(NvFlexExtContainer* container);
696 
-
702 NV_FLEX_API void NvFlexExtUpdateInstances(NvFlexExtContainer* container);
+
702 NV_FLEX_API void NvFlexExtPullFromDevice(NvFlexExtContainer* container);
703 
-
704 
- -
709 {
- -
712 
- -
715 
- -
718 };
+
709 NV_FLEX_API void NvFlexExtUpdateInstances(NvFlexExtContainer* container);
+
710 
+
711 
+ +
716 {
+
719 
- -
724 {
-
725  float mPosition[3];
-
726  float mRadius;
-
727  float mStrength;
- - -
730 };
-
731 
- -
737 
- -
746 
- + +
722 
+ +
725 };
+
726 
+ +
731 {
+
732  float mPosition[3];
+
733  float mRadius;
+
734  float mStrength;
+ + +
737 };
+
738 
+ +
744 
+
753 
-
761 NV_FLEX_API void NvFlexExtSetForceFields(NvFlexExtForceFieldCallback* callback, const NvFlexExtForceField* forceFields, int numForceFields);
-
762 
-
763 
-
764 
-
765 } // extern "C"
-
766 
-
767 #endif // NV_FLEX_EXT_H
-
768 
-
bool mLinearFalloff
Linear or no falloff.
Definition: NvFlexExt.h:729
-
void destroy()
Definition: NvFlexExt.h:85
-
int numParticles
Number of particles.
Definition: NvFlexExt.h:314
-
float * shapeCenters
The position of the center of mass of each shape, an array of vec3s mNumShapes in length...
Definition: NvFlexExt.h:328
+ +
760 
+
768 NV_FLEX_API void NvFlexExtSetForceFields(NvFlexExtForceFieldCallback* callback, const NvFlexExtForceField* forceFields, int numForceFields);
+
769 
+
770 
+
771 
+
772 } // extern "C"
+
773 
+
774 #endif // NV_FLEX_EXT_H
+
775 
+
bool mLinearFalloff
Linear or no falloff.
Definition: NvFlexExt.h:736
+
void destroy()
Definition: NvFlexExt.h:86
+
NvFlexBufferType type
Definition: NvFlexExt.h:76
+
int numParticles
Number of particles.
Definition: NvFlexExt.h:315
+
float * shapeCenters
The position of the center of mass of each shape, an array of vec3s mNumShapes in length...
Definition: NvFlexExt.h:329
NV_FLEX_API void NvFlexExtSetForceFields(NvFlexExtForceFieldCallback *callback, const NvFlexExtForceField *forceFields, int numForceFields)
NV_FLEX_API void NvFlexExtMovingFrameApply(NvFlexExtMovingFrame *frame, float *positions, float *velocities, int numParticles, float linearScale, float angularScale, float dt)
-
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateSoftFromMesh(const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness)
-
float * shapeRotations
Shape matching group rotations (quaternions)
Definition: NvFlexExt.h:355
-
int n
Number of valid tranforms.
Definition: NvFlexExt.h:605
+
float * shapeRotations
Shape matching group rotations (quaternions)
Definition: NvFlexExt.h:360
+
NvFlexVector(NvFlexLibrary *l, const T *ptr, int size, NvFlexBufferType type=eNvFlexBufferHost)
Definition: NvFlexExt.h:58
+
int n
Number of valid tranforms.
Definition: NvFlexExt.h:612
NvFlexLibrary * lib
Definition: NvFlexExt.h:70
-
float * particles
Local space particle positions, x,y,z,1/mass.
Definition: NvFlexExt.h:313
-
int * shapeOffsets
Each entry stores the end of the shape's indices in the indices array (exclusive prefix sum of shape ...
Definition: NvFlexExt.h:326
-
int newParticleIndex
Definition: NvFlexExt.h:444
+
float * particles
Local space particle positions, x,y,z,1/mass.
Definition: NvFlexExt.h:314
+
int * shapeOffsets
Each entry stores the end of the shape's indices in the indices array (exclusive prefix sum of shape ...
Definition: NvFlexExt.h:327
+
int newParticleIndex
Definition: NvFlexExt.h:449
NV_FLEX_API void NvFlexUnmap(NvFlexBuffer *buffer)
NV_FLEX_API void NvFlexExtDestroyInstance(NvFlexExtContainer *container, const NvFlexExtInstance *instance)
NV_FLEX_API void NvFlexExtMovingFrameUpdate(NvFlexExtMovingFrame *frame, const float *worldTranslation, const float *worldRotation, float dt)
-
void init(int size)
Definition: NvFlexExt.h:78
+
void init(int size)
Definition: NvFlexExt.h:79
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateRigidFromMesh(const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float radius, float expand)
-
float * springRestLengths
Spring rest-lengths.
Definition: NvFlexExt.h:320
-
int size() const
Definition: NvFlexExt.h:161
+
float * springRestLengths
Spring rest-lengths.
Definition: NvFlexExt.h:321
+
int size() const
Definition: NvFlexExt.h:162
NV_FLEX_API void NvFlexExtTickContainer(NvFlexExtContainer *container, float dt, int numSubsteps, bool enableTimers=false)
-
Definition: NvFlexExt.h:562
-
int numParticles
Number of simulation particles.
Definition: NvFlexExt.h:348
+
Definition: NvFlexExt.h:569
+
int numParticles
Number of simulation particles.
Definition: NvFlexExt.h:353
NV_FLEX_API void NvFlexExtUnmapParticleData(NvFlexExtContainer *container)
-
struct NvFlexExtContainer NvFlexExtContainer
Definition: NvFlexExt.h:365
-
T & operator[](int index)
Definition: NvFlexExt.h:127
-
NvFlexVector(NvFlexLibrary *l, const T *ptr, int size)
Definition: NvFlexExt.h:58
-
void * userData
User data pointer.
Definition: NvFlexExt.h:359
+
struct NvFlexExtContainer NvFlexExtContainer
Definition: NvFlexExt.h:370
+
T & operator[](int index)
Definition: NvFlexExt.h:128
+
void * userData
User data pointer.
Definition: NvFlexExt.h:364
NV_FLEX_API void NvFlexExtPullFromDevice(NvFlexExtContainer *container)
-
void resize(int newCount, const T &val)
Definition: NvFlexExt.h:210
-
int * triangleIndices
Indexed triangle mesh indices for clothing.
Definition: NvFlexExt.h:332
+
void resize(int newCount, const T &val)
Definition: NvFlexExt.h:211
+
int * triangleIndices
Indexed triangle mesh indices for clothing.
Definition: NvFlexExt.h:337
int capacity
Definition: NvFlexExt.h:75
-
int * particleIndices
Simulation particle indices.
Definition: NvFlexExt.h:347
-
float mRadius
Radius of the force field.
Definition: NvFlexExt.h:726
-
int numTriangles
Number of triangles.
Definition: NvFlexExt.h:333
+
int * particleIndices
Simulation particle indices.
Definition: NvFlexExt.h:352
+
float mRadius
Radius of the force field.
Definition: NvFlexExt.h:733
+
int numTriangles
Number of triangles.
Definition: NvFlexExt.h:338
Calling thread will be blocked until buffer is ready for access, default.
Definition: NvFlex.h:69
struct NvFlexSolver NvFlexSolver
Definition: NvFlex.h:57
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateClothFromMesh(const float *particles, int numParticles, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure)
-
Definition: NvFlexExt.h:723
-
int numShapeIndices
Total number of indices for shape constraints.
Definition: NvFlexExt.h:325
+
Definition: NvFlexExt.h:730
+
int numShapeIndices
Total number of indices for shape constraints.
Definition: NvFlexExt.h:326
NV_FLEX_API void NvFlexExtDestroyTearingCloth(NvFlexExtAsset *asset)
-
float * rotations
Receives a pointer to the array quaternion rotation data in [x, y z, w] format.
Definition: NvFlexExt.h:603
+
float * rotations
Receives a pointer to the array quaternion rotation data in [x, y z, w] format.
Definition: NvFlexExt.h:610
NV_FLEX_API int NvFlexExtGetActiveList(NvFlexExtContainer *container, int *indices)
-
int shapeIndex
Index in the container's shape body constraints array.
Definition: NvFlexExt.h:351
+
int shapeIndex
Index in the container's shape body constraints array.
Definition: NvFlexExt.h:356
Definition: NvFlexExt.h:45
NV_FLEX_API void NvFlexExtDestroyForceFieldCallback(NvFlexExtForceFieldCallback *callback)
NV_FLEX_API void * NvFlexMap(NvFlexBuffer *buffer, int flags)
-
int * springIndices
Spring indices.
Definition: NvFlexExt.h:318
-
void reserve(int minCapacity)
Definition: NvFlexExt.h:173
+
NvFlexVector(NvFlexLibrary *l, int size=0, NvFlexBufferType type=eNvFlexBufferHost)
Definition: NvFlexExt.h:47
+
int * springIndices
Spring indices.
Definition: NvFlexExt.h:319
+
void reserve(int minCapacity)
Definition: NvFlexExt.h:174
~NvFlexVector()
Definition: NvFlexExt.h:65
-
int maxParticles
Maximum number of particles, allows extra space for tearable assets which duplicate particles...
Definition: NvFlexExt.h:315
-
void push_back(const T &t)
Definition: NvFlexExt.h:135
+
int maxParticles
Maximum number of particles, allows extra space for tearable assets which duplicate particles...
Definition: NvFlexExt.h:316
+
void push_back(const T &t)
Definition: NvFlexExt.h:136
NV_FLEX_API void NvFlexExtDestroyContainer(NvFlexExtContainer *container)
-
float tau[3]
Definition: NvFlexExt.h:239
-
float omega[3]
Definition: NvFlexExt.h:236
+
float tau[3]
Definition: NvFlexExt.h:240
+
float omega[3]
Definition: NvFlexExt.h:237
NV_FLEX_API void NvFlexExtCreateSoftMeshSkinning(const float *vertices, int numVertices, const float *bones, int numBones, float falloff, float maxDistance, float *skinningWeights, int *skinningIndices)
-
bool empty() const
Definition: NvFlexExt.h:163
-
Definition: NvFlexExt.h:441
+
bool empty() const
Definition: NvFlexExt.h:164
+
Definition: NvFlexExt.h:446
NV_FLEX_API NvFlexExtContainer * NvFlexExtCreateContainer(NvFlexLibrary *lib, NvFlexSolver *solver, int maxParticles)
NV_FLEX_API NvFlexExtInstance * NvFlexExtCreateInstance(NvFlexExtContainer *container, NvFlexExtParticleData *particleData, const NvFlexExtAsset *asset, const float *transform, float vx, float vy, float vz, int phase, float invMassScale)
-
float rotation[4]
Definition: NvFlexExt.h:233
-
float inflatableVolume
The rest volume for the inflatable constraint.
Definition: NvFlexExt.h:337
-
Host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:79
+
float rotation[4]
Definition: NvFlexExt.h:234
+
float inflatableVolume
The rest volume for the inflatable constraint.
Definition: NvFlexExt.h:342
+
A host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:78
NV_FLEX_API void NvFlexExtUnmapShapeData(NvFlexExtContainer *container)
struct NvFlexBuffer NvFlexBuffer
Definition: NvFlex.h:62
NV_FLEX_API NvFlexExtShapeData NvFlexExtMapShapeData(NvFlexExtContainer *container)
-
Apply field value as an impulse.
Definition: NvFlexExt.h:714
-
float * particles
Receives a pointer to the particle position / mass data.
Definition: NvFlexExt.h:564
-
float * springCoefficients
Spring coefficients.
Definition: NvFlexExt.h:319
-
float * restParticles
Receives a pointer to the particle's rest position (used for self collision culling) ...
Definition: NvFlexExt.h:565
-
float * positions
Receives a pointer to an array of shape body translations in [x, y, z] format.
Definition: NvFlexExt.h:604
-
Definition: NvFlexExt.h:230
-
const T & operator[](int index) const
Definition: NvFlexExt.h:119
-
void unmap()
Definition: NvFlexExt.h:108
-
Definition: NvFlexExt.h:345
+
Apply field value as an impulse.
Definition: NvFlexExt.h:721
+
float * particles
Receives a pointer to the particle position / mass data.
Definition: NvFlexExt.h:571
+
float * springCoefficients
Spring coefficients.
Definition: NvFlexExt.h:320
+
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateSoftFromMesh(const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness, float clusterPlasticThreshold, float clusterPlasticCreep)
+
float * restParticles
Receives a pointer to the particle's rest position (used for self collision culling) ...
Definition: NvFlexExt.h:572
+
float * positions
Receives a pointer to an array of shape body translations in [x, y, z] format.
Definition: NvFlexExt.h:611
+
Definition: NvFlexExt.h:231
+
const T & operator[](int index) const
Definition: NvFlexExt.h:120
+
void unmap()
Definition: NvFlexExt.h:109
+
Definition: NvFlexExt.h:350
NV_FLEX_API void NvFlexExtUpdateInstances(NvFlexExtContainer *container)
-
float mPosition[3]
Center of force field.
Definition: NvFlexExt.h:725
-
int * indices
Receives a pointer to the array of triangle index data.
Definition: NvFlexExt.h:585
-
float * normals
Receives a pointer to an array of triangle normal data stored with 16 byte stride, i.e.: [nx, ny, nz].
Definition: NvFlexExt.h:586
+
float mPosition[3]
Center of force field.
Definition: NvFlexExt.h:732
+
int * indices
Receives a pointer to the array of triangle index data.
Definition: NvFlexExt.h:592
+
float * normals
Receives a pointer to an array of triangle normal data stored with 16 byte stride, i.e.: [nx, ny, nz].
Definition: NvFlexExt.h:593
NV_FLEX_API void NvFlexExtTearClothMesh(NvFlexExtAsset *asset, float maxStrain, int maxSplits, NvFlexExtTearingParticleClone *particleCopies, int *numParticleCopies, int maxCopies, NvFlexExtTearingMeshEdit *triangleEdits, int *numTriangleEdits, int maxEdits)
-
float acceleration[3]
Definition: NvFlexExt.h:238
-
Apply field value as a force.
Definition: NvFlexExt.h:711
-
float inflatableStiffness
How stiff the inflatable is.
Definition: NvFlexExt.h:339
+
float acceleration[3]
Definition: NvFlexExt.h:239
+
Apply field value as a force.
Definition: NvFlexExt.h:718
+
float inflatableStiffness
How stiff the inflatable is.
Definition: NvFlexExt.h:344
struct NvFlexLibrary NvFlexLibrary
Definition: NvFlex.h:52
-
int triIndex
Definition: NvFlexExt.h:443
-
float * normals
Receives a pointer to the particle normal data with 16 byte stride in format [nx, ny...
Definition: NvFlexExt.h:568
+
int triIndex
Definition: NvFlexExt.h:448
+
float * normals
Receives a pointer to the particle normal data with 16 byte stride in format [nx, ny...
Definition: NvFlexExt.h:575
NV_FLEX_API NvFlexExtTriangleData NvFlexExtMapTriangleData(NvFlexExtContainer *container)
-
int destIndex
Definition: NvFlexExt.h:431
-
float mStrength
Strength of the force field.
Definition: NvFlexExt.h:727
-
float position[3]
Definition: NvFlexExt.h:232
-
void resize(int newCount)
Definition: NvFlexExt.h:200
-
Definition: NvFlexExt.h:310
+
int destIndex
Definition: NvFlexExt.h:436
+
float mStrength
Strength of the force field.
Definition: NvFlexExt.h:734
+
float position[3]
Definition: NvFlexExt.h:233
+
void resize(int newCount)
Definition: NvFlexExt.h:201
+
Definition: NvFlexExt.h:311
NV_FLEX_API void NvFlexExtPushToDevice(NvFlexExtContainer *container)
-
struct NvFlexExtForceFieldCallback NvFlexExtForceFieldCallback
Definition: NvFlexExt.h:736
+
struct NvFlexExtForceFieldCallback NvFlexExtForceFieldCallback
Definition: NvFlexExt.h:743
int count
Definition: NvFlexExt.h:74
-
NvFlexExtForceMode
Definition: NvFlexExt.h:708
-
float * shapeCoefficients
The stiffness coefficient for each shape.
Definition: NvFlexExt.h:327
-
void map(int flags=eNvFlexMapWait)
Definition: NvFlexExt.h:99
-
Apply field value as a velocity change.
Definition: NvFlexExt.h:717
+
NvFlexExtForceMode
Definition: NvFlexExt.h:715
+
float * shapeCoefficients
The stiffness coefficient for each shape.
Definition: NvFlexExt.h:328
+
void map(int flags=eNvFlexMapWait)
Definition: NvFlexExt.h:100
+
Apply field value as a velocity change.
Definition: NvFlexExt.h:724
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateTearingClothFromMesh(const float *particles, int numParticles, int maxParticles, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float pressure)
-
Definition: NvFlexExt.h:601
+
Definition: NvFlexExt.h:608
NV_FLEX_API void NvFlexExtMovingFrameInit(NvFlexExtMovingFrame *frame, const float *worldTranslation, const float *worldRotation)
-
float inflatablePressure
How much over the rest volume the inflatable should attempt to maintain.
Definition: NvFlexExt.h:338
-
const float * upper
Receive a pointer to the particle upper bounds [x, y, z].
Definition: NvFlexExt.h:571
+
float inflatablePressure
How much over the rest volume the inflatable should attempt to maintain.
Definition: NvFlexExt.h:343
+
const float * upper
Receive a pointer to the particle upper bounds [x, y, z].
Definition: NvFlexExt.h:578
NV_FLEX_API NvFlexBuffer * NvFlexAllocBuffer(NvFlexLibrary *lib, int elementCount, int elementByteStride, NvFlexBufferType type)
-
int inflatableIndex
Index in the container's inflatables array.
Definition: NvFlexExt.h:352
-
NvFlexVector(NvFlexLibrary *l, int size=0)
Definition: NvFlexExt.h:47
+
int inflatableIndex
Index in the container's inflatables array.
Definition: NvFlexExt.h:357
NV_FLEX_API void NvFlexExtFreeParticles(NvFlexExtContainer *container, int n, const int *indices)
-
int * shapeIndices
The indices of the shape matching constraints.
Definition: NvFlexExt.h:324
+
int * shapeIndices
The indices of the shape matching constraints.
Definition: NvFlexExt.h:325
NV_FLEX_API int NvFlexExtCreateWeldedMeshIndices(const float *vertices, int numVertices, int *uniqueVerts, int *originalToUniqueMap, float threshold)
NV_FLEX_API NvFlexExtParticleData NvFlexExtMapParticleData(NvFlexExtContainer *container)
-
void assign(const T *srcPtr, int newCount)
Definition: NvFlexExt.h:145
-
const NvFlexExtAsset * asset
Source asset used to create this instance.
Definition: NvFlexExt.h:357
+
void assign(const T *srcPtr, int newCount)
Definition: NvFlexExt.h:146
+
float * shapePlasticThresholds
The plastic threshold coefficient for each shape.
Definition: NvFlexExt.h:333
+
const NvFlexExtAsset * asset
Source asset used to create this instance.
Definition: NvFlexExt.h:362
T * mappedPtr
Definition: NvFlexExt.h:73
-
float delta[4][4]
Definition: NvFlexExt.h:241
-
const float * lower
Receive a pointer to the particle lower bounds [x, y, z].
Definition: NvFlexExt.h:570
-
int triangleIndex
Index in the container's triangle array.
Definition: NvFlexExt.h:350
-
Definition: NvFlexExt.h:583
-
NvFlexExtForceMode mMode
Mode of field application.
Definition: NvFlexExt.h:728
+
float delta[4][4]
Definition: NvFlexExt.h:242
+
const float * lower
Receive a pointer to the particle lower bounds [x, y, z].
Definition: NvFlexExt.h:577
+
int triangleIndex
Index in the container's triangle array.
Definition: NvFlexExt.h:355
+
Definition: NvFlexExt.h:590
+
NvFlexExtForceMode mMode
Mode of field application.
Definition: NvFlexExt.h:735
NV_FLEX_API int NvFlexExtAllocParticles(NvFlexExtContainer *container, int n, int *indices)
-
int * phases
Receives a pointer to the particle phase data.
Definition: NvFlexExt.h:567
+
int * phases
Receives a pointer to the particle phase data.
Definition: NvFlexExt.h:574
NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer *buf)
-
int numShapes
The number of shape matching constraints.
Definition: NvFlexExt.h:329
+
int numShapes
The number of shape matching constraints.
Definition: NvFlexExt.h:330
NV_FLEX_API void NvFlexExtUnmapTriangleData(NvFlexExtContainer *container)
-
void copyto(T *dest, int count)
Definition: NvFlexExt.h:154
+
void copyto(T *dest, int count)
Definition: NvFlexExt.h:155
NV_FLEX_API void NvFlexExtDestroyAsset(NvFlexExtAsset *asset)
-
int srcIndex
Definition: NvFlexExt.h:430
-
float * shapeTranslations
Shape matching group translations (vec3s)
Definition: NvFlexExt.h:354
-
float velocity[3]
Definition: NvFlexExt.h:235
-
Definition: NvFlexExt.h:428
+
float * shapePlasticCreeps
The plastic creep coefficient for each shape.
Definition: NvFlexExt.h:334
+
int srcIndex
Definition: NvFlexExt.h:435
+
float * shapeTranslations
Shape matching group translations (vec3s)
Definition: NvFlexExt.h:359
+
float velocity[3]
Definition: NvFlexExt.h:236
+
Definition: NvFlexExt.h:433
NvFlexBuffer * buffer
Definition: NvFlexExt.h:71
-
float * velocities
Receives a pointer to the particle velocity data.
Definition: NvFlexExt.h:566
-
const T & back() const
Definition: NvFlexExt.h:165
+
float * velocities
Receives a pointer to the particle velocity data.
Definition: NvFlexExt.h:573
+
const T & back() const
Definition: NvFlexExt.h:166
NV_FLEX_API NvFlexExtForceFieldCallback * NvFlexExtCreateForceFieldCallback(NvFlexSolver *solver)
-
bool inflatable
Whether an inflatable constraint should be added.
Definition: NvFlexExt.h:336
-
int numSprings
Number of springs.
Definition: NvFlexExt.h:321
+
bool inflatable
Whether an inflatable constraint should be added.
Definition: NvFlexExt.h:341
+
int numSprings
Number of springs.
Definition: NvFlexExt.h:322
NV_FLEX_API void NvFlexExtNotifyAssetChanged(NvFlexExtContainer *container, const NvFlexExtAsset *asset)
+
NvFlexBufferType
Definition: NvFlex.h:76
diff --git a/doc/_static/api/dir_d44c64559bbebec7f509842c48db8b23.html b/doc/_static/api/dir_d44c64559bbebec7f509842c48db8b23.html index e2f9475..3f3697d 100644 --- a/doc/_static/api/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/doc/_static/api/dir_d44c64559bbebec7f509842c48db8b23.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -52,7 +52,7 @@ Files diff --git a/doc/_static/api/files.html b/doc/_static/api/files.html index 53ff079..7f6b61c 100644 --- a/doc/_static/api/files.html +++ b/doc/_static/api/files.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -45,7 +45,7 @@ diff --git a/doc/_static/api/globals.html b/doc/_static/api/globals.html index 42e1ec0..6039eb7 100644 --- a/doc/_static/api/globals.html +++ b/doc/_static/api/globals.html @@ -20,7 +20,7 @@ Logo
FLEX -  1.1.0 +  1.2.0
@@ -58,6 +58,15 @@
  • eNvFlexExtModeVelocityChange : NvFlexExt.h
  • +
  • eNvFlexFeatureModeDefault +: NvFlex.h +
  • +
  • eNvFlexFeatureModeSimpleFluids +: NvFlex.h +
  • +
  • eNvFlexFeatureModeSimpleSolids +: NvFlex.h +
  • eNvFlexLogAll : NvFlex.h
  • @@ -73,15 +82,15 @@
  • eNvFlexLogWarning : NvFlex.h
  • -
  • eNvFlexMapDiscard -: NvFlex.h -
  • eNvFlexMapDoNotWait : NvFlex.h
  • eNvFlexMapWait : NvFlex.h
  • +
  • eNvFlexPhaseFlagsMask +: NvFlex.h +
  • eNvFlexPhaseFluid : NvFlex.h
  • @@ -94,6 +103,36 @@
  • eNvFlexPhaseSelfCollideFilter : NvFlex.h
  • +
  • eNvFlexPhaseShapeChannel0 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel1 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel2 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel3 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel4 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel5 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel6 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel7 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannelMask +: NvFlex.h +
  • +
  • eNvFlexPhaseUnused +: NvFlex.h +
  • eNvFlexRelaxationGlobal : NvFlex.h
  • @@ -183,7 +222,7 @@ : NvFlex.h
  • NvFlexCreateSolver() -: NvFlex.h +: NvFlex.h
  • NvFlexCreateTriangleMesh() : NvFlex.h @@ -240,7 +279,7 @@ : NvFlexExt.h
  • NvFlexExtCreateSoftFromMesh() -: NvFlexExt.h +: NvFlexExt.h
  • NvFlexExtCreateSoftMeshSkinning() : NvFlexExt.h @@ -326,6 +365,9 @@
  • NvFlexExtUpdateInstances() : NvFlexExt.h
  • +
  • NvFlexFeatureMode +: NvFlex.h +
  • NvFlexFlush() : NvFlex.h
  • @@ -333,13 +375,13 @@ : NvFlex.h
  • NvFlexGetActive() -: NvFlex.h +: NvFlex.h
  • NvFlexGetActiveCount() : NvFlex.h
  • NvFlexGetAnisotropy() -: NvFlex.h +: NvFlex.h
  • NvFlexGetBounds() : NvFlex.h @@ -351,7 +393,7 @@ : NvFlex.h
  • NvFlexGetDensities() -: NvFlex.h +: NvFlex.h
  • NvFlexGetDetailTimers() : NvFlex.h @@ -360,37 +402,43 @@ : NvFlex.h
  • NvFlexGetDeviceLatency() -: NvFlex.h +: NvFlex.h
  • NvFlexGetDeviceName() : NvFlex.h
  • NvFlexGetDiffuseParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexGetDynamicTriangles() : NvFlex.h
  • +
  • NvFlexGetNeighbors() +: NvFlex.h +
  • NvFlexGetNormals() -: NvFlex.h +: NvFlex.h
  • NvFlexGetParams() : NvFlex.h
  • NvFlexGetParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexGetPhases() -: NvFlex.h +: NvFlex.h
  • NvFlexGetRestParticles() -: NvFlex.h +: NvFlex.h
  • -
  • NvFlexGetRigidTransforms() -: NvFlex.h +
  • NvFlexGetRigids() +: NvFlex.h
  • NvFlexGetSmoothParticles() -: NvFlex.h +: NvFlex.h +
  • +
  • NvFlexGetSolverDesc() +: NvFlex.h
  • NvFlexGetSolverLibrary() : NvFlex.h @@ -405,7 +453,7 @@ : NvFlex.h
  • NvFlexGetVelocities() -: NvFlex.h +: NvFlex.h
  • NvFlexGetVersion() : NvFlex.h @@ -417,11 +465,17 @@ : NvFlex.h
  • NvFlexMakePhase() -: NvFlex.h +: NvFlex.h +
  • +
  • NvFlexMakePhaseWithChannels() +: NvFlex.h
  • NvFlexMakeShapeFlags() : NvFlex.h
  • +
  • NvFlexMakeShapeFlagsWithChannels() +: NvFlex.h +
  • NvFlexMap() : NvFlex.h
  • @@ -447,7 +501,10 @@ : NvFlex.h
  • NvFlexSetActive() -: NvFlex.h +: NvFlex.h +
  • +
  • NvFlexSetActiveCount() +: NvFlex.h
  • NvFlexSetDiffuseParticles() : NvFlex.h @@ -459,31 +516,34 @@ : NvFlex.h
  • NvFlexSetNormals() -: NvFlex.h +: NvFlex.h
  • NvFlexSetParams() : NvFlex.h
  • NvFlexSetParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexSetPhases() -: NvFlex.h +: NvFlex.h
  • NvFlexSetRestParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexSetRigids() -: NvFlex.h +: NvFlex.h
  • NvFlexSetShapes() : NvFlex.h
  • +
  • NvFlexSetSolverDescDefaults() +: NvFlex.h +
  • NvFlexSetSprings() : NvFlex.h
  • NvFlexSetVelocities() -: NvFlex.h +: NvFlex.h
  • NvFlexShutdown() : NvFlex.h @@ -507,7 +567,7 @@ : NvFlex.h
  • NvFlexUpdateConvexMesh() -: NvFlex.h +: NvFlex.h
  • NvFlexUpdateDistanceField() : NvFlex.h @@ -518,11 +578,14 @@
  • NvFlexUpdateTriangleMesh() : NvFlex.h
  • +
  • NvFlexWait() +: NvFlex.h +
  • diff --git a/doc/_static/api/globals_enum.html b/doc/_static/api/globals_enum.html index c693fe9..99f3b98 100644 --- a/doc/_static/api/globals_enum.html +++ b/doc/_static/api/globals_enum.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -50,6 +50,9 @@
  • NvFlexExtForceMode : NvFlexExt.h
  • +
  • NvFlexFeatureMode +: NvFlex.h +
  • NvFlexMapFlags : NvFlex.h
  • @@ -66,7 +69,7 @@ diff --git a/doc/_static/api/globals_eval.html b/doc/_static/api/globals_eval.html index 465a0cb..22e284d 100644 --- a/doc/_static/api/globals_eval.html +++ b/doc/_static/api/globals_eval.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -58,6 +58,15 @@
  • eNvFlexExtModeVelocityChange : NvFlexExt.h
  • +
  • eNvFlexFeatureModeDefault +: NvFlex.h +
  • +
  • eNvFlexFeatureModeSimpleFluids +: NvFlex.h +
  • +
  • eNvFlexFeatureModeSimpleSolids +: NvFlex.h +
  • eNvFlexLogAll : NvFlex.h
  • @@ -73,15 +82,15 @@
  • eNvFlexLogWarning : NvFlex.h
  • -
  • eNvFlexMapDiscard -: NvFlex.h -
  • eNvFlexMapDoNotWait : NvFlex.h
  • eNvFlexMapWait : NvFlex.h
  • +
  • eNvFlexPhaseFlagsMask +: NvFlex.h +
  • eNvFlexPhaseFluid : NvFlex.h
  • @@ -94,6 +103,36 @@
  • eNvFlexPhaseSelfCollideFilter : NvFlex.h
  • +
  • eNvFlexPhaseShapeChannel0 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel1 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel2 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel3 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel4 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel5 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel6 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannel7 +: NvFlex.h +
  • +
  • eNvFlexPhaseShapeChannelMask +: NvFlex.h +
  • +
  • eNvFlexPhaseUnused +: NvFlex.h +
  • eNvFlexRelaxationGlobal : NvFlex.h
  • @@ -152,7 +191,7 @@ diff --git a/doc/_static/api/globals_func.html b/doc/_static/api/globals_func.html index 2766e2e..2ede00b 100644 --- a/doc/_static/api/globals_func.html +++ b/doc/_static/api/globals_func.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -47,7 +47,7 @@ : NvFlex.h
  • NvFlexCreateSolver() -: NvFlex.h +: NvFlex.h
  • NvFlexCreateTriangleMesh() : NvFlex.h @@ -92,7 +92,7 @@ : NvFlexExt.h
  • NvFlexExtCreateSoftFromMesh() -: NvFlexExt.h +: NvFlexExt.h
  • NvFlexExtCreateSoftMeshSkinning() : NvFlexExt.h @@ -179,13 +179,13 @@ : NvFlex.h
  • NvFlexGetActive() -: NvFlex.h +: NvFlex.h
  • NvFlexGetActiveCount() : NvFlex.h
  • NvFlexGetAnisotropy() -: NvFlex.h +: NvFlex.h
  • NvFlexGetBounds() : NvFlex.h @@ -197,7 +197,7 @@ : NvFlex.h
  • NvFlexGetDensities() -: NvFlex.h +: NvFlex.h
  • NvFlexGetDetailTimers() : NvFlex.h @@ -206,37 +206,43 @@ : NvFlex.h
  • NvFlexGetDeviceLatency() -: NvFlex.h +: NvFlex.h
  • NvFlexGetDeviceName() : NvFlex.h
  • NvFlexGetDiffuseParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexGetDynamicTriangles() : NvFlex.h
  • +
  • NvFlexGetNeighbors() +: NvFlex.h +
  • NvFlexGetNormals() -: NvFlex.h +: NvFlex.h
  • NvFlexGetParams() : NvFlex.h
  • NvFlexGetParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexGetPhases() -: NvFlex.h +: NvFlex.h
  • NvFlexGetRestParticles() -: NvFlex.h +: NvFlex.h
  • -
  • NvFlexGetRigidTransforms() -: NvFlex.h +
  • NvFlexGetRigids() +: NvFlex.h
  • NvFlexGetSmoothParticles() -: NvFlex.h +: NvFlex.h +
  • +
  • NvFlexGetSolverDesc() +: NvFlex.h
  • NvFlexGetSolverLibrary() : NvFlex.h @@ -251,7 +257,7 @@ : NvFlex.h
  • NvFlexGetVelocities() -: NvFlex.h +: NvFlex.h
  • NvFlexGetVersion() : NvFlex.h @@ -260,11 +266,17 @@ : NvFlex.h
  • NvFlexMakePhase() -: NvFlex.h +: NvFlex.h +
  • +
  • NvFlexMakePhaseWithChannels() +: NvFlex.h
  • NvFlexMakeShapeFlags() : NvFlex.h
  • +
  • NvFlexMakeShapeFlagsWithChannels() +: NvFlex.h +
  • NvFlexMap() : NvFlex.h
  • @@ -281,7 +293,10 @@ : NvFlex.h
  • NvFlexSetActive() -: NvFlex.h +: NvFlex.h +
  • +
  • NvFlexSetActiveCount() +: NvFlex.h
  • NvFlexSetDiffuseParticles() : NvFlex.h @@ -293,31 +308,34 @@ : NvFlex.h
  • NvFlexSetNormals() -: NvFlex.h +: NvFlex.h
  • NvFlexSetParams() : NvFlex.h
  • NvFlexSetParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexSetPhases() -: NvFlex.h +: NvFlex.h
  • NvFlexSetRestParticles() -: NvFlex.h +: NvFlex.h
  • NvFlexSetRigids() -: NvFlex.h +: NvFlex.h
  • NvFlexSetShapes() : NvFlex.h
  • +
  • NvFlexSetSolverDescDefaults() +: NvFlex.h +
  • NvFlexSetSprings() : NvFlex.h
  • NvFlexSetVelocities() -: NvFlex.h +: NvFlex.h
  • NvFlexShutdown() : NvFlex.h @@ -332,7 +350,7 @@ : NvFlex.h
  • NvFlexUpdateConvexMesh() -: NvFlex.h +: NvFlex.h
  • NvFlexUpdateDistanceField() : NvFlex.h @@ -343,11 +361,14 @@
  • NvFlexUpdateTriangleMesh() : NvFlex.h
  • +
  • NvFlexWait() +: NvFlex.h +
  • diff --git a/doc/_static/api/globals_type.html b/doc/_static/api/globals_type.html index 3ba1e90..1e6db85 100644 --- a/doc/_static/api/globals_type.html +++ b/doc/_static/api/globals_type.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -63,7 +63,7 @@ diff --git a/doc/_static/api/index.html b/doc/_static/api/index.html index 3130b0d..4066cf8 100644 --- a/doc/_static/api/index.html +++ b/doc/_static/api/index.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -43,7 +43,7 @@ diff --git a/doc/_static/api/struct_nv_flex_solver_callback.html b/doc/_static/api/struct_nv_flex_solver_callback.html index d96d2d2..041be39 100644 --- a/doc/_static/api/struct_nv_flex_solver_callback.html +++ b/doc/_static/api/struct_nv_flex_solver_callback.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -77,7 +77,7 @@ Data Fields diff --git a/doc/_static/api/struct_nv_flex_vector.html b/doc/_static/api/struct_nv_flex_vector.html index fa3a3d8..135150d 100644 --- a/doc/_static/api/struct_nv_flex_vector.html +++ b/doc/_static/api/struct_nv_flex_vector.html @@ -20,7 +20,7 @@ Logo
    FLEX -  1.1.0 +  1.2.0
    @@ -41,10 +41,10 @@ - - - - + + + + @@ -90,9 +90,11 @@ Data Fields + +

    Public Member Functions

     NvFlexVector (NvFlexLibrary *l, int size=0)
     
     NvFlexVector (NvFlexLibrary *l, const T *ptr, int size)
     
     NvFlexVector (NvFlexLibrary *l, int size=0, NvFlexBufferType type=eNvFlexBufferHost)
     
     NvFlexVector (NvFlexLibrary *l, const T *ptr, int size, NvFlexBufferType type=eNvFlexBufferHost)
     
     ~NvFlexVector ()
     
    void init (int size)
     
    int capacity
     
    NvFlexBufferType type
     

    Constructor & Destructor Documentation

    - +
    @@ -111,7 +113,13 @@ template<typename T >
    int  - size = 0  + size = 0, + + + + + NvFlexBufferType  + type = eNvFlexBufferHost  @@ -128,7 +136,7 @@ template<typename T >
    - +
    @@ -153,7 +161,13 @@ template<typename T >
    int  - size  + size, + + + + + NvFlexBufferType  + type = eNvFlexBufferHost  @@ -680,12 +694,26 @@ template<typename T >
    +
    + + +
    +
    +
    +template<typename T >
    + + + + +
    NvFlexBufferType NvFlexVector< T >::type
    +
    +
    diff --git a/doc/genindex.html b/doc/genindex.html index 008ed9b..c055e44 100644 --- a/doc/genindex.html +++ b/doc/genindex.html @@ -8,7 +8,7 @@ - Index — NVIDIA Flex 1.1.0 documentation + Index — NVIDIA Flex 1.2.0 documentation @@ -19,7 +19,7 @@ - +