MCPcopy Create free account
hub / github.com/carbonengine/trinity / RegisterShader

Method RegisterShader

trinity/Shader/Tr2EffectStateManager.cpp:466–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466uint32_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
515uint32_t Tr2EffectStateManager::RegisterShaderLibrary( const Tr2ShaderBytecodeAL& bytecode )
516{

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.80
GetTypeMethod · 0.45
GetBytecodeMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected