| 315 | } |
| 316 | |
| 317 | void TriTextureParameter::RebuildEffectHandles( Tr2Shader* effectRes ) |
| 318 | { |
| 319 | m_cachedEffect = effectRes; |
| 320 | |
| 321 | m_isUsedByEffect = false; |
| 322 | if( m_name.empty() || !effectRes ) |
| 323 | { |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | auto resource = effectRes->GetResource( m_name.c_str() ); |
| 328 | if( resource ) |
| 329 | { |
| 330 | m_resourceType = resource->type; |
| 331 | m_isUsedByEffect = true; |
| 332 | } |
| 333 | else |
| 334 | { |
| 335 | auto c = effectRes->GetConstant( m_name.c_str() ); |
| 336 | if( c ) |
| 337 | { |
| 338 | m_isUsedByEffect = true; |
| 339 | m_resourceType = Tr2EffectResource::TEXTURE_2D; |
| 340 | m_bindlessColorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR; |
| 341 | |
| 342 | if( auto annotations = effectRes->GetParameterAnnotations( m_name.c_str() ) ) |
| 343 | { |
| 344 | auto found = std::find_if( begin( *annotations ), end( *annotations ), []( auto& x ) { |
| 345 | return strcmp( x.name, "BindlessHandleType" ) == 0 && x.type == Tr2EffectParameterAnnotation::INT; |
| 346 | } ); |
| 347 | if( found != end( *annotations ) ) |
| 348 | { |
| 349 | m_resourceType = Tr2EffectResource::Type( found->intValue ); |
| 350 | //CCP_LOGERR( "Got resource type." ); |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | CCP_ASSERT_M( false, "Bindless texture input is defined as uint, but does not have the BindlessHandleType annotation set. Either change the type to BindlessTexture??? or add the annotation" ); |
| 355 | } |
| 356 | found = std::find_if( begin( *annotations ), end( *annotations ), [&]( auto& x ) { |
| 357 | return strcmp( x.name, "Tr2sRGB" ) == 0 && x.type == Tr2EffectParameterAnnotation::BOOL; |
| 358 | } ); |
| 359 | if( found != end( *annotations ) ) |
| 360 | { |
| 361 | m_bindlessColorSpace = found->boolValue ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | CacheTexture(); |
| 367 | } |
| 368 | |
| 369 | void TriTextureParameter::CacheTexture() |
| 370 | { |
nothing calls this directly
no test coverage detected