diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/NvFlow.h | 149 | ||||
| -rw-r--r-- | include/NvFlowContext.h | 2 | ||||
| -rw-r--r-- | include/NvFlowContextD3D12.h | 8 | ||||
| -rw-r--r-- | include/NvFlowContextExt.h | 637 | ||||
| -rw-r--r-- | include/NvFlowTypes.h | 20 |
5 files changed, 810 insertions, 6 deletions
diff --git a/include/NvFlow.h b/include/NvFlow.h index b62b9e6..435c940 100644 --- a/include/NvFlow.h +++ b/include/NvFlow.h @@ -126,6 +126,8 @@ struct NvFlowGridParams { NvFlowFloat3 gravity; //!< Gravity vector for use by buoyancy + bool singlePassAdvection; //!< If true, enables single pass advection + bool pressureLegacyMode; //!< If true, run older less accurate pressure solver bool bigEffectMode; //!< Tweaks block allocation for better big effect behavior @@ -253,7 +255,11 @@ struct NvFlowGridMaterialParams NvFlowGridMaterialPerComponent fuel; //!< Fuel component parameters float vorticityStrength; //!< Higher values increase rotation, reduce laminar flow - float vorticityVelocityMask; //!< 0.f means zero velocity magnitude influence on vorticity + float vorticityVelocityMask; //!< 0.f disabled; 1.0f higher velocities, higher strength; -1.0f for inverse + float vorticityTemperatureMask; //!< 0.f disabled; 1.0f higher temperatures, higher strength; -1.0f for inverse + float vorticitySmokeMask; //!< 0.f disabled; 1.0f higher smoke, higher strength; -1.0f for inverse + float vorticityFuelMask; //!< 0.f disabled; 1.0f higher fuel, higher strength; -1.0f for inverse + float vorticityConstantMask; //!< Works as other masks, provides fixed offset float ignitionTemp; //!< Minimum temperature for combustion float burnPerTemp; //!< Burn amount per unit temperature above ignitionTemp @@ -466,9 +472,8 @@ struct NvFlowGridEmitParams float deltaTime; //!< DeltaTime used to compute impulse - NvFlowGridMaterialHandle material; //!< Material for this emitter + NvFlowUint emitMaterialIndex; //!< Index into material lookup defined by NvFlowGridUpdateEmitMaterials() NvFlowUint emitMode; //!< Emitter behavior, based on NvFlowGridEmitMode, 0u is default - NvFlowUint numSubSteps; //!< Numbers of interations to perform on cell value NvFlowFloat3 allocationScale; //!< Higher values cause more blocks to allocate around emitter; 0.f means no allocation, 1.f is default float allocationPredict; //!< Higher values cause extra allocation based on linear velocity and predict velocity @@ -517,6 +522,15 @@ NV_FLOW_API void NvFlowGridEmitParamsDefaults(NvFlowGridEmitParams* params); NV_FLOW_API void NvFlowGridEmit(NvFlowGrid* grid, const NvFlowShapeDesc* shapes, NvFlowUint numShapes, const NvFlowGridEmitParams* params, NvFlowUint numParams); /** + * Update internal array of grid materials reference by emitMaterialIndex + * + * @param[in] grid The Flow grid to apply the emit events. + * @param[in] materials Array of grid materials. + * @param[in] numMaterials Number of grid materials in the array. + */ +NV_FLOW_API void NvFlowGridUpdateEmitMaterials(NvFlowGrid* grid, NvFlowGridMaterialHandle* materials, NvFlowUint numMaterials); + +/** * Update internal array of SDFs that can be referenced by sdfOffset * * @param[in] grid The Flow grid to apply the emit events. @@ -877,6 +891,135 @@ NV_FLOW_API void NvFlowGridImportUpdateStateCPU(NvFlowGridImportStateCPU* stateC NV_FLOW_API NvFlowGridImportHandle NvFlowGridImportStateCPUGetHandle(NvFlowGridImport* gridImport, NvFlowContext* context, const NvFlowGridImportStateCPUParams* params); ///@} +// -------------------------- NvFlowGridSummary ------------------------------- +///@defgroup NvFlowGridSummary +///@{ + +//! An object that captures coarse grid behavior and provides CPU access +struct NvFlowGridSummary; + +//! Description necessary to create grid summary +struct NvFlowGridSummaryDesc +{ + NvFlowGridExport* gridExport; //!< Grid export to use as template for allocation +}; + +/** + * Creates a grid summary object. + * + * @param[in] context The context for GPU resource allocation. + * @param[in] desc Description for memory allocation. + * + * @return The created grid summary object. + */ +NV_FLOW_API NvFlowGridSummary* NvFlowCreateGridSummary(NvFlowContext* context, const NvFlowGridSummaryDesc* desc); + +/** + * Releases a grid summary object. + * + * @param[in] gridSummary The grid summary object to be released. + */ +NV_FLOW_API void NvFlowReleaseGridSummary(NvFlowGridSummary* gridSummary); + +//! CPU state of grid summary +struct NvFlowGridSummaryStateCPU; + +/** + * Creates a grid summary CPU state object. + * + * @param[in] gridSummary The grid summary this CPU state will hold data from. + * + * @return The created grid summary CPU state object. + */ +NV_FLOW_API NvFlowGridSummaryStateCPU* NvFlowCreateGridSummaryStateCPU(NvFlowGridSummary* gridSummary); + +/** + * Releases a grid summary CPU state object. + * + * @param[in] stateCPU The grid summary CPU state object to be released. + */ +NV_FLOW_API void NvFlowReleaseGridSummaryStateCPU(NvFlowGridSummaryStateCPU* stateCPU); + +//! Parameters required to update summary CPU state +struct NvFlowGridSummaryUpdateParams +{ + NvFlowGridSummaryStateCPU* stateCPU; //!< The target to store summary data to + + NvFlowGridExport* gridExport; //!< GridExport to capture summary from +}; + +/** + * Updates the specified stateCPU with the latest available summary data. + * + * @param[in] gridSummary The grid summary operator to perform the update. + * @param[in] context The context the gridExport is valid on. + * @param[in] params Parameters required to update CPU state. + */ +NV_FLOW_API void NvFlowGridSummaryUpdate(NvFlowGridSummary* gridSummary, NvFlowContext* context, const NvFlowGridSummaryUpdateParams* params); + +//! Parameters to debug render the grid summary data +struct NvFlowGridSummaryDebugRenderParams +{ + NvFlowGridSummaryStateCPU* stateCPU; + + NvFlowRenderTargetView* renderTargetView; //!< Render target to draw visualization to + + NvFlowFloat4x4 projectionMatrix; //!< Render target projection matrix, row major + NvFlowFloat4x4 viewMatrix; //!< Render target view matrix, row major +}; + +/** + * Renders a visualization of the specified stateCPU. + * + * @param[in] gridSummary The grid summary operator to perform the debug render. + * @param[in] context The render context. + * @param[in] params Parameters required to render the CPU state. + */ +NV_FLOW_API void NvFlowGridSummaryDebugRender(NvFlowGridSummary* gridSummary, NvFlowContext* context, const NvFlowGridSummaryDebugRenderParams* params); + +//! Summary results +struct NvFlowGridSummaryResult +{ + NvFlowFloat4 worldLocation; + NvFlowFloat4 worldHalfSize; + NvFlowFloat3 averageVelocity; + float averageSpeed; + float averageTemperature; + float averageFuel; + float averageBurn; + float averageSmoke; +}; + +/** + * Returns the number of layers for the grid summary. This establishes the maximum number of results for a given world location. + * + * @param[in] stateCPU The grid summary cpu state. + * + * @return Returns the number of layers. + */ +NV_FLOW_API NvFlowUint NvFlowGridSummaryGetNumLayers(NvFlowGridSummaryStateCPU* stateCPU); + +/** + * Returns grid material mapped to specied layerIdx. + * + * @param[in] stateCPU The grid summary cpu state. + * @param[in] layerIdx The layer index to get the material mapping of. + * + * @return Returns grid material. + */ +NV_FLOW_API NvFlowGridMaterialHandle NvFlowGridSummaryGetLayerMaterial(NvFlowGridSummaryStateCPU* stateCPU, NvFlowUint layerIdx); + +/** + * Returns pointer to array of summary results for the specified layer. + * + * @param[in] stateCPU The grid summary state to sample. + * @param[out] results Pointer to array pointer. + * @param[out] numResults Pointer to array size. + * @param[in] layerIdx Layer index to return summary results array from. + */ +NV_FLOW_API void NvFlowGridSummaryGetSummaries(NvFlowGridSummaryStateCPU* stateCPU, NvFlowGridSummaryResult** results, NvFlowUint* numResults, NvFlowUint layerIdx); + +///@} // -------------------------- NvFlowRenderMaterial ------------------------------- ///@defgroup NvFlowRenderMaterial ///@{ diff --git a/include/NvFlowContext.h b/include/NvFlowContext.h index eb80d78..ca405ac 100644 --- a/include/NvFlowContext.h +++ b/include/NvFlowContext.h @@ -12,7 +12,7 @@ #include "NvFlowTypes.h" -#define NV_FLOW_VERSION 0x00010000 +#define NV_FLOW_VERSION 0x00010001 //! NvFlowContext: A framework for fluid simulation struct NvFlowContext; diff --git a/include/NvFlowContextD3D12.h b/include/NvFlowContextD3D12.h index 54940cd..161ad75 100644 --- a/include/NvFlowContextD3D12.h +++ b/include/NvFlowContextD3D12.h @@ -18,10 +18,14 @@ struct NvFlowDepthStencilViewDescD3D12 { D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle; D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc; + ID3D12Resource* dsvResource; + D3D12_RESOURCE_STATES dsvCurrentState; + D3D12_CPU_DESCRIPTOR_HANDLE srvHandle; D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc; - ID3D12Resource* resource; - D3D12_RESOURCE_STATES currentState; + ID3D12Resource* srvResource; + D3D12_RESOURCE_STATES srvCurrentState; + D3D12_VIEWPORT viewport; }; diff --git a/include/NvFlowContextExt.h b/include/NvFlowContextExt.h new file mode 100644 index 0000000..f1601bd --- /dev/null +++ b/include/NvFlowContextExt.h @@ -0,0 +1,637 @@ +/* +* 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 "NvFlowContext.h" + +//! GPU Graphics and compute interface +struct NvFlowContext; + +struct NvFlowConstantBuffer; +struct NvFlowVertexBuffer; +struct NvFlowIndexBuffer; +struct NvFlowResource; +struct NvFlowResourceRW; +struct NvFlowBuffer; +struct NvFlowTexture1D; +struct NvFlowTexture2D; +struct NvFlowTexture3D; + +//! Interface to manage resource reference count and lifetime +struct NvFlowContextObject; + +NV_FLOW_API NvFlowUint NvFlowContextObjectAddRef(NvFlowContextObject* object); + +NV_FLOW_API NvFlowUint NvFlowContextObjectRelease(NvFlowContextObject* object); + +NV_FLOW_API NvFlowUint64 NvFlowContextObjectGetGPUBytesUsed(NvFlowContextObject* object); + +//! Handle for mapped pitched data +struct NvFlowMappedData +{ + void* data; + NvFlowUint rowPitch; + NvFlowUint depthPitch; +}; + +//! A constant buffer +struct NvFlowConstantBuffer; + +struct NvFlowConstantBufferDesc +{ + NvFlowUint sizeInBytes; + bool uploadAccess; +}; + +NV_FLOW_API void NvFlowConstantBufferGetDesc(NvFlowConstantBuffer* buffer, NvFlowConstantBufferDesc* desc); + +NV_FLOW_API NvFlowConstantBuffer* NvFlowCreateConstantBuffer(NvFlowContext* context, const NvFlowConstantBufferDesc* desc); + +NV_FLOW_API void NvFlowReleaseConstantBuffer(NvFlowConstantBuffer* buffer); + +NV_FLOW_API NvFlowContextObject* NvFlowConstantBufferGetContextObject(NvFlowConstantBuffer* buffer); + +NV_FLOW_API void* NvFlowConstantBufferMap(NvFlowContext* context, NvFlowConstantBuffer* constantBuffer); + +NV_FLOW_API void NvFlowConstantBufferUnmap(NvFlowContext* context, NvFlowConstantBuffer* constantBuffer); + +//! A vertex buffer +struct NvFlowVertexBuffer; + +struct NvFlowVertexBufferDesc +{ + const void* data; + NvFlowUint sizeInBytes; +}; + +NV_FLOW_API void NvFlowVertexBufferGetDesc(NvFlowVertexBuffer* buffer, NvFlowVertexBufferDesc* desc); + +NV_FLOW_API NvFlowVertexBuffer* NvFlowCreateVertexBuffer(NvFlowContext* context, const NvFlowVertexBufferDesc* desc); + +NV_FLOW_API void NvFlowReleaseVertexBuffer(NvFlowVertexBuffer* vertexBuffer); + +NV_FLOW_API NvFlowContextObject* NvFlowVertexBufferGetContextObject(NvFlowVertexBuffer* buffer); + +NV_FLOW_API void* NvFlowVertexBufferMap(NvFlowContext* context, NvFlowVertexBuffer* vertexBuffer); + +NV_FLOW_API void NvFlowVertexBufferUnmap(NvFlowContext* context, NvFlowVertexBuffer* vertexBuffer); + +//! An index buffer +struct NvFlowIndexBuffer; + +struct NvFlowIndexBufferDesc +{ + const void* data; + NvFlowUint sizeInBytes; + NvFlowFormat format; +}; + +NV_FLOW_API void NvFlowIndexBufferGetDesc(NvFlowIndexBuffer* index, NvFlowIndexBufferDesc* desc); + +NV_FLOW_API NvFlowIndexBuffer* NvFlowCreateIndexBuffer(NvFlowContext* context, const NvFlowIndexBufferDesc* desc); + +NV_FLOW_API void NvFlowReleaseIndexBuffer(NvFlowIndexBuffer* buffer); + +NV_FLOW_API NvFlowContextObject* NvFlowIndexBufferGetContextObject(NvFlowIndexBuffer* buffer); + +NV_FLOW_API void* NvFlowIndexBufferMap(NvFlowContext* context, NvFlowIndexBuffer* indexBuffer); + +NV_FLOW_API void NvFlowIndexBufferUnmap(NvFlowContext* context, NvFlowIndexBuffer* indexBuffer); + +//! A read only resource interface +struct NvFlowResource; + +NV_FLOW_API NvFlowContextObject* NvFlowResourceGetContextObject(NvFlowResource* resource); + +//! A read/write resource interface +struct NvFlowResourceRW; + +NV_FLOW_API NvFlowContextObject* NvFlowResourceRWGetContextObject(NvFlowResourceRW* resourceRW); + +NV_FLOW_API NvFlowResource* NvFlowResourceRWGetResource(NvFlowResourceRW* resourceRW); + +//! A render target interface +struct NvFlowRenderTarget; + +//! Viewport description for rendering +struct NvFlowViewport +{ + float topLeftX; + float topLeftY; + float width; + float height; + float minDepth; + float maxDepth; +}; + +struct NvFlowRenderTargetDesc +{ + NvFlowViewport viewport; + NvFlowFormat rt_format; +}; + +NV_FLOW_API void NvFlowRenderTargetGetDesc(NvFlowRenderTarget* rt, NvFlowRenderTargetDesc* desc); + +NV_FLOW_API void NvFlowRenderTargetSetViewport(NvFlowRenderTarget* rt, const NvFlowViewport* viewport); + +//! A depth stencil inteface +struct NvFlowDepthStencil; + +struct NvFlowDepthStencilDesc +{ + NvFlowFormat ds_format; + NvFlowViewport viewport; + NvFlowUint width; + NvFlowUint height; +}; + +NV_FLOW_API void NvFlowDepthStencilGetDesc(NvFlowDepthStencil* ds, NvFlowDepthStencilDesc* desc); + +NV_FLOW_API void NvFlowDepthStencilSetViewport(NvFlowDepthStencil* ds, const NvFlowViewport* viewport); + +//! A buffer +struct NvFlowBuffer; + +struct NvFlowBufferDesc +{ + NvFlowFormat format; + NvFlowUint dim; + bool uploadAccess; + bool downloadAccess; +}; + +struct NvFlowBufferViewDesc +{ + NvFlowFormat format; +}; + +NV_FLOW_API void NvFlowBufferGetDesc(NvFlowBuffer* buffer, NvFlowBufferDesc* desc); + +NV_FLOW_API NvFlowBuffer* NvFlowCreateBuffer(NvFlowContext* context, const NvFlowBufferDesc* desc); + +NV_FLOW_API NvFlowBuffer* NvFlowCreateBufferView(NvFlowContext* context, NvFlowBuffer* buffer, const NvFlowBufferViewDesc* desc); + +NV_FLOW_API void NvFlowReleaseBuffer(NvFlowBuffer* buffer); + +NV_FLOW_API NvFlowContextObject* NvFlowBufferGetContextObject(NvFlowBuffer* buffer); + +NV_FLOW_API NvFlowResource* NvFlowBufferGetResource(NvFlowBuffer* buffer); + +NV_FLOW_API NvFlowResourceRW* NvFlowBufferGetResourceRW(NvFlowBuffer* buffer); + +NV_FLOW_API void* NvFlowBufferMap(NvFlowContext* context, NvFlowBuffer* buffer); + +NV_FLOW_API void NvFlowBufferUnmap(NvFlowContext* context, NvFlowBuffer* buffer); + +NV_FLOW_API void NvFlowBufferUnmapRange(NvFlowContext* context, NvFlowBuffer* buffer, NvFlowUint offset, NvFlowUint numBytes); + +NV_FLOW_API void NvFlowBufferDownload(NvFlowContext* context, NvFlowBuffer* buffer); + +NV_FLOW_API void NvFlowBufferDownloadRange(NvFlowContext* context, NvFlowBuffer* buffer, NvFlowUint offset, NvFlowUint numBytes); + +NV_FLOW_API void* NvFlowBufferMapDownload(NvFlowContext* context, NvFlowBuffer* buffer); + +NV_FLOW_API void NvFlowBufferUnmapDownload(NvFlowContext* context, NvFlowBuffer* buffer); + +//! A 1D Texture +struct NvFlowTexture1D; + +struct NvFlowTexture1DDesc +{ + NvFlowFormat format; + NvFlowUint dim; + bool uploadAccess; +}; + +NV_FLOW_API void NvFlowTexture1DGetDesc(NvFlowTexture1D* tex, NvFlowTexture1DDesc* desc); + +NV_FLOW_API NvFlowTexture1D* NvFlowCreateTexture1D(NvFlowContext* context, const NvFlowTexture1DDesc* desc); + +NV_FLOW_API void NvFlowReleaseTexture1D(NvFlowTexture1D* tex); + +NV_FLOW_API NvFlowContextObject* NvFlowTexture1DGetContextObject(NvFlowTexture1D* tex); + +NV_FLOW_API NvFlowResource* NvFlowTexture1DGetResource(NvFlowTexture1D* tex); + +NV_FLOW_API NvFlowResourceRW* NvFlowTexture1DGetResourceRW(NvFlowTexture1D* tex); + +NV_FLOW_API void* NvFlowTexture1DMap(NvFlowContext* context, NvFlowTexture1D* tex); + +NV_FLOW_API void NvFlowTexture1DUnmap(NvFlowContext* context, NvFlowTexture1D* tex); + +//! A 2D Texture +struct NvFlowTexture2D; + +struct NvFlowTexture2DDesc +{ + NvFlowFormat format; + NvFlowUint width; + NvFlowUint height; +}; + +NV_FLOW_API void NvFlowTexture2DGetDesc(NvFlowTexture2D* tex, NvFlowTexture2DDesc* desc); + +NV_FLOW_API NvFlowTexture2D* NvFlowCreateTexture2D(NvFlowContext* context, const NvFlowTexture2DDesc* desc); + +NV_FLOW_API NvFlowTexture2D* NvFlowShareTexture2D(NvFlowContext* context, NvFlowTexture2D* sharedTexture); + +NV_FLOW_API NvFlowTexture2D* NvFlowCreateTexture2DCrossAPI(NvFlowContext* context, const NvFlowTexture2DDesc* desc); + +NV_FLOW_API NvFlowTexture2D* NvFlowShareTexture2DCrossAPI(NvFlowContext* context, NvFlowTexture2D* sharedTexture); + +NV_FLOW_API void NvFlowReleaseTexture2D(NvFlowTexture2D* tex); + +NV_FLOW_API NvFlowContextObject* NvFlowTexture2DGetContextObject(NvFlowTexture2D* tex); + +NV_FLOW_API NvFlowResource* NvFlowTexture2DGetResource(NvFlowTexture2D* tex); + +NV_FLOW_API NvFlowResourceRW* NvFlowTexture2DGetResourceRW(NvFlowTexture2D* tex); + +//! A 3D Texture +struct NvFlowTexture3D; + +struct NvFlowTexture3DDesc +{ + NvFlowFormat format; + NvFlowDim dim; + bool uploadAccess; + bool downloadAccess; +}; + +NV_FLOW_API void NvFlowTexture3DGetDesc(NvFlowTexture3D* tex, NvFlowTexture3DDesc* desc); + +NV_FLOW_API NvFlowTexture3D* NvFlowCreateTexture3D(NvFlowContext* context, const NvFlowTexture3DDesc* desc); + +NV_FLOW_API void NvFlowReleaseTexture3D(NvFlowTexture3D* tex); + +NV_FLOW_API NvFlowContextObject* NvFlowTexture3DGetContextObject(NvFlowTexture3D* tex); + +NV_FLOW_API NvFlowResource* NvFlowTexture3DGetResource(NvFlowTexture3D* tex); + +NV_FLOW_API NvFlowResourceRW* NvFlowTexture3DGetResourceRW(NvFlowTexture3D* tex); + +NV_FLOW_API NvFlowMappedData NvFlowTexture3DMap(NvFlowContext* context, NvFlowTexture3D* tex); + +NV_FLOW_API void NvFlowTexture3DUnmap(NvFlowContext* context, NvFlowTexture3D* tex); + +NV_FLOW_API void NvFlowTexture3DDownload(NvFlowContext* context, NvFlowTexture3D* tex); + +NV_FLOW_API NvFlowMappedData NvFlowTexture3DMapDownload(NvFlowContext* context, NvFlowTexture3D* tex); + +NV_FLOW_API void NvFlowTexture3DUnmapDownload(NvFlowContext* context, NvFlowTexture3D* tex); + +//! A memory heap for 3D Hardware Sparse Texture +struct NvFlowHeapSparse; + +struct NvFlowHeapSparseDesc +{ + NvFlowUint sizeInBytes; +}; + +NV_FLOW_API void NvFlowHeapSparseGetDesc(NvFlowHeapSparse* heap, NvFlowHeapSparseDesc* desc); + +NV_FLOW_API NvFlowHeapSparse* NvFlowCreateHeapSparse(NvFlowContext* context, const NvFlowHeapSparseDesc* desc); + +NV_FLOW_API void NvFlowReleaseHeapSparse(NvFlowHeapSparse* heap); + +NV_FLOW_API NvFlowContextObject* NvFlowHeapSparseGetContextObject(NvFlowHeapSparse* heap); + +//! A 3D Hardware Sparse Texture +struct NvFlowTexture3DSparse; + +struct NvFlowTexture3DSparseDesc +{ + NvFlowFormat format; + NvFlowDim dim; +}; + +NV_FLOW_API void NvFlowTexture3DSparseGetDesc(NvFlowTexture3DSparse* tex, NvFlowTexture3DSparseDesc* desc); + +NV_FLOW_API NvFlowTexture3DSparse* NvFlowCreateTexture3DSparse(NvFlowContext* context, const NvFlowTexture3DSparseDesc* desc); + +NV_FLOW_API void NvFlowReleaseTexture3DSparse(NvFlowTexture3DSparse* tex); + +NV_FLOW_API NvFlowContextObject* NvFlowTexture3DSparseGetContextObject(NvFlowTexture3DSparse* tex); + +NV_FLOW_API NvFlowResource* NvFlowTexture3DSparseGetResource(NvFlowTexture3DSparse* tex); + +NV_FLOW_API NvFlowResourceRW* NvFlowTexture3DSparseGetResourceRW(NvFlowTexture3DSparse* tex); + +//! A 2D texture with render target support +struct NvFlowColorBuffer; + +struct NvFlowColorBufferDesc +{ + NvFlowFormat format; + NvFlowUint width; + NvFlowUint height; +}; + +NV_FLOW_API void NvFlowColorBufferGetDesc(NvFlowColorBuffer* tex, NvFlowColorBufferDesc* desc); + +NV_FLOW_API NvFlowColorBuffer* NvFlowCreateColorBuffer(NvFlowContext* context, const NvFlowColorBufferDesc* desc); + +NV_FLOW_API void NvFlowReleaseColorBuffer(NvFlowColorBuffer* tex); + +NV_FLOW_API NvFlowContextObject* NvFlowColorBufferGetContextObject(NvFlowColorBuffer* tex); + +NV_FLOW_API NvFlowResource* NvFlowColorBufferGetResource(NvFlowColorBuffer* tex); + +NV_FLOW_API NvFlowResourceRW* NvFlowColorBufferGetResourceRW(NvFlowColorBuffer* tex); + +NV_FLOW_API NvFlowRenderTarget* NvFlowColorBufferGetRenderTarget(NvFlowColorBuffer* tex); + +//! A 2D texture with depth stencil support +struct NvFlowDepthBuffer; + +struct NvFlowDepthBufferDesc +{ + NvFlowFormat format_resource; + NvFlowFormat format_dsv; + NvFlowFormat format_srv; + NvFlowUint width; + NvFlowUint height; +}; + +NV_FLOW_API void NvFlowDepthBufferGetDesc(NvFlowDepthBuffer* depthBuffer, NvFlowDepthBufferDesc* desc); + +NV_FLOW_API NvFlowDepthBuffer* NvFlowCreateDepthBuffer(NvFlowContext* context, const NvFlowDepthBufferDesc* desc); + +NV_FLOW_API void NvFlowReleaseDepthBuffer(NvFlowDepthBuffer* depthBuffer); + +NV_FLOW_API NvFlowContextObject* NvFlowDepthBufferGetContextObject(NvFlowDepthBuffer* depthBuffer); + +NV_FLOW_API NvFlowResource* NvFlowDepthBufferGetResource(NvFlowDepthBuffer* depthBuffer); + +NV_FLOW_API NvFlowDepthStencil* NvFlowDepthBufferGetDepthStencil(NvFlowDepthBuffer* depthBuffer); + +//! A depth stencil imported from the app +struct NvFlowDepthStencilView; + +NV_FLOW_API NvFlowResource* NvFlowDepthStencilViewGetResource(NvFlowDepthStencilView* dsv); + +NV_FLOW_API NvFlowDepthStencil* NvFlowDepthStencilViewGetDepthStencil(NvFlowDepthStencilView* dsv); + +NV_FLOW_API void NvFlowDepthStencilViewGetDepthBufferDesc(NvFlowDepthStencilView* dsv, NvFlowDepthBufferDesc* desc); + +//! A render target imported from the app +struct NvFlowRenderTargetView; + +NV_FLOW_API NvFlowRenderTarget* NvFlowRenderTargetViewGetRenderTarget(NvFlowRenderTargetView* rtv); + +//! Constants for dispatch and draw commands +#define NV_FLOW_DISPATCH_MAX_READ_TEXTURES ( 16u ) +#define NV_FLOW_DISPATCH_MAX_WRITE_TEXTURES ( 8u ) + +#define NV_FLOW_DRAW_MAX_READ_TEXTURES ( 16u ) +#define NV_FLOW_DRAW_MAX_WRITE_TEXTURES ( 1u ) +#define NV_FLOW_MAX_RENDER_TARGETS ( 8u ) + +//! A compute shader +struct NvFlowComputeShader; + +struct NvFlowComputeShaderDesc +{ + const void* cs; + NvFlowUint64 cs_length; + const wchar_t* label; +}; + +struct NvFlowDispatchParams +{ + NvFlowComputeShader* shader; + NvFlowDim gridDim; + NvFlowConstantBuffer* rootConstantBuffer; + NvFlowConstantBuffer* secondConstantBuffer; + NvFlowResource* readOnly[NV_FLOW_DISPATCH_MAX_READ_TEXTURES]; + NvFlowResourceRW* readWrite[NV_FLOW_DISPATCH_MAX_WRITE_TEXTURES]; +}; + +NV_FLOW_API NvFlowComputeShader* NvFlowCreateComputeShader(NvFlowContext* context, const NvFlowComputeShaderDesc* desc); + +NV_FLOW_API void NvFlowReleaseComputeShader(NvFlowComputeShader* computeShader); + +//! A graphics shader pipeline +struct NvFlowGraphicsShader; + +struct NvFlowInputElementDesc +{ + const char* semanticName; + NvFlowFormat format; +}; + +enum NvFlowBlendEnum +{ + eNvFlowBlend_Zero = 1, + eNvFlowBlend_One = 2, + eNvFlowBlend_SrcAlpha = 3, + eNvFlowBlend_InvSrcAlpha = 4, + eNvFlowBlend_DstAlpha = 5, + eNvFlowBlend_InvDstAlpha = 6, + + eNvFlowBlend_EnumCount = 7, +}; + +enum NvFlowBlendOpEnum +{ + eNvFlowBlendOp_Add = 1, + eNvFlowBlendOp_Subtract = 2, + eNvFlowBlendOp_RevSubtract = 3, + eNvFlowBlendOp_Min = 4, + eNvFlowBlendOp_Max = 5, + + eNvFlowBlendOp_EnumCount = 6 +}; + +enum NvFlowComparisonEnum +{ + eNvFlowComparison_Never = 1, + eNvFlowComparison_Less = 2, + eNvFlowComparison_Equal = 3, + eNvFlowComparison_LessEqual = 4, + eNvFlowComparison_Greater = 5, + eNvFlowComparison_NotEqual = 6, + eNvFlowComparison_GreaterEqual = 7, + eNvFlowComparison_Always = 8, + + eNvFlowComparison_EnumCount = 9 +}; + +struct NvFlowBlendStateDesc +{ + bool enable; + NvFlowBlendEnum srcBlendColor; + NvFlowBlendEnum dstBlendColor; + NvFlowBlendOpEnum blendOpColor; + NvFlowBlendEnum srcBlendAlpha; + NvFlowBlendEnum dstBlendAlpha; + NvFlowBlendOpEnum blendOpAlpha; +}; + +enum NvFlowDepthWriteMask +{ + eNvFlowDepthWriteMask_Zero = 0, + eNvFlowDepthWriteMask_All = 1 +}; + +struct NvFlowDepthStateDesc +{ + bool depthEnable; + NvFlowDepthWriteMask depthWriteMask; + NvFlowComparisonEnum depthFunc; +}; + +struct NvFlowGraphicsShaderDesc +{ + const void* vs; + NvFlowUint64 vs_length; + const void* ps; + NvFlowUint64 ps_length; + const wchar_t* label; + + NvFlowUint numInputElements; + NvFlowInputElementDesc* inputElementDescs; + + NvFlowBlendStateDesc blendState; + NvFlowDepthStateDesc depthState; + NvFlowUint numRenderTargets; + NvFlowFormat renderTargetFormat[NV_FLOW_MAX_RENDER_TARGETS]; + NvFlowFormat depthStencilFormat; + + bool uavTarget; + bool depthClipEnable; + bool lineList; +}; + +NV_FLOW_API void NvFlowGraphicsShaderGetDesc(NvFlowGraphicsShader* shader, NvFlowGraphicsShaderDesc* desc); + +struct NvFlowDrawParams +{ + NvFlowGraphicsShader* shader; + NvFlowConstantBuffer* rootConstantBuffer; + NvFlowResource* vs_readOnly[NV_FLOW_DRAW_MAX_READ_TEXTURES]; + NvFlowResource* ps_readOnly[NV_FLOW_DRAW_MAX_READ_TEXTURES]; + NvFlowResourceRW* ps_readWrite[NV_FLOW_DRAW_MAX_WRITE_TEXTURES]; + bool frontCounterClockwise; +}; + +NV_FLOW_API NvFlowGraphicsShader* NvFlowCreateGraphicsShader(NvFlowContext* context, const NvFlowGraphicsShaderDesc* desc); + +NV_FLOW_API void NvFlowReleaseGraphicsShader(NvFlowGraphicsShader* shader); + +NV_FLOW_API void NvFlowGraphicsShaderSetFormats(NvFlowContext* context, NvFlowGraphicsShader* shader, NvFlowFormat renderTargetFormat, NvFlowFormat depthStencilFormat); + +//! A timer for work submitted to a context +struct NvFlowContextTimer; + +NV_FLOW_API NvFlowContextTimer* NvFlowCreateContextTimer(NvFlowContext* context); + +NV_FLOW_API void NvFlowReleaseContextTimer(NvFlowContextTimer* timer); + +//! A queue of context events +struct NvFlowContextEventQueue; + +NV_FLOW_API NvFlowContextEventQueue* NvFlowCreateContextEventQueue(NvFlowContext* context); + +NV_FLOW_API void NvFlowReleaseContextEventQueue(NvFlowContextEventQueue* eventQueue); + +//! An interface that create resource and submit GPU work +struct NvFlowContext; + +NV_FLOW_API void NvFlowContextCopyConstantBuffer(NvFlowContext* context, NvFlowConstantBuffer* dst, NvFlowBuffer* src); + +NV_FLOW_API void NvFlowContextCopyBuffer(NvFlowContext* context, NvFlowBuffer* dst, NvFlowBuffer* src, NvFlowUint offset, NvFlowUint numBytes); + +NV_FLOW_API void NvFlowContextCopyTexture3D(NvFlowContext* context, NvFlowTexture3D* dst, NvFlowTexture3D* src); + +NV_FLOW_API void NvFlowContextCopyResource(NvFlowContext* context, NvFlowResourceRW* resourceRW, NvFlowResource* resource); + +NV_FLOW_API void NvFlowContextDispatch(NvFlowContext* context, const NvFlowDispatchParams* params); + +NV_FLOW_API void NvFlowContextSetVertexBuffer(NvFlowContext* context, NvFlowVertexBuffer* vertexBuffer, NvFlowUint stride, NvFlowUint offset); + +NV_FLOW_API void NvFlowContextSetIndexBuffer(NvFlowContext* context, NvFlowIndexBuffer* indexBuffer, NvFlowUint offset); + +NV_FLOW_API void NvFlowContextDrawIndexedInstanced(NvFlowContext* context, NvFlowUint indicesPerInstance, NvFlowUint numInstances, const NvFlowDrawParams* params); + +NV_FLOW_API void NvFlowContextSetRenderTarget(NvFlowContext* context, NvFlowRenderTarget* rt, NvFlowDepthStencil* ds); + +NV_FLOW_API void NvFlowContextSetViewport(NvFlowContext* context, const NvFlowViewport* viewport); + +NV_FLOW_API void NvFlowContextClearRenderTarget(NvFlowContext* context, NvFlowRenderTarget* rt, const NvFlowFloat4 color); + +NV_FLOW_API void NvFlowContextClearDepthStencil(NvFlowContext* context, NvFlowDepthStencil* ds, const float depth); + +NV_FLOW_API void NvFlowContextRestoreResourceState(NvFlowContext* context, NvFlowResource* resource); + +NV_FLOW_API bool NvFlowContextIsSparseTextureSupported(NvFlowContext* context); + +NV_FLOW_API void NvFlowContextUpdateSparseMapping(NvFlowContext* context, NvFlowTexture3DSparse* tex, NvFlowHeapSparse* heap, NvFlowUint* blockTableImage, NvFlowUint rowPitch, NvFlowUint depthPitch); + +NV_FLOW_API void NvFlowContextTimerBegin(NvFlowContext* context, NvFlowContextTimer* timer); + +NV_FLOW_API void NvFlowContextTimerEnd(NvFlowContext* context, NvFlowContextTimer* timer); + +NV_FLOW_API void NvFlowContextTimerGetResult(NvFlowContext* context, NvFlowContextTimer* timer, float* timeGPU, float* timeCPU); + +NV_FLOW_API void NvFlowContextEventQueuePush(NvFlowContext* context, NvFlowContextEventQueue* eventQueue, NvFlowUint64 uid); + +NV_FLOW_API NvFlowResult NvFlowContextEventQueuePop(NvFlowContext* context, NvFlowContextEventQueue* eventQueue, NvFlowUint64* pUid); + +NV_FLOW_API void NvFlowContextProfileGroupBegin(NvFlowContext* context, const wchar_t* label); + +NV_FLOW_API void NvFlowContextProfileGroupEnd(NvFlowContext* context); + +NV_FLOW_API void NvFlowContextProfileItemBegin(NvFlowContext* context, const wchar_t* label); + +NV_FLOW_API void NvFlowContextProfileItemEnd(NvFlowContext* context); + +//! A fence for queue synchronization +struct NvFlowFence; + +struct NvFlowFenceDesc +{ + bool crossAdapterShared; +}; + +NV_FLOW_API void NvFlowFenceGetDesc(NvFlowFence* fence, NvFlowFenceDesc* desc); + +NV_FLOW_API NvFlowFence* NvFlowCreateFence(NvFlowContext* context, const NvFlowFenceDesc* desc); + +NV_FLOW_API NvFlowFence* NvFlowShareFence(NvFlowContext* context, NvFlowFence* fence); + +NV_FLOW_API void NvFlowReleaseFence(NvFlowFence* fence); + +NV_FLOW_API void NvFlowContextWaitOnFence(NvFlowContext* context, NvFlowFence* fence, NvFlowUint64 fenceValue); + +NV_FLOW_API void NvFlowContextSignalFence(NvFlowContext* context, NvFlowFence* fence, NvFlowUint64 fenceValue); + +//! A cross adapter shared 2d texture +struct NvFlowTexture2DCrossAdapter; + +NV_FLOW_API NvFlowTexture2DCrossAdapter* NvFlowCreateTexture2DCrossAdapter(NvFlowContext* context, const NvFlowTexture2DDesc* desc); + +NV_FLOW_API NvFlowTexture2DCrossAdapter* NvFlowShareTexture2DCrossAdapter(NvFlowContext* context, NvFlowTexture2DCrossAdapter* sharedTexture); + +NV_FLOW_API void NvFlowReleaseTexture2DCrossAdapter(NvFlowTexture2DCrossAdapter* tex); + +NV_FLOW_API void NvFlowContextTransitionToCommonState(NvFlowContext* context, NvFlowResource* resource); + +NV_FLOW_API void NvFlowContextCopyToTexture2DCrossAdapter(NvFlowContext* context, NvFlowTexture2DCrossAdapter* dst, NvFlowTexture2D* src, NvFlowUint height); + +NV_FLOW_API void NvFlowContextCopyFromTexture2DCrossAdapter(NvFlowContext* context, NvFlowTexture2D* dst, NvFlowTexture2DCrossAdapter* src, NvFlowUint height); + +//! An opaque reference to another resource, for proper interqueue lifetime +struct NvFlowResourceReference; + +NV_FLOW_API NvFlowResourceReference* NvFlowShareResourceReference(NvFlowContext* context, NvFlowResource* resource); + +NV_FLOW_API void NvFlowReleaseResourceReference(NvFlowResourceReference* resource);
\ No newline at end of file diff --git a/include/NvFlowTypes.h b/include/NvFlowTypes.h index 487809f..dd78a96 100644 --- a/include/NvFlowTypes.h +++ b/include/NvFlowTypes.h @@ -42,6 +42,26 @@ struct NvFlowUint4 NvFlowUint x, y, z, w; }; +struct NvFlowInt2 +{ + int x, y; +}; + +struct NvFlowInt3 +{ + int x, y, z; +}; + +struct NvFlowInt4 +{ + int x, y, z, w; +}; + +struct NvFlowFloat2 +{ + float x, y; +}; + struct NvFlowFloat3 { float x, y, z; |