Old code removal, 4/4

This commit is contained in:
Emmanuel BENOîT 2017-11-15 17:24:42 +01:00
parent af974518cb
commit b7f79c11b0
2 changed files with 0 additions and 88 deletions

View file

@ -8,7 +8,6 @@
namespace {
const std::regex PreprocDirective_( "^\\s*//!\\s*([a-z]+(\\s+([^\\s]+))*)\\s*$" );
const std::regex UniformName_( "^[A-Za-z][A-Za-z0-9_]*$" );
const std::regex GLSLErrorNv_( "^[0-9]*\\(([0-9]+).*$" );
const std::map< std::string , E_ShaderInput > InputTypes_( ([] {
@ -24,20 +23,6 @@ const std::map< std::string , E_ShaderInput > InputTypes_( ([] {
return t;
})());
const std::unordered_map< std::string , E_UniformType > UniformTypes_( ([] {
std::unordered_map< std::string , E_UniformType > t;
t.emplace( "float" , E_UniformType::F1 );
t.emplace( "vec2" , E_UniformType::F2 );
t.emplace( "vec3" , E_UniformType::F3 );
t.emplace( "vec4" , E_UniformType::F4 );
t.emplace( "int" , E_UniformType::I1 );
t.emplace( "ivec2" , E_UniformType::I2 );
t.emplace( "ivec3" , E_UniformType::I3 );
t.emplace( "ivec4" , E_UniformType::I4 );
t.emplace( "sampler2D" , E_UniformType::SAMPLER2D );
return t;
})());
const GLenum ProgramTypes_[] = {
GL_VERTEX_SHADER ,
GL_FRAGMENT_SHADER ,
@ -82,7 +67,6 @@ struct T_InputReader_
void read( );
void handleDirective( T_Tokens_ const& tokens );
void parseInputDirective( T_Tokens_ const& tokens );
void error( T_String const& err );
void nl( );
@ -151,63 +135,12 @@ void T_InputReader_::handleDirective(
input.type = pos->second;
}
} else if ( directive == "input" ) {
nl( );
parseInputDirective( tokens );
} else if ( directive == "uniforms" ) {
nl( );
for ( auto const& c : input.chunks ) {
if ( c.type == E_ShaderInputChunk::UNIFORMS ) {
error( "duplicate uniform generation" );
return;
}
}
input.chunks.addNew( E_ShaderInputChunk::UNIFORMS , "" , 1 );
} else {
nl( );
error( "unknown directive" );
}
}
void T_InputReader_::parseInputDirective(
T_Tokens_ const& tokens )
{
if ( tokens.size( ) != 4 ) {
error( "invalid arguments" );
return;
}
// Local/global
const bool global{ tokens[ 1 ] == "global" };
if ( !global && tokens[ 1 ] != "local" ) {
error( "second argument should be 'local' or 'global'" );
return;
}
// Name
std::string const& name{ tokens[ 2 ] };
if ( input.uniforms.contains( name.c_str( ) ) ) {
error( "duplicate uniform" );
return;
}
if ( !std::regex_match( name , UniformName_ ) ) {
error( "invalid uniform name" );
return;
}
// Type
auto tPos( UniformTypes_.find( tokens[ 3 ] ) );
if ( tPos == UniformTypes_.end( ) ) {
error( "unsupported uniform type" );
return;
}
input.uniforms.add( T_ShaderUniform{
tokens[ 2 ].c_str( ) , global , tPos->second } );
}
/*----------------------------------------------------------------------------*/
void T_InputReader_::error(

View file

@ -9,7 +9,6 @@
enum class E_ShaderInputChunk {
CODE ,
INCLUDE ,
UNIFORMS
};
// Input chunk data
@ -51,32 +50,12 @@ struct T_ShaderInputError
{ }
};
// Uniform types
enum class E_UniformType {
F1 , F2 , F3 , F4 ,
I1 , I2 , I3 , I4 ,
SAMPLER2D
};
// Uniform declarations
struct T_ShaderUniform
{
T_String name;
bool global;
E_UniformType type;
};
// Source file
struct T_ShaderInput
{
E_ShaderInput type = E_ShaderInput::CHUNK;
T_Array< T_ShaderInputChunk > chunks;
T_Array< T_ShaderInputError > errors;
T_ObjectTable< T_String , T_ShaderUniform > uniforms{
[]( T_ShaderUniform const& su ) -> T_String {
return su.name;
}
};
bool load( T_String const& path );
};