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

Method compile

RenderSystems/Vulkan/src/OgreVulkanProgram.cpp:522–718  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

520 }
521 //-----------------------------------------------------------------------
522 bool VulkanProgram::compile( const bool checkErrors, const bool bReflectingArrays )
523 {
524 mCompiled = false;
525 mCompileError = false;
526
527 const bool bRootLayoutExtracted = extractRootLayoutFromSource();
528 if( !bRootLayoutExtracted && mReflectArrayRootLayouts && !bReflectingArrays )
529 {
530 // We will have to compile twice to know if there are arrays and where they are
531 // so we can patch our root layout. After that we can compile the final shader
532 //
533 // Without this step, we can't force bindings to be consecutive which can cause
534 // driver & tool bugs see https://github.com/baldurk/renderdoc/issues/2410
535 compile( checkErrors, true );
536 if( mCompiled )
537 gatherArrayedDescs( false );
538 }
539
540 const EShLanguage stage = static_cast<EShLanguage>( getEshLanguage() );
541 glslang::TShader shader( stage );
542
543 TBuiltInResource resources;
544 memset( &resources, 0, sizeof( resources ) );
545 initGlslResources( resources );
546
547 // Enable SPIR-V and Vulkan rules when parsing GLSL
548 EShMessages messages = (EShMessages)( EShMsgDefault | EShMsgSpvRules | EShMsgVulkanRules );
549 if( mShaderSyntax == HLSL )
550 {
551 // glslang::EShTargetClientVersion VulkanClientVersion = glslang::EShTargetVulkan_1_0;
552 // glslang::EShTargetLanguageVersion TargetVersion = glslang::EShTargetSpv_1_0;
553 messages = (EShMessages)( EShMsgDefault | EShMsgSpvRules | EShMsgReadHlsl );
554 shader.setEnvInput( glslang::EShSourceHlsl, stage, glslang::EShClientVulkan, 100 );
555 // shader.setEnvClient( glslang::EShClientVulkan, VulkanClientVersion );
556 // shader.setEnvTarget( glslang::EShTargetSpv, TargetVersion );
557 shader.setEntryPoint( "main" );
558 }
559
560#if OGRE_DEBUG_MODE >= OGRE_DEBUG_HIGH
561 messages = (EShMessages)( messages | EShMsgDebugInfo );
562#endif
563
564 const char *sourceCString = mSource.c_str();
565 shader.setStrings( &sourceCString, 1 );
566
567 if( !mCompileError )
568 {
569 if( mReplaceVersionMacro )
570 replaceVersionMacros();
571
572 String preamble;
573 getPreamble( preamble );
574 shader.setPreamble( preamble.c_str() );
575
576 if( !shader.parse( &resources, 450, false, messages ) )
577 {
578 LogManager::getSingleton().logMessage( "Vulkan GLSL compiler error in " + mName + ":\n" +
579 shader.getInfoLog() + "\nDEBUG LOG:\n" +

Callers

nothing calls this directly

Calls 11

makeVkStructFunction · 0.85
setObjectNameFunction · 0.85
getSpirvReflectErrorFunction · 0.85
c_strMethod · 0.45
parseMethod · 0.45
logMessageMethod · 0.45
clearMethod · 0.45
dumpMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected