| 464 | } |
| 465 | |
| 466 | uint32_t Tr2EffectStateManager::RegisterShader( |
| 467 | ShaderType type, |
| 468 | const Tr2ShaderBytecodeAL& bytecode, |
| 469 | const Tr2ShaderSignatureAL& signature, |
| 470 | const char* shaderPath ) |
| 471 | { |
| 472 | for( size_t i = 0; i != s_shaders.size(); ++i ) |
| 473 | { |
| 474 | const Tr2ShaderAL& existing = *s_shaders[i]; |
| 475 | if( existing.GetType() != type ) |
| 476 | { |
| 477 | continue; |
| 478 | } |
| 479 | |
| 480 | Tr2ShaderBytecodeAL existingBytecode; |
| 481 | if( FAILED( existing.GetBytecode( existingBytecode ) ) ) |
| 482 | { |
| 483 | continue; |
| 484 | } |
| 485 | |
| 486 | if( existingBytecode.size == bytecode.size ) |
| 487 | { |
| 488 | if( memcmp( existingBytecode.bytecode, bytecode.bytecode, bytecode.size ) == 0 ) |
| 489 | { |
| 490 | if( existing.GetSignature().samplers == signature.samplers ) |
| 491 | { |
| 492 | // We've seen this setup before |
| 493 | return (uint32_t)i; |
| 494 | } |
| 495 | } |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | // New shader, add it; created using the primary rendercontext. |
| 500 | std::unique_ptr<Tr2ShaderAL> shader( new Tr2ShaderAL ); |
| 501 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 502 | CR_RETURN_VAL( shader->Create( |
| 503 | type, |
| 504 | bytecode, |
| 505 | signature, |
| 506 | shaderPath, |
| 507 | renderContext ), |
| 508 | UNKNOWN ); |
| 509 | |
| 510 | s_shaders.push_back( shader.release() ); |
| 511 | |
| 512 | return (uint32_t)s_shaders.size() - 1; |
| 513 | } |
| 514 | |
| 515 | uint32_t Tr2EffectStateManager::RegisterShaderLibrary( const Tr2ShaderBytecodeAL& bytecode ) |
| 516 | { |
nothing calls this directly
no test coverage detected