2017-11-24 16:44:18 +01:00
|
|
|
#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
|
|
|
|
{
|
2017-12-29 11:33:15 +01:00
|
|
|
T_FSPath source;
|
2017-11-24 16:44:18 +01:00
|
|
|
uint32_t line;
|
|
|
|
T_String error;
|
|
|
|
|
|
|
|
T_ShaderError( ) = default;
|
|
|
|
|
2017-12-29 11:33:15 +01:00
|
|
|
T_ShaderError( T_FSPath source ,
|
2017-11-24 16:44:18 +01:00
|
|
|
const uint32_t line ,
|
|
|
|
T_String error )
|
|
|
|
: source( std::move( source ) ) , line( line ) ,
|
|
|
|
error( std::move( error ) )
|
|
|
|
{ }
|
|
|
|
|
2017-12-29 11:33:15 +01:00
|
|
|
T_ShaderError( T_FSPath source ,
|
2017-11-24 16:44:18 +01:00
|
|
|
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;
|
2017-12-29 11:33:15 +01:00
|
|
|
T_Union< T_String , T_FSPath > data;
|
2017-11-24 16:44:18 +01:00
|
|
|
uint32_t lines;
|
|
|
|
|
|
|
|
T_ShaderInputChunk( ) = default;
|
2017-12-29 11:33:15 +01:00
|
|
|
|
2017-11-24 16:44:18 +01:00
|
|
|
T_ShaderInputChunk(
|
|
|
|
T_String text ,
|
|
|
|
const uint32_t lines )
|
2017-12-29 11:33:15 +01:00
|
|
|
: 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 )
|
2017-11-24 16:44:18 +01:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2017-12-29 11:33:15 +01:00
|
|
|
bool load( T_FSPath const& path );
|
2017-11-24 16:44:18 +01:00
|
|
|
};
|
|
|
|
using P_ShaderInput = T_OwnPtr< T_ShaderInput >;
|