| 123 | } |
| 124 | |
| 125 | Tr2GpuResourcePool::Texture Tr2SSAO::PerformPass( const Layer& layer, const Tr2TextureAL& depthBuffer, const Tr2TextureAL& normalBuffer, bool reuseNormals, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) |
| 126 | { |
| 127 | m_detail.effect->SetOption( BlueSharedString( "SSAO_INPUT_2D_TEXTURE_TYPE" ), BlueSharedString( depthBuffer.GetMsaaDesc().samples > 1 ? "TEXTURE_2DMS" : "TEXTURE_2D" ) ); |
| 128 | |
| 129 | FFX_CACAO_BufferSizeInfo size{}; |
| 130 | FFX_CACAO_UpdateBufferSizeInfo( depthBuffer.GetWidth(), depthBuffer.GetHeight(), layer.downsampled, &size ); |
| 131 | if( !size.importanceMapWidth || !size.importanceMapHeight ) |
| 132 | { |
| 133 | return {}; |
| 134 | } |
| 135 | |
| 136 | for( unsigned i = 0; i <= SSAO_PASS_COUNT; i++ ) |
| 137 | { |
| 138 | if( !m_constBuffers[i].IsValid() ) |
| 139 | { |
| 140 | CR_RETURN_VAL( m_constBuffers[i].Create( sizeof( FFX_CACAO_Constants ), renderContext.GetPrimaryRenderContext() ), {} ); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | |
| 145 | // From CACAO sample project |
| 146 | FFX_CACAO_Matrix4x4 proj{}, normalsWorldToView{}; |
| 147 | { |
| 148 | XMFLOAT4X4 p; |
| 149 | XMMATRIX xProj = Tr2Renderer::GetReversedDepthProjectionTransform(); |
| 150 | XMStoreFloat4x4( &p, xProj ); |
| 151 | proj.elements[0][0] = p._11; |
| 152 | proj.elements[0][1] = p._12; |
| 153 | proj.elements[0][2] = p._13; |
| 154 | proj.elements[0][3] = p._14; |
| 155 | proj.elements[1][0] = p._21; |
| 156 | proj.elements[1][1] = p._22; |
| 157 | proj.elements[1][2] = p._23; |
| 158 | proj.elements[1][3] = p._24; |
| 159 | proj.elements[2][0] = p._31; |
| 160 | proj.elements[2][1] = p._32; |
| 161 | proj.elements[2][2] = p._33; |
| 162 | proj.elements[2][3] = p._34; |
| 163 | proj.elements[3][0] = p._41; |
| 164 | proj.elements[3][1] = p._42; |
| 165 | proj.elements[3][2] = p._43; |
| 166 | proj.elements[3][3] = p._44; |
| 167 | XMMATRIX xNormalsWorldToView = XMMATRIX( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 ) * Tr2Renderer::GetInverseViewTransform(); // should be transpose(inverse(view)), but XMM is row-major and HLSL is column-major |
| 168 | XMStoreFloat4x4( &p, xNormalsWorldToView ); |
| 169 | normalsWorldToView.elements[0][0] = p._11; |
| 170 | normalsWorldToView.elements[0][1] = p._12; |
| 171 | normalsWorldToView.elements[0][2] = p._13; |
| 172 | normalsWorldToView.elements[0][3] = p._14; |
| 173 | normalsWorldToView.elements[1][0] = p._21; |
| 174 | normalsWorldToView.elements[1][1] = p._22; |
| 175 | normalsWorldToView.elements[1][2] = p._23; |
| 176 | normalsWorldToView.elements[1][3] = p._24; |
| 177 | normalsWorldToView.elements[2][0] = p._31; |
| 178 | normalsWorldToView.elements[2][1] = p._32; |
| 179 | normalsWorldToView.elements[2][2] = p._33; |
| 180 | normalsWorldToView.elements[2][3] = p._34; |
| 181 | normalsWorldToView.elements[3][0] = p._41; |
| 182 | normalsWorldToView.elements[3][1] = p._42; |
nothing calls this directly
no test coverage detected