Emmanuel BENOîT
68d01ca42e
Shaders are no longer found under /shaders in the project; they can be anywhere. In addition, paths for both (program) instructions in the script and include directives in shader source code are relative to the file which contains them.
108 lines
2.1 KiB
C++
108 lines
2.1 KiB
C++
#pragma once
|
|
#ifndef REAL_BUILD
|
|
# include "externals.hh"
|
|
#endif
|
|
|
|
|
|
/*= COMMON PROPERTIES ========================================================*/
|
|
|
|
// Type of shader
|
|
enum class E_ShaderType {
|
|
VERTEX , FRAGMENT , GEOMETRY ,
|
|
COMPUTE ,
|
|
__COUNT__
|
|
};
|
|
|
|
// Errors in shader code - the errors it represents may come from either
|
|
// the input loader, the shader loader or the driver.
|
|
struct T_ShaderError
|
|
{
|
|
T_FSPath source;
|
|
uint32_t line;
|
|
T_String error;
|
|
|
|
T_ShaderError( ) = default;
|
|
|
|
T_ShaderError( T_FSPath source ,
|
|
const uint32_t line ,
|
|
T_String error )
|
|
: source( std::move( source ) ) , line( line ) ,
|
|
error( std::move( error ) )
|
|
{ }
|
|
|
|
T_ShaderError( T_FSPath source ,
|
|
const uint32_t line ,
|
|
T_StringBuilder& error )
|
|
: source( std::move( source ) ) , line( line ) ,
|
|
error( std::move( error ) )
|
|
{ }
|
|
};
|
|
|
|
|
|
/*= INPUT FILES ==============================================================*/
|
|
|
|
// Type of input chunk
|
|
enum class E_ShaderInputChunk {
|
|
CODE ,
|
|
INCLUDE ,
|
|
};
|
|
|
|
// Input chunk data
|
|
struct T_ShaderInputChunk
|
|
{
|
|
E_ShaderInputChunk type;
|
|
T_Union< T_String , T_FSPath > data;
|
|
uint32_t lines;
|
|
|
|
T_ShaderInputChunk( ) = default;
|
|
|
|
T_ShaderInputChunk(
|
|
T_String text ,
|
|
const uint32_t lines )
|
|
: type( E_ShaderInputChunk::CODE ) ,
|
|
data( std::move( text ) ) ,
|
|
lines( lines )
|
|
{ }
|
|
|
|
T_ShaderInputChunk(
|
|
T_FSPath path ,
|
|
const uint32_t lines )
|
|
: type( E_ShaderInputChunk::INCLUDE ) ,
|
|
data( std::move( path ) ) ,
|
|
lines( lines )
|
|
{ }
|
|
};
|
|
|
|
// Input file type
|
|
enum class E_ShaderInput {
|
|
CHUNK , // Chunk that may be repeated
|
|
LIBRARY , // Library (will only be loaded once)
|
|
|
|
// "Main" shader source files
|
|
VERTEX , FRAGMENT , GEOMETRY ,
|
|
COMPUTE
|
|
};
|
|
|
|
// Preprocessing errors
|
|
struct T_ShaderInputError
|
|
{
|
|
uint32_t line;
|
|
T_String error;
|
|
|
|
T_ShaderInputError(
|
|
const uint32_t line ,
|
|
T_String error )
|
|
: line( line ) , error( std::move( error ) )
|
|
{ }
|
|
};
|
|
|
|
// Source file
|
|
struct T_ShaderInput
|
|
{
|
|
E_ShaderInput type = E_ShaderInput::CHUNK;
|
|
T_Array< T_ShaderInputChunk > chunks;
|
|
T_Array< T_ShaderInputError > errors;
|
|
|
|
bool load( T_FSPath const& path );
|
|
};
|
|
using P_ShaderInput = T_OwnPtr< T_ShaderInput >;
|