Skip to content

Commit

Permalink
Revert "Modern operators in renderer"
Browse files Browse the repository at this point in the history
This reverts commit f82db7d.
  • Loading branch information
sguionni committed May 23, 2024
1 parent f82db7d commit 221052b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 55 deletions.
12 changes: 6 additions & 6 deletions lib/renderer/bench/src/user_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ namespace VTX::Bench
SDL_GL_SetSwapInterval( _vsync );

// Init ImGui.
if ( not IMGUI_CHECKVERSION() )
if ( IMGUI_CHECKVERSION() == false )
{
throw std::runtime_error( "IMGUI_CHECKVERSION() failed" );
}

ImGui::CreateContext();
ImGui::StyleColorsDark();

if ( not ImGui_ImplSDL2_InitForOpenGL( _window, _glContext ) )
if ( ImGui_ImplSDL2_InitForOpenGL( _window, _glContext ) == false )
{
throw std::runtime_error( "ImGui_ImplSDL2_InitForOpenGL failed" );
}
if ( not ImGui_ImplOpenGL3_Init( "#version 450 core" ) )
if ( ImGui_ImplOpenGL3_Init( "#version 450 core" ) == false )
{
throw std::runtime_error( "ImGui_ImplOpenGL3_Init failed" );
}
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace VTX::Bench

