Get GPU driven rendering mostly working

This commit is contained in:
2025-04-06 11:30:09 -04:00
parent 3a55398364
commit 32953416a2
73 changed files with 1007 additions and 560 deletions

View File

@@ -10,11 +10,17 @@
namespace fgl::engine::components
{
ModelComponent::ModelComponent( const std::shared_ptr< Model >& model ) :
m_model_instance( model->createInstance() ),
m_transform()
{}
void ModelComponent::drawImGui()
{
// drawComponentTransform( m_transform );
// TODO: If the model is not set then we should be able to set it to one from the file selection
/*
if ( this->m_model == nullptr )
{
ImGui::Text( "Undefined model" );
@@ -24,13 +30,14 @@ namespace fgl::engine::components
const auto& model { *this->m_model };
ImGui::Text( "%li primitives", model.m_primitives.size() );
*/
}
std::string_view ModelComponent::humanName() const
{
if ( !m_model ) return "Empty";
return m_model->getName();
if ( !m_model_instance ) return "Empty";
return "TODO";
// return m_model_instance->getModel()->getName();
}
std::string_view ModelComponent::className() const
@@ -38,6 +45,7 @@ namespace fgl::engine::components
return "ModelComponent";
}
/*
Model* ModelComponent::operator->()
{
return m_model.get();
@@ -47,4 +55,5 @@ namespace fgl::engine::components
{
return m_model.get();
}
} // namespace fgl::engine
*/
} // namespace fgl::engine::components

View File

@@ -0,0 +1,31 @@
//
// Created by kj16609 on 4/5/25.
//
#include "engine/gameobjects/components/TransformComponent.hpp"
#include "engine/assets/model/Model.hpp"
#include "gui/safe_include.hpp"
namespace fgl::engine::components
{
TransformComponent::TransformComponent( const WorldTransform& transform ) : m_transform( transform )
{}
void TransformComponent::drawImGui()
{}
std::string_view TransformComponent::humanName() const
{
return "Transform";
}
std::string_view TransformComponent::className() const
{
return "TransformComponent";
}
WorldTransform& TransformComponent::operator*()
{
return m_transform;
}
} // namespace fgl::engine::components

View File

@@ -218,6 +218,10 @@ namespace fgl::engine::filesystem
void FileBrowser::openFolder( const DirInfo& dir )
{
m_old_textures.push( m_file_textures );
if ( m_old_textures.size() > constants::MAX_FRAMES_IN_FLIGHT ) m_old_textures.pop();
m_file_textures.clear();
m_current_dir = std::make_unique< DirInfo >( dir.m_path );
}

View File

@@ -21,6 +21,7 @@ namespace fgl::engine::filesystem
struct FileBrowser
{
std::unordered_map< std::filesystem::path, std::shared_ptr< Texture > > m_file_textures {};
std::queue< std::unordered_map< std::filesystem::path, std::shared_ptr< Texture > > > m_old_textures;
std::unique_ptr< DirInfo > m_current_dir { nullptr };

View File

@@ -99,6 +99,7 @@ namespace fgl::engine::gui
void itterateGameObjectNode( FrameInfo& info, OctTreeNode& node )
{
/*
if ( node.isLeaf() )
{
if ( node.itemCount() == 0 ) return;
@@ -143,6 +144,7 @@ namespace fgl::engine::gui
}
}
}
*/
}
void drawEntityGUI( FrameInfo& info )
@@ -152,6 +154,7 @@ namespace fgl::engine::gui
// itterateGameObjectNode( info, info.game_objects );
/*
for ( OctTreeNodeLeaf* leaf : info.game_objects.getAllLeafs() )
{
for ( GameObject& entity : *leaf )
@@ -166,6 +169,7 @@ namespace fgl::engine::gui
ImGui::PopID();
}
}
*/
ImGui::End();
}

View File

@@ -44,27 +44,24 @@ namespace fgl::engine::gui
// Load model and drop it into the game objects
GameObject obj { GameObject::createGameObject() };
std::shared_ptr< Model > model {
Model::
createModel( data->m_path, info.model_vertex_buffer, info.model_index_buffer )
};
std::shared_ptr< Model > model { Model::createModel( data->m_path ) };
obj.addFlag( IsEntity | IsVisible );
info.context.models()
.loadModel( data->m_path, info.model_vertex_buffer, info.model_index_buffer );
// info.context.models().loadModel( data->m_path );
auto component { std::make_unique< components::ModelComponent >( std::move( model ) ) };
auto component { std::make_unique< components::ModelComponent >( model ) };
obj.addComponent( std::move( component ) );
info.game_objects.addGameObject( std::move( obj ) );
info.game_objects.emplace_back( std::move( obj ) );
break;
}
case filesystem::SCENE:
{
SceneBuilder builder { info.model_vertex_buffer, info.model_index_buffer };
auto& buffers { getModelBuffers() };
SceneBuilder builder { buffers.m_vertex_buffer, buffers.m_index_buffer };
builder.loadScene( data->m_path );
@@ -72,7 +69,7 @@ namespace fgl::engine::gui
for ( auto& obj : objs )
{
info.game_objects.addGameObject( std::move( obj ) );
info.game_objects.emplace_back( std::move( obj ) );
}
}
}
@@ -173,7 +170,7 @@ namespace fgl::engine::gui
void drawRenderingOutputs( FrameInfo& info, const Camera& camera )
{
ZoneScoped;
const auto frame_index { info.frame_idx };
const auto frame_index { info.in_flight_idx };
static std::uint_fast8_t current { Composite };

View File

@@ -63,7 +63,7 @@ int main()
editor_camera->setFOV( glm::radians( 90.0f ) );
// Create a default world to assign to the engine before we load or create a new one.
World world {};
// World world {};
constexpr bool playing { false };
@@ -74,9 +74,9 @@ int main()
engine_ctx.tickDeltaTime();
engine_ctx.setWorld( world );
// engine_ctx.setWorld( world );
if ( playing ) world = engine_ctx.tickSimulation();
// if ( playing ) world = engine_ctx.tickSimulation();
engine_ctx.handleTransfers();
@@ -86,7 +86,7 @@ int main()
// Here we can decide if we want to tick fully or not.
// Simulate step
engine_ctx.tickSimulation();
// engine_ctx.tickSimulation();
// Update the viewer camera