MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / compileMicrocode

Method compileMicrocode

RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp:449–1143  ·  view source on GitHub ↗

-----------------------------------------------------------------------

Source from the content-addressed store, hash-verified

447 }
448 //-----------------------------------------------------------------------
449 void D3D11HLSLProgram::compileMicrocode()
450 {
451 OgreProfileExhaustive( "D3D11HLSLProgram::compileMicrocode" );
452
453 // If we are running from the cache, we should not be trying to compile/reflect on shaders.
454#if defined( ENABLE_SHADERS_CACHE_LOAD ) && ( ENABLE_SHADERS_CACHE_LOAD == 1 )
455 String message = "Cannot compile/reflect D3D11 shader: " + mName + " in shipping code\n";
456 OGRE_EXCEPT( Exception::ERR_NOT_IMPLEMENTED, message, "D3D11HLSLProgram::compileMicrocode" );
457#else
458# pragma comment( lib, "d3dcompiler.lib" )
459
460 // include handler
461 HLSLIncludeHandler includeHandler( this );
462
463 String stringBuffer;
464 vector<D3D_SHADER_MACRO>::type defines;
465 getDefines( stringBuffer, defines, mPreprocessorDefines );
466 const D3D_SHADER_MACRO *pDefines = defines.empty() ? NULL : &defines[0];
467
468 UINT compileFlags = 0;
469 D3D11RenderSystem *rsys =
470 static_cast<D3D11RenderSystem *>( Root::getSingleton().getRenderSystem() );
471
472 if( rsys->getDebugShaders() )
473 {
474 compileFlags |= D3DCOMPILE_DEBUG;
475 // Skip optimization only if we have enough instruction slots (>=256)
476 // and not feature level 9 hardware
477 if( mTarget != "ps_2_0" && mTarget != "ps_4_0_level_9_1" &&
478 rsys->_getFeatureLevel() >= D3D_FEATURE_LEVEL_10_0 )
479 {
480 compileFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
481 }
482 }
483 else
484 {
485 compileFlags |= D3DCOMPILE_OPTIMIZATION_LEVEL3;
486 }
487
488 if( mColumnMajorMatrices )
489 {
490 compileFlags |= D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR;
491 }
492 else
493 {
494 compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
495 }
496
497 if( mEnableBackwardsCompatibility )
498 {
499 compileFlags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
500 }
501
502 const char *target = getCompatibleTarget().c_str();
503
504 ComPtr<ID3DBlob> pMicroCode;
505 ComPtr<ID3DBlob> errors;
506

Callers

nothing calls this directly

Calls 13

GetTypeMethod · 0.80
createMicrocodeMethod · 0.80
addMicrocodeToCacheMethod · 0.80
emptyMethod · 0.45
getRenderSystemMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
logMessageMethod · 0.45
resizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected