IT LIVES!!!!!!!!

Ok, so it can display stuff.
This commit is contained in:
Emmanuel BENOîT 2017-11-15 09:46:07 +01:00
parent 210be3a852
commit 1b06f9e299
4 changed files with 74 additions and 26 deletions

16
demo.cc
View file

@ -68,7 +68,7 @@ void T_Demo::makeUI( )
void T_Demo::render( )
{
if ( !context ) {
if ( program && !context ) {
runInit( );
}
@ -198,6 +198,16 @@ bool T_Demo::loadProgram( )
program = compiler.compile( *parser.result( ) );
return true;
}
T_StringBuilder sb;
sb << "- PARSE ERRORS -------------------------\n";
const auto nErrors( parser.errors( ).size( ) );
for ( auto i = 0u ; i < nErrors ; i ++ ) {
WriteSRDError( sb , parser.errors( )[ i ] );
}
sb << "----------------------------------------\n";
sb << '\0';
fprintf( stderr , "%s" , sb.data( ) );
return false;
}
@ -219,6 +229,10 @@ void T_Demo::runInit( )
for ( auto i = 0u ; i < n ; i ++ ) {
Globals::Sync( ).addInput( program->inputs[ i ] ,
context->initialInputs[ i ] );
#ifdef INVASIVE_TRACES
printf( "#%d %s pos %d\n" , i , program->inputs[ i ].toOSString( ).data( ) ,
Globals::Sync( ).inputPos( program->inputs[ i ] ) );
#endif //INVASIVE_TRACES
}
Globals::Sync( ).updateCurveCaches( );
}

View file

