IT LIVES!!!!!!!!
Ok, so it can display stuff.
This commit is contained in:
parent
210be3a852
commit
1b06f9e299
4 changed files with 74 additions and 26 deletions
16
demo.cc
16
demo.cc
|
@ -68,7 +68,7 @@ void T_Demo::makeUI( )
|
||||||
|
|
||||||
void T_Demo::render( )
|
void T_Demo::render( )
|
||||||
{
|
{
|
||||||
if ( !context ) {
|
if ( program && !context ) {
|
||||||
runInit( );
|
runInit( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +198,16 @@ bool T_Demo::loadProgram( )
|
||||||
program = compiler.compile( *parser.result( ) );
|
program = compiler.compile( *parser.result( ) );
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +229,10 @@ void T_Demo::runInit( )
|
||||||
for ( auto i = 0u ; i < n ; i ++ ) {
|
for ( auto i = 0u ; i < n ; i ++ ) {
|
||||||
Globals::Sync( ).addInput( program->inputs[ i ] ,
|
Globals::Sync( ).addInput( program->inputs[ i ] ,
|
||||||
context->initialInputs[ 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( );
|
Globals::Sync( ).updateCurveCaches( );
|
||||||
}
|
}
|
||||||
|
|
65
demo.srd
65
demo.srd
|
@ -44,7 +44,6 @@
|
||||||
(color tx-scene-depth))
|
(color tx-scene-depth))
|
||||||
|
|
||||||
(program prg-scene-p1 "scene.f.glsl")
|
(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)
|
(pipeline pl-scene-p1 prg-fullscreen prg-scene-p1)
|
||||||
|
|
||||||
(odbg tx-scene-output hdr "Scene output")
|
(odbg tx-scene-output hdr "Scene output")
|
||||||
|
@ -52,7 +51,7 @@
|
||||||
|
|
||||||
(input camera-pos-x 0)
|
(input camera-pos-x 0)
|
||||||
(input camera-pos-y 0)
|
(input camera-pos-y 0)
|
||||||
(input camera-pos-z -5)
|
(input camera-pos-z 30)
|
||||||
(input camera-lookat-x 0)
|
(input camera-lookat-x 0)
|
||||||
(input camera-lookat-y 0)
|
(input camera-lookat-y 0)
|
||||||
(input camera-lookat-z 0)
|
(input camera-lookat-z 0)
|
||||||
|
@ -72,6 +71,10 @@
|
||||||
|
|
||||||
(fn scene-render ()
|
(fn scene-render ()
|
||||||
(profiling "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 0 $time)
|
||||||
(uniforms prg-scene-p1 2
|
(uniforms prg-scene-p1 2
|
||||||
(get-input camera-pos-x)
|
(get-input camera-pos-x)
|
||||||
|
@ -134,10 +137,6 @@
|
||||||
# Programs
|
# Programs
|
||||||
(program prg-dof-pass1 "dof-pass1.f.glsl")
|
(program prg-dof-pass1 "dof-pass1.f.glsl")
|
||||||
(program prg-dof-pass2 "dof-pass2.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
|
# Pipelines
|
||||||
(pipeline pl-dof-pass1 prg-fullscreen prg-dof-pass1)
|
(pipeline pl-dof-pass1 prg-fullscreen prg-dof-pass1)
|
||||||
|
@ -177,6 +176,13 @@
|
||||||
(profiling "Depth of Field"
|
(profiling "Depth of Field"
|
||||||
(use-texture 1 in-depth smp-dof)
|
(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
|
# First pass
|
||||||
(call dof-set-uniforms prg-dof-pass1)
|
(call dof-set-uniforms prg-dof-pass1)
|
||||||
(use-texture 0 in-image smp-dof)
|
(use-texture 0 in-image smp-dof)
|
||||||
|
@ -202,6 +208,8 @@
|
||||||
# Samplers
|
# Samplers
|
||||||
(sampler smp-bloom-blur
|
(sampler smp-bloom-blur
|
||||||
(sampling linear)
|
(sampling linear)
|
||||||
|
(mipmaps linear)
|
||||||
|
(lod 0 100)
|
||||||
(wrapping clamp-edge)
|
(wrapping clamp-edge)
|
||||||
)
|
)
|
||||||
(sampler smp-bloom-input
|
(sampler smp-bloom-input
|
||||||
|
@ -226,23 +234,19 @@
|
||||||
(framebuffer rt-bloom2-lod3 (color tx-bloom2 3))
|
(framebuffer rt-bloom2-lod3 (color tx-bloom2 3))
|
||||||
(framebuffer rt-bloom2-lod4 (color tx-bloom2 4))
|
(framebuffer rt-bloom2-lod4 (color tx-bloom2 4))
|
||||||
(framebuffer rt-bloom2-lod5 (color tx-bloom2 5))
|
(framebuffer rt-bloom2-lod5 (color tx-bloom2 5))
|
||||||
|
(odbg tx-bloom2 hdr "Bloom (partial)")
|
||||||
|
|
||||||
# High pass program
|
# High pass program
|
||||||
(program prg-bloom-highpass "bloom-highpass.f.glsl")
|
(program prg-bloom-highpass "bloom-highpass.f.glsl")
|
||||||
(pipeline pl-bloom-highpass prg-fullscreen prg-bloom-highpass)
|
(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
|
# Downsampling program
|
||||||
(program prg-bloom-downsample "downsample.f.glsl")
|
(program prg-bloom-downsample "downsample.f.glsl")
|
||||||
(pipeline pl-bloom-downsample prg-fullscreen prg-bloom-downsample)
|
(pipeline pl-bloom-downsample prg-fullscreen prg-bloom-downsample)
|
||||||
(uniforms-i prg-bloom-downsample 0 0)
|
|
||||||
|
|
||||||
# Blur pass
|
# Blur pass
|
||||||
(program prg-bloom-blur "blur-pass.f.glsl")
|
(program prg-bloom-blur "blur-pass.f.glsl")
|
||||||
(pipeline pl-bloom-blur prg-fullscreen prg-bloom-blur)
|
(pipeline pl-bloom-blur prg-fullscreen prg-bloom-blur)
|
||||||
(uniforms-i prg-bloom-blur 0 0)
|
|
||||||
|
|
||||||
# Inputs that control the high pass filter
|
# Inputs that control the high pass filter
|
||||||
# FIXME I don't remember what they actually do, rename them later
|
# FIXME I don't remember what they actually do, rename them later
|
||||||
|
@ -262,6 +266,14 @@
|
||||||
|
|
||||||
(fn bloom-render (in-scene)
|
(fn bloom-render (in-scene)
|
||||||
(profiling "BLOOOOM!"
|
(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
|
# High pass
|
||||||
(use-texture 0 in-scene smp-bloom-input)
|
(use-texture 0 in-scene smp-bloom-input)
|
||||||
(uniforms prg-bloom-highpass 3
|
(uniforms prg-bloom-highpass 3
|
||||||
|
@ -273,8 +285,15 @@
|
||||||
(viewport 0 0 $vp-width $vp-height)
|
(viewport 0 0 $vp-width $vp-height)
|
||||||
(fullscreen)
|
(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
|
# 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-blur-pass 0 rt-bloom1-lod0 rt-bloom2-lod0)
|
||||||
(call bloom-downsample rt-bloom1-lod1 1)
|
(call bloom-downsample rt-bloom1-lod1 1)
|
||||||
(call bloom-blur-pass 1 rt-bloom1-lod1 rt-bloom2-lod1)
|
(call bloom-blur-pass 1 rt-bloom1-lod1 rt-bloom2-lod1)
|
||||||
|
@ -333,13 +352,14 @@
|
||||||
(fn combine-init ()
|
(fn combine-init ()
|
||||||
# Assets
|
# Assets
|
||||||
(sampler smp-combine-input (sampling nearest))
|
(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)
|
(texture tx-combined rgba-nu8 $vp-width $vp-height)
|
||||||
(odbg tx-combined ldr-alpha "Combined output")
|
(odbg tx-combined ldr-alpha "Combined output")
|
||||||
(framebuffer rt-combined tx-combined)
|
(framebuffer rt-combined tx-combined)
|
||||||
(program prg-combine "combine.f.glsl")
|
(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)
|
(pipeline pl-combine prg-fullscreen prg-combine)
|
||||||
|
|
||||||
# Bloom parameters
|
# Bloom parameters
|
||||||
|
@ -368,10 +388,16 @@
|
||||||
|
|
||||||
(fn combine-render (in-main in-bloom)
|
(fn combine-render (in-main in-bloom)
|
||||||
(profiling "Combine"
|
(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-pipeline pl-combine)
|
||||||
(use-framebuffer rt-combined)
|
(use-framebuffer rt-combined)
|
||||||
(use-texture 0 in-main smp-combine-input)
|
(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
|
(uniforms prg-combine 3
|
||||||
(get-input bloom-strength)
|
(get-input bloom-strength)
|
||||||
(get-input bloom-attenuation))
|
(get-input bloom-attenuation))
|
||||||
|
@ -407,8 +433,6 @@
|
||||||
(fn fxaa-init ()
|
(fn fxaa-init ()
|
||||||
(program prg-fxaa "fxaa.f.glsl")
|
(program prg-fxaa "fxaa.f.glsl")
|
||||||
(pipeline pl-fxaa prg-fullscreen prg-fxaa)
|
(pipeline pl-fxaa prg-fullscreen prg-fxaa)
|
||||||
(uniforms-i prg-fxaa 0 0)
|
|
||||||
(uniforms prg-fxaa 1 $vp-width $vp-height)
|
|
||||||
|
|
||||||
(sampler smp-fxaa
|
(sampler smp-fxaa
|
||||||
(sampling linear)
|
(sampling linear)
|
||||||
|
@ -421,6 +445,11 @@
|
||||||
|
|
||||||
(fn fxaa-render (in-image)
|
(fn fxaa-render (in-image)
|
||||||
(profiling "FXAA"
|
(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)
|
(main-output)
|
||||||
(viewport 0 0 $width $height)
|
(viewport 0 0 $width $height)
|
||||||
(clear 0 0 0 0)
|
(clear 0 0 0 0)
|
||||||
|
|
|
@ -433,7 +433,6 @@ bool T_CompilerImpl_::compileNode(
|
||||||
const auto cpos( output->ops.sizeOf( funcIndex ) );
|
const auto cpos( output->ops.sizeOf( funcIndex ) );
|
||||||
const auto ppos( condJumps.last( ).prevCase );
|
const auto ppos( condJumps.last( ).prevCase );
|
||||||
const auto diff( cpos - ppos );
|
const auto diff( cpos - ppos );
|
||||||
assert( diff > 1 );
|
|
||||||
output->ops.get( funcIndex , ppos ).args[ 0 ] = diff - 1;
|
output->ops.get( funcIndex , ppos ).args[ 0 ] = diff - 1;
|
||||||
} else {
|
} else {
|
||||||
// If there is a previous skip location, insert the skip instruction
|
// If there is a previous skip location, insert the skip instruction
|
||||||
|
@ -649,7 +648,7 @@ bool T_CompilerImpl_::compileNode(
|
||||||
value.f = in.defValue( );
|
value.f = in.defValue( );
|
||||||
addInstruction( OP_UI_INPUT_DFT , {
|
addInstruction( OP_UI_INPUT_DFT , {
|
||||||
uint32_t( output->inputs.indexOf( in.id( ) ) ) ,
|
uint32_t( output->inputs.indexOf( in.id( ) ) ) ,
|
||||||
uint32_t( constants.indexOf( value.u ) + 3 ) } ,
|
uint32_t( constants.indexOf( value.u ) + 3 + output->nVariables ) } ,
|
||||||
node.location( ) );
|
node.location( ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
12
ops.cc
12
ops.cc
|
@ -393,7 +393,7 @@ void T_OpContext::run(
|
||||||
|
|
||||||
case OP_GET_INPUT:
|
case OP_GET_INPUT:
|
||||||
ensureFpuStack( instr , 0 , 1 );
|
ensureFpuStack( instr , 0 , 1 );
|
||||||
x87stack[ x87sp ++ ] = Globals::Sync( ).inputs( )[ instr.args[ 0 ] + 1 ];
|
x87stack[ x87sp ++ ] = Globals::Sync( ).inputs( )[ instr.args[ 0 ] ];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_FP_LOAD:
|
case OP_FP_LOAD:
|
||||||
|
@ -786,11 +786,14 @@ void T_OpContext::run(
|
||||||
|
|
||||||
const auto ss( stack.size( ) );
|
const auto ss( stack.size( ) );
|
||||||
T_OpValue values[ 4 ];
|
T_OpValue values[ 4 ];
|
||||||
|
// printf( "OP_UNIFORMS %d %d" , instr.args[ 0 ] , instr.args[ 1 ] );
|
||||||
for ( auto i = 0u ; i <= instr.args[ 0 ] ; i ++ ) {
|
for ( auto i = 0u ; i <= instr.args[ 0 ] ; i ++ ) {
|
||||||
if ( instr.args[ 1 ] ) {
|
if ( instr.args[ 1 ] ) {
|
||||||
values[ i ] = uint32_t( stack[ ss - 3 - i ].f );
|
values[ i ] = uint32_t( stack[ ss - 3 - i ].f );
|
||||||
|
// printf( " %d" , values[ i ].i );
|
||||||
} else {
|
} else {
|
||||||
values[ i ] = stack[ ss - 3 - i ];
|
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 ] ) {
|
if ( sv == 0 || sv > programs.size( ) || !programs[ sv - 1 ] ) {
|
||||||
throw X_OpFailure{ instr , "invalid program" };
|
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* );
|
typedef void (*F_SetUniform_)( int , int , int , void* );
|
||||||
void const* const funcs[] = {
|
void const* const funcs[] = {
|
||||||
|
@ -815,8 +819,10 @@ void T_OpContext::run(
|
||||||
{
|
{
|
||||||
ensureStack( instr , 4 );
|
ensureStack( instr , 4 );
|
||||||
const auto ss( stack.size( ) );
|
const auto ss( stack.size( ) );
|
||||||
glViewport( stack[ ss - 1 ].f , stack[ ss - 2 ].f ,
|
glViewport( int32_t( stack[ ss - 1 ].f ) ,
|
||||||
stack[ ss - 3 ].f , stack[ ss - 4 ].f );
|
int32_t( stack[ ss - 2 ].f ) ,
|
||||||
|
int32_t( stack[ ss - 3 ].f ) ,
|
||||||
|
int32_t( stack[ ss - 4 ].f ) );
|
||||||
stack.resize( ss - 4 );
|
stack.resize( ss - 4 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue