Parser - (odbg) instruction

This commit is contained in:
Emmanuel BENOîT 2017-11-10 12:48:57 +01:00
parent 448acdf16b
commit eae82f1f9a
4 changed files with 118 additions and 10 deletions

View file

@ -42,10 +42,8 @@
(uniforms prg-scene-p1 1 $vp-width $vp-height) (uniforms prg-scene-p1 1 $vp-width $vp-height)
(pipeline pl-scene-p1 prg-fullscreen prg-scene-p1) (pipeline pl-scene-p1 prg-fullscreen prg-scene-p1)
{ NOT IMPLEMENTED
(odbg tx-scene-output hdr "Scene output") (odbg tx-scene-output hdr "Scene output")
(odbg tx-scene-depth depth "Scene depth") (odbg tx-scene-depth depth "Scene depth")
}
) )
(fn scene-main () (fn scene-main ()
@ -101,10 +99,8 @@
# MAYBE ? (alias tx-dof-output tx-dof-pass2) # MAYBE ? (alias tx-dof-output tx-dof-pass2)
# Output debugging # Output debugging
{ NOT IMPLEMENTED
(odbg tx-dof-pass1 hdr "DoF - First pass") (odbg tx-dof-pass1 hdr "DoF - First pass")
(odbg tx-dof-pass2 hdr "DoF - Output") (odbg tx-dof-pass2 hdr "DoF - Output")
}
# Programs # Programs
(program prg-dof-pass1 "dof-pass1.f.glsl") (program prg-dof-pass1 "dof-pass1.f.glsl")

View file

@ -101,7 +101,7 @@ A_Node* opast::ASTVisitorBrowser(
// //
case A_Node::OP_PROGRAM: case A_Node::OP_PIPELINE: case A_Node::OP_PROGRAM: case A_Node::OP_PIPELINE:
case A_Node::OP_INPUT: case A_Node::OP_FULLSCREEN: case A_Node::OP_INPUT: case A_Node::OP_FULLSCREEN:
case A_Node::OP_FRAMEBUFFER: case A_Node::OP_FRAMEBUFFER: case A_Node::OP_ODBG:
// //
case A_Node::OP_USE_FRAMEBUFFER: case A_Node::OP_USE_PIPELINE: case A_Node::OP_USE_FRAMEBUFFER: case A_Node::OP_USE_PIPELINE:
case A_Node::OP_USE_PROGRAM: case A_Node::OP_USE_TEXTURE: case A_Node::OP_USE_PROGRAM: case A_Node::OP_USE_TEXTURE:
@ -364,3 +364,20 @@ bool T_FramebufferInstrNode::setDepthAttachment(
locDepthAttachment_ = token.location( ); locDepthAttachment_ = token.location( );
return true; return true;
} }
/*= T_OutputDebugInstrNode ===================================================*/
T_OutputDebugInstrNode::T_OutputDebugInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& texture ,
const E_ODbgMode mode ,
T_SRDLocation const& modeLocation ,
T_SRDToken const& description ) noexcept
: A_InstructionNode( OP_ODBG , parent ) ,
idTexture_( texture.stringValue( ) ) ,
locTexture_( texture.location( ) ) ,
mode_( mode ) , locMode_( modeLocation ) ,
description_( description.stringValue( ) ) ,
locDescription_( description.location( ) )
{ }

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "texture.hh" #include "odbg.hh"
#include <ebcl/SRDData.hh> #include <ebcl/SRDData.hh>
@ -25,6 +25,7 @@ class A_Node
OP_FRAMEBUFFER ,// Define framebuffer OP_FRAMEBUFFER ,// Define framebuffer
OP_FULLSCREEN , // Draw a fullscreen quad OP_FULLSCREEN , // Draw a fullscreen quad
OP_INPUT , // Input declaration OP_INPUT , // Input declaration
OP_ODBG , // Output debugging
OP_PIPELINE , // Shader pipeline declaration OP_PIPELINE , // Shader pipeline declaration
OP_PROFILE , // Profiling block OP_PROFILE , // Profiling block
OP_PROGRAM , // Shader program declaration OP_PROGRAM , // Shader program declaration
@ -468,6 +469,41 @@ class T_InputInstrNode : public A_InstructionNode
{ return dvLocation_; } { return dvLocation_; }
}; };
// Output debugging
class T_OutputDebugInstrNode : public A_InstructionNode
{
private:
T_String idTexture_;
T_SRDLocation locTexture_;
E_ODbgMode mode_;
T_SRDLocation locMode_;
T_String description_;
T_SRDLocation locDescription_;
public:
T_OutputDebugInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& texture ,
const E_ODbgMode mode ,
T_SRDLocation const& modeLocation ,
T_SRDToken const& description ) noexcept;
T_String const& texture( ) const noexcept
{ return idTexture_; }
T_SRDLocation const& textureLocation( ) const noexcept
{ return locTexture_; }
E_ODbgMode mode( ) const noexcept
{ return mode_; }
T_SRDLocation const& modeLocation( ) const noexcept
{ return locMode_; }
T_String const& description( ) const noexcept
{ return description_; }
T_SRDLocation const& descriptionLocation( ) const noexcept
{ return locDescription_; }
};
// Pipeline declaration instruction // Pipeline declaration instruction
class T_PipelineInstrNode : public A_InstructionNode class T_PipelineInstrNode : public A_InstructionNode
{ {

View file

@ -18,6 +18,7 @@ struct T_ParserImpl_
FULLSCREEN , FULLSCREEN ,
IF , IF ,
INPUT , INPUT ,
ODBG ,
PIPELINE , PIPELINE ,
PROFILE , PROFILE ,
PROGRAM , PROGRAM ,
@ -43,6 +44,7 @@ struct T_ParserImpl_
add( "fullscreen" , E_InstrType::FULLSCREEN ); add( "fullscreen" , E_InstrType::FULLSCREEN );
add( "if" , E_InstrType::IF ); add( "if" , E_InstrType::IF );
add( "input" , E_InstrType::INPUT ); add( "input" , E_InstrType::INPUT );
add( "odbg" , E_InstrType::ODBG );
add( "pipeline" , E_InstrType::PIPELINE ); add( "pipeline" , E_InstrType::PIPELINE );
add( "profiling" , E_InstrType::PROFILE ); add( "profiling" , E_InstrType::PROFILE );
add( "program" , E_InstrType::PROGRAM ); add( "program" , E_InstrType::PROGRAM );
@ -118,6 +120,23 @@ struct T_ParserImpl_
return temp; return temp;
})( ) }; })( ) };
const T_KeyValueTable< T_String , E_ODbgMode > odbgModes{ ([]() {
T_KeyValueTable< T_String , E_ODbgMode > temp{ 32 , 32 , 32 };
const auto add{ [&temp]( char const* name ,
const E_ODbgMode it ) {
temp.add( T_String::Pooled( name ) , it );
} };
add( "hdr" , E_ODbgMode::HDR );
add( "ldr" , E_ODbgMode::LDR );
add( "ldr-alpha" , E_ODbgMode::LDR_ALPHA );
add( "depth" , E_ODbgMode::DEPTH );
assert( temp.size( ) == uint32_t( E_ODbgMode::__COUNT__ ) );
return temp;
})( ) };
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
T_OwnPtr< T_RootNode >& root; T_OwnPtr< T_RootNode >& root;
@ -170,6 +189,7 @@ struct T_ParserImpl_
M_DPARSER_( If ); M_DPARSER_( If );
M_DPARSER_( Input ); M_DPARSER_( Input );
M_DPARSER_( ODebug );
M_DPARSER_( Pipeline ); M_DPARSER_( Pipeline );
M_DPARSER_( Profile ); M_DPARSER_( Profile );
M_DPARSER_( Program ); M_DPARSER_( Program );
@ -449,6 +469,7 @@ void T_ParserImpl_::parseInstructions(
M_CASE_( FRAMEBUFFER , Framebuffer ); M_CASE_( FRAMEBUFFER , Framebuffer );
M_CASE_( IF , If ); M_CASE_( IF , If );
M_CASE_( INPUT , Input ); M_CASE_( INPUT , Input );
M_CASE_( ODBG , ODebug );
M_CASE_( PIPELINE , Pipeline ); M_CASE_( PIPELINE , Pipeline );
M_CASE_( PROFILE , Profile ); M_CASE_( PROFILE , Profile );
M_CASE_( PROGRAM , Program ); M_CASE_( PROGRAM , Program );
@ -639,6 +660,44 @@ M_INSTR_( Input )
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
M_INSTR_( ODebug )
{
const auto ni( input.size( ) );
if ( ni == 1 || input[ 1 ].type( ) != E_SRDTokenType::WORD ) {
errors.addNew( "texture identifier expected" ,
input[ ni == 1 ? 0 : 1 ].location( ) );
return;
}
if ( ni == 2 || input[ 2 ].type( ) != E_SRDTokenType::WORD ) {
errors.addNew( "display mode expected" ,
input[ ni == 2 ? 0 : 2 ].location( ) );
return;
}
auto const* const mode( odbgModes.get( input[ 2 ].stringValue( ) ) );
if ( !mode ) {
errors.addNew( "invalid display mode" , input[ 2 ].location( ) );
return;
}
if ( ni == 3 || !input[ 3 ].isText( ) ) {
errors.addNew( "description expected" ,
input[ ni == 3 ? 0 : 3 ].location( ) );
return;
}
auto& instr{ instructions.add< T_OutputDebugInstrNode >(
input[ 1 ] , *mode , input[ 2 ].location( ) ,
input[ 3 ] ) };
instr.location( ) = input[ 0 ].location( );
if ( ni > 4 ) {
errors.addNew( "too many arguments" , input[ 4 ].location( ) );
}
}
/*----------------------------------------------------------------------------*/
M_INSTR_( Pipeline ) M_INSTR_( Pipeline )
{ {
if ( input.size( ) < 3 ) { if ( input.size( ) < 3 ) {