@ -44,7 +44,6 @@
(color tx-scene-depth))
(program prg-scene-p1 "scene.f.glsl")
(uniforms prg-scene-p1 1 $vp-width $vp-height)
(pipeline pl-scene-p1 prg-fullscreen prg-scene-p1)
(odbg tx-scene-output hdr "Scene output")
@ -52,7 +51,7 @@
(input camera-pos-x 0)
(input camera-pos-y 0)
(input camera-pos-z -5)
(input camera-pos-z 30)
(input camera-lookat-x 0)
(input camera-lookat-y 0)
(input camera-lookat-z 0)
@ -72,6 +71,10 @@
(fn scene-render ()
(profiling "Scene render"
# FIXME temp - we'll need to do init right before this
# can be moved back to initialisation
(uniforms prg-scene-p1 1 $vp-width $vp-height)
(uniforms prg-scene-p1 0 $time)
(uniforms prg-scene-p1 2
(get-input camera-pos-x)
@ -134,10 +137,6 @@
# Programs
(program prg-dof-pass1 "dof-pass1.f.glsl")
(program prg-dof-pass2 "dof-pass2.f.glsl")
(uniforms-i prg-dof-pass1 0 1)
(uniforms-i prg-dof-pass1 1 1)
(uniforms-i prg-dof-pass2 0 1)
(uniforms-i prg-dof-pass2 1 1)
# Pipelines
(pipeline pl-dof-pass1 prg-fullscreen prg-dof-pass1)
@ -177,6 +176,13 @@
(profiling "Depth of Field"
(use-texture 1 in-depth smp-dof)
# FIXME temp - we'll need to do init right before this
# can be moved back to initialisation
(uniforms-i prg-dof-pass1 0 0)
(uniforms-i prg-dof-pass1 1 1)
(uniforms-i prg-dof-pass2 0 0)
(uniforms-i prg-dof-pass2 1 1)
# First pass
(call dof-set-uniforms prg-dof-pass1)
(use-texture 0 in-image smp-dof)
@ -202,6 +208,8 @@
# Samplers
(sampler smp-bloom-blur
(sampling linear)
(mipmaps linear)
(lod 0 100)
(wrapping clamp-edge)
)
(sampler smp-bloom-input
@ -226,23 +234,19 @@
(framebuffer rt-bloom2-lod3 (color tx-bloom2 3))
(framebuffer rt-bloom2-lod4 (color tx-bloom2 4))
(framebuffer rt-bloom2-lod5 (color tx-bloom2 5))
(odbg tx-bloom2 hdr "Bloom (partial)")
# High pass program
(program prg-bloom-highpass "bloom-highpass.f.glsl")
(pipeline pl-bloom-highpass prg-fullscreen prg-bloom-highpass)
(uniforms-i prg-bloom-highpass 0 0)
(uniforms-i prg-bloom-highpass 1 0)
(uniforms prg-bloom-highpass 2 $vp-width $vp-height)
# Downsampling program
(program prg-bloom-downsample "downsample.f.glsl")
(pipeline pl-bloom-downsample prg-fullscreen prg-bloom-downsample)
(uniforms-i prg-bloom-downsample 0 0)
# Blur pass
(program prg-bloom-blur "blur-pass.f.glsl")
(pipeline pl-bloom-blur prg-fullscreen prg-bloom-blur)
(uniforms-i prg-bloom-blur 0 0)
# Inputs that control the high pass filter
# FIXME I don't remember what they actually do, rename them later
@ -262,6 +266,14 @@
(fn bloom-render (in-scene)
(profiling "BLOOOOM!"
# FIXME temp - we'll need to do init right before this
# can be moved back to initialisation
(uniforms-i prg-bloom-highpass 0 0)
(uniforms-i prg-bloom-highpass 1 0)
(uniforms prg-bloom-highpass 2 $vp-width $vp-height)
(uniforms-i prg-bloom-downsample 0 0)
(uniforms-i prg-bloom-blur 0 0)
# High pass
(use-texture 0 in-scene smp-bloom-input)
(uniforms prg-bloom-highpass 3
@ -273,8 +285,15 @@
(viewport 0 0 $vp-width $vp-height)
(fullscreen)
# Set up blur weights
(uniforms prg-bloom-blur 4
(get-input bloom-bw0)
(get-input bloom-bw1)
(get-input bloom-bw2)
(get-input bloom-bw3))
# Blur & downsample
(uniforms prg-bloom-downsample 1 $vp-width $vp-height)
(uniforms prg-bloom-blur 1 $vp-width $vp-height)
(call bloom-blur-pass 0 rt-bloom1-lod0 rt-bloom2-lod0)
(call bloom-downsample rt-bloom1-lod1 1)
(call bloom-blur-pass 1 rt-bloom1-lod1 rt-bloom2-lod1)
@ -333,13 +352,14 @@
(fn combine-init ()
# Assets
(sampler smp-combine-input (sampling nearest))
(sampler smp-combine-bloom
(sampling linear)
(mipmaps nearest)
(lod 0 100))
(texture tx-combined rgba-nu8 $vp-width $vp-height)
(odbg tx-combined ldr-alpha "Combined output")
(framebuffer rt-combined tx-combined)
(program prg-combine "combine.f.glsl")
(uniforms-i prg-combine 0 0)
(uniforms-i prg-combine 1 1)
(uniforms prg-combine 2 $vp-width $vp-height)
(pipeline pl-combine prg-fullscreen prg-combine)
# Bloom parameters
@ -368,10 +388,16 @@
(fn combine-render (in-main in-bloom)
(profiling "Combine"
# FIXME temp - we'll need to do init right before this
# can be moved back to initialisation
(uniforms-i prg-combine 0 0)
(uniforms-i prg-combine 1 1)
(uniforms prg-combine 2 $vp-width $vp-height)
(use-pipeline pl-combine)
(use-framebuffer rt-combined)
(use-texture 0 in-main smp-combine-input)
(use-texture 1 in-bloom smp-combine-input)
(use-texture 1 in-bloom smp-combine-bloom)
(uniforms prg-combine 3
(get-input bloom-strength)
(get-input bloom-attenuation))
@ -407,8 +433,6 @@
(fn fxaa-init ()
(program prg-fxaa "fxaa.f.glsl")
(pipeline pl-fxaa prg-fullscreen prg-fxaa)
(uniforms-i prg-fxaa 0 0)
(uniforms prg-fxaa 1 $vp-width $vp-height)
(sampler smp-fxaa
(sampling linear)
@ -421,6 +445,11 @@
(fn fxaa-render (in-image)
(profiling "FXAA"
# FIXME temp - we'll need to do init right before this
# can be moved back to initialisation
(uniforms-i prg-fxaa 0 0)
(uniforms prg-fxaa 1 $vp-width $vp-height)
(main-output)
(viewport 0 0 $width $height)
(clear 0 0 0 0)

View file

@ -433,7 +433,6 @@ bool T_CompilerImpl_::compileNode(
const auto cpos( output->ops.sizeOf( funcIndex ) );
const auto ppos( condJumps.last( ).prevCase );
const auto diff( cpos - ppos );
assert( diff > 1 );
output->ops.get( funcIndex , ppos ).args[ 0 ] = diff - 1;
} else {
// If there is a previous skip location, insert the skip instruction
@ -648,9 +647,9 @@ bool T_CompilerImpl_::compileNode(
T_OpValue value;
value.f = in.defValue( );
addInstruction( OP_UI_INPUT_DFT , {
uint32_t( output->inputs.indexOf( in.id( ) ) ) ,
uint32_t( constants.indexOf( value.u ) + 3 ) } ,
node.location( ) );
uint32_t( output->inputs.indexOf( in.id( ) ) ) ,
uint32_t( constants.indexOf( value.u ) + 3 + output->nVariables ) } ,
node.location( ) );
}
break;

12
ops.cc
View file

@ -393,7 +393,7 @@ void T_OpContext::run(
case OP_GET_INPUT:
ensureFpuStack( instr , 0 , 1 );
x87stack[ x87sp ++ ] = Globals::Sync( ).inputs( )[ instr.args[ 0 ] + 1 ];
x87stack[ x87sp ++ ] = Globals::Sync( ).inputs( )[ instr.args[ 0 ] ];
break;
case OP_FP_LOAD:
@ -786,11 +786,14 @@ void T_OpContext::run(
const auto ss( stack.size( ) );
T_OpValue values[ 4 ];
// printf( "OP_UNIFORMS %d %d" , instr.args[ 0 ] , instr.args[ 1 ] );
for ( auto i = 0u ; i <= instr.args[ 0 ] ; i ++ ) {
if ( instr.args[ 1 ] ) {
values[ i ] = uint32_t( stack[ ss - 3 - i ].f );
// printf( " %d" , values[ i ].i );
} else {
values[ i ] = stack[ ss - 3 - i ];
// printf( " %f" , values[ i ].f );
}
}
@ -798,6 +801,7 @@ void T_OpContext::run(
if ( sv == 0 || sv > programs.size( ) || !programs[ sv - 1 ] ) {
throw X_OpFailure{ instr , "invalid program" };
}
// printf( " -> %s %d\n" , programs[ sv - 1 ]->name( ).toOSString( ).data( ) , stack[ ss - 2 ].u );
typedef void (*F_SetUniform_)( int , int , int , void* );
void const* const funcs[] = {
@ -815,8 +819,10 @@ void T_OpContext::run(
{
ensureStack( instr , 4 );
const auto ss( stack.size( ) );
glViewport( stack[ ss - 1 ].f , stack[ ss - 2 ].f ,
stack[ ss - 3 ].f , stack[ ss - 4 ].f );
glViewport( int32_t( stack[ ss - 1 ].f ) ,
int32_t( stack[ ss - 2 ].f ) ,
int32_t( stack[ ss - 3 ].f ) ,
int32_t( stack[ ss - 4 ].f ) );
stack.resize( ss - 4 );
break;
}