void _drawRenderer( Renderer::Renderer * const p_renderer )
{
if ( ImGui::Begin( "Renderer" ) and p_renderer->hasContext() )
if ( ImGui::Begin( "Renderer" ) && p_renderer->hasContext() )
{
size_t sizeAtoms = 0, sizeBonds = 0, sizeRibbons = 0, sizeVoxels = 0;
for ( auto count : p_renderer->drawRangeSpheres.counts )
Expand Down Expand Up @@ -656,7 +656,7 @@ namespace VTX::Bench
for ( const Uniform & uniform : program.uniforms )
{
std::string key = pass->name + program.name + uniform.name;
bool isEditable = isBuilt and isInRenderQueue;
bool isEditable = isBuilt && isInRenderQueue;

// ImGui::Text( uniform.name.c_str() );
ImGui::SetNextItemWidth( 150 );
Expand Down Expand Up @@ -887,7 +887,7 @@ namespace VTX::Bench
}
}

if ( p_isEditable and updated )
if ( p_isEditable && updated )
{
p_renderer->setValue( value, p_key );
}
Expand Down
4 changes: 2 additions & 2 deletions lib/renderer/include/renderer/context/gl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace VTX::Renderer::Context::GL
inline void setData( const std::vector<T> & p_vector, const GLenum p_usage )
{
assert( glIsBuffer( _id ) );
assert( not p_vector.empty() );
assert( p_vector.empty() == false );

GLsizei size = GLsizei( sizeof( T ) * p_vector.size() );

Expand Down Expand Up @@ -160,7 +160,7 @@ namespace VTX::Renderer::Context::GL
inline void setStorage( const std::vector<T> & p_vector, const GLbitfield p_flags = 0 )
{
assert( glIsBuffer( _id ) );
assert( not p_vector.empty() );
assert( p_vector.empty() == false );

GLsizei size = GLsizei( sizeof( T ) * p_vector.size() );

Expand Down
10 changes: 5 additions & 5 deletions lib/renderer/include/renderer/render_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ namespace VTX::Renderer
}

bool addLink(
Pass * const p_passSrc,
Pass * const p_passDest,
const E_CHAN_OUT & p_channelSrc = E_CHAN_OUT::COLOR_0,
const E_CHAN_IN & p_channelDest = E_CHAN_IN::_0
Pass * const p_passSrc,
Pass * const p_passDest,
const E_CHAN_OUT & p_channelSrc = E_CHAN_OUT::COLOR_0,
const E_CHAN_IN & p_channelDest = E_CHAN_IN::_0
)
{
// Check I/O existence.
Expand All @@ -81,7 +81,7 @@ namespace VTX::Renderer
visitor, p_passSrc->outputs[ p_channelSrc ].desc, p_passDest->inputs[ p_channelDest ].desc
);

if ( not areCompatible )
if ( areCompatible == false )
{
VTX_WARNING( "{}", "Descriptors are not compatible" );
return false;
Expand Down
8 changes: 3 additions & 5 deletions lib/renderer/include/renderer/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ namespace VTX::Renderer
const size_t p_height,
const FilePath & p_shaderPath,
void * p_loader = nullptr
) :
width( p_width ),
height( p_height ), _shaderPath( p_shaderPath ), _loader( p_loader )
) : width( p_width ), height( p_height ), _shaderPath( p_shaderPath ), _loader( p_loader )
{
// Graph.
_renderGraph = std::make_unique<RenderGraphOpenGL45>();
Expand Down Expand Up @@ -170,7 +168,7 @@ namespace VTX::Renderer
_render( p_time );
}

if ( not forceUpdate )
if ( forceUpdate == false )
{
if ( _needUpdate )
{
Expand Down Expand Up @@ -218,7 +216,7 @@ namespace VTX::Renderer
inline void setNeedUpdate( const bool p_value )
{
_needUpdate = p_value;
if ( not p_value )
if ( p_value == false )
{
_framesRemaining = BUFFER_COUNT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace VTX::Renderer::Scheduler
std::vector<size_t> sorted;
for ( size_t index = 0; index < passes.size(); ++index )
{
if ( not visited[ index ] )
if ( visited[ index ] == false )
{
_depthFirstSearch( p_passes, adjacentList, index, visited, onStack, isCyclic, sorted );
if ( isCyclic )
Expand Down Expand Up @@ -120,7 +120,7 @@ namespace VTX::Renderer::Scheduler
return;
}

if ( not p_visited[ neighbour ] )
if ( p_visited[ neighbour ] == false )
{
_depthFirstSearch(
p_passes, p_adjacencyLists, neighbour, p_visited, p_onStack, p_isCyclic, p_sorted
Expand Down
58 changes: 31 additions & 27 deletions lib/renderer/src/renderer/context/opengl_45.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ namespace VTX::Renderer::Context
assert( p_width > 0 );
assert( p_height > 0 );

if ( not gladLoaded )
if ( gladLoaded )
{
VTX_WARNING( "GLAD loaded" );
}
else
{
VTX_WARNING( "GLAD not loaded" );
}

// Load opengl 4.5.
// With external loader.
if ( p_proc and gladLoadGLLoader( (GLADloadproc)p_proc ) == 0 )
if ( p_proc && gladLoadGLLoader( (GLADloadproc)p_proc ) == 0 )
{
VTX_ERROR( "Failed to load OpenGL" );
// throw GLException( "Failed to load OpenGL" );
Expand All @@ -29,7 +33,7 @@ namespace VTX::Renderer::Context
}

// Check version.
if ( not GLAD_GL_VERSION_4_5 )
if ( GLAD_GL_VERSION_4_5 == false )
{
VTX_ERROR( "OpenGL 4.5 or higher is required" );
// throw GLException( "OpenGL 4.5 or higher is required" );
Expand Down Expand Up @@ -108,7 +112,7 @@ namespace VTX::Renderer::Context
_output = p_output;

// Create shared buffers.
if ( not p_uniforms.empty() )
if ( p_uniforms.empty() == false )
{
p_outInstructionsDurationRanges.emplace_back( InstructionsDurationRange { "Start",
p_outInstructions.size() } );
Expand All @@ -118,7 +122,7 @@ namespace VTX::Renderer::Context
const Key keyBuffer = _getKey( uniform );
buffers.push_back( keyBuffer );

if ( not _buffers.contains( keyBuffer ) )
if ( _buffers.contains( keyBuffer ) == false )
{
_buffers.emplace( keyBuffer, std::make_unique<GL::Buffer>() );
}
Expand Down Expand Up @@ -150,12 +154,12 @@ namespace VTX::Renderer::Context
_createInputs( p_links, descPassPtr, vertexArrays, buffers, textures );

// Create FBO.
if ( not isLastPass )
if ( isLastPass == false )
{
Key keyFramebuffer = _getKey( *descPassPtr );
framebuffers.push_back( keyFramebuffer );

if ( not _framebuffers.contains( keyFramebuffer ) )
if ( _framebuffers.contains( keyFramebuffer ) == false )
{
_framebuffers.emplace( keyFramebuffer, std::make_unique<GL::Framebuffer>() );
}
Expand All @@ -164,7 +168,7 @@ namespace VTX::Renderer::Context
_createOuputs( descPassPtr, drawBuffers, textures );

// Set draw buffers.
if ( not drawBuffers.empty() )
if ( drawBuffers.empty() == false )
{
_framebuffers[ keyFramebuffer ]->setDrawBuffers( drawBuffers );
}
Expand All @@ -180,18 +184,18 @@ namespace VTX::Renderer::Context
const Key keyProgram = _getKey( descPassPtr, descProgram );
programs.push_back( keyProgram );

if ( not _programs.contains( keyProgram ) )
if ( _programs.contains( keyProgram ) == false )
{
_programs.emplace( keyProgram, program );
}

// Uniforms.
if ( not descProgram.uniforms.empty() )
if ( descProgram.uniforms.empty() == false )
{
const Key keyBuffer = _getKey( descPassPtr, descProgram );
buffers.push_back( keyBuffer );

if ( not _buffers.contains( keyBuffer ) )
if ( _buffers.contains( keyBuffer ) == false )
{
_buffers.emplace( keyBuffer, std::make_unique<GL::Buffer>() );
}
Expand Down Expand Up @@ -219,7 +223,7 @@ namespace VTX::Renderer::Context
}

// Bind fbo.
if ( not isLastPass )
if ( isLastPass == false )
{
GL::Framebuffer * const fbo = _framebuffers[ keyPass ].get();
p_outInstructions.emplace_back( [ fbo ]() { fbo->bind( GL_DRAW_FRAMEBUFFER ); } );
Expand Down Expand Up @@ -308,7 +312,7 @@ namespace VTX::Renderer::Context
{
const Key keyProgram = _getKey( descPassPtr, descProgram );

if ( not descProgram.uniforms.empty() )
if ( descProgram.uniforms.empty() == false )
{
assert( _buffers.contains( keyProgram ) );

Expand Down Expand Up @@ -350,7 +354,7 @@ namespace VTX::Renderer::Context
p_outInstructions.emplace_back(
[ program, vao, ebo, primitive, ranges, needRenderFun ]()
{
if ( needRenderFun == nullptr or needRenderFun() )
if ( needRenderFun == nullptr || needRenderFun() )
{
vao->bind();
vao->bindElementBuffer( *ebo );
Expand All @@ -374,7 +378,7 @@ namespace VTX::Renderer::Context
p_outInstructions.emplace_back(
[ program, vao, primitive, ranges, needRenderFun ]()
{
if ( needRenderFun == nullptr or needRenderFun() )
if ( needRenderFun == nullptr || needRenderFun() )
{
vao->bind();
program->use();
Expand Down Expand Up @@ -406,7 +410,7 @@ namespace VTX::Renderer::Context
);
}

if ( not descProgram.uniforms.empty() )
if ( descProgram.uniforms.empty() == false )
{
assert( _buffers.contains( keyProgram ) );
GL::Buffer * ubo = _buffers[ keyProgram ].get();
Expand All @@ -424,7 +428,7 @@ namespace VTX::Renderer::Context
}

// Unbind fbo.
if ( not isLastPass )
if ( isLastPass == false )
{
const Key k = _getKey( *descPassPtr );
assert( _framebuffers.contains( k ) );
Expand Down Expand Up @@ -607,7 +611,7 @@ namespace VTX::Renderer::Context
// Create and bind buffers.
for ( ComputePass::Data * const data : p_pass.data )
{
if ( not _computeBuffers.contains( data ) )
if ( _computeBuffers.contains( data ) == false )
{
_computeBuffers.emplace( data, std::make_unique<GL::Buffer>( GLsizei( data->size ), data->data ) );
}
Expand Down Expand Up @@ -637,7 +641,7 @@ namespace VTX::Renderer::Context
z = 1;
}

assert( x and y and z );
assert( x && y && z );

glMemoryBarrier( GL_SHADER_STORAGE_BARRIER_BIT );
glDispatchCompute( x, y, z );
Expand Down Expand Up @@ -683,7 +687,7 @@ namespace VTX::Renderer::Context
const Attachment & attachment = std::get<Attachment>( descIO );
const auto src = _getInputTextureKey( p_links, p_descPassPtr, channel );

if ( not src.has_value() and attachment.data != nullptr )
if ( src.has_value() == false && attachment.data != nullptr )
{
_createTexture( descIO, _getKey( *p_descPassPtr, true, uint( channel ) ), p_textures );
}
Expand All @@ -700,12 +704,12 @@ namespace VTX::Renderer::Context
p_vertexArrays.push_back( keyVao );
p_buffers.push_back( keyEbo );

if ( not _vertexArrays.contains( keyVao ) )
if ( _vertexArrays.contains( keyVao ) == false )
{
_vertexArrays.emplace( keyVao, std::make_unique<GL::VertexArray>() );
}

if ( not _buffers.contains( keyEbo ) )
if ( _buffers.contains( keyEbo ) == false )
{
_buffers.emplace( keyEbo, std::make_unique<GL::Buffer>() );
}
Expand All @@ -721,7 +725,7 @@ namespace VTX::Renderer::Context
const Key keyData = _getKey( input, entry );
p_buffers.push_back( keyData );

if ( not _buffers.contains( keyData ) )
if ( _buffers.contains( keyData ) == false )
{
_buffers.emplace( keyData, std::make_unique<GL::Buffer>() );
}
Expand Down Expand Up @@ -785,7 +789,7 @@ namespace VTX::Renderer::Context
p_links.begin(),
p_links.end(),
[ p_pass, p_channel ]( const std::unique_ptr<Link> & p_e )
{ return p_e->dest == p_pass and p_e->channelDest == p_channel; }
{ return p_e->dest == p_pass && p_e->channelDest == p_channel; }
);

if ( it == p_links.end() )
Expand Down Expand Up @@ -833,7 +837,7 @@ namespace VTX::Renderer::Context

p_textures.push_back( p_key );

if ( not _textures.contains( p_key ) )
if ( _textures.contains( p_key ) == false )
{
_textures.emplace(
p_key,
Expand Down Expand Up @@ -887,11 +891,11 @@ namespace VTX::Renderer::Context
{
padding = 4 - ( size % 4 );
}
else if ( size > 4 and size % 8 != 0 )
else if ( size > 4 && size % 8 != 0 )
{
padding = 8 - ( size % 8 );
}
else if ( size > 8 and size % 16 != 0 )
else if ( size > 8 && size % 16 != 0 )
{
padding = 16 - ( size % 16 );
}
Expand Down
Loading

0 comments on commit 221052b

Please sign in to comment.