| 207 | } |
| 208 | |
| 209 | void Tr2Material::ApplyMaterialDataForPass( uint32_t techniqueIndex, unsigned int passIndex, Tr2RenderContext& renderContext ) const |
| 210 | { |
| 211 | if( !m_shader ) |
| 212 | { |
| 213 | return; |
| 214 | } |
| 215 | unsigned mask = m_shader->GetShaderTypeMask( techniqueIndex ); |
| 216 | auto& pp = *m_parametersForPasses[techniqueIndex].passes[passIndex]; |
| 217 | bool descChanged = pp.m_resourceSetDirty; |
| 218 | for( unsigned i = 0; i != Tr2RenderContextEnum::SHADER_TYPE_COUNT && mask; ++i ) |
| 219 | { |
| 220 | if( mask & ( 1 << i ) ) |
| 221 | { |
| 222 | descChanged |= ApplyShaderInputs( techniqueIndex, passIndex, Tr2RenderContextEnum::ShaderType( i ), renderContext ); |
| 223 | mask &= ~( 1 << i ); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | if( descChanged || !pp.m_resourceSet.IsValid() ) |
| 228 | { |
| 229 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 230 | |
| 231 | CCP_STATS_INC( effectResourceSetCreated ); |
| 232 | |
| 233 | auto sp = renderContext.m_esm.GetShaderProgram( m_shader->GetEffect().techniques[techniqueIndex].passes[passIndex].shaderProgram ); |
| 234 | if( !sp ) |
| 235 | { |
| 236 | return; |
| 237 | } |
| 238 | pp.m_resourceSet.Create( pp.m_resourceSetDesc, *sp, renderContext ); |
| 239 | pp.m_resourceSetHash = pp.m_resourceSetDesc.ComputeHash(); |
| 240 | pp.m_resourceSetDirty = false; |
| 241 | |
| 242 | m_resourceSetHash = 0; |
| 243 | |
| 244 | for( auto& technique : m_parametersForPasses ) |
| 245 | { |
| 246 | for( auto& params : technique.passes ) |
| 247 | { |
| 248 | m_resourceSetHash = CcpHashFNV1( ¶ms->m_resourceSetHash, sizeof( params->m_resourceSetHash ), m_resourceSetHash ); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | renderContext.SetResourceSet( pp.m_resourceSet ); |
| 254 | } |
| 255 | |
| 256 | void Tr2Material::ApplyMaterialDataForPassWithOverride( uint32_t techniqueIndex, unsigned int passIndex, uint32_t overrideProgram, Tr2RenderContext& renderContext ) const |
| 257 | { |
no test coverage detected