init
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
// Modifications Copyright © 2021. Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2016, Intel Corporation
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
// the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// File changes (yyyy-mm-dd)
|
||||
// 2016-09-07: filip.strugar@intel.com: first commit
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*! \file */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t FFX_CACAO_Bool;
|
||||
static const FFX_CACAO_Bool FFX_CACAO_TRUE = 1;
|
||||
static const FFX_CACAO_Bool FFX_CACAO_FALSE = 0;
|
||||
|
||||
/**
|
||||
The quality levels that FidelityFX CACAO can generate SSAO at. This affects the number of samples taken for generating SSAO.
|
||||
*/
|
||||
typedef enum FFX_CACAO_Quality {
|
||||
FFX_CACAO_QUALITY_LOWEST = 0,
|
||||
FFX_CACAO_QUALITY_LOW = 1,
|
||||
FFX_CACAO_QUALITY_MEDIUM = 2,
|
||||
FFX_CACAO_QUALITY_HIGH = 3,
|
||||
FFX_CACAO_QUALITY_HIGHEST = 4,
|
||||
} FFX_CACAO_Quality;
|
||||
|
||||
/**
|
||||
A structure representing a 4x4 matrix of floats. The matrix is stored in row major order in memory.
|
||||
*/
|
||||
typedef struct FFX_CACAO_Matrix4x4 {
|
||||
float elements[4][4];
|
||||
} FFX_CACAO_Matrix4x4;
|
||||
|
||||
/**
|
||||
A structure for the settings used by FidelityFX CACAO. These settings may be updated with each draw call.
|
||||
*/
|
||||
typedef struct FFX_CACAO_Settings {
|
||||
float radius; ///< [0.0, ~ ] World (view) space size of the occlusion sphere.
|
||||
float shadowMultiplier; ///< [0.0, 5.0] Effect strength linear multiplier.
|
||||
float shadowPower; ///< [0.5, 5.0] Effect strength pow modifier.
|
||||
float shadowClamp; ///< [0.0, 1.0] Effect max limit (applied after multiplier but before blur).
|
||||
float horizonAngleThreshold; ///< [0.0, 0.2] Limits self-shadowing (makes the sampling area less of a hemisphere, more of a spherical cone, to avoid self-shadowing and various artifacts due to low tessellation and depth buffer imprecision, etc.).
|
||||
float fadeOutFrom; ///< [0.0, ~ ] Distance to start fading out the effect.
|
||||
float fadeOutTo; ///< [0.0, ~ ] Distance at which the effect is faded out.
|
||||
FFX_CACAO_Quality qualityLevel; ///< Effect quality, affects number of taps etc.
|
||||
float adaptiveQualityLimit; ///< [0.0, 1.0] (only for quality level FFX_CACAO_QUALITY_HIGHEST).
|
||||
uint32_t blurPassCount; ///< [ 0, 8] Number of edge-sensitive smart blur passes to apply.
|
||||
float sharpness; ///< [0.0, 1.0] (How much to bleed over edges; 1: not at all, 0.5: half-half; 0.0: completely ignore edges).
|
||||
float temporalSupersamplingAngleOffset; ///< [0.0, PI] Used to rotate sampling kernel; If using temporal AA / supersampling, suggested to rotate by ( (frame%3)/3.0*PI ) or similar. Kernel is already symmetrical, which is why we use PI and not 2*PI.
|
||||
float temporalSupersamplingRadiusOffset; ///< [0.0, 2.0] Used to scale sampling kernel; If using temporal AA / supersampling, suggested to scale by ( 1.0f + (((frame%3)-1.0)/3.0)*0.1 ) or similar.
|
||||
float detailShadowStrength; ///< [0.0, 5.0] Used for high-res detail AO using neighboring depth pixels: adds a lot of detail but also reduces temporal stability (adds aliasing).
|
||||
FFX_CACAO_Bool generateNormals; ///< This option should be set to FFX_CACAO_TRUE if FidelityFX-CACAO should reconstruct a normal buffer from the depth buffer. It is required to be FFX_CACAO_TRUE if no normal buffer is provided.
|
||||
float bilateralSigmaSquared; ///< [0.0, ~ ] Sigma squared value for use in bilateral upsampler giving Gaussian blur term. Should be greater than 0.0.
|
||||
float bilateralSimilarityDistanceSigma; ///< [0.0, ~ ] Sigma squared value for use in bilateral upsampler giving similarity weighting for neighbouring pixels. Should be greater than 0.0.
|
||||
} FFX_CACAO_Settings;
|
||||
|
||||
static const FFX_CACAO_Settings FFX_CACAO_DEFAULT_SETTINGS = {
|
||||
/* radius */ 1.2f,
|
||||
/* shadowMultiplier */ 1.0f,
|
||||
/* shadowPower */ 1.50f,
|
||||
/* shadowClamp */ 0.98f,
|
||||
/* horizonAngleThreshold */ 0.06f,
|
||||
/* fadeOutFrom */ 50.0f,
|
||||
/* fadeOutTo */ 300.0f,
|
||||
/* qualityLevel */ FFX_CACAO_QUALITY_HIGHEST,
|
||||
/* adaptiveQualityLimit */ 0.45f,
|
||||
/* blurPassCount */ 2,
|
||||
/* sharpness */ 0.98f,
|
||||
/* temporalSupersamplingAngleOffset */ 0.0f,
|
||||
/* temporalSupersamplingRadiusOffset */ 0.0f,
|
||||
/* detailShadowStrength */ 0.5f,
|
||||
/* generateNormals */ FFX_CACAO_FALSE,
|
||||
/* bilateralSigmaSquared */ 5.0f,
|
||||
/* bilateralSimilarityDistanceSigma */ 0.01f,
|
||||
};
|
||||
|
||||
/**
|
||||
A C++ structure for the constant buffer used by FidelityFX CACAO.
|
||||
*/
|
||||
typedef struct FFX_CACAO_Constants {
|
||||
float DepthUnpackConsts[2];
|
||||
float CameraTanHalfFOV[2];
|
||||
|
||||
float NDCToViewMul[2];
|
||||
float NDCToViewAdd[2];
|
||||
|
||||
float DepthBufferUVToViewMul[2];
|
||||
float DepthBufferUVToViewAdd[2];
|
||||
|
||||
float EffectRadius;
|
||||
float EffectShadowStrength;
|
||||
float EffectShadowPow;
|
||||
float EffectShadowClamp;
|
||||
|
||||
float EffectFadeOutMul;
|
||||
float EffectFadeOutAdd;
|
||||
float EffectHorizonAngleThreshold;
|
||||
float EffectSamplingRadiusNearLimitRec;
|
||||
|
||||
float DepthPrecisionOffsetMod;
|
||||
float NegRecEffectRadius;
|
||||
float LoadCounterAvgDiv;
|
||||
float AdaptiveSampleCountLimit;
|
||||
|
||||
float InvSharpness;
|
||||
int PassIndex;
|
||||
float BilateralSigmaSquared;
|
||||
float BilateralSimilarityDistanceSigma;
|
||||
|
||||
float PatternRotScaleMatrices[5][4];
|
||||
|
||||
float NormalsUnpackMul;
|
||||
float NormalsUnpackAdd;
|
||||
float DetailAOStrength;
|
||||
float Dummy0;
|
||||
|
||||
float SSAOBufferDimensions[2];
|
||||
float SSAOBufferInverseDimensions[2];
|
||||
|
||||
float DepthBufferDimensions[2];
|
||||
float DepthBufferInverseDimensions[2];
|
||||
|
||||
int DepthBufferOffset[2];
|
||||
float PerPassFullResUVOffset[2];
|
||||
|
||||
float InputOutputBufferDimensions[2];
|
||||
float InputOutputBufferInverseDimensions[2];
|
||||
|
||||
float ImportanceMapDimensions[2];
|
||||
float ImportanceMapInverseDimensions[2];
|
||||
|
||||
float DeinterleavedDepthBufferDimensions[2];
|
||||
float DeinterleavedDepthBufferInverseDimensions[2];
|
||||
|
||||
float DeinterleavedDepthBufferOffset[2];
|
||||
float DeinterleavedDepthBufferNormalisedOffset[2];
|
||||
|
||||
FFX_CACAO_Matrix4x4 NormalsWorldToViewspaceMatrix;
|
||||
} FFX_CACAO_Constants;
|
||||
|
||||
/**
|
||||
A structure containing sizes of each of the buffers used by FidelityFX CACAO.
|
||||
*/
|
||||
typedef struct FFX_CACAO_BufferSizeInfo {
|
||||
uint32_t inputOutputBufferWidth;
|
||||
uint32_t inputOutputBufferHeight;
|
||||
|
||||
uint32_t ssaoBufferWidth;
|
||||
uint32_t ssaoBufferHeight;
|
||||
|
||||
uint32_t depthBufferXOffset;
|
||||
uint32_t depthBufferYOffset;
|
||||
|
||||
uint32_t depthBufferWidth;
|
||||
uint32_t depthBufferHeight;
|
||||
|
||||
uint32_t deinterleavedDepthBufferXOffset;
|
||||
uint32_t deinterleavedDepthBufferYOffset;
|
||||
|
||||
uint32_t deinterleavedDepthBufferWidth;
|
||||
uint32_t deinterleavedDepthBufferHeight;
|
||||
|
||||
uint32_t importanceMapWidth;
|
||||
uint32_t importanceMapHeight;
|
||||
|
||||
uint32_t downsampledSsaoBufferWidth;
|
||||
uint32_t downsampledSsaoBufferHeight;
|
||||
} FFX_CACAO_BufferSizeInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
Update buffer size info for resolution width x height.
|
||||
|
||||
\code{.cpp}
|
||||
FFX_CACAO_BufferSizeInfo bufferSizeInfo = {};
|
||||
FFX_CACAO_UpdateBufferSizeInfo(width, height, useDownsampledSsao, &bufferSizeInfo);
|
||||
\endcode
|
||||
|
||||
\param width Screen width.
|
||||
\param height Screen height.
|
||||
\param useDownsampledSsao Whether FFX CACAO should use downsampling.
|
||||
*/
|
||||
void FFX_CACAO_UpdateBufferSizeInfo(uint32_t width, uint32_t height, FFX_CACAO_Bool useDownsampledSsao, FFX_CACAO_BufferSizeInfo* bsi);
|
||||
|
||||
/**
|
||||
Update the contents of the FFX CACAO constant buffer (an FFX_CACAO_Constants struct). Note, this function does not update
|
||||
per pass constants.
|
||||
|
||||
\code{.cpp}
|
||||
FFX_CACAO_Matrix4x4 proj = ...; // projection matrix for the frame
|
||||
FFX_CACAO_Matrix4x4 normalsToView = ...; // normals world space to view space matrix for the frame
|
||||
FFX_CACAO_Settings settings = ...; // settings
|
||||
FFX_CACAO_BufferSizeInfo bufferSizeInfo = ...; // buffer size info
|
||||
|
||||
FFX_CACAO_Constants constants = {};
|
||||
FFX_CACAO_UpdateConstants(&constants, &settings, &bufferSizeInfo, &proj, &normalsToView);
|
||||
\endcode
|
||||
|
||||
\param consts FFX_CACAO_Constants constant buffer.
|
||||
\param settings FFX_CACAO_Settings settings.
|
||||
\param bufferSizeInfo FFX_CACAO_BufferSizeInfo buffer size info.
|
||||
\param proj Projection matrix for the frame.
|
||||
\param normalsToView Normals world space to view space matrix for the frame.
|
||||
*/
|
||||
void FFX_CACAO_UpdateConstants(FFX_CACAO_Constants* consts, const FFX_CACAO_Settings* settings, const FFX_CACAO_BufferSizeInfo* bufferSizeInfo, const FFX_CACAO_Matrix4x4* proj, const FFX_CACAO_Matrix4x4* normalsToView);
|
||||
|
||||
/**
|
||||
Update the contents of the FFX CACAO constant buffer (an FFX_CACAO_Constants struct) with per pass constants.
|
||||
FFX CACAO runs 4 passes which use different constants. It is recommended to have four separate FFX_CACAO_Constants structs
|
||||
each filled with constants for each of the 4 passes.
|
||||
|
||||
\code{.cpp}
|
||||
FFX_CACAO_Settings settings = ...; // settings
|
||||
FFX_CACAO_BufferSizeInfo bufferSizeInfo = ...; // buffer size info
|
||||
|
||||
FFX_CACAO_Constants perPassConstants[4] = {};
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
FFX_CACAO_UpdatePerPassConstants(&perPassConstants[i], &settings, &bufferSizeInfo, i);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\param consts FFX_CACAO_Constants constants buffer.
|
||||
\param settings FFX_CACAO_Settings settings.
|
||||
\param bufferSizeInfo FFX_CACAO_BufferSizeInfo buffer size info.
|
||||
\param pass pass number.
|
||||
*/
|
||||
void FFX_CACAO_UpdatePerPassConstants(FFX_CACAO_Constants* consts, const FFX_CACAO_Settings* settings, const FFX_CACAO_BufferSizeInfo* bufferSizeInfo, int pass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,312 @@
|
||||
// Modifications Copyright © 2021. Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2016, Intel Corporation
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
// the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// File changes (yyyy-mm-dd)
|
||||
// 2016-09-07: filip.strugar@intel.com: first commit
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*! \file */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ffx_cacao.h"
|
||||
|
||||
// #define FFX_CACAO_ENABLE_PROFILING
|
||||
// #define FFX_CACAO_ENABLE_D3D12
|
||||
// #define FFX_CACAO_ENABLE_VULKAN
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_D3D12
|
||||
#include <d3d12.h>
|
||||
#endif
|
||||
#ifdef FFX_CACAO_ENABLE_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
The return codes for the API functions.
|
||||
*/
|
||||
typedef enum FFX_CACAO_Status {
|
||||
FFX_CACAO_STATUS_OK = 0,
|
||||
FFX_CACAO_STATUS_INVALID_ARGUMENT = -1,
|
||||
FFX_CACAO_STATUS_INVALID_POINTER = -2,
|
||||
FFX_CACAO_STATUS_OUT_OF_MEMORY = -3,
|
||||
FFX_CACAO_STATUS_FAILED = -4,
|
||||
} FFX_CACAO_Status;
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_D3D12
|
||||
/**
|
||||
A struct containing all of the data used by FidelityFX-CACAO.
|
||||
A context corresponds to an ID3D12Device.
|
||||
*/
|
||||
typedef struct FFX_CACAO_D3D12Context FFX_CACAO_D3D12Context;
|
||||
|
||||
/**
|
||||
The parameters for creating a context.
|
||||
*/
|
||||
typedef struct FFX_CACAO_D3D12ScreenSizeInfo {
|
||||
uint32_t width; ///< width of the input/output buffers
|
||||
uint32_t height; ///< height of the input/output buffers
|
||||
ID3D12Resource *depthBufferResource; ///< pointer to depth buffer ID3D12Resource
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC depthBufferSrvDesc; ///< depth buffer D3D12_SHADER_RESOURCE_VIEW_DESC
|
||||
ID3D12Resource *normalBufferResource; ///< optional pointer to normal buffer ID3D12Resource (leave as NULL if none is provided)
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC normalBufferSrvDesc; ///< normal buffer D3D12_SHADER_RESOURCE_VIEW_DESC
|
||||
ID3D12Resource *outputResource; ///< pointer to output buffer ID3D12Resource
|
||||
D3D12_UNORDERED_ACCESS_VIEW_DESC outputUavDesc; ///< output buffer D3D12_UNORDERED_ACCESS_VIEW_DESC
|
||||
FFX_CACAO_Bool useDownsampledSsao; ///< Whether SSAO should be generated at native resolution or half resolution. It is recommended to enable this setting for improved performance.
|
||||
} FFX_CACAO_D3D12ScreenSizeInfo;
|
||||
#endif
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_VULKAN
|
||||
/**
|
||||
A struct containing all of the data used by FidelityFX-CACAO.
|
||||
A context corresponds to a VkDevice.
|
||||
*/
|
||||
typedef struct FFX_CACAO_VkContext FFX_CACAO_VkContext;
|
||||
|
||||
/**
|
||||
Miscellaneous flags for used for Vulkan context creation by FidelityFX-CACAO
|
||||
*/
|
||||
typedef enum FFX_CACAO_VkCreateFlagsBits {
|
||||
FFX_CACAO_VK_CREATE_USE_16_BIT = 0x00000001, ///< Flag controlling whether 16-bit optimisations are enabled in shaders.
|
||||
FFX_CACAO_VK_CREATE_USE_DEBUG_MARKERS = 0x00000002, ///< Flag controlling whether debug markers should be used.
|
||||
FFX_CACAO_VK_CREATE_NAME_OBJECTS = 0x00000004, ///< Flag controlling whether Vulkan objects should be named.
|
||||
} FFX_CACAO_VkCreateFlagsBits;
|
||||
typedef uint32_t FFX_CACAO_VkCreateFlags;
|
||||
|
||||
/**
|
||||
The parameters for creating a context.
|
||||
*/
|
||||
typedef struct FFX_CACAO_VkCreateInfo {
|
||||
VkPhysicalDevice physicalDevice; ///< The VkPhysicalDevice corresponding to the VkDevice in use
|
||||
VkDevice device; ///< The VkDevice to use FFX CACAO with
|
||||
FFX_CACAO_VkCreateFlags flags; ///< Miscellaneous flags for context creation
|
||||
} FFX_CACAO_VkCreateInfo;
|
||||
|
||||
/**
|
||||
The parameters necessary when changing the screen size of FidelityFX CACAO.
|
||||
*/
|
||||
typedef struct FFX_CACAO_VkScreenSizeInfo {
|
||||
uint32_t width; ///< width of the input/output buffers
|
||||
uint32_t height; ///< height of the input/output buffers
|
||||
VkImageView depthView; ///< An image view for the depth buffer, should be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL when used with FFX CACAO
|
||||
VkImageView normalsView; ///< An optional image view for the normal buffer (may be VK_NULL_HANDLE). Should be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL when used with FFX CACAO
|
||||
VkImage output; ///< An image for writing output from FFX CACAO, must have the same dimensions as the input
|
||||
VkImageView outputView; ///< An image view corresponding to the output image.
|
||||
FFX_CACAO_Bool useDownsampledSsao; ///< Whether SSAO should be generated at native resolution or half resolution. It is recommended to enable this setting for improved performance.
|
||||
} FFX_CACAO_VkScreenSizeInfo;
|
||||
#endif
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_PROFILING
|
||||
/**
|
||||
A timestamp. The label gives the name of the stage of the effect, and the ticks is the number of GPU ticks spent on that stage.
|
||||
*/
|
||||
typedef struct FFX_CACAO_Timestamp {
|
||||
const char *label; ///< name of timestamp stage
|
||||
uint64_t ticks; ///< number of GPU ticks taken for stage
|
||||
} FFX_CACAO_Timestamp;
|
||||
|
||||
/**
|
||||
An array of timestamps for detailed profiling information. The array timestamps contains numTimestamps entries.
|
||||
Entry 0 of the timestamps array is guaranteed to be the total time taken by the effect.
|
||||
*/
|
||||
typedef struct FFX_CACAO_DetailedTiming {
|
||||
uint32_t numTimestamps; ///< number of timetstamps in the array timestamps
|
||||
FFX_CACAO_Timestamp timestamps[32]; ///< array of timestamps for each FFX CACAO stage
|
||||
} FFX_CACAO_DetailedTiming;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_D3D12
|
||||
/**
|
||||
Gets the size in bytes required by a context. This is to be used to allocate space for the context.
|
||||
For example:
|
||||
|
||||
\code{.cpp}
|
||||
size_t FFX_CACAO_D3D12ContextSize = ffxCacaoD3D12GetContextSize();
|
||||
FFX_CACAO_D3D12Context *context = (FFX_CACAO_D3D12Context*)malloc(FFX_CACAO_D3D12GetContextSize);
|
||||
|
||||
// ...
|
||||
|
||||
FFX_CACAO_D3D12DestroyContext(context);
|
||||
free(context);
|
||||
\endcode
|
||||
|
||||
\return The size in bytes of an FFX_CACAO_D3D12Context.
|
||||
*/
|
||||
size_t FFX_CACAO_D3D12GetContextSize();
|
||||
|
||||
/**
|
||||
Initialises an FFX_CACAO_D3D12Context.
|
||||
|
||||
\param context A pointer to the context to initialise.
|
||||
\param device A pointer to the D3D12 device.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12InitContext(FFX_CACAO_D3D12Context* context, ID3D12Device* device);
|
||||
|
||||
/**
|
||||
Destroys an FFX_CACAO_D3D12Context.
|
||||
|
||||
\param context A pointer to the context to be destroyed.
|
||||
\return The corresponding error code.
|
||||
|
||||
\note This function does not destroy screen size dependent resources, and must be called after FFX_CACAO_D3D12DestroyScreenSizeDependentResources.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12DestroyContext(FFX_CACAO_D3D12Context* context);
|
||||
|
||||
/**
|
||||
Initialises screen size dependent resources for the FFX_CACAO_D3D12Context.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_D3D12Context.
|
||||
\param info A pointer to an FFX_CACAO_D3D12ScreenSizeInfo struct containing screen size info.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12InitScreenSizeDependentResources(FFX_CACAO_D3D12Context* context, const FFX_CACAO_D3D12ScreenSizeInfo* info);
|
||||
|
||||
/**
|
||||
Destroys screen size dependent resources for the FFX_CACAO_D3D12Context.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_D3D12Context.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12DestroyScreenSizeDependentResources(FFX_CACAO_D3D12Context* context);
|
||||
|
||||
/**
|
||||
Update the settings of the FFX_CACAO_D3D12Context to those stored in the FFX_CACAO_Settings struct.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_D3D12Context to update.
|
||||
\param settings A pointer to the FFX_CACAO_Settings struct containing the new settings.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12UpdateSettings(FFX_CACAO_D3D12Context* context, const FFX_CACAO_Settings* settings);
|
||||
|
||||
/**
|
||||
Append commands for drawing FFX CACAO to the provided ID3D12GraphicsCommandList.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_D3D12Context.
|
||||
\param commandList A pointer to the ID3D12GraphicsCommandList to append commands to.
|
||||
\param proj A pointer to the projection matrix.
|
||||
\param normalsToView An optional pointer to a matrix for transforming normals to in the normal buffer to viewspace.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12Draw(FFX_CACAO_D3D12Context* context, ID3D12GraphicsCommandList* commandList, const FFX_CACAO_Matrix4x4* proj, const FFX_CACAO_Matrix4x4* normalsToView);
|
||||
|
||||
#if FFX_CACAO_ENABLE_PROFILING
|
||||
/**
|
||||
Get detailed performance timings from the previous frame.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_D3D12Context.
|
||||
\param timings A pointer to an FFX_CACAO_DetailedTiming struct to fill in with detailed timings.
|
||||
\result The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_D3D12GetDetailedTimings(FFX_CACAO_D3D12Context* context, FFX_CACAO_DetailedTiming* timings);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_VULKAN
|
||||
/**
|
||||
Gets the size in bytes required by a Vulkan context. This is to be used to allocate space for the context.
|
||||
For example:
|
||||
|
||||
\code{.cpp}
|
||||
size_t FFX_CACAO_VkContextSize = ffxCacaoVkGetContextSize();
|
||||
FFX_CACAO_VkContext *context = (FFX_CACAO_VkContext*)malloc(FFX_CACAO_VkGetContextSize);
|
||||
|
||||
// ...
|
||||
|
||||
FFX_CACAO_VkDestroyContext(context);
|
||||
free(context);
|
||||
\endcode
|
||||
|
||||
\return The size in bytes of an FFX_CACAO_VkContext.
|
||||
*/
|
||||
size_t FFX_CACAO_VkGetContextSize();
|
||||
|
||||
/**
|
||||
Initialises an FFX_CACAO_VkContext.
|
||||
|
||||
\param context A pointer to the context to initialise.
|
||||
\param info A pointer to an FFX_CACAO_VkCreateInfo struct with parameters such as the vulkan device.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkInitContext(FFX_CACAO_VkContext* context, const FFX_CACAO_VkCreateInfo *info);
|
||||
|
||||
/**
|
||||
Destroys an FFX_CACAO_VkContext.
|
||||
|
||||
\param context A pointer to the context to be destroyed.
|
||||
\return The corresponding error code.
|
||||
|
||||
\note This function does not destroy screen size dependent resources, and must be called after FFX_CACAO_VkDestroyScreenSizeDependentResources.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkDestroyContext(FFX_CACAO_VkContext* context);
|
||||
|
||||
/**
|
||||
Initialises screen size dependent resources for the FFX_CACAO_VkContext.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_VkContext.
|
||||
\param info A pointer to an FFX_CACAO_VkScreenSizeInfo struct containing screen size info.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkInitScreenSizeDependentResources(FFX_CACAO_VkContext* context, const FFX_CACAO_VkScreenSizeInfo* info);
|
||||
|
||||
/**
|
||||
Destroys screen size dependent resources for the FFX_CACAO_VkContext.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_VkContext.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkDestroyScreenSizeDependentResources(FFX_CACAO_VkContext* context);
|
||||
|
||||
/**
|
||||
Update the settings of the FFX_CACAO_VkContext to those stored in the FFX_CACAO_Settings struct.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_VkContext to update.
|
||||
\param settings A pointer to the FFX_CACAO_Settings struct containing the new settings.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkUpdateSettings(FFX_CACAO_VkContext* context, const FFX_CACAO_Settings* settings);
|
||||
|
||||
/**
|
||||
Append commands for drawing FFX CACAO to the provided VkCommandBuffer.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_VkContext.
|
||||
\param commandList The VkCommandBuffer to append commands to.
|
||||
\param proj A pointer to the projection matrix.
|
||||
\param normalsToView An optional pointer to a matrix for transforming normals to in the normal buffer to viewspace.
|
||||
\return The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkDraw(FFX_CACAO_VkContext* context, VkCommandBuffer commandList, const FFX_CACAO_Matrix4x4* proj, const FFX_CACAO_Matrix4x4* normalsToView);
|
||||
|
||||
#ifdef FFX_CACAO_ENABLE_PROFILING
|
||||
/**
|
||||
Get detailed performance timings from the previous frame.
|
||||
|
||||
\param context A pointer to the FFX_CACAO_VkContext.
|
||||
\param timings A pointer to an FFX_CACAO_DetailedTiming struct to fill in with detailed timings.
|
||||
\result The corresponding error code.
|
||||
*/
|
||||
FFX_CACAO_Status FFX_CACAO_VkGetDetailedTimings(FFX_CACAO_VkContext* context, FFX_CACAO_DetailedTiming* timings);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,196 @@
|
||||
# FidelityFX CACAO
|
||||
|
||||
The **FidelityFX CACAO** library implements screen space ambient occlusion for use in real time applications. A full sample can be found on the [FidelityFX CACAO Github page](https://github.com/GPUOpen-Effects/FidelityFX-CACAO).
|
||||
|
||||
# Project Integration
|
||||
|
||||
FidelityFX CACAO comes with two main header files, `ffx-cacao/inc/ffx_cacao.h` and `ffx-cacao/inc/ffx_cacao_impl.h`. The file `ffx-cacao/inc/ffx_cacao.h` contains reusable C++ functions and struct definitions for integration of FidelityFX CACAO into custom engines. The functions declared in this header file are defined in `ffx-cacao/src/ffx_cacao.cpp`. The header file `ffx-cacao/inc/ffx_cacao_impl.h` is for use in quick integration of FidelityFX CACAO into DX12 and Vulkan engines. The functions declared in this file are defined in `ffx-cacao/src/ffx_cacao_impl.cpp`, which serves as a reference implementation of FidelityFX CACAO.
|
||||
|
||||
# Reusable Functions and Structs
|
||||
|
||||
The reusable functions and structs provided in `ffx-cacao/src/ffx_cacao.h` are documented via doxygen comments in the header file itself. The functions and structs are used to initialise the constant buffers used by FidelityFX CACAO from a user friendly settings struct `FFX_CACAO_Settings`.
|
||||
|
||||
# Reference Implementation
|
||||
|
||||
The reference implementation of FidelityFX CACAO supports three compile time options. These are:
|
||||
|
||||
```C++
|
||||
FFX_CACAO_ENABLE_D3D12
|
||||
FFX_CACAO_ENABLE_VK
|
||||
FFX_CACAO_ENABLE_PROFILING
|
||||
```
|
||||
|
||||
For use with D3D12 or Vulkan, the symbols `FFX_CACAO_ENABLE_D3D12` or `FFX_CACAO_ENABLE_VK` must be defined. If you wish to get detailed timings from FFX CACAO the symbol `FFX_CACAO_ENABLE_PROFILING` must be defined. These symbols can either be defined in the header `ffx-cacao/inc/ffx_cacao_impl.h` itself by uncommenting the respective definitions, or they can defined in compiler flags. The provided sample of FFX CACAO defines these symbols using compiler flags.
|
||||
|
||||
# Context Initialisation and Shutdown
|
||||
|
||||
First the FFX CACAO header must be included. This can be found at `ffx-cacao/inc/ffx_cacao_impl.h`. Then a context must be created. This is usually done only once per device. To create a context you must first query for the size of a context, allocate space for a context, then inintialise the context.
|
||||
|
||||
|
||||
For D3D12 the initialisation and shutdown processes are as follows:
|
||||
|
||||
```C++
|
||||
// initialisation
|
||||
size_t ffxCacaoContextSize = ffxCacaoD3D12GetContextSize();
|
||||
FfxCacaoD3D12Context *context = (FfxCacaoD3D12Context*)malloc(ffxCacaoContextSize);
|
||||
assert(context);
|
||||
FfxCacaoStatus status = ffxCacaoD3D12InitContext(context, d3d12Device);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
...
|
||||
// finalisation
|
||||
status = ffxCacaoD3D12DestroyContext(context);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
free(context);
|
||||
```
|
||||
|
||||
The only argument required for initialisation of a D3D12 context is an `ID3D12Device*` for the D3D12 device.
|
||||
|
||||
For Vulkan the initialisation and shutdown processes are as follows:
|
||||
|
||||
```C++
|
||||
// initialisation
|
||||
size_t ffxCacaoContextSize = ffxCacaoVkGetContextSize();
|
||||
FfxCacaoVkContext *context = (FfxCacaoVkContext*)malloc(ffxCacaoContextSize);
|
||||
assert(context);
|
||||
FfxCacaoVkCreateInfo info = {};
|
||||
info.physicalDevice = vkPhysicalDevice;
|
||||
info.device = vkDevice;
|
||||
info.flags = FFX_CACAO_VK_CREATE_USE_16_BIT | FFX_CACAO_VK_CREATE_USE_DEBUG_MARKERS | FFX_CACAO_VK_CREATE_NAME_OBJECTS;
|
||||
FfxCacaoStatus status = ffxCacaoVkInitContext(context, &info);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
...
|
||||
// finalisation
|
||||
status = ffxCacaoVkDestroyContext(context);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
free(context);
|
||||
```
|
||||
|
||||
To initialise the FFX CACAO context in Vulkan, the parameters of the `FfxCacaoVkCreateInfo` struct must be filled in. These are the Vulkan physical device and Vulkan device, and a field of flags. The flags is a bitwise combination of the following options. The option `FFX_CACAO_VK_CREATE_USE_16_BIT` enables 16 bit optimisations, and requires a Vulkan device created using 16 bit extensions. This option is strongly recommended for compatible devices. The options `FFX_CACAO_VK_CREATE_USE_DEBUG_MARKERS` and `FFX_CACAO_VK_CREATE_NAME_OBJECTS` will add debug markers and name objects (e.g. textures, shaders) to aid inspection of FFX CACAO with a frame debugger.
|
||||
|
||||
# Screen Size Dependent Resource Initialisation
|
||||
|
||||
Once the context is initialised, it will need to have screen size dependent resources initialised each time the screen size is changed. To do this, an `FfxCacaoD3D12ScreenSizeInfo` struct must be filled out. The FFX CACAO effect is computed using a depth buffer and optional normal buffer. FFX CACAO writes its output to a user provided output buffer. The depth buffer, normal buffer and output buffer provided to FFX CACAO must all be the same size.
|
||||
|
||||
|
||||
For FFX CACAO D3D12, the process is as follows:
|
||||
|
||||
```C++
|
||||
// initialisation
|
||||
FfxCacaoD3D12ScreenSizeInfo screenSizeInfo = {};
|
||||
screenSizeInfo.width = /* width of the input/output buffers */;
|
||||
screenSizeInfo.height = /* height of the input/output buffers */;
|
||||
screenSizeInfo.depthBufferResource = /* ID3D12Resource* for the depth input buffer */;
|
||||
screenSizeInfo.depthBufferSrvDesc = /* D3D12_SHADER_RESOURCE_VIEW_DESC for the depth input buffer */;
|
||||
screenSizeInfo.normalBufferResource = /* ID3D12Resource* for the normal input buffer - or NULL if none shall be provided */;
|
||||
screenSizeInfo.normalBufferSrvDesc = /* D3D12_SHADER_RESOURCE_VIEW_DESC for the normal input buffer */;
|
||||
screenSizeInfo.outputResource = /* ID3D12Resource* for the output buffer */;
|
||||
screenSizeInfo.depthBufferSrvDesc = /* D3D12_SHADER_RESOURCE_VIEW_DESC for the depth output */;
|
||||
status = ffxCacaoD3D12InitScreenSizeDependentResources(context, &screenSizeInfo);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
...
|
||||
// finalisation
|
||||
status = ffxCacaoD3D12DestroyScreenSizeDependentResources(context);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
For FFX CACAO Vulkan, the process is as follows:
|
||||
|
||||
```C++
|
||||
// Initialisation
|
||||
FfxCacaoVkScreenSizeInfo screenSizeInfo = {};
|
||||
screenSizeInfo.width = /* width of the input/output buffers */;
|
||||
screenSizeInfo.height = /* height of the input/output buffers */;
|
||||
screenSizeInfo.depthView = /* a VkImageView for the depth buffer, should be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */;
|
||||
screenSizeInfo.normalsView = /* an optional VkImageView for the normal buffer (VK_NULL_HANDLE if not provided), should be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */;
|
||||
screenSizeInfo.output = /* a VkImage for writing the output of FFX CACAO */;
|
||||
screenSizeInfo.outputView = /* a VkImageView corresponding to the VkImage for writing the output of FFX CACAO */;
|
||||
status = ffxCacaoVkInitScreenSizeDependentResources(context, &screenSizeInfo);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
...
|
||||
// finalisation
|
||||
status = ffxCacaoVkDestroyScreenSizeDependentResources(context);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
# Initialising/Updating FFX CACAO Settings
|
||||
|
||||
The settings for the FFX CACAO effect may be changed via the `FfxCacaoSettings` struct and the `ffxCacaoD3D12UpdateSettings` or `ffxCacaoVkUpdateSettings` functions as follows.
|
||||
|
||||
```C++
|
||||
FfxCacaoSettings settings = {};
|
||||
settings.radius = /* world view radius of the occlusion sphere */;
|
||||
settings.shadowMultiplier = /* effect strength linear multiplier */;
|
||||
settings.shadowPower = /* effect strength power multiplier */;
|
||||
settings.shadowClamp = /* effect max limit */;
|
||||
settings.horizonAngleThreshold = /* minimum horizon angle for contributions to occlusion to limit self shadowing */
|
||||
settings.fadeOutFrom = /* effect fade out from world space distance */;
|
||||
settings.fadeOutTo = /* effect fade out to world space distance */;
|
||||
settings.qualityLevel = /* the quality of the effect, ranging from lowest to highest (adaptive). This affects the number of samples taken to generate SSAO. */;
|
||||
settings.adaptiveQualityLimit = /* quality limit for adaptive quality */;
|
||||
settings.blurPassCount = /* a number of edge sensitive blurs from 1 to 8 to perform after SSAO generation */;
|
||||
settings.sharpness = /* how much to bleed over edges - 0 = ignore edges, 1 = don't bleed over edges */;
|
||||
settings.temporalSupersamplingAngleOffset = /* sampling angle offset for temporal super sampling */;
|
||||
settings.temporalSupersamplingRaidusOffset = /* sampling effect radius offset for temporal super sampling */;
|
||||
settings.detailShadowStrength = /* used to generate details in high res AO */;
|
||||
settings.generateNormals = /* should the effect generate normals from the depth buffer or use a provided normal buffer */;
|
||||
settings.bilateralSigmaSquared = /* a parameter for use in bilateral upsampling. Higher values create more blur to help reduce noise */;
|
||||
settings.bilateralSimilarityDistanceSigma = /* a parameter for use in bilateral upsampling. Lower values create reduce bluring across edge boundaries */;
|
||||
```
|
||||
|
||||
These settings can be set to sensible defaults from the constant `FFX_CACAO_DEFAULT_SETTINGS` and updated using the function `ffxCacaoD3D12UpdateSettings` or `ffxCacaoVkUpdateSettings` as follows.
|
||||
|
||||
```C++
|
||||
FfxCacaoSettings settings = FFX_CACAO_DEFAULT_SETTINGS;
|
||||
status = ffxCacaoD3D12UpdateSettings(context, &settings);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
Note that the `FFX_CACAO_DEFAULT_SETTINGS` provides a sensible quick start for high quality settings. The parameters `radius`, `fadeOutFrom` and `fadeOutTo` should
|
||||
be changed to match the world space of the target scene, and the parameter `blurPassCount` is recommended to be increased for lower quality settings. A more complete
|
||||
set of sensible defaults may be found in the FFX CACAO sample in the file `sample/src/Common/FFX_CACAO_Common.h`, where multiple parameters have been varied to move
|
||||
from high to low quality presets.
|
||||
|
||||
# Drawing
|
||||
|
||||
In D3D12, FFX CACAO can be called to add commands to a `ID3D12GraphicsCommandList` using the `ffxCacaoD3D12Draw` function as follows:
|
||||
|
||||
```C++
|
||||
FfxCacaoMatrix4x4 proj = /* row major projection matrix */;
|
||||
FfxCacaoMatrix4x4 normalsToView = /* row major matrix to convert normals to viewspace */
|
||||
status = ffxCacaoD3D12Draw(context, commandList, &proj, &normalsToView);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
In Vulkan, FFX CACAO can add commands to a `VkCommandBuffer` using the `ffxCacaoVkDraw` function as follows:
|
||||
|
||||
```C++
|
||||
FfxCacaoMatrix4x4 proj = /* row major projection matrix */;
|
||||
FfxCacaoMatrix4x4 normalsToView = /* row major matrix to convert normals to viewspace */
|
||||
status = ffxCacaoVkDraw(context, commandBuffer, &proj, &normalsToView);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
The matrix `proj` is the projection matrix used from viewspace to normalised device coordinates. The matrix `normalsToView` is a matrix to convert the normals provided in the normal buffer to viewspace.
|
||||
|
||||
# Profiling
|
||||
|
||||
Finally, if the preprocessor symbol `FFX_CACAO_ENABLE_PROFILING` is defined, then detailed timings can be read from FFX CACAO using the functions `ffxCacaoD3D12GetDetailedTimings` and `ffxCacaoVkGetDetailedTimings` for D3D12 and Vulkan respectively. These functions should be called as follows:
|
||||
|
||||
```C++
|
||||
FfxCacaoDetailedTiming timings = {};
|
||||
uint64_t gpuTicksPerMicrosecond;
|
||||
FfxCacaoStatus status = ffxCacaoD3D12GetDetailedTimings(context, &timings, &gpuTicksPerMicrosecond);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
The timings returned are in GPU ticks. These can be converted into seconds using the value returned in the `gpuTicksPerMicrosecond` parameter above.
|
||||
|
||||
Or in Vulkan:
|
||||
|
||||
```C++
|
||||
FfxCacaoDetailedTiming timings = {};
|
||||
FfxCacaoStatus status = ffxCacaoD3D12GetDetailedTimings(context, &timings);
|
||||
assert(status == FFX_CACAO_STATUS_OK);
|
||||
```
|
||||
|
||||
The timings returned are measured in GPU ticks, and will need to be converted using th GPU ticks per microsecond parameter available from `vkGetPhysicalDeviceLimits`.
|
||||
@@ -0,0 +1,55 @@
|
||||
%echo off
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
set cauldron_dxc=..\..\sample\libs\cauldron\libs\DXC\bin\dxc.exe -T cs_6_2
|
||||
|
||||
if not exist "PrecompiledShadersDXIL" mkdir "PrecompiledShadersDXIL"
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOClearLoadCounter.h -Vn CSClearLoadCounterDXIL -E FFX_CACAO_ClearLoadCounter ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareDownsampledDepths.h -Vn CSPrepareDownsampledDepthsDXIL -E FFX_CACAO_PrepareDownsampledDepths ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareNativeDepths.h -Vn CSPrepareNativeDepthsDXIL -E FFX_CACAO_PrepareNativeDepths ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareDownsampledDepthsAndMips.h -Vn CSPrepareDownsampledDepthsAndMipsDXIL -E FFX_CACAO_PrepareDownsampledDepthsAndMips ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareNativeDepthsAndMips.h -Vn CSPrepareNativeDepthsAndMipsDXIL -E FFX_CACAO_PrepareNativeDepthsAndMips ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareDownsampledNormals.h -Vn CSPrepareDownsampledNormalsDXIL -E FFX_CACAO_PrepareDownsampledNormals ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareNativeNormals.h -Vn CSPrepareNativeNormalsDXIL -E FFX_CACAO_PrepareNativeNormals ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareDownsampledNormalsFromInputNormals.h -Vn CSPrepareDownsampledNormalsFromInputNormalsDXIL -E FFX_CACAO_PrepareDownsampledNormalsFromInputNormals ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareNativeNormalsFromInputNormals.h -Vn CSPrepareNativeNormalsFromInputNormalsDXIL -E FFX_CACAO_PrepareNativeNormalsFromInputNormals ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareDownsampledDepthsHalf.h -Vn CSPrepareDownsampledDepthsHalfDXIL -E FFX_CACAO_PrepareDownsampledDepthsHalf ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPrepareNativeDepthsHalf.h -Vn CSPrepareNativeDepthsHalfDXIL -E FFX_CACAO_PrepareNativeDepthsHalf ffx_cacao.hlsl
|
||||
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOGenerateQ0.h -Vn CSGenerateQ0DXIL -E FFX_CACAO_GenerateQ0 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOGenerateQ1.h -Vn CSGenerateQ1DXIL -E FFX_CACAO_GenerateQ1 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOGenerateQ2.h -Vn CSGenerateQ2DXIL -E FFX_CACAO_GenerateQ2 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOGenerateQ3.h -Vn CSGenerateQ3DXIL -E FFX_CACAO_GenerateQ3 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOGenerateQ3Base.h -Vn CSGenerateQ3BaseDXIL -E FFX_CACAO_GenerateQ3Base ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOGenerateImportanceMap.h -Vn CSGenerateImportanceMapDXIL -E FFX_CACAO_GenerateImportanceMap ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPostprocessImportanceMapA.h -Vn CSPostprocessImportanceMapADXIL -E FFX_CACAO_PostprocessImportanceMapA ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOPostprocessImportanceMapB.h -Vn CSPostprocessImportanceMapBDXIL -E FFX_CACAO_PostprocessImportanceMapB ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur1.h -Vn CSEdgeSensitiveBlur1DXIL -E FFX_CACAO_EdgeSensitiveBlur1 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur2.h -Vn CSEdgeSensitiveBlur2DXIL -E FFX_CACAO_EdgeSensitiveBlur2 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur3.h -Vn CSEdgeSensitiveBlur3DXIL -E FFX_CACAO_EdgeSensitiveBlur3 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur4.h -Vn CSEdgeSensitiveBlur4DXIL -E FFX_CACAO_EdgeSensitiveBlur4 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur5.h -Vn CSEdgeSensitiveBlur5DXIL -E FFX_CACAO_EdgeSensitiveBlur5 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur6.h -Vn CSEdgeSensitiveBlur6DXIL -E FFX_CACAO_EdgeSensitiveBlur6 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur7.h -Vn CSEdgeSensitiveBlur7DXIL -E FFX_CACAO_EdgeSensitiveBlur7 ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOEdgeSensitiveBlur8.h -Vn CSEdgeSensitiveBlur8DXIL -E FFX_CACAO_EdgeSensitiveBlur8 ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOApply.h -Vn CSApplyDXIL -E FFX_CACAO_Apply ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAONonSmartApply.h -Vn CSNonSmartApplyDXIL -E FFX_CACAO_NonSmartApply ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAONonSmartHalfApply.h -Vn CSNonSmartHalfApplyDXIL -E FFX_CACAO_NonSmartHalfApply ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOUpscaleBilateral5x5NonSmart.h -Vn CSUpscaleBilateral5x5NonSmartDXIL -E FFX_CACAO_UpscaleBilateral5x5NonSmart ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOUpscaleBilateral5x5Smart.h -Vn CSUpscaleBilateral5x5SmartDXIL -E FFX_CACAO_UpscaleBilateral5x5Smart ffx_cacao.hlsl
|
||||
%cauldron_dxc% -Fh PrecompiledShadersDXIL/CACAOUpscaleBilateral5x5Half.h -Vn CSUpscaleBilateral5x5HalfDXIL -E FFX_CACAO_UpscaleBilateral5x5Half ffx_cacao.hlsl
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,103 @@
|
||||
%echo off
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
set cauldron_dxc_16=glslc -Wno-conversion -spirv -T cs_6_2 -enable-16bit-types -fspv-target-env=vulkan1.1 -fvk-s-shift 0 0 -fvk-b-shift 10 0 -fvk-t-shift 20 0 -fvk-u-shift 30 0
|
||||
set cauldron_dxc_32=glslc -Wno-conversion -spirv -T cs_6_2 -fspv-target-env=vulkan1.1 -fvk-s-shift 0 0 -fvk-b-shift 10 0 -fvk-t-shift 20 0 -fvk-u-shift 30 0
|
||||
|
||||
if not exist "PrecompiledShadersSPIRV" mkdir "PrecompiledShadersSPIRV"
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOClearLoadCounter_16.h -Vn CSClearLoadCounterSPIRV16 -E FFX_CACAO_ClearLoadCounter ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledDepths_16.h -Vn CSPrepareDownsampledDepthsSPIRV16 -E FFX_CACAO_PrepareDownsampledDepths ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeDepths_16.h -Vn CSPrepareNativeDepthsSPIRV16 -E FFX_CACAO_PrepareNativeDepths ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledDepthsAndMips_16.h -Vn CSPrepareDownsampledDepthsAndMipsSPIRV16 -E FFX_CACAO_PrepareDownsampledDepthsAndMips ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeDepthsAndMips_16.h -Vn CSPrepareNativeDepthsAndMipsSPIRV16 -E FFX_CACAO_PrepareNativeDepthsAndMips ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledNormals_16.h -Vn CSPrepareDownsampledNormalsSPIRV16 -E FFX_CACAO_PrepareDownsampledNormals ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeNormals_16.h -Vn CSPrepareNativeNormalsSPIRV16 -E FFX_CACAO_PrepareNativeNormals ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledNormalsFromInputNormals_16.h -Vn CSPrepareDownsampledNormalsFromInputNormalsSPIRV16 -E FFX_CACAO_PrepareDownsampledNormalsFromInputNormals ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeNormalsFromInputNormals_16.h -Vn CSPrepareNativeNormalsFromInputNormalsSPIRV16 -E FFX_CACAO_PrepareNativeNormalsFromInputNormals ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledDepthsHalf_16.h -Vn CSPrepareDownsampledDepthsHalfSPIRV16 -E FFX_CACAO_PrepareDownsampledDepthsHalf ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeDepthsHalf_16.h -Vn CSPrepareNativeDepthsHalfSPIRV16 -E FFX_CACAO_PrepareNativeDepthsHalf ffx_cacao.hlsl
|
||||
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ0_16.h -Vn CSGenerateQ0SPIRV16 -E FFX_CACAO_GenerateQ0 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ1_16.h -Vn CSGenerateQ1SPIRV16 -E FFX_CACAO_GenerateQ1 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ2_16.h -Vn CSGenerateQ2SPIRV16 -E FFX_CACAO_GenerateQ2 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ3_16.h -Vn CSGenerateQ3SPIRV16 -E FFX_CACAO_GenerateQ3 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ3Base_16.h -Vn CSGenerateQ3BaseSPIRV16 -E FFX_CACAO_GenerateQ3Base ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOGenerateImportanceMap_16.h -Vn CSGenerateImportanceMapSPIRV16 -E FFX_CACAO_GenerateImportanceMap ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPostprocessImportanceMapA_16.h -Vn CSPostprocessImportanceMapASPIRV16 -E FFX_CACAO_PostprocessImportanceMapA ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOPostprocessImportanceMapB_16.h -Vn CSPostprocessImportanceMapBSPIRV16 -E FFX_CACAO_PostprocessImportanceMapB ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur1_16.h -Vn CSEdgeSensitiveBlur1SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur1 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur2_16.h -Vn CSEdgeSensitiveBlur2SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur2 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur3_16.h -Vn CSEdgeSensitiveBlur3SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur3 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur4_16.h -Vn CSEdgeSensitiveBlur4SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur4 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur5_16.h -Vn CSEdgeSensitiveBlur5SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur5 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur6_16.h -Vn CSEdgeSensitiveBlur6SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur6 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur7_16.h -Vn CSEdgeSensitiveBlur7SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur7 ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur8_16.h -Vn CSEdgeSensitiveBlur8SPIRV16 -E FFX_CACAO_EdgeSensitiveBlur8 ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOApply_16.h -Vn CSApplySPIRV16 -E FFX_CACAO_Apply ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAONonSmartApply_16.h -Vn CSNonSmartApplySPIRV16 -E FFX_CACAO_NonSmartApply ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAONonSmartHalfApply_16.h -Vn CSNonSmartHalfApplySPIRV16 -E FFX_CACAO_NonSmartHalfApply ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOUpscaleBilateral5x5Smart_16.h -Vn CSUpscaleBilateral5x5SmartSPIRV16 -E FFX_CACAO_UpscaleBilateral5x5Smart ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOUpscaleBilateral5x5NonSmart_16.h -Vn CSUpscaleBilateral5x5NonSmartSPIRV16 -E FFX_CACAO_UpscaleBilateral5x5NonSmart ffx_cacao.hlsl
|
||||
%cauldron_dxc_16% -Fh PrecompiledShadersSPIRV/CACAOUpscaleBilateral5x5Half_16.h -Vn CSUpscaleBilateral5x5HalfSPIRV16 -E FFX_CACAO_UpscaleBilateral5x5Half ffx_cacao.hlsl
|
||||
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOClearLoadCounter_32.h -Vn CSClearLoadCounterSPIRV32 -E FFX_CACAO_ClearLoadCounter ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledDepths_32.h -Vn CSPrepareDownsampledDepthsSPIRV32 -E FFX_CACAO_PrepareDownsampledDepths ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeDepths_32.h -Vn CSPrepareNativeDepthsSPIRV32 -E FFX_CACAO_PrepareNativeDepths ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledDepthsAndMips_32.h -Vn CSPrepareDownsampledDepthsAndMipsSPIRV32 -E FFX_CACAO_PrepareDownsampledDepthsAndMips ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeDepthsAndMips_32.h -Vn CSPrepareNativeDepthsAndMipsSPIRV32 -E FFX_CACAO_PrepareNativeDepthsAndMips ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledNormals_32.h -Vn CSPrepareDownsampledNormalsSPIRV32 -E FFX_CACAO_PrepareDownsampledNormals ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeNormals_32.h -Vn CSPrepareNativeNormalsSPIRV32 -E FFX_CACAO_PrepareNativeNormals ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledNormalsFromInputNormals_32.h -Vn CSPrepareDownsampledNormalsFromInputNormalsSPIRV32 -E FFX_CACAO_PrepareDownsampledNormalsFromInputNormals ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeNormalsFromInputNormals_32.h -Vn CSPrepareNativeNormalsFromInputNormalsSPIRV32 -E FFX_CACAO_PrepareNativeNormalsFromInputNormals ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareDownsampledDepthsHalf_32.h -Vn CSPrepareDownsampledDepthsHalfSPIRV32 -E FFX_CACAO_PrepareDownsampledDepthsHalf ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPrepareNativeDepthsHalf_32.h -Vn CSPrepareNativeDepthsHalfSPIRV32 -E FFX_CACAO_PrepareNativeDepthsHalf ffx_cacao.hlsl
|
||||
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ0_32.h -Vn CSGenerateQ0SPIRV32 -E FFX_CACAO_GenerateQ0 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ1_32.h -Vn CSGenerateQ1SPIRV32 -E FFX_CACAO_GenerateQ1 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ2_32.h -Vn CSGenerateQ2SPIRV32 -E FFX_CACAO_GenerateQ2 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ3_32.h -Vn CSGenerateQ3SPIRV32 -E FFX_CACAO_GenerateQ3 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOGenerateQ3Base_32.h -Vn CSGenerateQ3BaseSPIRV32 -E FFX_CACAO_GenerateQ3Base ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOGenerateImportanceMap_32.h -Vn CSGenerateImportanceMapSPIRV32 -E FFX_CACAO_GenerateImportanceMap ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPostprocessImportanceMapA_32.h -Vn CSPostprocessImportanceMapASPIRV32 -E FFX_CACAO_PostprocessImportanceMapA ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOPostprocessImportanceMapB_32.h -Vn CSPostprocessImportanceMapBSPIRV32 -E FFX_CACAO_PostprocessImportanceMapB ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur1_32.h -Vn CSEdgeSensitiveBlur1SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur1 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur2_32.h -Vn CSEdgeSensitiveBlur2SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur2 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur3_32.h -Vn CSEdgeSensitiveBlur3SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur3 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur4_32.h -Vn CSEdgeSensitiveBlur4SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur4 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur5_32.h -Vn CSEdgeSensitiveBlur5SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur5 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur6_32.h -Vn CSEdgeSensitiveBlur6SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur6 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur7_32.h -Vn CSEdgeSensitiveBlur7SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur7 ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOEdgeSensitiveBlur8_32.h -Vn CSEdgeSensitiveBlur8SPIRV32 -E FFX_CACAO_EdgeSensitiveBlur8 ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOApply_32.h -Vn CSApplySPIRV32 -E FFX_CACAO_Apply ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAONonSmartApply_32.h -Vn CSNonSmartApplySPIRV32 -E FFX_CACAO_NonSmartApply ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAONonSmartHalfApply_32.h -Vn CSNonSmartHalfApplySPIRV32 -E FFX_CACAO_NonSmartHalfApply ffx_cacao.hlsl
|
||||
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOUpscaleBilateral5x5Smart_32.h -Vn CSUpscaleBilateral5x5SmartSPIRV32 -E FFX_CACAO_UpscaleBilateral5x5Smart ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOUpscaleBilateral5x5NonSmart_32.h -Vn CSUpscaleBilateral5x5NonSmartSPIRV32 -E FFX_CACAO_UpscaleBilateral5x5NonSmart ffx_cacao.hlsl
|
||||
%cauldron_dxc_32% -Fh PrecompiledShadersSPIRV/CACAOUpscaleBilateral5x5Half_32.h -Vn CSUpscaleBilateral5x5HalfSPIRV32 -E FFX_CACAO_UpscaleBilateral5x5Half ffx_cacao.hlsl
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,263 @@
|
||||
// Modifications Copyright © 2021. Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2016, Intel Corporation
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
// the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// File changes (yyyy-mm-dd)
|
||||
// 2016-09-07: filip.strugar@intel.com: first commit
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ffx_cacao.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h> // cos, sin
|
||||
#include <string.h> // memcpy
|
||||
#include <stdio.h> // snprintf
|
||||
|
||||
// Define symbol to enable DirectX debug markers created using Cauldron
|
||||
#define FFX_CACAO_ENABLE_CAULDRON_DEBUG
|
||||
|
||||
#define FFX_CACAO_ASSERT(exp) assert(exp)
|
||||
#define FFX_CACAO_ARRAY_SIZE(xs) (sizeof(xs)/sizeof(xs[0]))
|
||||
#define FFX_CACAO_COS(x) cosf(x)
|
||||
#define FFX_CACAO_SIN(x) sinf(x)
|
||||
#define FFX_CACAO_MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define FFX_CACAO_MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define FFX_CACAO_CLAMP(value, lower, upper) FFX_CACAO_MIN(FFX_CACAO_MAX(value, lower), upper)
|
||||
#define FFX_CACAO_OFFSET_OF(T, member) (size_t)(&(((T*)0)->member))
|
||||
|
||||
#define MATRIX_ROW_MAJOR_ORDER 1
|
||||
static const FFX_CACAO_Matrix4x4 FFX_CACAO_IDENTITY_MATRIX = {
|
||||
{ { 1.0f, 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f } }
|
||||
};
|
||||
|
||||
void FFX_CACAO_UpdateBufferSizeInfo(uint32_t width, uint32_t height, FFX_CACAO_Bool useDownsampledSsao, FFX_CACAO_BufferSizeInfo* bsi)
|
||||
{
|
||||
uint32_t halfWidth = (width + 1) / 2;
|
||||
uint32_t halfHeight = (height + 1) / 2;
|
||||
uint32_t quarterWidth = (halfWidth + 1) / 2;
|
||||
uint32_t quarterHeight = (halfHeight + 1) / 2;
|
||||
uint32_t eighthWidth = (quarterWidth + 1) / 2;
|
||||
uint32_t eighthHeight = (quarterHeight + 1) / 2;
|
||||
|
||||
uint32_t depthBufferWidth = width;
|
||||
uint32_t depthBufferHeight = height;
|
||||
uint32_t depthBufferHalfWidth = halfWidth;
|
||||
uint32_t depthBufferHalfHeight = halfHeight;
|
||||
uint32_t depthBufferQuarterWidth = quarterWidth;
|
||||
uint32_t depthBufferQuarterHeight = quarterHeight;
|
||||
|
||||
uint32_t depthBufferXOffset = 0;
|
||||
uint32_t depthBufferYOffset = 0;
|
||||
uint32_t depthBufferHalfXOffset = 0;
|
||||
uint32_t depthBufferHalfYOffset = 0;
|
||||
uint32_t depthBufferQuarterXOffset = 0;
|
||||
uint32_t depthBufferQuarterYOffset = 0;
|
||||
|
||||
bsi->inputOutputBufferWidth = width;
|
||||
bsi->inputOutputBufferHeight = height;
|
||||
bsi->depthBufferXOffset = depthBufferXOffset;
|
||||
bsi->depthBufferYOffset = depthBufferYOffset;
|
||||
bsi->depthBufferWidth = depthBufferWidth;
|
||||
bsi->depthBufferHeight = depthBufferHeight;
|
||||
|
||||
if (useDownsampledSsao)
|
||||
{
|
||||
bsi->ssaoBufferWidth = quarterWidth;
|
||||
bsi->ssaoBufferHeight = quarterHeight;
|
||||
bsi->deinterleavedDepthBufferXOffset = depthBufferQuarterXOffset;
|
||||
bsi->deinterleavedDepthBufferYOffset = depthBufferQuarterYOffset;
|
||||
bsi->deinterleavedDepthBufferWidth = depthBufferQuarterWidth;
|
||||
bsi->deinterleavedDepthBufferHeight = depthBufferQuarterHeight;
|
||||
bsi->importanceMapWidth = eighthWidth;
|
||||
bsi->importanceMapHeight = eighthHeight;
|
||||
bsi->downsampledSsaoBufferWidth = halfWidth;
|
||||
bsi->downsampledSsaoBufferHeight = halfHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
bsi->ssaoBufferWidth = halfWidth;
|
||||
bsi->ssaoBufferHeight = halfHeight;
|
||||
bsi->deinterleavedDepthBufferXOffset = depthBufferHalfXOffset;
|
||||
bsi->deinterleavedDepthBufferYOffset = depthBufferHalfYOffset;
|
||||
bsi->deinterleavedDepthBufferWidth = depthBufferHalfWidth;
|
||||
bsi->deinterleavedDepthBufferHeight = depthBufferHalfHeight;
|
||||
bsi->importanceMapWidth = quarterWidth;
|
||||
bsi->importanceMapHeight = quarterHeight;
|
||||
bsi->downsampledSsaoBufferWidth = 1;
|
||||
bsi->downsampledSsaoBufferHeight = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void FFX_CACAO_UpdateConstants(FFX_CACAO_Constants* consts, const FFX_CACAO_Settings* settings, const FFX_CACAO_BufferSizeInfo* bufferSizeInfo, const FFX_CACAO_Matrix4x4* proj, const FFX_CACAO_Matrix4x4* normalsToView)
|
||||
{
|
||||
consts->BilateralSigmaSquared = settings->bilateralSigmaSquared;
|
||||
consts->BilateralSimilarityDistanceSigma = settings->bilateralSimilarityDistanceSigma;
|
||||
|
||||
if (settings->generateNormals)
|
||||
{
|
||||
consts->NormalsWorldToViewspaceMatrix = FFX_CACAO_IDENTITY_MATRIX;
|
||||
}
|
||||
else
|
||||
{
|
||||
consts->NormalsWorldToViewspaceMatrix = *normalsToView;
|
||||
}
|
||||
|
||||
// used to get average load per pixel; 9.0 is there to compensate for only doing every 9th InterlockedAdd in PSPostprocessImportanceMapB for performance reasons
|
||||
consts->LoadCounterAvgDiv = 9.0f / (float)(bufferSizeInfo->importanceMapWidth * bufferSizeInfo->importanceMapHeight * 255.0);
|
||||
|
||||
float depthLinearizeMul = (MATRIX_ROW_MAJOR_ORDER) ? (-proj->elements[3][2]) : (-proj->elements[2][3]); // float depthLinearizeMul = ( clipFar * clipNear ) / ( clipFar - clipNear );
|
||||
float depthLinearizeAdd = (MATRIX_ROW_MAJOR_ORDER) ? (proj->elements[2][2]) : (proj->elements[2][2]); // float depthLinearizeAdd = clipFar / ( clipFar - clipNear );
|
||||
// correct the handedness issue. need to make sure this below is correct, but I think it is.
|
||||
if (depthLinearizeMul * depthLinearizeAdd < 0)
|
||||
depthLinearizeAdd = -depthLinearizeAdd;
|
||||
consts->DepthUnpackConsts[0] = depthLinearizeMul;
|
||||
consts->DepthUnpackConsts[1] = depthLinearizeAdd;
|
||||
|
||||
float tanHalfFOVY = 1.0f / proj->elements[1][1]; // = tanf( drawContext.Camera.GetYFOV( ) * 0.5f );
|
||||
float tanHalfFOVX = 1.0F / proj->elements[0][0]; // = tanHalfFOVY * drawContext.Camera.GetAspect( );
|
||||
consts->CameraTanHalfFOV[0] = tanHalfFOVX;
|
||||
consts->CameraTanHalfFOV[1] = tanHalfFOVY;
|
||||
|
||||
consts->NDCToViewMul[0] = consts->CameraTanHalfFOV[0] * 2.0f;
|
||||
consts->NDCToViewMul[1] = consts->CameraTanHalfFOV[1] * -2.0f;
|
||||
consts->NDCToViewAdd[0] = consts->CameraTanHalfFOV[0] * -1.0f;
|
||||
consts->NDCToViewAdd[1] = consts->CameraTanHalfFOV[1] * 1.0f;
|
||||
|
||||
float ratio = ((float)bufferSizeInfo->inputOutputBufferWidth) / ((float)bufferSizeInfo->depthBufferWidth);
|
||||
float border = (1.0f - ratio) / 2.0f;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
consts->DepthBufferUVToViewMul[i] = consts->NDCToViewMul[i] / ratio;
|
||||
consts->DepthBufferUVToViewAdd[i] = consts->NDCToViewAdd[i] - consts->NDCToViewMul[i] * border / ratio;
|
||||
}
|
||||
|
||||
consts->EffectRadius = FFX_CACAO_CLAMP(settings->radius, 0.0f, 100000.0f);
|
||||
consts->EffectShadowStrength = FFX_CACAO_CLAMP(settings->shadowMultiplier * 4.3f, 0.0f, 10.0f);
|
||||
consts->EffectShadowPow = FFX_CACAO_CLAMP(settings->shadowPower, 0.0f, 10.0f);
|
||||
consts->EffectShadowClamp = FFX_CACAO_CLAMP(settings->shadowClamp, 0.0f, 1.0f);
|
||||
consts->EffectFadeOutMul = -1.0f / (settings->fadeOutTo - settings->fadeOutFrom);
|
||||
consts->EffectFadeOutAdd = settings->fadeOutFrom / (settings->fadeOutTo - settings->fadeOutFrom) + 1.0f;
|
||||
consts->EffectHorizonAngleThreshold = FFX_CACAO_CLAMP(settings->horizonAngleThreshold, 0.0f, 1.0f);
|
||||
|
||||
// 1.2 seems to be around the best trade off - 1.0 means on-screen radius will stop/slow growing when the camera is at 1.0 distance, so, depending on FOV, basically filling up most of the screen
|
||||
// This setting is viewspace-dependent and not screen size dependent intentionally, so that when you change FOV the effect stays (relatively) similar.
|
||||
float effectSamplingRadiusNearLimit = (settings->radius * 1.2f);
|
||||
|
||||
// if the depth precision is switched to 32bit float, this can be set to something closer to 1 (0.9999 is fine)
|
||||
consts->DepthPrecisionOffsetMod = 0.9992f;
|
||||
|
||||
// Special settings for lowest quality level - just nerf the effect a tiny bit
|
||||
if (settings->qualityLevel <= FFX_CACAO_QUALITY_LOW)
|
||||
{
|
||||
//consts.EffectShadowStrength *= 0.9f;
|
||||
effectSamplingRadiusNearLimit *= 1.50f;
|
||||
|
||||
if (settings->qualityLevel == FFX_CACAO_QUALITY_LOWEST)
|
||||
consts->EffectRadius *= 0.8f;
|
||||
}
|
||||
|
||||
effectSamplingRadiusNearLimit /= tanHalfFOVY; // to keep the effect same regardless of FOV
|
||||
|
||||
consts->EffectSamplingRadiusNearLimitRec = 1.0f / effectSamplingRadiusNearLimit;
|
||||
|
||||
consts->AdaptiveSampleCountLimit = settings->adaptiveQualityLimit;
|
||||
|
||||
consts->NegRecEffectRadius = -1.0f / consts->EffectRadius;
|
||||
|
||||
consts->InvSharpness = FFX_CACAO_CLAMP(1.0f - settings->sharpness, 0.0f, 1.0f);
|
||||
|
||||
consts->DetailAOStrength = settings->detailShadowStrength;
|
||||
|
||||
// set buffer size constants.
|
||||
consts->SSAOBufferDimensions[0] = (float)bufferSizeInfo->ssaoBufferWidth;
|
||||
consts->SSAOBufferDimensions[1] = (float)bufferSizeInfo->ssaoBufferHeight;
|
||||
consts->SSAOBufferInverseDimensions[0] = 1.0f / ((float)bufferSizeInfo->ssaoBufferWidth);
|
||||
consts->SSAOBufferInverseDimensions[1] = 1.0f / ((float)bufferSizeInfo->ssaoBufferHeight);
|
||||
|
||||
consts->DepthBufferDimensions[0] = (float)bufferSizeInfo->depthBufferWidth;
|
||||
consts->DepthBufferDimensions[1] = (float)bufferSizeInfo->depthBufferHeight;
|
||||
consts->DepthBufferInverseDimensions[0] = 1.0f / ((float)bufferSizeInfo->depthBufferWidth);
|
||||
consts->DepthBufferInverseDimensions[1] = 1.0f / ((float)bufferSizeInfo->depthBufferHeight);
|
||||
|
||||
consts->DepthBufferOffset[0] = bufferSizeInfo->depthBufferXOffset;
|
||||
consts->DepthBufferOffset[1] = bufferSizeInfo->depthBufferYOffset;
|
||||
|
||||
consts->InputOutputBufferDimensions[0] = (float)bufferSizeInfo->inputOutputBufferWidth;
|
||||
consts->InputOutputBufferDimensions[1] = (float)bufferSizeInfo->inputOutputBufferHeight;
|
||||
consts->InputOutputBufferInverseDimensions[0] = 1.0f / ((float)bufferSizeInfo->inputOutputBufferWidth);
|
||||
consts->InputOutputBufferInverseDimensions[1] = 1.0f / ((float)bufferSizeInfo->inputOutputBufferHeight);
|
||||
|
||||
consts->ImportanceMapDimensions[0] = (float)bufferSizeInfo->importanceMapWidth;
|
||||
consts->ImportanceMapDimensions[1] = (float)bufferSizeInfo->importanceMapHeight;
|
||||
consts->ImportanceMapInverseDimensions[0] = 1.0f / ((float)bufferSizeInfo->importanceMapWidth);
|
||||
consts->ImportanceMapInverseDimensions[1] = 1.0f / ((float)bufferSizeInfo->importanceMapHeight);
|
||||
|
||||
consts->DeinterleavedDepthBufferDimensions[0] = (float)bufferSizeInfo->deinterleavedDepthBufferWidth;
|
||||
consts->DeinterleavedDepthBufferDimensions[1] = (float)bufferSizeInfo->deinterleavedDepthBufferHeight;
|
||||
consts->DeinterleavedDepthBufferInverseDimensions[0] = 1.0f / ((float)bufferSizeInfo->deinterleavedDepthBufferWidth);
|
||||
consts->DeinterleavedDepthBufferInverseDimensions[1] = 1.0f / ((float)bufferSizeInfo->deinterleavedDepthBufferHeight);
|
||||
|
||||
consts->DeinterleavedDepthBufferOffset[0] = (float)bufferSizeInfo->deinterleavedDepthBufferXOffset;
|
||||
consts->DeinterleavedDepthBufferOffset[1] = (float)bufferSizeInfo->deinterleavedDepthBufferYOffset;
|
||||
consts->DeinterleavedDepthBufferNormalisedOffset[0] = ((float)bufferSizeInfo->deinterleavedDepthBufferXOffset) / ((float)bufferSizeInfo->deinterleavedDepthBufferWidth);
|
||||
consts->DeinterleavedDepthBufferNormalisedOffset[1] = ((float)bufferSizeInfo->deinterleavedDepthBufferYOffset) / ((float)bufferSizeInfo->deinterleavedDepthBufferHeight);
|
||||
|
||||
if (!settings->generateNormals)
|
||||
{
|
||||
consts->NormalsUnpackMul = 2.0f; // inputs->NormalsUnpackMul;
|
||||
consts->NormalsUnpackAdd = -1.0f; // inputs->NormalsUnpackAdd;
|
||||
}
|
||||
else
|
||||
{
|
||||
consts->NormalsUnpackMul = 2.0f;
|
||||
consts->NormalsUnpackAdd = -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void FFX_CACAO_UpdatePerPassConstants(FFX_CACAO_Constants* consts, const FFX_CACAO_Settings* settings, const FFX_CACAO_BufferSizeInfo* bufferSizeInfo, int pass)
|
||||
{
|
||||
consts->PerPassFullResUVOffset[0] = ((float)(pass % 2)) / (float)bufferSizeInfo->ssaoBufferWidth;
|
||||
consts->PerPassFullResUVOffset[1] = ((float)(pass / 2)) / (float)bufferSizeInfo->ssaoBufferHeight;
|
||||
|
||||
consts->PassIndex = pass;
|
||||
|
||||
float additionalAngleOffset = settings->temporalSupersamplingAngleOffset; // if using temporal supersampling approach (like "Progressive Rendering Using Multi-frame Sampling" from GPU Pro 7, etc.)
|
||||
float additionalRadiusScale = settings->temporalSupersamplingRadiusOffset; // if using temporal supersampling approach (like "Progressive Rendering Using Multi-frame Sampling" from GPU Pro 7, etc.)
|
||||
const int subPassCount = 5;
|
||||
for (int subPass = 0; subPass < subPassCount; subPass++)
|
||||
{
|
||||
int a = pass;
|
||||
int b = subPass;
|
||||
|
||||
int spmap[5]{ 0, 1, 4, 3, 2 };
|
||||
b = spmap[subPass];
|
||||
|
||||
float ca, sa;
|
||||
float angle0 = ((float)a + (float)b / (float)subPassCount) * (3.1415926535897932384626433832795f) * 0.5f;
|
||||
|
||||
ca = FFX_CACAO_COS(angle0);
|
||||
sa = FFX_CACAO_SIN(angle0);
|
||||
|
||||
float scale = 1.0f + (a - 1.5f + (b - (subPassCount - 1.0f) * 0.5f) / (float)subPassCount) * 0.07f;
|
||||
|
||||
consts->PatternRotScaleMatrices[subPass][0] = scale * ca;
|
||||
consts->PatternRotScaleMatrices[subPass][1] = scale * -sa;
|
||||
consts->PatternRotScaleMatrices[subPass][2] = -scale * sa;
|
||||
consts->PatternRotScaleMatrices[subPass][3] = -scale * ca;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,367 @@
|
||||
// Modifications Copyright © 2021. Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2016, Intel Corporation
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
// the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// File changes (yyyy-mm-dd)
|
||||
// 2016-09-07: filip.strugar@intel.com: first commit
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef FFX_CACAO_BINDINGS_HLSL
|
||||
#define FFX_CACAO_BINDINGS_HLSL
|
||||
|
||||
// =============================================================================
|
||||
// Constants
|
||||
|
||||
struct FFX_CACAO_Constants
|
||||
{
|
||||
float2 DepthUnpackConsts;
|
||||
float2 CameraTanHalfFOV;
|
||||
|
||||
float2 NDCToViewMul;
|
||||
float2 NDCToViewAdd;
|
||||
|
||||
float2 DepthBufferUVToViewMul;
|
||||
float2 DepthBufferUVToViewAdd;
|
||||
|
||||
float EffectRadius; // world (viewspace) maximum size of the shadow
|
||||
float EffectShadowStrength; // global strength of the effect (0 - 5)
|
||||
float EffectShadowPow;
|
||||
float EffectShadowClamp;
|
||||
|
||||
float EffectFadeOutMul; // effect fade out from distance (ex. 25)
|
||||
float EffectFadeOutAdd; // effect fade out to distance (ex. 100)
|
||||
float EffectHorizonAngleThreshold; // limit errors on slopes and caused by insufficient geometry tessellation (0.05 to 0.5)
|
||||
float EffectSamplingRadiusNearLimitRec; // if viewspace pixel closer than this, don't enlarge shadow sampling radius anymore (makes no sense to grow beyond some distance, not enough samples to cover everything, so just limit the shadow growth; could be SSAOSettingsFadeOutFrom * 0.1 or less)
|
||||
|
||||
float DepthPrecisionOffsetMod;
|
||||
float NegRecEffectRadius; // -1.0 / EffectRadius
|
||||
float LoadCounterAvgDiv; // 1.0 / ( halfDepthMip[SSAO_DEPTH_MIP_LEVELS-1].sizeX * halfDepthMip[SSAO_DEPTH_MIP_LEVELS-1].sizeY )
|
||||
float AdaptiveSampleCountLimit;
|
||||
|
||||
float InvSharpness;
|
||||
int PassIndex;
|
||||
float BilateralSigmaSquared;
|
||||
float BilateralSimilarityDistanceSigma;
|
||||
|
||||
float4 PatternRotScaleMatrices[5];
|
||||
|
||||
float NormalsUnpackMul;
|
||||
float NormalsUnpackAdd;
|
||||
float DetailAOStrength;
|
||||
float Dummy0;
|
||||
|
||||
float2 SSAOBufferDimensions;
|
||||
float2 SSAOBufferInverseDimensions;
|
||||
|
||||
float2 DepthBufferDimensions;
|
||||
float2 DepthBufferInverseDimensions;
|
||||
|
||||
int2 DepthBufferOffset;
|
||||
float2 PerPassFullResUVOffset;
|
||||
|
||||
float2 OutputBufferDimensions;
|
||||
float2 OutputBufferInverseDimensions;
|
||||
|
||||
float2 ImportanceMapDimensions;
|
||||
float2 ImportanceMapInverseDimensions;
|
||||
|
||||
float2 DeinterleavedDepthBufferDimensions;
|
||||
float2 DeinterleavedDepthBufferInverseDimensions;
|
||||
|
||||
float2 DeinterleavedDepthBufferOffset;
|
||||
float2 DeinterleavedDepthBufferNormalisedOffset;
|
||||
|
||||
float4x4 NormalsWorldToViewspaceMatrix;
|
||||
};
|
||||
|
||||
cbuffer SSAOConstantsBuffer : register(b0)
|
||||
{
|
||||
FFX_CACAO_Constants g_FFX_CACAO_Consts;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Samplers
|
||||
|
||||
SamplerState g_PointClampSampler : register(s0);
|
||||
SamplerState g_PointMirrorSampler : register(s1);
|
||||
SamplerState g_LinearClampSampler : register(s2);
|
||||
SamplerState g_ViewspaceDepthTapSampler : register(s3);
|
||||
SamplerState g_RealPointClampSampler : register(s4);
|
||||
|
||||
// =============================================================================
|
||||
// Clear Load Counter
|
||||
|
||||
RWTexture1D<uint> g_ClearLoadCounter_LoadCounter : register(u0);
|
||||
|
||||
void FFX_CACAO_ClearLoadCounter_SetLoadCounter(uint val)
|
||||
{
|
||||
g_ClearLoadCounter_LoadCounter[0] = val;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Edge Sensitive Blur
|
||||
|
||||
Texture2DArray<float2> g_EdgeSensitiveBlur_Input : register(t0);
|
||||
RWTexture2DArray<float2> g_EdgeSensitiveBlur_Output : register(u0);
|
||||
|
||||
float2 FFX_CACAO_EdgeSensitiveBlur_SampleInputOffset(float2 uv, int2 offset)
|
||||
{
|
||||
return g_EdgeSensitiveBlur_Input.SampleLevel(g_PointMirrorSampler, float3(uv, 0.0f), 0.0f, offset);
|
||||
}
|
||||
|
||||
float2 FFX_CACAO_EdgeSensitiveBlur_SampleInput(float2 uv)
|
||||
{
|
||||
return g_EdgeSensitiveBlur_Input.SampleLevel(g_PointMirrorSampler, float3(uv, 0.0f), 0.0f);
|
||||
}
|
||||
|
||||
void FFX_CACAO_EdgeSensitiveBlur_StoreOutput(int2 coord, float2 value)
|
||||
{
|
||||
g_EdgeSensitiveBlur_Output[int3(coord, 0)] = value;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// SSAO Generation
|
||||
|
||||
Texture2DArray<float> g_ViewspaceDepthSource : register(t0);
|
||||
Texture2DArray<float4> g_DeinterleavedNormals : register(t1);
|
||||
Texture1D<uint> g_LoadCounter : register(t2);
|
||||
Texture2D<float> g_ImportanceMap : register(t3);
|
||||
Texture2DArray<float2> g_FinalSSAO : register(t4);
|
||||
|
||||
RWTexture2DArray<float2> g_SSAOOutput : register(u0);
|
||||
|
||||
float FFX_CACAO_SSAOGeneration_SampleViewspaceDepthMip(float2 uv, float mip)
|
||||
{
|
||||
return g_ViewspaceDepthSource.SampleLevel(g_ViewspaceDepthTapSampler, float3(uv, 0.0f), mip);
|
||||
}
|
||||
|
||||
float4 FFX_CACAO_SSAOGeneration_GatherViewspaceDepthOffset(float2 uv, int2 offset)
|
||||
{
|
||||
return g_ViewspaceDepthSource.GatherRed(g_PointMirrorSampler, float3(uv, 0.0f), offset);
|
||||
}
|
||||
|
||||
uint FFX_CACAO_SSAOGeneration_GetLoadCounter()
|
||||
{
|
||||
return g_LoadCounter[0];
|
||||
}
|
||||
|
||||
float FFX_CACAO_SSAOGeneration_SampleImportance(float2 uv)
|
||||
{
|
||||
return g_ImportanceMap.SampleLevel(g_LinearClampSampler, uv, 0.0f);
|
||||
}
|
||||
|
||||
float2 FFX_CACAO_SSAOGeneration_LoadBasePassSSAOPass(int2 coord, int pass)
|
||||
{
|
||||
return g_FinalSSAO.Load(int4(coord, pass, 0)).xy;
|
||||
}
|
||||
|
||||
float3 FFX_CACAO_SSAOGeneration_GetNormalPass(int2 coord, int pass)
|
||||
{
|
||||
return g_DeinterleavedNormals[int3(coord, pass)].xyz;
|
||||
}
|
||||
|
||||
void FFX_CACAO_SSAOGeneration_StoreOutput(int2 coord, float2 val)
|
||||
{
|
||||
g_SSAOOutput[int3(coord, 0)] = val;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Apply
|
||||
|
||||
Texture2DArray<float2> g_ApplyFinalSSAO : register(t0);
|
||||
RWTexture2D<float> g_ApplyOutput : register(u0);
|
||||
|
||||
float FFX_CACAO_Apply_SampleSSAOUVPass(float2 uv, int pass)
|
||||
{
|
||||
return g_ApplyFinalSSAO.SampleLevel(g_LinearClampSampler, float3(uv, pass), 0.0f).x;
|
||||
}
|
||||
|
||||
float2 FFX_CACAO_Apply_LoadSSAOPass(int2 coord, int pass)
|
||||
{
|
||||
return g_ApplyFinalSSAO.Load(int4(coord, pass, 0));
|
||||
}
|
||||
|
||||
void FFX_CACAO_Apply_StoreOutput(int2 coord, float val)
|
||||
{
|
||||
g_ApplyOutput[coord] = val;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Prepare
|
||||
|
||||
Texture2D<float> g_DepthIn : register(t0);
|
||||
Texture2D<float4> g_PrepareNormalsFromNormalsInput : register(t0);
|
||||
|
||||
RWTexture2DArray<float> g_PrepareDepthsAndMips_OutMip0 : register(u0);
|
||||
RWTexture2DArray<float> g_PrepareDepthsAndMips_OutMip1 : register(u1);
|
||||
RWTexture2DArray<float> g_PrepareDepthsAndMips_OutMip2 : register(u2);
|
||||
RWTexture2DArray<float> g_PrepareDepthsAndMips_OutMip3 : register(u3);
|
||||
|
||||
RWTexture2DArray<float> g_PrepareDepthsOut : register(u0);
|
||||
|
||||
RWTexture2DArray<float4> g_PrepareNormals_NormalOut : register(u0);
|
||||
|
||||
float FFX_CACAO_Prepare_SampleDepthOffset(float2 uv, int2 offset)
|
||||
{
|
||||
return g_DepthIn.SampleLevel(g_PointClampSampler, uv, 0.0f, offset);
|
||||
}
|
||||
|
||||
float4 FFX_CACAO_Prepare_GatherDepth(float2 uv)
|
||||
{
|
||||
return g_DepthIn.GatherRed(g_PointClampSampler, uv);
|
||||
}
|
||||
|
||||
float FFX_CACAO_Prepare_LoadDepth(int2 coord)
|
||||
{
|
||||
return g_DepthIn.Load(int3(coord, 0));
|
||||
}
|
||||
|
||||
float FFX_CACAO_Prepare_LoadDepthOffset(int2 coord, int2 offset)
|
||||
{
|
||||
return g_DepthIn.Load(int3(coord, 0), offset);
|
||||
}
|
||||
|
||||
float4 FFX_CACAO_Prepare_GatherDepthOffset(float2 uv, int2 offset)
|
||||
{
|
||||
return g_DepthIn.GatherRed(g_PointClampSampler, uv, offset);
|
||||
}
|
||||
|
||||
float3 FFX_CACAO_Prepare_LoadNormal(int2 coord)
|
||||
{
|
||||
float3 normal = g_PrepareNormalsFromNormalsInput.Load(int3(coord, 0)).xyz;
|
||||
normal = normal * g_FFX_CACAO_Consts.NormalsUnpackMul.xxx + g_FFX_CACAO_Consts.NormalsUnpackAdd.xxx;
|
||||
normal = mul(normal, (float3x3)g_FFX_CACAO_Consts.NormalsWorldToViewspaceMatrix).xyz;
|
||||
// normal = normalize(normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Prepare_StoreDepthMip0(int2 coord, int index, float val)
|
||||
{
|
||||
g_PrepareDepthsAndMips_OutMip0[int3(coord, index)] = val;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Prepare_StoreDepthMip1(int2 coord, int index, float val)
|
||||
{
|
||||
g_PrepareDepthsAndMips_OutMip1[int3(coord, index)] = val;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Prepare_StoreDepthMip2(int2 coord, int index, float val)
|
||||
{
|
||||
g_PrepareDepthsAndMips_OutMip2[int3(coord, index)] = val;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Prepare_StoreDepthMip3(int2 coord, int index, float val)
|
||||
{
|
||||
g_PrepareDepthsAndMips_OutMip3[int3(coord, index)] = val;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Prepare_StoreDepth(int2 coord, int index, float val)
|
||||
{
|
||||
g_PrepareDepthsOut[int3(coord, index)] = val;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Prepare_StoreNormal(int2 coord, int index, float3 normal)
|
||||
{
|
||||
g_PrepareNormals_NormalOut[int3(coord, index)] = float4(normal, 1.0f);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Importance Map
|
||||
|
||||
Texture2DArray<float2> g_ImportanceFinalSSAO : register(t0);
|
||||
RWTexture2D<float> g_ImportanceOut : register(u0);
|
||||
|
||||
Texture2D<float> g_ImportanceAIn : register(t0);
|
||||
RWTexture2D<float> g_ImportanceAOut : register(u0);
|
||||
|
||||
Texture2D<float> g_ImportanceBIn : register(t0);
|
||||
RWTexture2D<float> g_ImportanceBOut : register(u0);
|
||||
RWTexture1D<uint> g_ImportanceBLoadCounter : register(u1);
|
||||
|
||||
float4 FFX_CACAO_Importance_GatherSSAO(float2 uv, int index)
|
||||
{
|
||||
return g_ImportanceFinalSSAO.GatherRed(g_PointClampSampler, float3(uv, index));
|
||||
}
|
||||
|
||||
void FFX_CACAO_Importance_StoreImportance(int2 coord, float val)
|
||||
{
|
||||
g_ImportanceOut[coord] = val;
|
||||
}
|
||||
|
||||
float FFX_CACAO_Importance_SampleImportanceA(float2 uv)
|
||||
{
|
||||
return g_ImportanceAIn.SampleLevel(g_LinearClampSampler, uv, 0.0f);
|
||||
}
|
||||
|
||||
void FFX_CACAO_Importance_StoreImportanceA(int2 coord, float val)
|
||||
{
|
||||
g_ImportanceAOut[coord] = val;
|
||||
}
|
||||
|
||||
float FFX_CACAO_Importance_SampleImportanceB(float2 uv)
|
||||
{
|
||||
return g_ImportanceBIn.SampleLevel(g_LinearClampSampler, uv, 0.0f);
|
||||
}
|
||||
|
||||
void FFX_CACAO_Importance_StoreImportanceB(int2 coord, float val)
|
||||
{
|
||||
g_ImportanceBOut[coord] = val;
|
||||
}
|
||||
|
||||
void FFX_CACAO_Importance_LoadCounterInterlockedAdd(uint val)
|
||||
{
|
||||
InterlockedAdd(g_ImportanceBLoadCounter[0], val);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Bilateral Upscale
|
||||
|
||||
RWTexture2D<float> g_BilateralUpscaleOutput : register(u0);
|
||||
|
||||
Texture2DArray<float2> g_BilateralUpscaleInput : register(t0);
|
||||
Texture2D<float> g_BilateralUpscaleDepth : register(t1);
|
||||
Texture2DArray<float> g_BilateralUpscaleDownscaledDepth : register(t2);
|
||||
|
||||
void FFX_CACAO_BilateralUpscale_StoreOutput(int2 coord, int2 offset, float val)
|
||||
{
|
||||
g_BilateralUpscaleOutput[coord + offset] = val;
|
||||
}
|
||||
|
||||
float FFX_CACAO_BilateralUpscale_SampleSSAOLinear(float2 uv, int index)
|
||||
{
|
||||
return g_BilateralUpscaleInput.SampleLevel(g_LinearClampSampler, float3(uv, index), 0).x;
|
||||
}
|
||||
|
||||
float FFX_CACAO_BilateralUpscale_SampleSSAOPoint(float2 uv, int index)
|
||||
{
|
||||
return g_BilateralUpscaleInput.SampleLevel(g_PointClampSampler, float3(uv, index), 0).x;
|
||||
}
|
||||
|
||||
float2 FFX_CACAO_BilateralUpscale_LoadSSAO(int2 coord, int index)
|
||||
{
|
||||
return g_BilateralUpscaleInput.Load(int4(coord, index, 0));
|
||||
}
|
||||
|
||||
float FFX_CACAO_BilateralUpscale_LoadDepth(int2 coord, int2 offset)
|
||||
{
|
||||
return g_BilateralUpscaleDepth.Load(int3(coord, 0), offset);
|
||||
}
|
||||
|
||||
float FFX_CACAO_BilateralUpscale_LoadDownscaledDepth(int2 coord, int index)
|
||||
{
|
||||
return g_BilateralUpscaleDownscaledDepth.Load(int4(coord, index, 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
// Modifications Copyright © 2021. Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2016, Intel Corporation
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
// the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// File changes (yyyy-mm-dd)
|
||||
// 2016-09-07: filip.strugar@intel.com: first commit
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Defines for constants common to both CACAO.cpp and CACAO.hlsl
|
||||
|
||||
#ifndef FFX_CACAO_DEFINES_H
|
||||
#define FFX_CACAO_DEFINES_H
|
||||
|
||||
// ============================================================================
|
||||
// Prepare
|
||||
|
||||
#define FFX_CACAO_PREPARE_DEPTHS_AND_MIPS_WIDTH 8
|
||||
#define FFX_CACAO_PREPARE_DEPTHS_AND_MIPS_HEIGHT 8
|
||||
|
||||
#define FFX_CACAO_PREPARE_DEPTHS_WIDTH 8
|
||||
#define FFX_CACAO_PREPARE_DEPTHS_HEIGHT 8
|
||||
|
||||
#define FFX_CACAO_PREPARE_DEPTHS_HALF_WIDTH 8
|
||||
#define FFX_CACAO_PREPARE_DEPTHS_HALF_HEIGHT 8
|
||||
|
||||
#define FFX_CACAO_PREPARE_NORMALS_WIDTH 8
|
||||
#define FFX_CACAO_PREPARE_NORMALS_HEIGHT 8
|
||||
|
||||
#define PREPARE_NORMALS_FROM_INPUT_NORMALS_WIDTH 8
|
||||
#define PREPARE_NORMALS_FROM_INPUT_NORMALS_HEIGHT 8
|
||||
|
||||
// ============================================================================
|
||||
// SSAO Generation
|
||||
|
||||
#define FFX_CACAO_GENERATE_SPARSE_WIDTH 4
|
||||
#define FFX_CACAO_GENERATE_SPARSE_HEIGHT 16
|
||||
|
||||
#define FFX_CACAO_GENERATE_WIDTH 8
|
||||
#define FFX_CACAO_GENERATE_HEIGHT 8
|
||||
|
||||
// ============================================================================
|
||||
// Importance Map
|
||||
|
||||
#define IMPORTANCE_MAP_WIDTH 8
|
||||
#define IMPORTANCE_MAP_HEIGHT 8
|
||||
|
||||
#define IMPORTANCE_MAP_A_WIDTH 8
|
||||
#define IMPORTANCE_MAP_A_HEIGHT 8
|
||||
|
||||
#define IMPORTANCE_MAP_B_WIDTH 8
|
||||
#define IMPORTANCE_MAP_B_HEIGHT 8
|
||||
|
||||
// ============================================================================
|
||||
// Edge Sensitive Blur
|
||||
|
||||
#define FFX_CACAO_BLUR_WIDTH 16
|
||||
#define FFX_CACAO_BLUR_HEIGHT 16
|
||||
|
||||
// ============================================================================
|
||||
// Apply
|
||||
|
||||
#define FFX_CACAO_APPLY_WIDTH 8
|
||||
#define FFX_CACAO_APPLY_HEIGHT 8
|
||||
|
||||
// ============================================================================
|
||||
// Bilateral Upscale
|
||||
|
||||
#define FFX_CACAO_BILATERAL_UPSCALE_WIDTH 8
|
||||
#define FFX_CACAO_BILATERAL_UPSCALE_HEIGHT 8
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user