diff options
| author | Jason Maskell <[email protected]> | 2016-05-09 10:39:54 +0200 |
|---|---|---|
| committer | Jason Maskell <[email protected]> | 2016-05-09 10:39:54 +0200 |
| commit | 79b3462799c28af8ba586349bd671b1b56e72353 (patch) | |
| tree | 3b06e36c390254c0dc7f3733a0d32af213d87293 /include | |
| download | archived-waveworks-archive-79b3462799c28af8ba586349bd671b1b56e72353.tar.xz archived-waveworks-archive-79b3462799c28af8ba586349bd671b1b56e72353.zip | |
Initial commit with PS4 and XBone stuff trimmed.
Diffstat (limited to 'include')
| -rw-r--r-- | include/GFSDK_WaveWorks.h | 445 | ||||
| -rw-r--r-- | include/GFSDK_WaveWorks_Common.h | 200 | ||||
| -rw-r--r-- | include/GFSDK_WaveWorks_D3D_Util.h | 153 | ||||
| -rw-r--r-- | include/GFSDK_WaveWorks_GUID.h | 37 | ||||
| -rw-r--r-- | include/GFSDK_WaveWorks_Types.h | 364 | ||||
| -rw-r--r-- | include/restricted/GFSDK_WaveWorks_CPU_Scheduler.h | 111 | ||||
| -rw-r--r-- | include/restricted/GFSDK_WaveWorks_GUID_NDA.h | 37 | ||||
| -rw-r--r-- | include/restricted/GFSDK_WaveWorks_Orbis.h | 108 | ||||
| -rw-r--r-- | include/restricted/GFSDK_WaveWorks_Orbis_API_Implementation.h | 211 | ||||
| -rw-r--r-- | include/restricted/GFSDK_WaveWorks_Orbis_API_Interface.h | 137 |
10 files changed, 1803 insertions, 0 deletions
diff --git a/include/GFSDK_WaveWorks.h b/include/GFSDK_WaveWorks.h new file mode 100644 index 0000000..eaf26ab --- /dev/null +++ b/include/GFSDK_WaveWorks.h @@ -0,0 +1,445 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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. +// + +/* + * WaveWorks is a library for simulating terrain water surfaces, such as lakes and oceans, using the GPU. + * The library includes shader fragments which can be used to reference the results of the simulation. + * + * See documentation for details + */ + +#ifndef _GFSDK_WAVEWORKS_H +#define _GFSDK_WAVEWORKS_H + +#include <GFSDK_WaveWorks_Common.h> +#include <GFSDK_WaveWorks_Types.h> +#include <GFSDK_WaveWorks_GUID.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================== + Preamble + ===========================================================================*/ + +#ifndef GFSDK_WAVEWORKS_LINKAGE + #ifndef GFSDK_WAVEWORKS_DLL + #define GFSDK_WAVEWORKS_DLL 0 + #endif + #if GFSDK_WAVEWORKS_DLL + #define GFSDK_WAVEWORKS_LINKAGE __GFSDK_IMPORT__ + #else + #define GFSDK_WAVEWORKS_LINKAGE + #endif +#endif + +#define GFSDK_WAVEWORKS_DECL(ret_type) GFSDK_WAVEWORKS_LINKAGE ret_type GFSDK_WAVEWORKS_CALL_CONV + + +/*=========================================================================== + Memory management definitions + ===========================================================================*/ + +#ifndef GFSDK_WAVEWORKS_MALLOC_HOOKS_DEFINED +#define GFSDK_WAVEWORKS_MALLOC_HOOKS_DEFINED + +typedef void* (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_MALLOC) (size_t size); +typedef void (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_FREE) (void *p); +typedef void* (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_ALIGNED_MALLOC) (size_t size, size_t alignment); +typedef void (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_ALIGNED_FREE) (void *p); + +struct GFSDK_WaveWorks_Malloc_Hooks +{ + GFSDK_WAVEWORKS_MALLOC pMalloc; + GFSDK_WAVEWORKS_FREE pFree; + GFSDK_WAVEWORKS_ALIGNED_MALLOC pAlignedMalloc; + GFSDK_WAVEWORKS_ALIGNED_FREE pAlignedFree; +}; + +#endif + + +/*=========================================================================== + Globals/init + ===========================================================================*/ + +GFSDK_WAVEWORKS_DECL(gfsdk_cstr) GFSDK_WaveWorks_GetBuildString(); + +// Use these calls to globally initialize/release on D3D device create/destroy. +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_InitNoGraphics(const GFSDK_WaveWorks_Malloc_Hooks* pOptionalMallocHooks, const GFSDK_WaveWorks_API_GUID& apiGUID); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_ReleaseNoGraphics(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_InitD3D9(IDirect3DDevice9* pD3DDevice, const GFSDK_WaveWorks_Malloc_Hooks* pOptionalMallocHooks, const GFSDK_WaveWorks_API_GUID& apiGUID); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_ReleaseD3D9(IDirect3DDevice9* pD3DDevice); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_InitD3D10(ID3D10Device* pD3DDevice, const GFSDK_WaveWorks_Malloc_Hooks* pOptionalMallocHooks, const GFSDK_WaveWorks_API_GUID& apiGUID); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_ReleaseD3D10(ID3D10Device* pD3DDevice); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_InitD3D11(ID3D11Device* pD3DDevice, const GFSDK_WaveWorks_Malloc_Hooks* pOptionalMallocHooks, const GFSDK_WaveWorks_API_GUID& apiGUID); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_ReleaseD3D11(ID3D11Device* pD3DDevice); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_InitGL2(const GFSDK_WAVEWORKS_GLFunctions* pGLFuncs, const GFSDK_WaveWorks_Malloc_Hooks* pOptionalMallocHooks, const GFSDK_WaveWorks_API_GUID& apiGUID); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_ReleaseGL2(); + +// Utility function to test whether a given GL attrib is a match for a given shader input, based on name +GFSDK_WAVEWORKS_DECL(gfsdk_bool) GFSDK_WaveWorks_GLAttribIsShaderInput(gfsdk_cstr attribName, const GFSDK_WaveWorks_ShaderInput_Desc& inputDesc); + + +/*=========================================================================== + Save/restore of graphics device state + ===========================================================================*/ + +// In order to preserve D3D state across certain calls, create a save-state object, pass it to the call +// and then once the call is done, use it to restore the previous D3D state +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_CreateD3D9(GFSDK_WaveWorks_StatePreserveFlags PreserveFlags, IDirect3DDevice9* pD3DDevice, GFSDK_WaveWorks_SavestateHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_CreateD3D10(GFSDK_WaveWorks_StatePreserveFlags PreserveFlags, ID3D10Device* pD3DDevice, GFSDK_WaveWorks_SavestateHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_CreateD3D11(GFSDK_WaveWorks_StatePreserveFlags PreserveFlags, ID3D11Device* pD3DDevice, GFSDK_WaveWorks_SavestateHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_RestoreD3D9(GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_RestoreD3D10(GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_RestoreD3D11(GFSDK_WaveWorks_SavestateHandle hSavestate, ID3D11DeviceContext* pDC); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result) GFSDK_WaveWorks_Savestate_Destroy(GFSDK_WaveWorks_SavestateHandle hSavestate); + + +/*=========================================================================== + Simulation + ===========================================================================*/ + +struct GFSDK_WaveWorks_Simulation_Params +{ + // Global scale factor for simulated wave amplitude + gfsdk_F32 wave_amplitude; + // The direction of the wind inducing the waves + gfsdk_float2 wind_dir; + // The speed of the wind inducing the waves. If GFSDK_WaveWorks_Simulation_Settings.UseBeaufortScale is set, this is + // interpreted as a Beaufort scale value. Otherwise, it is interpreted as metres per second + gfsdk_F32 wind_speed; + // The degree to which waves appear to move in the wind direction (vs. standing waves), in the [0,1] range + gfsdk_F32 wind_dependency; + // In addition to height displacements, the simulation also applies lateral displacements. This controls the non-linearity + // and therefore 'choppiness' in the resulting wave shapes. Should normally be set in the [0,1] range. + gfsdk_F32 choppy_scale; + // The simulation spectrum is low-pass filtered to eliminate wavelengths that could end up under-sampled, this controls + // how much of the frequency range is considered 'high frequency' (i.e. small wave). + gfsdk_F32 small_wave_fraction; + + // The global time multiplier + gfsdk_F32 time_scale; + + // The turbulent energy representing foam and bubbles spread in water starts generating on the tips of the waves if + // Jacobian of wave curvature gets higher than this threshold. The range is [0,1], the typical values are [0.2,0.4] range. + gfsdk_F32 foam_generation_threshold; + // The amount of turbulent energy injected in areas defined by foam_generation_threshold parameter on each simulation step. + // The range is [0,1], the typical values are [0,0.1] range. + gfsdk_F32 foam_generation_amount; + // The speed of spatial dissipation of turbulent energy. The range is [0,1], the typical values are in [0.5,1] range. + gfsdk_F32 foam_dissipation_speed; + // In addition to spatial dissipation, the turbulent energy dissolves over time. This parameter sets the speed of + // dissolving over time. The range is [0,1], the typical values are in [0.9,0.99] range. + gfsdk_F32 foam_falloff_speed; +}; + +struct GFSDK_WaveWorks_Simulation_Settings +{ + // The detail level of the simulation: this drives the resolution of the FFT and also determines whether the simulation workload is done + // on the GPU or CPU + GFSDK_WaveWorks_Simulation_DetailLevel detail_level; + + // The repeat interval for the fft simulation, in world units + gfsdk_F32 fft_period; + + // True if wind_speed in GFSDK_WaveWorks_Simulation_Params should accept Beaufort scale value + // False if wind_speed in GFSDK_WaveWorks_Simulation_Params should accept meters/second + gfsdk_bool use_Beaufort_scale; + + // Should the displacement data be read back to the CPU? + gfsdk_bool readback_displacements; + + // If readback is enabled, displacement data can be kept alive in a FIFO for historical lookups + // e.g. in order to implement predict/correct for a networked application + gfsdk_U32 num_readback_FIFO_entries; + + // Set max aniso degree for sampling of gradient maps + gfsdk_U8 aniso_level; + + // The threading model to use when the CPU simulation path is active + // Can be set to none (meaning: simulation is performed on the calling thread, synchronously), automatic, or even + // an explicitly specified thread count + GFSDK_WaveWorks_Simulation_CPU_Threading_Model CPU_simulation_threading_model; + + // Number of GPUs used + gfsdk_S32 num_GPUs; + + // Usage of texture arrays in GL + gfsdk_bool use_texture_arrays; + + // Controls whether timer events will be used to gather stats on the CUDA simulation path + // This can impact negatively on GPU/CPU parallelism, so it is recommended to enable this only when necessary + gfsdk_bool enable_CUDA_timers; + + // Controls the use of graphics pipeline timers + gfsdk_bool enable_gfx_timers; + + // Controls the use of CPU timers to gather profiling data + gfsdk_bool enable_CPU_timers; +}; + +struct GFSDK_WaveWorks_Simulation_Stats +{ + // the times spent on particular simulation tasks, measured in milliseconds (1e-3 sec) + gfsdk_F32 CPU_main_thread_wait_time; // CPU time spent by main app thread waiting for CPU FFT simulation results using CPU + gfsdk_F32 CPU_threads_start_to_finish_time; // CPU time spent on CPU FFT simulation: time between 1st thread starts work and last thread finishes simulation work + gfsdk_F32 CPU_threads_total_time; // CPU time spent on CPU FFT simulation: sum time spent in threads that perform simulation work + gfsdk_F32 GPU_simulation_time; // GPU time spent on GPU simulation + gfsdk_F32 GPU_FFT_simulation_time; // GPU simulation time spent on FFT + gfsdk_F32 GPU_gfx_time; // GPU time spent on non-simulation e.g. updating gradient maps + gfsdk_F32 GPU_update_time; // Total GPU time spent on simulation workloads +}; + +struct GFSDK_WaveWorks_Simulation_GL_Pool +{ + // Just like any other GL client, WaveWorks must use a GL texture unit each time it binds a texture + // as a shader input. The app therefore needs to reserve a small pool of texture units for WaveWorks + // to use when setting simulation state for GL rendering, in order to avoid clashes with the app's + // own simultaneous use of texture units. All the slots in the pool must be allocated with valid + // zero-based GL texture unit indices, without repeats or clashes. + // + // There is no particular requirement for the contents of the pool to be consistent from one invocation + // to the next. The app just needs to ensure that it does not use any of the texture units in the + // pool for as long as the graphics state set by WaveWorks is required to persist. + // + // The actual amount of reserved texture units depends on whether the library was set up to use OpenGL + // Texture Arrays or not, and can be queried using GFSDK_WaveWorks_Simulation_GetTextureUnitCountGL2() + + enum { MaxNumReservedTextureUnits = 8 }; + gfsdk_U32 Reserved_Texture_Units[MaxNumReservedTextureUnits]; +}; + +// These functions can be used to check whether a particular graphics device supports a particular detail level, +// *before* initialising the graphics device +GFSDK_WAVEWORKS_DECL(gfsdk_bool) GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_NoGraphics(GFSDK_WaveWorks_Simulation_DetailLevel detailLevel); +GFSDK_WAVEWORKS_DECL(gfsdk_bool) GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_D3D9(IDirect3D9* pD3D9, const _D3DADAPTER_IDENTIFIER9& adapterIdentifier, GFSDK_WaveWorks_Simulation_DetailLevel detailLevel); +GFSDK_WAVEWORKS_DECL(gfsdk_bool) GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_D3D10(IDXGIAdapter* adapter, GFSDK_WaveWorks_Simulation_DetailLevel detailLevel); +GFSDK_WAVEWORKS_DECL(gfsdk_bool) GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_D3D11(IDXGIAdapter* adapter, GFSDK_WaveWorks_Simulation_DetailLevel detailLevel); +GFSDK_WAVEWORKS_DECL(gfsdk_bool) GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_GL2(GFSDK_WaveWorks_Simulation_DetailLevel detailLevel); + +// Simulation lifetime management +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateNoGraphics(const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params, GFSDK_WaveWorks_SimulationHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateD3D9(const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params, IDirect3DDevice9* pD3DDevice, GFSDK_WaveWorks_SimulationHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateD3D10(const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params, ID3D10Device* pD3DDevice, GFSDK_WaveWorks_SimulationHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateD3D11(const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params, ID3D11Device* pD3DDevice, GFSDK_WaveWorks_SimulationHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateGL2(const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params, void *pGLContext, GFSDK_WaveWorks_SimulationHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_Destroy(GFSDK_WaveWorks_SimulationHandle hSim); + +// A simulation can be 'updated' with new settings and properties - this is universally preferable to recreating +// a simulation from scratch, since WaveWorks will only do as much reinitialization work as is necessary to implement +// the changes in the setup. For instance, simple changes of wind speed require no reallocations and no interruptions +// to the simulation and rendering pipeline +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_UpdateProperties(GFSDK_WaveWorks_SimulationHandle hSim,const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params); + +// Sets the absolute simulation time for the next kick. WaveWorks guarantees that the same displacements will be +// generated for the same settings and input times, even across different platforms (e.g. to enable network- +// synchronized implementations) +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_SetTime(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_F64 dAppTime); + +// Retrieve information about the WaveWorks shader inputs for a given platform. This information can be used to +// query compiled shaders via a reflection interface to obtain register or constant buffer indices for subsequent +// calls to SetRenderState +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Simulation_GetShaderInputCountD3D9(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetShaderInputDescD3D9(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Simulation_GetShaderInputCountD3D10(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetShaderInputDescD3D10(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Simulation_GetShaderInputCountD3D11(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetShaderInputDescD3D11(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Simulation_GetShaderInputCountGL2(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetShaderInputDescGL2(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); + +// For GL only, get the number of texture units that need to be reserved for WaveWorks in GFSDK_WaveWorks_Simulation_GL_Pool +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Simulation_GetTextureUnitCountGL2(gfsdk_bool useTextureArrays); + +// Set WaveWorks shader inputs ready for rendering - use GetStagingCursor() to identify the kick which produced the simulation +// results that are about to be set +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_SetRenderStateD3D9(GFSDK_WaveWorks_SimulationHandle hSim, const gfsdk_float4x4& matView, const gfsdk_U32 * pShaderInputRegisterMappings, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_SetRenderStateD3D10(GFSDK_WaveWorks_SimulationHandle hSim, const gfsdk_float4x4& matView, const gfsdk_U32 * pShaderInputRegisterMappings, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_SetRenderStateD3D11(GFSDK_WaveWorks_SimulationHandle hSim, ID3D11DeviceContext* pDC, const gfsdk_float4x4& matView, const gfsdk_U32 * pShaderInputRegisterMappings, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_SetRenderStateGL2(GFSDK_WaveWorks_SimulationHandle hSim, const gfsdk_float4x4& matView, const gfsdk_U32 * pShaderInputRegisterMappings, const GFSDK_WaveWorks_Simulation_GL_Pool& glPool); + +// Retrieve an array of simulated displacements for some given array of x-y locations - use GetReadbackCursor() to identify the +// kick which produced the simulation results that are about to be retrieved +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetDisplacements(GFSDK_WaveWorks_SimulationHandle hSim, const gfsdk_float2* inSamplePoints, gfsdk_float4* outDisplacements, gfsdk_U32 numSamples); + +// Get the most recent simulation statistics +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetStats(GFSDK_WaveWorks_SimulationHandle hSim, GFSDK_WaveWorks_Simulation_Stats& stats); + +// For the current simulation settings and params, calculate an estimate of the maximum displacement that can be generated by the simulation. +// This can be used to conservatively inflate camera frusta for culling purposes (e.g. as a suitable value for Quadtree_SetFrustumCullMargin) +GFSDK_WAVEWORKS_DECL(gfsdk_F32 ) GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(GFSDK_WaveWorks_SimulationHandle hSim); + +// Kicks off the work to update the simulation to the most recent time specified by SetTime +// The top of the simulation pipeline is always run on the CPU, whereas the bottom may be run on either the CPU or GPU, depending on whether the simulation +// is using the CPU or GPU path internally, and whether graphics interop is required for rendering. +// If necessary, this call will block until the CPU part of the pipeline is able to accept further in-flight work. If the CPU part of the pipeline +// is already completely full, this means waiting for an in-flight kick to exit the CPU pipeline (kicks are processed in FIFO order) +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_KickNoGraphics(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_KickD3D9(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_KickD3D10(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_KickD3D11(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID, ID3D11DeviceContext* pDC, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_KickGL2(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID); + +// The staging cursor points to the most recent kick to exit the CPU part of the simulation pipeline (and therefore the kick whose state would be set by a +// subsequent call to SetRenderState) +// Returns gfsdk_waveworks_result_NONE if no simulation results are staged +// The staging cursor will only ever change during an API call, and is guaranteed to advance by a maximum of one kick in any one call +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetStagingCursor(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID); + +// Advances the staging cursor +// Use block to specify behaviour in the case where there is an in-flight kick in the CPU part of the simulation pipeline +// Returns gfsdk_waveworks_result_NONE if there are no in-flight kicks in the CPU part of the simulation pipeline +// Returns gfsdk_waveworks_result_WOULD_BLOCK if there are in-flight kicks in the CPU part of the pipeline, but they're not ready for staging +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceStagingCursorNoGraphics(GFSDK_WaveWorks_SimulationHandle hSim, bool block); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceStagingCursorD3D9(GFSDK_WaveWorks_SimulationHandle hSim, bool block, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceStagingCursorD3D10(GFSDK_WaveWorks_SimulationHandle hSim, bool block, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceStagingCursorD3D11(GFSDK_WaveWorks_SimulationHandle hSim, bool block, ID3D11DeviceContext* pDC, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceStagingCursorGL2(GFSDK_WaveWorks_SimulationHandle hSim, bool block); + +// Waits until the staging cursor is ready to advance (i.e. waits until a non-blocking call to AdvanceStagingCursor would succeed) +// Returns gfsdk_waveworks_result_NONE if there are no in-flight kicks in the CPU part of the simulation pipeline +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_WaitStagingCursor(GFSDK_WaveWorks_SimulationHandle hSim); + +// The readback cursor points to the kick whose results would be fetched by a call to GetDisplacements +// Returns gfsdk_waveworks_result_NONE if no results are available for readback +// The readback cursor will only ever change during an API call, and is guaranteed to advance by a maximum of one kick in any one call +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetReadbackCursor(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID); + +// Advances the readback cursor +// Use block to specify behaviour in the case where there is an in-flight readback +// Returns gfsdk_waveworks_result_NONE if there are no readbacks in-flight beyond staging +// Returns gfsdk_waveworks_result_WOULD_BLOCK if there are readbacks in-flight beyond staging, but they're not yet ready +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceReadbackCursor(GFSDK_WaveWorks_SimulationHandle hSim, bool block); + +// Archives the current readback results in the readback FIFO, evicting the oldest FIFO entry if necessary +// Returns gfsdk_waveworks_result_FAIL if no results are available for readback +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_ArchiveDisplacements(GFSDK_WaveWorks_SimulationHandle hSim); + +// Identical to GFSDK_WaveWorks_Simulation_GetDisplacements, except values are retrieved from the readback FIFO +// The readback entries to use are specified using the 'coord' parameter, as follows: +// - specify 0.f to read from the most recent entry in the FIFO +// - specify (num_readback_FIFO_entries-1) to read from the oldest entry in the FIFO +// - intervening entries may be accessed the same way, using a zero-based index +// - if 'coord' is fractional, the nearest pair of entries will be lerp'd accordingly (fractional lookups are therefore more CPU-intensive) +// +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetArchivedDisplacements(GFSDK_WaveWorks_SimulationHandle hSim, float coord, const gfsdk_float2* inSamplePoints, gfsdk_float4* outDisplacements, gfsdk_U32 numSamples); + +/*=========================================================================== + Quad-tree geometry generator + ===========================================================================*/ + +struct GFSDK_WaveWorks_Quadtree_Params +{ + // Dimension of a single square patch, default to 128x128 grids + gfsdk_S32 mesh_dim; + // The size of the smallest permissible leaf quad in world space (i.e. the size of a lod zero patch) + gfsdk_F32 min_patch_length; + // The coordinates of the min corner of patch (0,0,lod). This is only necessary if AllocPatch/FreePatch + // is being used to drive the quad-tree structure + gfsdk_float2 patch_origin; + // The lod of the root patch used for frustum culling and mesh lodding. This is only necessary if + // AllocPatch/FreePatch is *not* being used to drive the quad-tree structure. This determines the furthest + // coverage of the water surface from the eye point + gfsdk_U32 auto_root_lod; + // The upper limit of the pixel number a grid can cover in screen space + gfsdk_F32 upper_grid_coverage; + // The offset required to place the surface at sea level + gfsdk_F32 sea_level; + // The flag that defines if tessellation friendly topology and mesh must be generated + gfsdk_bool use_tessellation; + // The tessellation LOD scale parameter + gfsdk_F32 tessellation_lod; + // The degree of geomorphing to use when tessellation is not available, in the range [0,1] + gfsdk_F32 geomorphing_degree; + // Controls the use of CPU timers to gather profiling data + gfsdk_bool enable_CPU_timers; +}; + +struct GFSDK_WaveWorks_Quadtree_Stats +{ + gfsdk_S32 num_patches_drawn; + + // CPU time spent on quadtree update, measured in milliseconds (1e-3 sec) + gfsdk_F32 CPU_quadtree_update_time; +}; + +// Quadtree lifetime management +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_CreateD3D9(const GFSDK_WaveWorks_Quadtree_Params& params, IDirect3DDevice9* pD3DDevice, GFSDK_WaveWorks_QuadtreeHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_CreateD3D10(const GFSDK_WaveWorks_Quadtree_Params& params, ID3D10Device* pD3DDevice, GFSDK_WaveWorks_QuadtreeHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_CreateD3D11(const GFSDK_WaveWorks_Quadtree_Params& params, ID3D11Device* pD3DDevice, GFSDK_WaveWorks_QuadtreeHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_CreateGL2(const GFSDK_WaveWorks_Quadtree_Params& params, unsigned int Program, GFSDK_WaveWorks_QuadtreeHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_Destroy(GFSDK_WaveWorks_QuadtreeHandle hQuadtree); + +// A quadtree can be udpated with new parameters. This is something of a corner-case for quadtrees, but is provided for completeness +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_UpdateParams(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, const GFSDK_WaveWorks_Quadtree_Params& params); + +// Retrieve information about the WaveWorks shader inputs for a given platform. This information can be used to +// query compiled shaders via a reflection interface to obtain register or constant buffer indices for subsequent +// calls to Draw +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Quadtree_GetShaderInputCountD3D9(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_GetShaderInputDescD3D9(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Quadtree_GetShaderInputCountD3D10(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_GetShaderInputDescD3D10(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Quadtree_GetShaderInputCountD3D11(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_GetShaderInputDescD3D11(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Quadtree_GetShaderInputCountGL2(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_GetShaderInputDescGL2(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); + +// Explicit control over quadtree tiles, primarily for removing tiles that are known to be entirey hidden by terrain. +// If AllocPatch is never called, the quadtree runs in automatic mode and is assumed to be rooted on a eye-centred +// patch whose dimension is determined by GFSDK_WaveWorks_Quadtree_Params.auto_root_lod +// Otherwise, WaveWorks starts frustum culling from the list of patches implied by calls to AllocPatch/FreePatch +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_AllocPatch(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, gfsdk_S32 x, gfsdk_S32 y, gfsdk_U32 lod, gfsdk_bool enabled); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_FreePatch(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, gfsdk_S32 x, gfsdk_S32 y, gfsdk_U32 lod); + +// Draw the water surface using the specified quadtree with the specified view and projection matrices +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_DrawD3D9(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, const gfsdk_float4x4& matView, const gfsdk_float4x4& matProj, const gfsdk_U32 * pShaderInputRegisterMappings, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_DrawD3D10(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, const gfsdk_float4x4& matView, const gfsdk_float4x4& matProj, const gfsdk_U32 * pShaderInputRegisterMappings, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_DrawD3D11(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, ID3D11DeviceContext* pDC, const gfsdk_float4x4& matView, const gfsdk_float4x4& matProj, const gfsdk_U32 * pShaderInputRegisterMappings, GFSDK_WaveWorks_SavestateHandle hSavestate); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_DrawGL2(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, const gfsdk_float4x4& matView, const gfsdk_float4x4& matProj, const gfsdk_U32 * pShaderInputRegisterMappings); + +// Get the most recent quadtree rendering statistics +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_GetStats(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, GFSDK_WaveWorks_Quadtree_Stats& stats); + +// Patches are culled based on their undisplaced footrpint plus an additional user-supplied margin to take account +// of simulated displacements. Simulation_GetConservativeMaxDisplacementEstimate() can be used for this directly +// when WaveWorks is the only source of displacement on the water surface, otherwise it can be added to estimates +// from any other sources as necessary (e.g. wakes, explosions etc.) +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, gfsdk_F32 margin); + +/*=========================================================================== + The End + ===========================================================================*/ + +#ifdef __cplusplus +}; //extern "C" { +#endif + +#endif // _GFSDK_WAVEWORKS_H diff --git a/include/GFSDK_WaveWorks_Common.h b/include/GFSDK_WaveWorks_Common.h new file mode 100644 index 0000000..808cd45 --- /dev/null +++ b/include/GFSDK_WaveWorks_Common.h @@ -0,0 +1,200 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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. +// + +/*=========================================================================== +GFSDK_WaveWorks_Common.h + +GFSDK_Common defines common macros, types and structs used generally by +all NVIDIA TECH Libraries. You won't find anything particularly interesting +here. + +For any issues with this particular header please contact: + + +For any issues with the specific FX library you are using, see the header +file for that library for contact information. + +===========================================================================*/ + +#include <cstdlib> + +#pragma pack(push,8) // Make sure we have consistent structure packings + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================== +AUTO CONFIG +===========================================================================*/ +#ifndef __GFSDK_COMMON_AUTOCONFIG +#define __GFSDK_COMMON_AUTOCONFIG + + #if defined(__GNUC__) //|| defined (__ANDROID__) + #define __GFSDK_CC_GNU__ 1 + #define __GFSDK_CC_MSVC__ 0 + #else + #define __GFSDK_CC_GNU__ 0 + #define __GFSDK_CC_MSVC__ 1 + #endif + +#endif + +/*=========================================================================== +FORWARD DECLARATIONS +===========================================================================*/ +#ifndef __GFSDK_COMMON_FORWARDDECLS +#define __GFSDK_COMMON_FORWARDDECLS + + #if __GFSDK_GL__ + // $ TODO Add common fwd decls for OGL + #endif + /*-------------------------------------------------------------------------*/ + #if __GFSDK_DX11__ + // $ TODO Add common fwd decls for D3D11 + #endif + +#endif // __GFSDK_COMMON_FORWARDDECLS + +/*=========================================================================== +TYPES +===========================================================================*/ +#ifndef __GFSDK_COMMON_TYPES +#define __GFSDK_COMMON_TYPES + + typedef unsigned char gfsdk_U8; + typedef unsigned short gfsdk_U16; + typedef signed int gfsdk_S32; + typedef signed long long gfsdk_S64; + typedef unsigned int gfsdk_U32; + typedef unsigned long long gfsdk_U64; + typedef float gfsdk_F32; + typedef void gfsdk_void; + + typedef struct { + gfsdk_F32 x; + gfsdk_F32 y; + } gfsdk_float2; + + typedef struct { + gfsdk_F32 x; + gfsdk_F32 y; + gfsdk_F32 z; + } gfsdk_float3; + + typedef struct { + gfsdk_F32 x; + gfsdk_F32 y; + gfsdk_F32 z; + gfsdk_F32 w; + } gfsdk_float4; + + // implicit row major + typedef struct { + gfsdk_F32 _11, _12, _13, _14; + gfsdk_F32 _21, _22, _23, _24; + gfsdk_F32 _31, _32, _33, _34; + gfsdk_F32 _41, _42, _43, _44; + } gfsdk_float4x4; + + typedef bool gfsdk_bool; + typedef char gfsdk_char; + typedef const gfsdk_char* gfsdk_cstr; + typedef double gfsdk_F64; + +#endif // __GFSDK_COMMON_TYPES + +/*=========================================================================== +MACROS +===========================================================================*/ +#ifndef __GFSDK_COMMON_MACROS +#define __GFSDK_COMMON_MACROS + + // GNU + #if __GFSDK_CC_GNU__ + #define __GFSDK_ALIGN__(bytes) __attribute__((aligned (bytes))) + #define __GFSDK_EXPECT__(exp,tf) __builtin_expect(exp, tf) + #define __GFSDK_INLINE__ __attribute__((always_inline)) + #define __GFSDK_NOLINE__ __attribute__((noinline)) + #define __GFSDK_RESTRICT__ __restrict + /*-------------------------------------------------------------------------*/ + #define __GFSDK_CDECL__ + #define __GFSDK_IMPORT__ __declspec(dllimport) + #define __GFSDK_EXPORT__ __declspec(dllexport) + #define __GFSDK_STDCALL__ + #endif + + + // MSVC + #if __GFSDK_CC_MSVC__ + #define __GFSDK_ALIGN__(bytes) __declspec(align(bytes)) + #define __GFSDK_EXPECT__(exp, tf) (exp) + #define __GFSDK_INLINE__ __forceinline + #define __GFSDK_NOINLINE__ + #define __GFSDK_RESTRICT__ __restrict + /*-------------------------------------------------------------------------*/ + #define __GFSDK_CDECL__ __cdecl + #define __GFSDK_IMPORT__ __declspec(dllimport) + #define __GFSDK_EXPORT__ __declspec(dllexport) + #define __GFSDK_STDCALL__ __stdcall + #endif + +#endif // __GFSDK_COMMON_MACROS + +/*=========================================================================== +RETURN CODES +===========================================================================*/ +#ifndef __GFSDK_COMMON_RETURNCODES +#define __GFSDK_COMMON_RETURNCODES + + #define GFSDK_RETURN_OK 0 + #define GFSDK_RETURN_FAIL 1 + #define GFSDK_RETURN_EMULATION 2 + +#endif // __GFSDK_COMMON_RETURNCODES + +/*=========================================================================== +CUSTOM HEAP +===========================================================================*/ +#ifndef __GFSDK_COMMON_CUSTOMHEAP +#define __GFSDK_COMMON_CUSTOMHEAP + + typedef struct { + void* (*new_)(size_t); + void (*delete_)(void*); + } gfsdk_new_delete_t; + +#endif // __GFSDK_COMMON_CUSTOMHEAP + +#ifdef __cplusplus +}; //extern "C" { + +#endif + +#pragma pack(pop) diff --git a/include/GFSDK_WaveWorks_D3D_Util.h b/include/GFSDK_WaveWorks_D3D_Util.h new file mode 100644 index 0000000..2d89bae --- /dev/null +++ b/include/GFSDK_WaveWorks_D3D_Util.h @@ -0,0 +1,153 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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 _GFSDK_WAVEWORKS_D3D_UTIL_H +#define _GFSDK_WAVEWORKS_D3D_UTIL_H + +#include <GFSDK_WaveWorks_Types.h> + +// Convenience functions for converting between DX and NV types when using the WaveWorks API +// This header should be #included *AFTER* d3d and d3dx headers + +//////////////////////////////////////////////////////////////////////////////// +// Conversion helpers +//////////////////////////////////////////////////////////////////////////////// +__GFSDK_INLINE__ D3DXVECTOR2 NvToDX(const gfsdk_float2& rhs) { + D3DXVECTOR2 result; + result.x = rhs.x; + result.y = rhs.y; + return result; +} + +__GFSDK_INLINE__ gfsdk_float2 NvFromDX(const D3DXVECTOR2& rhs) { + gfsdk_float2 result; + result.x = rhs.x; + result.y = rhs.y; + return result; +} + +__GFSDK_INLINE__ D3DXVECTOR4 NvToDX(const gfsdk_float4& rhs) { + D3DXVECTOR4 result; + result.x = rhs.x; + result.y = rhs.y; + result.z = rhs.z; + result.w = rhs.w; + return result; +} + +__GFSDK_INLINE__ gfsdk_float4 NvFromDX(const D3DXVECTOR4& rhs) { + gfsdk_float4 result; + result.x = rhs.x; + result.y = rhs.y; + result.z = rhs.z; + result.w = rhs.w; + return result; +} + +__GFSDK_INLINE__ D3DXMATRIX NvToDX(const gfsdk_float4x4& rhs) { + + D3DXMATRIX result; + + result._11 = rhs._11; + result._12 = rhs._12; + result._13 = rhs._13; + result._14 = rhs._14; + + result._21 = rhs._21; + result._22 = rhs._22; + result._23 = rhs._23; + result._24 = rhs._24; + + result._31 = rhs._31; + result._32 = rhs._32; + result._33 = rhs._33; + result._34 = rhs._34; + + result._41 = rhs._41; + result._42 = rhs._42; + result._43 = rhs._43; + result._44 = rhs._44; + + return result; +} + +__GFSDK_INLINE__ gfsdk_float4x4 NvFromDX(const D3DXMATRIX& rhs) { + + gfsdk_float4x4 result; + + result._11 = rhs._11; + result._12 = rhs._12; + result._13 = rhs._13; + result._14 = rhs._14; + + result._21 = rhs._21; + result._22 = rhs._22; + result._23 = rhs._23; + result._24 = rhs._24; + + result._31 = rhs._31; + result._32 = rhs._32; + result._33 = rhs._33; + result._34 = rhs._34; + + result._41 = rhs._41; + result._42 = rhs._42; + result._43 = rhs._43; + result._44 = rhs._44; + + return result; +} + +__GFSDK_INLINE__ gfsdk_float4x4 NvFromGL(const float* rhs) { + + gfsdk_float4x4 result; + + result._11 = rhs[0]; + result._12 = rhs[1]; + result._13 = rhs[2]; + result._14 = rhs[3]; + + result._21 = rhs[4]; + result._22 = rhs[5]; + result._23 = rhs[6]; + result._24 = rhs[7]; + + result._31 = rhs[8]; + result._32 = rhs[9]; + result._33 = rhs[10]; + result._34 = rhs[11]; + + result._41 = rhs[12]; + result._42 = rhs[13]; + result._43 = rhs[14]; + result._44 = rhs[15]; + + return result; +} + +#endif // _GFSDK_WAVEWORKS_D3D_UTIL_H diff --git a/include/GFSDK_WaveWorks_GUID.h b/include/GFSDK_WaveWorks_GUID.h new file mode 100644 index 0000000..a241859 --- /dev/null +++ b/include/GFSDK_WaveWorks_GUID.h @@ -0,0 +1,37 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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 _GFSDK_WAVEWORKS_GUID_H +#define _GFSDK_WAVEWORKS_GUID_H + +#include <GFSDK_WaveWorks_Common.h> +#include <GFSDK_WaveWorks_Types.h> + +#define GFSDK_WAVEWORKS_API_GUID GFSDK_WaveWorks_API_GUID(0x40C55E2B, 0x2AE34be0, 0xA4849F24, 0x585EB898) + +#endif // _GFSDK_WAVEWORKS_GUID_H diff --git a/include/GFSDK_WaveWorks_Types.h b/include/GFSDK_WaveWorks_Types.h new file mode 100644 index 0000000..13fbbcd --- /dev/null +++ b/include/GFSDK_WaveWorks_Types.h @@ -0,0 +1,364 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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 _GFSDK_WAVEWORKS_TYPES_H +#define _GFSDK_WAVEWORKS_TYPES_H + +#include <GFSDK_WaveWorks_Common.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================== + Calling conventions + ===========================================================================*/ + +#define GFSDK_WAVEWORKS_CALL_CONV __GFSDK_CDECL__ + + +/*=========================================================================== + Result codes + ===========================================================================*/ +enum gfsdk_waveworks_result { + gfsdk_waveworks_result_INTERNAL_ERROR = -2, + gfsdk_waveworks_result_FAIL = -1, + gfsdk_waveworks_result_OK = 0, + gfsdk_waveworks_result_NONE = 1, + gfsdk_waveworks_result_WOULD_BLOCK = 2, +}; + +/*=========================================================================== + Fwd decls of system types + ===========================================================================*/ +struct _D3DADAPTER_IDENTIFIER9; +struct IDXGIAdapter; +struct IDirect3DDevice9; +struct IDirect3D9; +struct ID3D10Device; +struct ID3D11Device; +struct ID3D11DeviceContext; + +/*=========================================================================== + Value class used in answering queries about shader inputs + ===========================================================================*/ +struct GFSDK_WaveWorks_ShaderInput_Desc +{ + enum InputType + { + VertexShader_FloatConstant = 0, + VertexShader_ConstantBuffer, + VertexShader_Texture, + VertexShader_Sampler, + HullShader_FloatConstant, + HullShader_ConstantBuffer, + HullShader_Texture, + HullShader_Sampler, + DomainShader_FloatConstant, + DomainShader_ConstantBuffer, + DomainShader_Texture, + DomainShader_Sampler, + PixelShader_FloatConstant, + PixelShader_ConstantBuffer, + PixelShader_Texture, + PixelShader_Sampler, + GL_VertexShader_UniformLocation, + GL_TessEvalShader_UniformLocation, + GL_FragmentShader_UniformLocation, + GL_VertexShader_TextureBindLocation, + GL_TessEvalShader_TextureBindLocation, + GL_FragmentShader_TextureBindLocation, + GL_VertexShader_TextureArrayBindLocation, + GL_TessEvalShader_TextureArrayBindLocation, + GL_FragmentShader_TextureArrayBindLocation, + GL_AttribLocation + }; + + InputType Type; + gfsdk_cstr Name; + gfsdk_U32 RegisterOffset; // This will be the offset specified to the shader macro i.e. 'Regoff' +}; + +enum { GFSDK_WaveWorks_UnusedShaderInputRegisterMapping = 0xFFFFFFFF }; + +/*=========================================================================== + Flags used to specify what state to preserve during rendering + ===========================================================================*/ +enum GFSDK_WaveWorks_StatePreserveFlags +{ + GFSDK_WaveWorks_StatePreserve_None = 0, + GFSDK_WaveWorks_StatePreserve_Shaders = 1, + GFSDK_WaveWorks_StatePreserve_ShaderConstants = 2, + GFSDK_WaveWorks_StatePreserve_Samplers = 4, // Includes textures/shader-resources + GFSDK_WaveWorks_StatePreserve_RenderTargets = 8, + GFSDK_WaveWorks_StatePreserve_Viewports = 16, + GFSDK_WaveWorks_StatePreserve_Streams = 32, // Includes vertex/index-buffers, decls/input-layouts + GFSDK_WaveWorks_StatePreserve_UnorderedAccessViews = 64, + GFSDK_WaveWorks_StatePreserve_Other = 128, + GFSDK_WaveWorks_StatePreserve_All = 0xFFFFFFFF, + GFSDK_WaveWorks_StatePreserve_ForceDWORD = 0xFFFFFFFF +}; + +/*=========================================================================== + Specifies the detail level of the simulation + ===========================================================================*/ +enum GFSDK_WaveWorks_Simulation_DetailLevel +{ + GFSDK_WaveWorks_Simulation_DetailLevel_Normal = 0, + GFSDK_WaveWorks_Simulation_DetailLevel_High, + GFSDK_WaveWorks_Simulation_DetailLevel_Extreme, + Num_GFSDK_WaveWorks_Simulation_DetailLevels +}; + +/*=========================================================================== + Controls the threading model when the CPU simulation path is used + ===========================================================================*/ +enum GFSDK_WaveWorks_Simulation_CPU_Threading_Model +{ + GFSDK_WaveWorks_Simulation_CPU_Threading_Model_None = -1, // Do not use worker threads + GFSDK_WaveWorks_Simulation_CPU_Threading_Model_Automatic = 0, // Use an automatically-determined number of worker threads + GFSDK_WaveWorks_Simulation_CPU_Threading_Model_1 = 1, // Use 1 worker thread + GFSDK_WaveWorks_Simulation_CPU_Threading_Model_2 = 2, // Use 2 worker threads + GFSDK_WaveWorks_Simulation_CPU_Threading_Model_3 = 3, // Use 3 worker threads + // etc... + // i.e. it's safe to use higher values to represent even larger thread counts +}; + +/*=========================================================================== + Handles + ===========================================================================*/ +struct GFSDK_WaveWorks_Context; +struct GFSDK_WaveWorks_Simulation; +struct GFSDK_WaveWorks_Quadtree; +struct GFSDK_WaveWorks_Savestate; +typedef GFSDK_WaveWorks_Context* GFSDK_WaveWorks_ContextHandle; +typedef GFSDK_WaveWorks_Simulation* GFSDK_WaveWorks_SimulationHandle; +typedef GFSDK_WaveWorks_Quadtree* GFSDK_WaveWorks_QuadtreeHandle; +typedef GFSDK_WaveWorks_Savestate* GFSDK_WaveWorks_SavestateHandle; + +/*=========================================================================== + API GUID + ===========================================================================*/ +struct GFSDK_WaveWorks_API_GUID +{ + GFSDK_WaveWorks_API_GUID(gfsdk_U32 c1, gfsdk_U32 c2, gfsdk_U32 c3, gfsdk_U32 c4) : + Component1(c1), Component2(c2), Component3(c3), Component4(c4) + { + } + + gfsdk_U32 Component1; + gfsdk_U32 Component2; + gfsdk_U32 Component3; + gfsdk_U32 Component4; +}; + +/*=========================================================================== + Kick IDs + ===========================================================================*/ + +#define GFSDK_WaveWorks_InvalidKickID gfsdk_U64(-1) + +/*=========================================================================== + OpenGL types + ===========================================================================*/ + +// We reluctantly pull in the defs for ptrdiff_t and uint64_t here - there are of course other ways +// of defining these on a particular platform without needing an include, but they are not generally +// portable +#if !defined(_MSC_VER) +#include <stddef.h> +#include <stdint.h> +#endif + +// GL base types +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef signed char GLbyte; +typedef short GLshort; +typedef int GLint; +#if defined(_MSC_VER) +typedef unsigned __int64 GLuint64; +#else +typedef uint64_t GLuint64; +#endif +typedef int GLsizei; +typedef unsigned char GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef float GLfloat; +typedef void GLvoid; +typedef unsigned int GLbitfield; +#if defined(__ANDROID__) +typedef long GLintptr; +typedef long GLsizeiptr; +#else +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#endif +typedef char GLchar; +typedef void* GLhandleARB; + +// GL function type definitions +#define APIENTRYP __GFSDK_STDCALL__ * +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name); +typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); + + +// GL functions used by WaveWorks, in alphabetic order +struct GFSDK_WAVEWORKS_GLFunctions +{ + PFNGLACTIVETEXTUREPROC glActiveTexture; + PFNGLATTACHSHADERPROC glAttachShader; + PFNGLBINDBUFFERPROC glBindBuffer; + PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; + PFNGLBINDTEXTUREPROC glBindTexture; + PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; + PFNGLBUFFERDATAPROC glBufferData; + PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; + PFNGLCLEARCOLORPROC glClearColor; + PFNGLCLEARPROC glClear; + PFNGLCOLORMASKPROC glColorMask; + PFNGLCOMPILESHADERPROC glCompileShader; + PFNGLCREATEPROGRAMPROC glCreateProgram; + PFNGLCREATESHADERPROC glCreateShader; + PFNGLDELETEBUFFERSPROC glDeleteBuffers; + PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; + PFNGLDELETEPROGRAMPROC glDeleteProgram; + PFNGLDELETEQUERIESPROC glDeleteQueries; + PFNGLDELETESHADERPROC glDeleteShader; + PFNGLDELETETEXTURESPROC glDeleteTextures; + PFNGLDISABLEPROC glDisable; + PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; + PFNGLDRAWELEMENTSPROC glDrawElements; + PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; + PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; + PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; + PFNGLGENBUFFERSPROC glGenBuffers; + PFNGLGENERATEMIPMAPPROC glGenerateMipmap; + PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; + PFNGLGENQUERIESPROC glGenQueries; + PFNGLGENTEXTURESPROC glGenTextures; + PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; + PFNGLGETERRORPROC glGetError; + PFNGLGETINTEGERVPROC glGetIntegerv; + PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; + PFNGLGETPROGRAMIVPROC glGetProgramiv; + PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; + PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; + PFNGLGETSHADERIVPROC glGetShaderiv; + PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; + PFNGLLINKPROGRAMPROC glLinkProgram; + PFNGLMAPBUFFERRANGEPROC glMapBufferRange; + PFNGLPATCHPARAMETERIPROC glPatchParameteri; + PFNGLQUERYCOUNTERPROC glQueryCounter; + PFNGLSHADERSOURCEPROC glShaderSource; + PFNGLTEXIMAGE2DPROC glTexImage2D; + PFNGLTEXIMAGE3DPROC glTexImage3D; + PFNGLTEXPARAMETERFPROC glTexParameterf; + PFNGLTEXPARAMETERIPROC glTexParameteri; + PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; + PFNGLUNIFORM1FPROC glUniform1f; + PFNGLUNIFORM1IPROC glUniform1i; + PFNGLUNIFORM3FVPROC glUniform3fv; + PFNGLUNIFORM4FVPROC glUniform4fv; + PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv; + PFNGLUNMAPBUFFERPROC glUnmapBuffer; + PFNGLUSEPROGRAMPROC glUseProgram; + PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; + PFNGLVIEWPORTPROC glViewport; + PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib; + PFNGLREADBUFFERPROC glReadBuffer; + PFNGLDRAWBUFFERSPROC glDrawBuffers; +}; + +#ifdef __cplusplus +}; //extern "C" { +#endif + +#endif // _GFSDK_WAVEWORKS_TYPES_H diff --git a/include/restricted/GFSDK_WaveWorks_CPU_Scheduler.h b/include/restricted/GFSDK_WaveWorks_CPU_Scheduler.h new file mode 100644 index 0000000..0d0b7f1 --- /dev/null +++ b/include/restricted/GFSDK_WaveWorks_CPU_Scheduler.h @@ -0,0 +1,111 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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 _GFSDK_WAVEWORKS_CPU_SCHEDULER_H +#define _GFSDK_WAVEWORKS_CPU_SCHEDULER_H + +#include <GFSDK_WaveWorks_Common.h> +#include <GFSDK_WaveWorks_Types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// Fwd. decls +struct GFSDK_WaveWorks_CPU_Scheduler_Interface; + +// Scheduler-variation entrypoints +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateD3D11_NDA( const GFSDK_WaveWorks_Simulation_Settings& settings, + const GFSDK_WaveWorks_Simulation_Params& params, + GFSDK_WaveWorks_CPU_Scheduler_Interface* pOptionalScheduler, + ID3D11Device* pD3DDevice, + GFSDK_WaveWorks_SimulationHandle* pResult + ); + +// The scheduler interface +struct GFSDK_WaveWorks_CPU_Scheduler_Interface +{ + /* + * This interface can be used to cause WaveWorks CPU simulation tasks to be handled + * by the client's own scheduler. + * + * First, note that you will need to provide one instance of this interface per + * WaveWorks simulation. The semantics of the interface imply a little bit of + * statefulness which evolves over a simulation cycle, therefore it is necessary + * to have a unique scheduler object per simulation + * + * A single simulation cycle consists of: + * + * 1/ one or more 'push' calls to queue the initial simulation tasks + * + * 2/ a call to 'kick()', which is a signal that the initial tasks are fully + * queued and simulation can commence + * + * 3/ scheduler calls 'taskHandler' for each queued task. This *may* result + * in further 'push' calls to queue further work + * + * 4/ the simulation cycle is complete when a 'taskHandler' call exits and + * there are no tasks left in the queue + * + * 5/ WaveWorks will either poll or wait for the simulation cycle to complete + * via isWorkDone() or waitForWorkDone(), depending on the calls made to + * the WaveWorks API by the client + * + * No more than ONE simulation cycle will be scheduled at a time. WaveWorks will + * wait for the current cycle to complete before attempting to push tasks for a new + * cycle. + */ + + // Queue a single item of work + virtual void push(gfsdk_U32 taskData) = 0; + + // Queue a batch of 'n' items of work + virtual void push(const gfsdk_U32* taskData, int n) = 0; + + // Queue a single item of work but insert at a random location in the existing work + // queue (reason: this gives better perf on some platforms by 'relaxing' the memory bus) + virtual void pushRandom(gfsdk_U32 taskData) = 0; + + // Wait until the current simulation cycle is out of tasks and all handlers have + // returned + virtual void waitForWorkDone() = 0; + + // Test whether the current simulation cycle is out of tasks and all handlers have + // returned + virtual bool isWorkDone() = 0; + + // Signal the scheduler to begin work on a new simulation cycle + typedef void (*ProcessTaskFn)(void* pContext, gfsdk_U32 taskData); + virtual bool kick(ProcessTaskFn taskHandler, void* pContext) = 0; +}; + +#ifdef __cplusplus +}; //extern "C" { +#endif + +#endif // _GFSDK_WAVEWORKS_CPU_SCHEDULER_H diff --git a/include/restricted/GFSDK_WaveWorks_GUID_NDA.h b/include/restricted/GFSDK_WaveWorks_GUID_NDA.h new file mode 100644 index 0000000..79da031 --- /dev/null +++ b/include/restricted/GFSDK_WaveWorks_GUID_NDA.h @@ -0,0 +1,37 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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 _GFSDK_WAVEWORKS_GUID_H +#define _GFSDK_WAVEWORKS_GUID_H + +#include <GFSDK_WaveWorks_Common.h> +#include <GFSDK_WaveWorks_Types.h> + +#define GFSDK_WAVEWORKS_API_GUID GFSDK_WaveWorks_API_GUID(0x8cc7a204, 0x75144563, 0xa43ace52, 0x81bce01d) + +#endif // _GFSDK_WAVEWORKS_GUID_H diff --git a/include/restricted/GFSDK_WaveWorks_Orbis.h b/include/restricted/GFSDK_WaveWorks_Orbis.h new file mode 100644 index 0000000..9ffa32e --- /dev/null +++ b/include/restricted/GFSDK_WaveWorks_Orbis.h @@ -0,0 +1,108 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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. +// + +/* + * This header defines the Orbis-specific parts of the WaveWorks API + */ + +#ifndef _GFSDK_WAVEWORKS_ORBIS_H +#define _GFSDK_WAVEWORKS_ORBIS_H + +#include <GFSDK_WaveWorks_Common.h> +#include <GFSDK_WaveWorks_Types.h> + + +/*=========================================================================== + Orbis-specific malloc hooks (replaces the definition in the generic header) + ===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GFSDK_WAVEWORKS_MALLOC_HOOKS_DEFINED +#define GFSDK_WAVEWORKS_MALLOC_HOOKS_DEFINED + +typedef void* (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_MALLOC) (size_t size); +typedef void (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_FREE) (void *p); +typedef void* (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_ALIGNED_MALLOC) (size_t size, size_t alignment); +typedef void (GFSDK_WAVEWORKS_CALL_CONV *GFSDK_WAVEWORKS_ALIGNED_FREE) (void *p); + +struct GFSDK_WaveWorks_Malloc_Hooks +{ + GFSDK_WAVEWORKS_ALIGNED_MALLOC pOnionAlloc; + GFSDK_WAVEWORKS_ALIGNED_FREE pOnionFree; + GFSDK_WAVEWORKS_ALIGNED_MALLOC pGarlicAlloc; + GFSDK_WAVEWORKS_ALIGNED_FREE pGarlicFree; +}; + +#endif + +#ifdef __cplusplus +}; //extern "C" { +#endif + + +/*=========================================================================== + The generic public header + ===========================================================================*/ +#include <GFSDK_WaveWorks.h> + + +/*=========================================================================== + Orbis-specifics + ===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +// Fwd. decls +namespace sce { namespace Gnmx { class LightweightGfxContext; } } +struct GFSDK_WaveWorks_GnmxWrap; +struct GFSDK_WaveWorks_CPU_Scheduler_Interface; + +// Entrypoints +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_InitGnm(const GFSDK_WaveWorks_Malloc_Hooks* pRequiredMallocHooks, const GFSDK_WaveWorks_API_GUID& apiGUID, GFSDK_WaveWorks_GnmxWrap* pRequiredGnmxWrap); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_ReleaseGnm(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_CreateGnm(const GFSDK_WaveWorks_Simulation_Settings& settings, const GFSDK_WaveWorks_Simulation_Params& params, GFSDK_WaveWorks_CPU_Scheduler_Interface* pOptionalScheduler, GFSDK_WaveWorks_SimulationHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Simulation_GetShaderInputCountGnm(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_GetShaderInputDescGnm(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_SetRenderStateGnm(GFSDK_WaveWorks_SimulationHandle hSim, sce::Gnmx::LightweightGfxContext* pGC, const gfsdk_float4x4& matView, const gfsdk_U32 * pShaderInputRegisterMappings); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_KickGnm(GFSDK_WaveWorks_SimulationHandle hSim, gfsdk_U64* pKickID, sce::Gnmx::LightweightGfxContext* pGC); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Simulation_AdvanceStagingCursorGnm(GFSDK_WaveWorks_SimulationHandle hSim, bool block, sce::Gnmx::LightweightGfxContext* pGC); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_CreateGnm(const GFSDK_WaveWorks_Quadtree_Params& params, GFSDK_WaveWorks_QuadtreeHandle* pResult); +GFSDK_WAVEWORKS_DECL(gfsdk_U32 ) GFSDK_WaveWorks_Quadtree_GetShaderInputCountGnm(); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_GetShaderInputDescGnm(gfsdk_U32 inputIndex, GFSDK_WaveWorks_ShaderInput_Desc* pDesc); +GFSDK_WAVEWORKS_DECL(gfsdk_waveworks_result ) GFSDK_WaveWorks_Quadtree_DrawGnm(GFSDK_WaveWorks_QuadtreeHandle hQuadtree, sce::Gnmx::LightweightGfxContext* pGC, const gfsdk_float4x4& matView, const gfsdk_float4x4& matProj, const gfsdk_float2& viewportDims, const gfsdk_U32 * pShaderInputRegisterMappings); + +#ifdef __cplusplus +}; //extern "C" { +#endif + +#endif // _GFSDK_WAVEWORKS_ORBIS_H diff --git a/include/restricted/GFSDK_WaveWorks_Orbis_API_Implementation.h b/include/restricted/GFSDK_WaveWorks_Orbis_API_Implementation.h new file mode 100644 index 0000000..82ca914 --- /dev/null +++ b/include/restricted/GFSDK_WaveWorks_Orbis_API_Implementation.h @@ -0,0 +1,211 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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. +// + +/* + * This header defines a default implementation for GnmxWrap which can be + * trivially #included in the client's compilation space to handle Gnmx calls + */ + +#ifndef _GFSDK_WAVEWORKS_ORBIS_API_IMPLEMENTATION_H +#define _GFSDK_WAVEWORKS_ORBIS_API_IMPLEMENTATION_H + +#include <GFSDK_WaveWorks_Orbis_API_Interface.h> + +#include <gnmx/lwgfxcontext.h> +#include <gnmx/shader_parser.h> + +struct GFSDK_WaveWorks_GnmxWrapImplementation : public GFSDK_WaveWorks_GnmxWrap +{ + virtual void setShaderType(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderType shaderType) + { gfxc.setShaderType(shaderType); } + + virtual void setCsShader(sce::Gnmx::LightweightGfxContext& gfxc, const sce::Gnmx::CsShader *csb, sce::Gnmx::InputResourceOffsets* csros) + { gfxc.setCsShader(csb, csros); } + + virtual void setRwBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *rwBuffers) + { gfxc.setRwBuffers(stage, startSlot, numSlots, rwBuffers); } + + virtual void setBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *buffers) + { gfxc.setBuffers(stage, startSlot, numSlots, buffers); } + + virtual void setConstantBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *buffers) + { gfxc.setConstantBuffers(stage, startSlot, numSlots, buffers); } + + virtual void dispatch(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t threadGroupX, uint32_t threadGroupY, uint32_t threadGroupZ) + { gfxc.dispatch(threadGroupX, threadGroupY, threadGroupZ); } + + virtual void * allocateFromCommandBuffer(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t sizeInBytes, sce::Gnm::EmbeddedDataAlignment alignment) + { return gfxc.allocateFromCommandBuffer(sizeInBytes, alignment); } + + virtual void setVertexBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *buffers) + { gfxc.setVertexBuffers(stage, startSlot, numSlots, buffers); } + + virtual void setPrimitiveType(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::PrimitiveType primType) + { gfxc.setPrimitiveType(primType); } + + virtual void setIndexSize(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::IndexSize indexSize) + { gfxc.setIndexSize(indexSize); } + + virtual void setIndexCount(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t indexCount) + { gfxc.setIndexCount(indexCount); } + + virtual void setIndexOffset(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t offset) + { gfxc.setIndexOffset(offset); } + + virtual void setIndexBuffer(sce::Gnmx::LightweightGfxContext& gfxc, const void * indexAddr) + { gfxc.setIndexBuffer(indexAddr); } + + virtual void drawIndexOffset(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t indexOffset, uint32_t indexCount) + { gfxc.drawIndexOffset(indexOffset, indexCount); } + + virtual void pushMarker(sce::Gnmx::LightweightGfxContext& gfxc, const char * debugString) + { gfxc.pushMarker(debugString); } + + virtual void popMarker(sce::Gnmx::LightweightGfxContext& gfxc) + { gfxc.popMarker(); } + + virtual void setActiveShaderStages(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ActiveShaderStages activeStages) + { gfxc.setActiveShaderStages(activeStages); } + + virtual void setVsShader(sce::Gnmx::LightweightGfxContext& gfxc, const sce::Gnmx::VsShader *vsb, uint32_t shaderModifier, void *fetchShaderAddr, sce::Gnmx::InputResourceOffsets* vsros) + { gfxc.setVsShader(vsb, shaderModifier, fetchShaderAddr, vsros); } + + virtual void setPsShader(sce::Gnmx::LightweightGfxContext& gfxc, const sce::Gnmx::PsShader *psb, sce::Gnmx::InputResourceOffsets* psros) + { gfxc.setPsShader(psb, psros); } + + virtual void setRenderTarget(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t rtSlot, sce::Gnm::RenderTarget const *target) + { gfxc.setRenderTarget(rtSlot, target); } + + virtual void setDepthRenderTarget(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::DepthRenderTarget const * depthTarget) + { gfxc.setDepthRenderTarget(depthTarget); } + + virtual void setupScreenViewport(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t left, uint32_t top, uint32_t right, uint32_t bottom, float zScale, float zOffset) + { gfxc.setupScreenViewport(left, top, right, bottom, zScale, zOffset); } + + virtual void setTextures(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Texture *textures) + { gfxc.setTextures(stage, startSlot, numSlots, textures); } + + virtual void setSamplers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Sampler *samplers) + { gfxc.setSamplers(stage, startSlot, numSlots, samplers); } + + virtual void setDepthStencilControl(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::DepthStencilControl depthControl) + { gfxc.setDepthStencilControl(depthControl); } + + virtual void setBlendControl(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t rtSlot, sce::Gnm::BlendControl blendControl) + { gfxc.setBlendControl(rtSlot, blendControl); } + + virtual void setPrimitiveSetup(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::PrimitiveSetup reg) + { gfxc.setPrimitiveSetup(reg); } + + virtual void setRenderTargetMask(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t mask) + { gfxc.setRenderTargetMask(mask); } + + virtual void waitForGraphicsWrites(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t baseAddr256, uint32_t sizeIn256ByteBlocks, uint32_t targetMask, sce::Gnm::CacheAction cacheAction, uint32_t extendedCacheMask, sce::Gnm::StallCommandBufferParserMode commandBufferStallMode) + { gfxc.waitForGraphicsWrites(baseAddr256, sizeIn256ByteBlocks, targetMask, cacheAction, extendedCacheMask, commandBufferStallMode); } + + virtual void setRwTextures(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Texture *rwTextures) + { gfxc.setRwTextures(stage, startSlot, numSlots, rwTextures); } + + virtual void generateInputResourceOffsetTable(sce::Gnmx::InputResourceOffsets* outTable, sce::Gnm::ShaderStage shaderStage, const void* gnmxShaderStruct) + { sce::Gnmx::generateInputResourceOffsetTable(outTable, shaderStage, gnmxShaderStruct); } + + virtual void patchShaderGpuAddress(sce::Gnmx::PsShader& psShader, void *gpuAddress) + { psShader.patchShaderGpuAddress(gpuAddress); } + + virtual void patchShaderGpuAddress(sce::Gnmx::CsShader& csShader, void *gpuAddress) + { csShader.patchShaderGpuAddress(gpuAddress); } + + virtual void patchShaderGpuAddress(sce::Gnmx::VsShader& vsShader, void *gpuAddress) + { vsShader.patchShaderGpuAddress(gpuAddress); } + + virtual void applyFetchShaderModifier(sce::Gnmx::VsShader& vsShader, uint32_t shaderModifier) + { vsShader.applyFetchShaderModifier(shaderModifier); } + + virtual const sce::Gnm::PsStageRegisters& getPsStageRegisters(sce::Gnmx::PsShader& psShader) + { return psShader.m_psStageRegisters; } + + virtual const sce::Gnm::CsStageRegisters& getCsStageRegisters(sce::Gnmx::CsShader& csShader) + { return csShader.m_csStageRegisters; } + + virtual const sce::Gnm::VsStageRegisters& getVsStageRegisters(sce::Gnmx::VsShader& vsShader) + { return vsShader.m_vsStageRegisters; } + + virtual uint32_t computeVsFetchShaderSize(const sce::Gnmx::VsShader *vsb) + { return sce::Gnmx::computeVsFetchShaderSize(vsb); } + + virtual void generateVsFetchShader(void *fs, uint32_t* shaderModifier, const sce::Gnmx::VsShader *vsb, const sce::Gnm::FetchShaderInstancingMode *instancingData) + { return sce::Gnmx::generateVsFetchShader(fs, shaderModifier, vsb, instancingData); } + + virtual uint32_t computeSize(sce::Gnmx::PsShader& psShader) + { return psShader.computeSize(); } + + virtual uint32_t computeSize(sce::Gnmx::VsShader& vsShader) + { return vsShader.computeSize(); } + + virtual uint32_t computeSize(sce::Gnmx::CsShader& csShader) + { return csShader.computeSize(); } + + virtual void parseShader(sce::Gnmx::ShaderInfo& shaderInfo, const void* data, int /* deprecated: shaderType*/) + { sce::Gnmx::parseShader(&shaderInfo, data); } + + virtual uint32_t getGpuShaderCodeSize(sce::Gnmx::ShaderInfo& shaderInfo) + { return shaderInfo.m_gpuShaderCodeSize; } + + virtual const uint32_t* getGpuShaderCode(sce::Gnmx::ShaderInfo& shaderInfo) + { return shaderInfo.m_gpuShaderCode; } + + virtual sce::Gnmx::PsShader* getPsShader(sce::Gnmx::ShaderInfo& shaderInfo) + { return shaderInfo.m_psShader; } + + virtual sce::Gnmx::CsShader* getCsShader(sce::Gnmx::ShaderInfo& shaderInfo) + { return shaderInfo.m_csShader; } + + virtual sce::Gnmx::VsShader* getVsShader(sce::Gnmx::ShaderInfo& shaderInfo) + { return shaderInfo.m_vsShader; } + + // Synthesised wrappers/accessors + virtual sce::Gnm::DrawCommandBuffer* getDcb(sce::Gnmx::LightweightGfxContext& gfxc) + { return &gfxc.m_dcb; } + + virtual int getVsShaderType() + { return sce::Gnmx::kVertexShader; } + + virtual int getPsShaderType() + { return sce::Gnmx::kPixelShader; } + + virtual int getCsShaderType() + { return sce::Gnmx::kComputeShader; } + + virtual size_t getSizeofShaderInfo() + { return sizeof(sce::Gnmx::ShaderInfo); } + + virtual size_t getSizeofInputResourceOffsets() + { return sizeof(sce::Gnmx::InputResourceOffsets); } +}; + +#endif // _GFSDK_WAVEWORKS_ORBIS_API_IMPLEMENTATION_H diff --git a/include/restricted/GFSDK_WaveWorks_Orbis_API_Interface.h b/include/restricted/GFSDK_WaveWorks_Orbis_API_Interface.h new file mode 100644 index 0000000..500f3e2 --- /dev/null +++ b/include/restricted/GFSDK_WaveWorks_Orbis_API_Interface.h @@ -0,0 +1,137 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and 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. +// + +/* + * This header defines ABC's for indirecting WaveWorks access to Gnmx + * The raison d'etre of this header is to avoid generating linkage into Gnmx inside + * WaveWorks. By generating linkage outside of the lib (i.e. in the client app), it + * is possible for clients to use customised versions of Gnmx + */ + +#ifndef _GFSDK_WAVEWORKS_ORBIS_API_INTERFACE_H +#define _GFSDK_WAVEWORKS_ORBIS_API_INTERFACE_H + +#include <GFSDK_WaveWorks_Common.h> +#include <GFSDK_WaveWorks_Types.h> + +#include <gnm/constants.h> + +namespace sce { + namespace Gnmx { + class LightweightGfxContext; + class ShaderInfo; + class CsShader; + class PsShader; + class VsShader; + struct InputResourceOffsets; + } + namespace Gnm { + class Buffer; + class DrawCommandBuffer; + class RenderTarget; + class DepthRenderTarget; + class Texture; + class Sampler; + class DepthStencilControl; + class BlendControl; + class PrimitiveSetup; + class PsStageRegisters; + class CsStageRegisters; + class VsStageRegisters; + } +} + + struct GFSDK_WaveWorks_GnmxWrap + { + // LightweightGfxContext wrappers + virtual void setShaderType(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderType shaderType) = 0; + virtual void setCsShader(sce::Gnmx::LightweightGfxContext& gfxc, const sce::Gnmx::CsShader *csb, sce::Gnmx::InputResourceOffsets* csros) = 0; + virtual void setRwBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *rwBuffers) = 0; + virtual void setBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *buffers) = 0; + virtual void setConstantBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *buffers) = 0; + virtual void dispatch(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t threadGroupX, uint32_t threadGroupY, uint32_t threadGroupZ) = 0; + virtual void * allocateFromCommandBuffer(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t sizeInBytes, sce::Gnm::EmbeddedDataAlignment alignment) = 0; + virtual void setVertexBuffers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Buffer *buffers) = 0; + virtual void setPrimitiveType(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::PrimitiveType primType) = 0; + virtual void setIndexSize(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::IndexSize indexSize) = 0; + virtual void setIndexCount(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t indexCount) = 0; + virtual void setIndexOffset(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t offset) = 0; + virtual void setIndexBuffer(sce::Gnmx::LightweightGfxContext& gfxc, const void * indexAddr) = 0; + virtual void drawIndexOffset(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t indexOffset, uint32_t indexCount) = 0; + virtual void pushMarker(sce::Gnmx::LightweightGfxContext& gfxc, const char * debugString) = 0; + virtual void popMarker(sce::Gnmx::LightweightGfxContext& gfxc) = 0; + virtual void setActiveShaderStages(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ActiveShaderStages activeStages) = 0; + virtual void setVsShader(sce::Gnmx::LightweightGfxContext& gfxc, const sce::Gnmx::VsShader *vsb, uint32_t shaderModifier, void *fetchShaderAddr, sce::Gnmx::InputResourceOffsets* vsros) = 0; + virtual void setPsShader(sce::Gnmx::LightweightGfxContext& gfxc, const sce::Gnmx::PsShader *psb, sce::Gnmx::InputResourceOffsets* psros) = 0; + virtual void setRenderTarget(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t rtSlot, sce::Gnm::RenderTarget const *target) = 0; + virtual void setDepthRenderTarget(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::DepthRenderTarget const * depthTarget) = 0; + virtual void setupScreenViewport(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t left, uint32_t top, uint32_t right, uint32_t bottom, float zScale, float zOffset) = 0; + virtual void setTextures(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Texture *textures) = 0; + virtual void setSamplers(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Sampler *samplers) = 0; + virtual void setDepthStencilControl(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::DepthStencilControl depthControl) = 0; + virtual void setBlendControl(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t rtSlot, sce::Gnm::BlendControl blendControl) = 0; + virtual void setPrimitiveSetup(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::PrimitiveSetup reg) = 0; + virtual void setRenderTargetMask(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t mask) = 0; + virtual void waitForGraphicsWrites(sce::Gnmx::LightweightGfxContext& gfxc, uint32_t baseAddr256, uint32_t sizeIn256ByteBlocks, uint32_t targetMask, sce::Gnm::CacheAction cacheAction, uint32_t extendedCacheMask, sce::Gnm::StallCommandBufferParserMode commandBufferStallMode) = 0; + virtual void setRwTextures(sce::Gnmx::LightweightGfxContext& gfxc, sce::Gnm::ShaderStage stage, uint32_t startSlot, uint32_t numSlots, const sce::Gnm::Texture *rwTextures) = 0; + + // Shader wrappers + virtual void patchShaderGpuAddress(sce::Gnmx::PsShader& psShader, void *gpuAddress) = 0; + virtual void patchShaderGpuAddress(sce::Gnmx::CsShader& csShader, void *gpuAddress) = 0; + virtual void patchShaderGpuAddress(sce::Gnmx::VsShader& vsShader, void *gpuAddress) = 0; + virtual void applyFetchShaderModifier(sce::Gnmx::VsShader& vsShader, uint32_t shaderModifier) = 0; + virtual const sce::Gnm::PsStageRegisters& getPsStageRegisters(sce::Gnmx::PsShader& psShader) = 0; + virtual const sce::Gnm::CsStageRegisters& getCsStageRegisters(sce::Gnmx::CsShader& csShader) = 0; + virtual const sce::Gnm::VsStageRegisters& getVsStageRegisters(sce::Gnmx::VsShader& vsShader) = 0; + virtual uint32_t computeVsFetchShaderSize(const sce::Gnmx::VsShader *vsb) = 0; + virtual void generateVsFetchShader(void *fs, uint32_t* shaderModifier, const sce::Gnmx::VsShader *vsb, const sce::Gnm::FetchShaderInstancingMode *instancingData) = 0; + virtual uint32_t computeSize(sce::Gnmx::PsShader& psShader) = 0; + virtual uint32_t computeSize(sce::Gnmx::VsShader& vsShader) = 0; + virtual uint32_t computeSize(sce::Gnmx::CsShader& csShader) = 0; + + // ShaderInfo wrappers + virtual void parseShader(sce::Gnmx::ShaderInfo& shaderInfo, const void* data, int shaderType) = 0; + virtual uint32_t getGpuShaderCodeSize(sce::Gnmx::ShaderInfo& shaderInfo) = 0; + virtual const uint32_t* getGpuShaderCode(sce::Gnmx::ShaderInfo& shaderInfo) = 0; + virtual sce::Gnmx::PsShader* getPsShader(sce::Gnmx::ShaderInfo& shaderInfo) = 0; + virtual sce::Gnmx::CsShader* getCsShader(sce::Gnmx::ShaderInfo& shaderInfo) = 0; + virtual sce::Gnmx::VsShader* getVsShader(sce::Gnmx::ShaderInfo& shaderInfo) = 0; + + // InputResourceOffsets wrappers + virtual void generateInputResourceOffsetTable(sce::Gnmx::InputResourceOffsets* outTable, sce::Gnm::ShaderStage shaderStage, const void* gnmxShaderStruct) = 0; + + // Synthesised wrappers/accessors + virtual sce::Gnm::DrawCommandBuffer* getDcb(sce::Gnmx::LightweightGfxContext& gfxc) = 0; + virtual int getVsShaderType() = 0; + virtual int getPsShaderType() = 0; + virtual int getCsShaderType() = 0; + virtual size_t getSizeofShaderInfo() = 0; + virtual size_t getSizeofInputResourceOffsets() = 0; + }; + +#endif // _GFSDK_WAVEWORKS_ORBIS_API_INTERFACE_H |