diff options
| author | lbavoil <[email protected]> | 2018-03-15 11:08:34 +0100 |
|---|---|---|
| committer | lbavoil <[email protected]> | 2018-03-15 11:08:34 +0100 |
| commit | 636807e68a85a978473764d171ed0c7cc36f9be6 (patch) | |
| tree | 784a3d4fa8f48b4c085dd959678505b2af12f425 /include | |
| parent | Remove test folder (diff) | |
| download | hbaoplus-636807e68a85a978473764d171ed0c7cc36f9be6.tar.xz hbaoplus-636807e68a85a978473764d171ed0c7cc36f9be6.zip | |
HBAO+ 4.0.0.23740451
Diffstat (limited to 'include')
| -rw-r--r-- | include/GFSDK_SSAO.h | 445 |
1 files changed, 43 insertions, 402 deletions
diff --git a/include/GFSDK_SSAO.h b/include/GFSDK_SSAO.h index d0743fc..63a86f1 100644 --- a/include/GFSDK_SSAO.h +++ b/include/GFSDK_SSAO.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2008-2018, NVIDIA CORPORATION. All rights reserved. * * NVIDIA CORPORATION and its licensors retain all intellectual property * and proprietary rights in and to this software, related documentation @@ -26,9 +26,15 @@ similar to "Scalable Ambient Obscurance" [McGuire et al. 2012] [Bukowski et al. (3.) To minimize flickering, the HBAO+ is always rendered in full resolution, from full-resolution depths. +(4.) To reduce halo artifacts behind foreground objects, HBAO+ can take as input a second depth layer, +using the multi-layer SSAO approach from [Bavoil and Sainz 2009] and [McGuire et al. 2013]. + [Bavoil et al. 2008] "Image-Space Horizon-Based Ambient Occlusion" http://www.nvidia.com/object/siggraph-2008-HBAO.html +[Bavoil and Sainz 2009] "Multi-Layer Dual-Resolution Screen-Space Ambient Occlusion" +https://dl.acm.org/citation.cfm?id=1598035 + [McGuire et al. 2012] "Scalable Ambient Obscurance" http://graphics.cs.williams.edu/papers/SAOHPG12/ @@ -38,6 +44,9 @@ http://graphics.cs.williams.edu/papers/VVSIGGRAPH12/ [Bavoil and Jansen 2013] "Particle Shadows & Cache-Efficient Post-Processing" https://developer.nvidia.com/gdc-2013 +[McGuire et al. 2013] "Lighting Deep G-Buffers: Single-Pass, Layered Depth Images with Minimum Separation Applied to Indirect Illumination" +http://research.nvidia.com/publication/lighting-deep-g-buffers-single-pass-layered-depth-images-minimum-separation-applied + ------------------------------------------------------------------------------------------- MSAA ------------------------------------------------------------------------------------------- @@ -54,8 +63,10 @@ https://developer.nvidia.com/gdc-2013 PERFORMANCE ------------------------------------------------------------------------------------------- -In 1920x1080 1xAA, using HARDWARE_DEPTHS as input and BLUR_RADIUS_4, the RenderAO call takes -up to 46 MB of video memory and 2.3 ms / frame on GeForce GTX 680. +In 3840x2160 (4K-UHD) on GeForce GTX 1080, using 1xAA HARDWARE_DEPTHS as input, STEP_COUNT_4, +BLUR_RADIUS_4, and FP16_VIEW_DEPTHS, the RenderAO call takes: +- 2.4 ms / frame & up to 150 MB of video memory with 1 input depth texture +- 3.6 ms / frame & up to 197 MB of video memory with 2 input depth textures. ------------------------------------------------------------------------------------------- INTEGRATION EXAMPLE @@ -140,7 +151,7 @@ up to 46 MB of video memory and 2.3 ms / frame on GeForce GTX 680. #else -#if !_WINDLL +#if !defined(_WINDLL) || !_WINDLL #define GFSDK_SSAO_DECL(RETURN_TYPE, FUNCTION_NAME, ...) extern "C" RETURN_TYPE GFSDK_SSAO_CDECL FUNCTION_NAME(__VA_ARGS__) #else #define GFSDK_SSAO_DECL(RETURN_TYPE, FUNCTION_NAME, ...) extern "C" GFSDK_SSAO_EXPORT RETURN_TYPE GFSDK_SSAO_CDECL FUNCTION_NAME(__VA_ARGS__) @@ -155,18 +166,6 @@ up to 46 MB of video memory and 2.3 ms / frame on GeForce GTX 680. Forward declarations. ====================================================================================================*/ -typedef char GLchar; -typedef int GLint; -typedef int GLsizei; -typedef void GLvoid; -typedef float GLfloat; -typedef float GLclampf; -typedef unsigned int GLenum; -typedef unsigned int GLuint; -typedef unsigned char GLboolean; -typedef unsigned char GLubyte; -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; typedef unsigned int GFSDK_SSAO_BOOL; typedef unsigned int GFSDK_SSAO_UINT; typedef float GFSDK_SSAO_FLOAT; @@ -195,10 +194,10 @@ struct D3D12_BLEND_DESC; struct GFSDK_SSAO_Version { GFSDK_SSAO_Version() - : Major(3) - , Minor(1) + : Major(4) + , Minor(0) , Branch(0) - , Revision(21602716) + , Revision(23740451) { } @@ -223,26 +222,18 @@ enum GFSDK_SSAO_Status GFSDK_SSAO_INVALID_NORMAL_TEXTURE_SAMPLE_COUNT, // The normal-texture sample count does not match the depth-texture sample count GFSDK_SSAO_INVALID_VIEWPORT_DIMENSIONS, // One of the viewport dimensions (width or height) is 0 GFSDK_SSAO_INVALID_VIEWPORT_DEPTH_RANGE, // The viewport depth range is not a sub-range of [0.f,1.f] + GFSDK_SSAO_INVALID_SECOND_DEPTH_TEXTURE_RESOLUTION, // The resolution of the second depth texture does not match the one of the first depth texture + GFSDK_SSAO_INVALID_SECOND_DEPTH_TEXTURE_SAMPLE_COUNT, // The sample count of the second depth texture does not match the one of the first depth texture GFSDK_SSAO_MEMORY_ALLOCATION_FAILED, // Failed to allocate memory on the heap GFSDK_SSAO_INVALID_DEPTH_STENCIL_RESOLUTION, // The depth-stencil resolution does not match the output render-target resolution GFSDK_SSAO_INVALID_DEPTH_STENCIL_SAMPLE_COUNT, // The depth-stencil sample count does not match the output render-target sample count - // - // D3D-specific enums - // GFSDK_SSAO_D3D_FEATURE_LEVEL_NOT_SUPPORTED, // The current D3D11 feature level is lower than 11_0 GFSDK_SSAO_D3D_RESOURCE_CREATION_FAILED, // A resource-creation call has failed (running out of memory?) GFSDK_SSAO_D3D12_UNSUPPORTED_DEPTH_CLAMP_MODE, // CLAMP_TO_BORDER is used (implemented on D3D11 & GL, but not on D3D12) GFSDK_SSAO_D3D12_INVALID_HEAP_TYPE, // One of the heaps provided to GFSDK_SSAO_CreateContext_D3D12 has an unexpected type GFSDK_SSAO_D3D12_INSUFFICIENT_DESCRIPTORS, // One of the heaps provided to GFSDK_SSAO_CreateContext_D3D12 has insufficient descriptors GFSDK_SSAO_D3D12_INVALID_NODE_MASK, // NodeMask has more than one bit set. HBAO+ only supports operation on one D3D12 device node. - // - // GL-specific enums - // - GFSDK_SSAO_GL_INVALID_TEXTURE_TARGET, // One of the input textures is not GL_TEXTURE_2D or GL_TEXTURE_2D_MULTISAMPLE - GFSDK_SSAO_GL_INVALID_TEXTURE_OBJECT, // One of the input texture objects has index 0 - GFSDK_SSAO_GL_RESOURCE_CREATION_FAILED, // A GL resource-creation call has failed (running out of memory?) - GFSDK_SSAO_GL_NULL_FUNCTION_POINTER, // One of the provided GL function pointers is NULL - GFSDK_SSAO_GL_UNSUPPORTED_VIEWPORT, // A custom input viewport is enabled (not supported on GL) + GFSDK_SSAO_NO_SECOND_LAYER_PROVIDED // FullResDepthTexture2ndLayerSRV is not set, but DualLayerAO is enabled. }; enum GFSDK_SSAO_DepthTextureType @@ -277,6 +268,12 @@ enum GFSDK_SSAO_DepthStorage GFSDK_SSAO_FP32_VIEW_DEPTHS, // Store the internal view depths in FP32 (slower) }; +enum GFSDK_SSAO_StepCount +{ + GFSDK_SSAO_STEP_COUNT_4, // Use 4 steps per sampled direction (same as in HBAO+ 3.x) + GFSDK_SSAO_STEP_COUNT_8, // Use 8 steps per sampled direction (slower, to reduce banding artifacts) +}; + enum GFSDK_SSAO_DepthClampMode { GFSDK_SSAO_CLAMP_TO_EDGE, // Use clamp-to-edge when sampling depth (may cause false occlusion near screen borders) @@ -330,23 +327,6 @@ struct GFSDK_SSAO_RenderTargetView_D3D12 GFSDK_SSAO_SIZE_T CpuHandle; }; -struct GFSDK_SSAO_Texture_GL -{ - GLenum Target; // Must be GL_TEXTURE_2D or GL_TEXTURE_2D_MULTISAMPLE - GLuint TextureId; // OpenGL texture object index - - GFSDK_SSAO_Texture_GL() - : Target(0) - , TextureId(0) - { - } - GFSDK_SSAO_Texture_GL(GLenum InTarget, GLuint InTextureId) - : Target(InTarget) - , TextureId(InTextureId) - { - } -}; - /*==================================================================================================== Input data. ====================================================================================================*/ @@ -427,7 +407,7 @@ struct GFSDK_SSAO_InputViewport // { P20, P21, P22, P23 } // { 0.f, 0.f, P32, 0.f } // -// Remarks: +// Remark: // * MetersToViewSpaceUnits is used to convert the AO radius parameter from meters to view-space units, // as well as to convert the blur sharpness parameter from inverse meters to inverse view-space units. //--------------------------------------------------------------------------------------------------- @@ -448,22 +428,20 @@ struct GFSDK_SSAO_InputDepthData struct GFSDK_SSAO_InputDepthData_D3D12 : GFSDK_SSAO_InputDepthData { - GFSDK_SSAO_ShaderResourceView_D3D12 FullResDepthTextureSRV; // Full-resolution depth texture + GFSDK_SSAO_ShaderResourceView_D3D12 FullResDepthTextureSRV; // Full-resolution depth texture + GFSDK_SSAO_ShaderResourceView_D3D12 FullResDepthTexture2ndLayerSRV; // Full-resolution depth texture for the second layer }; struct GFSDK_SSAO_InputDepthData_D3D11 : GFSDK_SSAO_InputDepthData { - ID3D11ShaderResourceView* pFullResDepthTextureSRV; // Full-resolution depth texture + ID3D11ShaderResourceView* pFullResDepthTextureSRV; // Full-resolution depth texture + ID3D11ShaderResourceView* pFullResDepthTexture2ndLayerSRV; // Full-resolution depth texture for the second layer GFSDK_SSAO_InputDepthData_D3D11() - : pFullResDepthTextureSRV(NULL) - { - } -}; - -struct GFSDK_SSAO_InputDepthData_GL : GFSDK_SSAO_InputDepthData -{ - GFSDK_SSAO_Texture_GL FullResDepthTexture; // Full-resolution depth texture + { + pFullResDepthTextureSRV = NULL; + pFullResDepthTexture2ndLayerSRV = NULL; + } }; //--------------------------------------------------------------------------------------------------- @@ -517,11 +495,6 @@ struct GFSDK_SSAO_InputNormalData_D3D11 : GFSDK_SSAO_InputNormalData } }; -struct GFSDK_SSAO_InputNormalData_GL : GFSDK_SSAO_InputNormalData -{ - GFSDK_SSAO_Texture_GL FullResNormalTexture; // Full-resolution world-space normal texture -}; - //--------------------------------------------------------------------------------------------------- // Input data. //--------------------------------------------------------------------------------------------------- @@ -538,12 +511,6 @@ struct GFSDK_SSAO_InputData_D3D11 GFSDK_SSAO_InputNormalData_D3D11 NormalData; // Optional GBuffer normals }; -struct GFSDK_SSAO_InputData_GL -{ - GFSDK_SSAO_InputDepthData_GL DepthData; // Required - GFSDK_SSAO_InputNormalData_GL NormalData; // Optional GBuffer normals -}; - /*==================================================================================================== Parameters. ====================================================================================================*/ @@ -646,10 +613,12 @@ struct GFSDK_SSAO_Parameters GFSDK_SSAO_FLOAT PowerExponent; // The final AO output is pow(AO, powerExponent) // 1.0~4.0 GFSDK_SSAO_ForegroundAO ForegroundAO; // To limit the occlusion scale in the foreground GFSDK_SSAO_BackgroundAO BackgroundAO; // To add larger-scale occlusion in the distance - GFSDK_SSAO_DepthStorage DepthStorage; // Quality / performance tradeoff + GFSDK_SSAO_StepCount StepCount; // The number of steps per direction in the AO-generation pass + GFSDK_SSAO_DepthStorage DepthStorage; // The format of the internal depth texture sampled in the AO-generation pass GFSDK_SSAO_DepthClampMode DepthClampMode; // To hide possible false-occlusion artifacts near screen borders GFSDK_SSAO_DepthThreshold DepthThreshold; // Optional Z threshold, to hide possible depth-precision artifacts GFSDK_SSAO_BlurParameters Blur; // Optional AO blur, to blur the AO before compositing it + GFSDK_SSAO_BOOL EnableDualLayerAO; // To reduce halo artifacts behind foreground object GFSDK_SSAO_Parameters() : Radius(1.f) @@ -657,8 +626,10 @@ struct GFSDK_SSAO_Parameters , SmallScaleAO(1.f) , LargeScaleAO(1.f) , PowerExponent(2.f) + , StepCount(GFSDK_SSAO_STEP_COUNT_4) , DepthStorage(GFSDK_SSAO_FP16_VIEW_DEPTHS) , DepthClampMode(GFSDK_SSAO_CLAMP_TO_EDGE) + , EnableDualLayerAO(false) { } }; @@ -695,44 +666,6 @@ struct GFSDK_SSAO_CustomBlendState_D3D11 } }; -struct GFSDK_SSAO_CustomBlendState_GL -{ - struct - { - GLenum ModeRGB; - GLenum ModeAlpha; - } BlendEquationSeparate; - - struct - { - GLenum SrcRGB; - GLenum DstRGB; - GLenum SrcAlpha; - GLenum DstAlpha; - } BlendFuncSeparate; - - struct - { - GLclampf R; - GLclampf G; - GLclampf B; - GLclampf A; - } BlendColor; - - struct - { - GLboolean R; - GLboolean G; - GLboolean B; - GLboolean A; - } ColorMask; - - GFSDK_SSAO_CustomBlendState_GL() - { - memset(this, 0, sizeof(*this)); - } -}; - //--------------------------------------------------------------------------------------------------- // Compositing blend state. //--------------------------------------------------------------------------------------------------- @@ -759,17 +692,6 @@ struct GFSDK_SSAO_BlendState_D3D11 } }; -struct GFSDK_SSAO_BlendState_GL -{ - GFSDK_SSAO_BlendMode Mode; // OVERWRITE_RGB, MULTIPLY_RGB or CUSTOM_BLEND - GFSDK_SSAO_CustomBlendState_GL CustomState; // Relevant only if Mode is CUSTOM_BLEND - - GFSDK_SSAO_BlendState_GL() - : Mode(GFSDK_SSAO_OVERWRITE_RGB) - { - } -}; - //--------------------------------------------------------------------------------------------------- // [Optional] Custom depth-stencil state. //--------------------------------------------------------------------------------------------------- @@ -798,36 +720,6 @@ struct GFSDK_SSAO_DepthStencilState_D3D11 }; //--------------------------------------------------------------------------------------------------- -// [Optional] Two-pass AO compositing. -//--------------------------------------------------------------------------------------------------- - -struct GFSDK_SSAO_BlendPass_D3D11 -{ - GFSDK_SSAO_BlendState_D3D11 Blend; - GFSDK_SSAO_DepthStencilState_D3D11 DepthStencil; -}; - -//--------------------------------------------------------------------------------------------------- -// Remarks: -// * This can be useful to use different blend states depending on the stencil value. -// * For instance: 1) for character pixels (with Stencil==A), write AO with blending disabled, -// 2) for other pixels (with Stencil!=A), write AO with MIN blending. -//--------------------------------------------------------------------------------------------------- -struct GFSDK_SSAO_TwoPassBlend_D3D11 -{ - GFSDK_SSAO_BOOL Enable; // When enabled, overrides any other compositing state - ID3D11DepthStencilView* pDepthStencilView; // Used to mask the pixels in each of the 2 passses - GFSDK_SSAO_BlendPass_D3D11 FirstPass; // Blend & depth-stencil state for the first compositing pass - GFSDK_SSAO_BlendPass_D3D11 SecondPass; // Blend & depth-stencil state for the second compositing pass - - GFSDK_SSAO_TwoPassBlend_D3D11() - : Enable(false) - , pDepthStencilView(NULL) - { - } -}; - -//--------------------------------------------------------------------------------------------------- // Output render target & compositing state. //--------------------------------------------------------------------------------------------------- @@ -846,7 +738,6 @@ struct GFSDK_SSAO_Output_D3D11 { ID3D11RenderTargetView* pRenderTargetView; // Output render target of RenderAO GFSDK_SSAO_BlendState_D3D11 Blend; // Blend state used when writing the AO to pRenderTargetView - GFSDK_SSAO_TwoPassBlend_D3D11 TwoPassBlend; // Optional two-pass compositing using depth-stencil masking GFSDK_SSAO_Output_D3D11() : pRenderTargetView(NULL) @@ -854,17 +745,6 @@ struct GFSDK_SSAO_Output_D3D11 } }; -struct GFSDK_SSAO_Output_GL -{ - GLuint OutputFBO; // Output Frame Buffer Object of RenderAO - GFSDK_SSAO_BlendState_GL Blend; // Blend state used when writing the AO to OutputFBO - - GFSDK_SSAO_Output_GL() - : OutputFBO(0) - { - } -}; - /*==================================================================================================== [Optional] Let the library allocate its memory on a custom heap. ====================================================================================================*/ @@ -1015,245 +895,6 @@ GFSDK_SSAO_DECL(GFSDK_SSAO_Status, GFSDK_SSAO_CreateContext_D3D11, GFSDK_SSAO_VERSION_ARGUMENT); /*==================================================================================================== - GL interface. -====================================================================================================*/ - -//--------------------------------------------------------------------------------------------------- -// Note: The RenderAO, PreCreateFBOs and Release entry points should not be called simultaneously from different threads. -//--------------------------------------------------------------------------------------------------- -class GFSDK_SSAO_Context_GL : public GFSDK_SSAO_Context -{ -public: - - //--------------------------------------------------------------------------------------------------- - // Renders SSAO. - // - // Remarks: - // * Allocates internal GL framebuffer objects on first use, and re-allocates them when the depth-texture resolution changes. - // * All the relevant GL states are saved and restored internally when entering and exiting the call. - // * Setting RenderMask = GFSDK_SSAO_RENDER_DEBUG_NORMAL_Z can be useful to visualize the normals used for the AO rendering. - // * The current GL PolygonMode is assumed to be GL_FILL. - // * The OutputFBO cannot contain a texture bound in InputData. - // - // Returns: - // GFSDK_SSAO_NULL_ARGUMENT - One of the required argument pointers is NULL - // GFSDK_SSAO_INVALID_PROJECTION_MATRIX - The projection matrix is not valid - // GFSDK_SSAO_INVALID_VIEWPORT_DEPTH_RANGE - The viewport depth range is not a sub-range of [0.f,1.f] - // GFSDK_SSAO_GL_INVALID_TEXTURE_TARGET - One of the input textures is not GL_TEXTURE_2D or GL_TEXTURE_2D_MULTISAMPLE - // GFSDK_SSAO_GL_INVALID_TEXTURE_OBJECT - One of the input texture objects has index 0 - // GFSDK_SSAO_GL_RESOURCE_CREATION_FAILED - A GL resource-creation call has failed (running out of memory?) - // GFSDK_SSAO_GL_UNSUPPORTED_VIEWPORT - A custom input viewport is enabled (not supported on GL) - // GFSDK_SSAO_OK - Success - //--------------------------------------------------------------------------------------------------- - virtual GFSDK_SSAO_Status RenderAO( - const GFSDK_SSAO_InputData_GL& InputData, - const GFSDK_SSAO_Parameters& Parameters, - const GFSDK_SSAO_Output_GL& Output, - GFSDK_SSAO_RenderMask RenderMask = GFSDK_SSAO_RENDER_AO) = 0; - - //--------------------------------------------------------------------------------------------------- - // [Optional] Pre-creates all internal FBOs for RenderAO. - // - // Remarks: - // * This call may be safely skipped since RenderAO creates its framebuffer objects on demand if they were not pre-created. - // * This call releases and re-creates the internal framebuffer objects if the provided resolution changes. - // - // Returns: - // GFSDK_SSAO_NULL_ARGUMENT - One of the required argument pointers is NULL - // GFSDK_SSAO_GL_RESOURCE_CREATION_FAILED - A GL resource-creation call has failed (running out of memory?) - // GFSDK_SSAO_OK - Success - //--------------------------------------------------------------------------------------------------- - virtual GFSDK_SSAO_Status PreCreateFBOs( - const GFSDK_SSAO_Parameters& Parameters, - GFSDK_SSAO_UINT ViewportWidth, - GFSDK_SSAO_UINT ViewportHeight) = 0; - - //--------------------------------------------------------------------------------------------------- - // [Optional] Gets the library-internal ZNear and ZFar values derived from the input projection matrix. - // - // Remarks: - // * HBAO+ supports all perspective projection matrices, with arbitrary ZNear and ZFar. - // * For reverse infinite projections, GetProjectionMatrixDepthRange should return ZNear=+INF and ZFar=0.f. - // - // Returns: - // GFSDK_SSAO_NULL_ARGUMENT - One of the required argument pointers is NULL - // GFSDK_SSAO_INVALID_PROJECTION_MATRIX - The projection matrix is not valid - // GFSDK_SSAO_OK - Success - //--------------------------------------------------------------------------------------------------- - virtual GFSDK_SSAO_Status GetProjectionMatrixDepthRange( - const GFSDK_SSAO_InputData_GL& InputData, - GFSDK_SSAO_ProjectionMatrixDepthRange& OutputDepthRange) = 0; - - //--------------------------------------------------------------------------------------------------- - // Releases all GL resources created by the library. - //--------------------------------------------------------------------------------------------------- - virtual void Release() = 0; - -}; // class GFSDK_SSAO_Context_GL - -//--------------------------------------------------------------------------------------------------- -// GL functions used by the GL context, in alphabetic order. -// Requires GL 3.2 (Core Profile) or above. -//--------------------------------------------------------------------------------------------------- -struct GFSDK_SSAO_GLFunctions -{ - void (GFSDK_SSAO_STDCALL* glActiveTexture) (GLenum texture); - void (GFSDK_SSAO_STDCALL* glAttachShader) (GLuint program, GLuint shader); - void (GFSDK_SSAO_STDCALL* glBindBuffer) (GLenum target, GLuint buffer); - void (GFSDK_SSAO_STDCALL* glBindBufferBase) (GLenum target, GLuint index, GLuint buffer); - void (GFSDK_SSAO_STDCALL* glBindFramebuffer) (GLenum target, GLuint framebuffer); - void (GFSDK_SSAO_STDCALL* glBindFragDataLocation) (GLuint, GLuint, const GLchar*); - void (GFSDK_SSAO_STDCALL* glBindTexture) (GLenum target, GLuint texture); - void (GFSDK_SSAO_STDCALL* glBindVertexArray) (GLuint array); - void (GFSDK_SSAO_STDCALL* glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void (GFSDK_SSAO_STDCALL* glBlendEquationSeparate) (GLenum modeRGB, GLenum modeAlpha); - void (GFSDK_SSAO_STDCALL* glBlendFuncSeparate) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); - void (GFSDK_SSAO_STDCALL* glBufferData) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); - void (GFSDK_SSAO_STDCALL* glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); - void (GFSDK_SSAO_STDCALL* glColorMaski) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); - void (GFSDK_SSAO_STDCALL* glCompileShader) (GLuint shader); - GLuint (GFSDK_SSAO_STDCALL* glCreateShader) (GLenum type); - GLuint (GFSDK_SSAO_STDCALL* glCreateProgram) (void); - void (GFSDK_SSAO_STDCALL* glDeleteBuffers) (GLsizei n, const GLuint* buffers); - void (GFSDK_SSAO_STDCALL* glDeleteFramebuffers) (GLsizei n, const GLuint* framebuffers); - void (GFSDK_SSAO_STDCALL* glDeleteProgram) (GLuint program); - void (GFSDK_SSAO_STDCALL* glDeleteShader) (GLuint shader); - void (GFSDK_SSAO_STDCALL* glDeleteTextures) (GLsizei n, const GLuint *textures); - void (GFSDK_SSAO_STDCALL* glDeleteVertexArrays) (GLsizei n, const GLuint* arrays); - void (GFSDK_SSAO_STDCALL* glDisable) (GLenum cap); - void (GFSDK_SSAO_STDCALL* glDrawBuffers) (GLsizei n, const GLenum* bufs); - void (GFSDK_SSAO_STDCALL* glEnable) (GLenum cap); - void (GFSDK_SSAO_STDCALL* glDrawArrays) (GLenum mode, GLint first, GLsizei count); - void (GFSDK_SSAO_STDCALL* glFramebufferTexture) (GLenum, GLenum, GLuint, GLint); - void (GFSDK_SSAO_STDCALL* glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void (GFSDK_SSAO_STDCALL* glFramebufferTextureLayer) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); - void (GFSDK_SSAO_STDCALL* glGenBuffers) (GLsizei n, GLuint* buffers); - void (GFSDK_SSAO_STDCALL* glGenFramebuffers) (GLsizei n, GLuint* framebuffers); - void (GFSDK_SSAO_STDCALL* glGenTextures) (GLsizei n, GLuint *textures); - void (GFSDK_SSAO_STDCALL* glGenVertexArrays) (GLsizei n, GLuint* arrays); - GLenum (GFSDK_SSAO_STDCALL* glGetError) (void); - void (GFSDK_SSAO_STDCALL* glGetBooleani_v) (GLenum, GLuint, GLboolean*); - void (GFSDK_SSAO_STDCALL* glGetFloatv) (GLenum pname, GLfloat *params); - void (GFSDK_SSAO_STDCALL* glGetIntegerv) (GLenum pname, GLint *params); - void (GFSDK_SSAO_STDCALL* glGetIntegeri_v) (GLenum target, GLuint index, GLint* data); - void (GFSDK_SSAO_STDCALL* glGetProgramiv) (GLuint program, GLenum pname, GLint* param); - void (GFSDK_SSAO_STDCALL* glGetProgramInfoLog) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); - void (GFSDK_SSAO_STDCALL* glGetShaderiv) (GLuint shader, GLenum pname, GLint* param); - void (GFSDK_SSAO_STDCALL* glGetShaderInfoLog) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); - const GLubyte* (GFSDK_SSAO_STDCALL* glGetString) (GLenum name); - GLuint (GFSDK_SSAO_STDCALL* glGetUniformBlockIndex) (GLuint program, const GLchar* uniformBlockName); - GLint (GFSDK_SSAO_STDCALL* glGetUniformLocation) (GLuint program, const GLchar* name); - void (GFSDK_SSAO_STDCALL* glGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint *params); - GLboolean (GFSDK_SSAO_STDCALL* glIsEnabled) (GLenum cap); - GLboolean (GFSDK_SSAO_STDCALL* glIsEnabledi) (GLenum, GLuint); - void (GFSDK_SSAO_STDCALL* glLinkProgram) (GLuint program); - void (GFSDK_SSAO_STDCALL* glPolygonOffset) (GLfloat factor, GLfloat units); - void (GFSDK_SSAO_STDCALL* glShaderSource) (GLuint shader, GLsizei count, const GLchar* const* strings, const GLint* lengths); - void (GFSDK_SSAO_STDCALL* glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - void (GFSDK_SSAO_STDCALL* glTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - void (GFSDK_SSAO_STDCALL* glTexParameteri) (GLenum target, GLenum pname, GLint param); - void (GFSDK_SSAO_STDCALL* glTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params); - void (GFSDK_SSAO_STDCALL* glUniform1i) (GLint location, GLint v0); - void (GFSDK_SSAO_STDCALL* glUniformBlockBinding) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); - void (GFSDK_SSAO_STDCALL* glUseProgram) (GLuint program); - void (GFSDK_SSAO_STDCALL* glViewport) (GLint x, GLint y, GLsizei width, GLsizei height); - typedef void (GFSDK_SSAO_STDCALL* glShaderSourceGLESType) (GLuint shader, GLsizei count, const GLchar* const* strings, const GLint* lengths); - - GFSDK_SSAO_GLFunctions() - { - memset(this, 0, sizeof(*this)); - } -}; - -//--------------------------------------------------------------------------------------------------- -// Helper macro to initialize all the GL function pointers. -//--------------------------------------------------------------------------------------------------- -#define GFSDK_SSAO_INIT_GL_FUNCTIONS(GL)\ -{\ - GL.glActiveTexture = glActiveTexture;\ - GL.glAttachShader = glAttachShader;\ - GL.glBindBuffer = glBindBuffer;\ - GL.glBindBufferBase = glBindBufferBase;\ - GL.glBindFramebuffer = glBindFramebuffer;\ - GL.glBindFragDataLocation = glBindFragDataLocation;\ - GL.glBindTexture = glBindTexture;\ - GL.glBindVertexArray = glBindVertexArray;\ - GL.glBlendColor = glBlendColor;\ - GL.glBlendEquationSeparate = glBlendEquationSeparate;\ - GL.glBlendFuncSeparate = glBlendFuncSeparate;\ - GL.glBufferData = glBufferData;\ - GL.glBufferSubData = glBufferSubData;\ - GL.glColorMaski = glColorMaski;\ - GL.glCompileShader = glCompileShader;\ - GL.glCreateShader = glCreateShader;\ - GL.glCreateProgram = glCreateProgram;\ - GL.glDeleteBuffers = glDeleteBuffers;\ - GL.glDeleteFramebuffers = glDeleteFramebuffers;\ - GL.glDeleteProgram = glDeleteProgram;\ - GL.glDeleteShader = glDeleteShader;\ - GL.glDeleteTextures = glDeleteTextures;\ - GL.glDeleteVertexArrays = glDeleteVertexArrays;\ - GL.glDisable = glDisable;\ - GL.glDrawBuffers = glDrawBuffers;\ - GL.glEnable = glEnable;\ - GL.glDrawArrays = glDrawArrays;\ - GL.glFramebufferTexture = glFramebufferTexture;\ - GL.glFramebufferTexture2D = glFramebufferTexture2D;\ - GL.glFramebufferTextureLayer = glFramebufferTextureLayer;\ - GL.glGenBuffers = glGenBuffers;\ - GL.glGenFramebuffers = glGenFramebuffers;\ - GL.glGenTextures = glGenTextures;\ - GL.glGenVertexArrays = glGenVertexArrays;\ - GL.glGetError = glGetError;\ - GL.glGetBooleani_v = glGetBooleani_v;\ - GL.glGetFloatv = glGetFloatv;\ - GL.glGetIntegerv = glGetIntegerv;\ - GL.glGetIntegeri_v = glGetIntegeri_v;\ - GL.glGetProgramiv = glGetProgramiv;\ - GL.glGetProgramInfoLog = glGetProgramInfoLog;\ - GL.glGetShaderiv = glGetShaderiv;\ - GL.glGetShaderInfoLog = glGetShaderInfoLog;\ - GL.glGetString = glGetString;\ - GL.glGetUniformBlockIndex = glGetUniformBlockIndex;\ - GL.glGetUniformLocation = glGetUniformLocation;\ - GL.glGetTexLevelParameteriv = glGetTexLevelParameteriv;\ - GL.glIsEnabled = glIsEnabled;\ - GL.glIsEnabledi = glIsEnabledi;\ - GL.glLinkProgram = glLinkProgram;\ - GL.glPolygonOffset = glPolygonOffset;\ - GL.glShaderSource = (GFSDK_SSAO_GLFunctions::glShaderSourceGLESType)glShaderSource;\ - GL.glTexImage2D = glTexImage2D;\ - GL.glTexImage3D = glTexImage3D;\ - GL.glTexParameteri = glTexParameteri;\ - GL.glTexParameterfv = glTexParameterfv;\ - GL.glUniform1i = glUniform1i;\ - GL.glUniformBlockBinding = glUniformBlockBinding;\ - GL.glUseProgram = glUseProgram;\ - GL.glViewport = glViewport;\ -} - -//--------------------------------------------------------------------------------------------------- -// Creates a GFSDK_SSAO_Context_GL associated with the current GL context. -// -// Remarks: -// * Requires GL Core 3.2 or above. -// * Allocates GL resources internally. -// * Allocates memory using the default "::operator new", or "pCustomHeap->new_" if provided. -// -// Returns: -// GFSDK_SSAO_NULL_ARGUMENT - One of the required argument pointers is NULL -// GFSDK_SSAO_VERSION_MISMATCH - Invalid HeaderVersion (have you set HeaderVersion = GFSDK_SSAO_Version()?) -// GFSDK_SSAO_GL_RESOURCE_CREATION_FAILED - A GL resource-creation call has failed (running out of memory?) -// GFSDK_SSAO_GL_NULL_FUNCTION_POINTER, - One of the provided GL function pointers is NULL -// GFSDK_SSAO_OK - Success -//--------------------------------------------------------------------------------------------------- -GFSDK_SSAO_DECL(GFSDK_SSAO_Status, GFSDK_SSAO_CreateContext_GL, - GFSDK_SSAO_Context_GL** ppContext, - const GFSDK_SSAO_GLFunctions* pGLFunctions, - GFSDK_SSAO_CUSTOM_HEAP_ARGUMENT, - GFSDK_SSAO_VERSION_ARGUMENT); - -/*==================================================================================================== D3D12 interface. ====================================================================================================*/ @@ -1338,8 +979,8 @@ public: // * Describes the D3D12 descriptor heap space that is passed to the library // //--------------------------------------------------------------------------------------------------- -#define GFSDK_SSAO_NUM_DESCRIPTORS_RTV_HEAP_D3D12 38 // Number of required descriptors for RTV heap type -#define GFSDK_SSAO_NUM_DESCRIPTORS_CBV_SRV_UAV_HEAP_D3D12 57 // Number of required descriptors for CBV/SRV/UAV heap type +#define GFSDK_SSAO_NUM_DESCRIPTORS_RTV_HEAP_D3D12 40 // Number of required descriptors for RTV heap type +#define GFSDK_SSAO_NUM_DESCRIPTORS_CBV_SRV_UAV_HEAP_D3D12 60 // Number of required descriptors for CBV/SRV/UAV heap type struct GFSDK_SSAO_DescriptorHeapRange_D3D12 { |