Skip to content

Commit

Permalink
Merge branch 'v2-3' into v3-0
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed May 1, 2024
2 parents 772c94f + e1b25f3 commit ce87b76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,16 @@ namespace Ogre
*/
char *Parse( const char *iSource, size_t iLength, size_t &oLength );

/** Parse the input string as a preamble (i.e. to define a lot of enums).
@param iSource
The source text containing preamble macros.
@param iLength
The length of iSource text in characters.
@return
False on errors. True on success.
*/
bool ParsePreamble( const char *iSource, size_t iLength );

/**
* An error handler function type.
* The default implementation just drops a note to stderr and
Expand Down
6 changes: 6 additions & 0 deletions RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,4 +1437,10 @@ namespace Ogre
return retval.Buffer;
}

bool CPreprocessor::ParsePreamble( const char *iSource, size_t iLength )
{
Token retval = Parse( Token( Token::TK_TEXT, iSource, iLength ) );
return retval.Type != Token::TK_ERROR;
}

} // namespace Ogre
3 changes: 1 addition & 2 deletions RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ namespace Ogre
replaceVersionMacros();

// Mask out vulkan_layout() macros
size_t unusedVal = 0;
const String preamble =
"#define vulkan_layout(x)\n"
"#define vulkan( x )\n"
Expand All @@ -180,7 +179,7 @@ namespace Ogre
"#define vkSampler2DArray( a, b ) a\n"
"#define vkSampler3D( a, b ) a\n"
"#define vkSamplerCube( a, b ) a\n";
cpp.Parse( preamble.c_str(), preamble.size(), unusedVal );
cpp.ParsePreamble( preamble.c_str(), preamble.size() );

// Pass all user-defined macros to preprocessor
if( !mPreprocessorDefines.empty() )
Expand Down

0 comments on commit ce87b76

Please sign in to comment.