Organize systems better
This commit is contained in:
@@ -61,7 +61,6 @@ namespace fgl::engine
|
||||
constexpr std::size_t grid_size { 16 };
|
||||
constexpr float factor_offset { 1.0f / static_cast< float >( grid_size ) };
|
||||
|
||||
/*
|
||||
for ( std::size_t x = 0; x < grid_size; ++x )
|
||||
for ( std::size_t y = 0; y < grid_size; ++y )
|
||||
{
|
||||
@@ -96,7 +95,7 @@ namespace fgl::engine
|
||||
|
||||
m_game_objects_root.addGameObject( std::move( obj ) );
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
static Average< float, 60 * 15 > rolling_ms_average;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#include "engine/math/literals/size.hpp"
|
||||
#include "engine/rendering/Renderer.hpp"
|
||||
#include "engine/tree/octtree/OctTreeNode.hpp"
|
||||
#include "systems/GuiSystem.hpp"
|
||||
#include "systems/TerrainSystem.hpp"
|
||||
#include "systems/composition/GuiSystem.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#include "CameraSwapchain.hpp"
|
||||
#include "engine/rendering/SwapChain.hpp"
|
||||
#include "engine/systems/CompositionSystem.hpp"
|
||||
#include "engine/systems/CullingSystem.hpp"
|
||||
#include "engine/systems/EntityRendererSystem.hpp"
|
||||
#include "engine/systems/LineDrawer.hpp"
|
||||
#include "engine/systems/composition/CompositionSystem.hpp"
|
||||
#include "engine/systems/prerender/CullingSystem.hpp"
|
||||
#include "engine/systems/render/EntityRendererSystem.hpp"
|
||||
#include "engine/systems/render/LineDrawer.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 3/11/24.
|
||||
//
|
||||
|
||||
#include "TerrainSystem.hpp"
|
||||
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
#include "DrawPair.hpp"
|
||||
#include "engine/camera/Camera.hpp"
|
||||
#include "engine/math/literals/size.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
/*
|
||||
TerrainSystem::TerrainSystem( Device& device, vk::raii::RenderPass& render_pass )
|
||||
{
|
||||
ZoneScoped;
|
||||
PipelineConfigInfo info { render_pass };
|
||||
|
||||
PipelineConfigInfo::setPointPatch( info );
|
||||
PipelineConfigInfo::setQuadTesselation( info );
|
||||
|
||||
info.assembly_info.topology = vk::PrimitiveTopology::ePatchList;
|
||||
|
||||
for ( int i = 0; i < 3; ++i ) PipelineConfigInfo::addColorAttachmentConfig( info );
|
||||
|
||||
info.subpass = 0;
|
||||
|
||||
m_pipeline = std::make_unique< Pipeline >( device, std::move( info ) );
|
||||
m_pipeline->setDebugName( "Terrain pipeline" );
|
||||
|
||||
using namespace fgl::literals::size_literals;
|
||||
|
||||
initVertexBuffer( 16_MiB );
|
||||
initIndexBuffer( 2_MiB );
|
||||
|
||||
this->m_index_buffer->setDebugName( "Terrain index buffer" );
|
||||
this->m_vertex_buffer->setDebugName( "Terrain vertex buffer" );
|
||||
}
|
||||
|
||||
vk::raii::CommandBuffer& TerrainSystem::setupSystem( FrameInfo& info )
|
||||
{
|
||||
auto& command_buffer { info.command_buffer };
|
||||
m_pipeline->bind( command_buffer );
|
||||
|
||||
m_pipeline->bindDescriptor( command_buffer, 0, info.global_descriptor_set );
|
||||
m_pipeline->bindDescriptor( command_buffer, 1, Texture::getTextureDescriptorSet() );
|
||||
|
||||
return info.command_buffer;
|
||||
}
|
||||
|
||||
void TerrainSystem::pass( [[maybe_unused]] FrameInfo& info )
|
||||
{
|
||||
ZoneScopedN( "Terrain pass" );
|
||||
auto& command_buffer { setupSystem( info ) };
|
||||
TracyVkZone( info.tracy_ctx, *command_buffer, "Render terrain" );
|
||||
|
||||
return;
|
||||
|
||||
auto [ draw_commands, model_matricies ] =
|
||||
getDrawCallsFromTree( info.game_objects, info.camera_data.camera.getFrustumBounds(), IS_VISIBLE );
|
||||
|
||||
if ( draw_commands.size() == 0 ) return;
|
||||
|
||||
//Load commands and matricies into buffer
|
||||
auto& draw_parameter_buffer { m_draw_parameter_buffers[ info.frame_idx ] };
|
||||
draw_parameter_buffer =
|
||||
std::make_unique< DrawParameterBufferSuballocation >( info.draw_parameter_buffer, draw_commands );
|
||||
|
||||
auto& model_matrix_info_buffer { m_model_matrix_info_buffers[ info.frame_idx ] };
|
||||
|
||||
model_matrix_info_buffer =
|
||||
std::make_unique< ModelMatrixInfoBufferSuballocation >( info.model_matrix_info_buffer, model_matricies );
|
||||
|
||||
const std::vector< vk::Buffer > vertex_buffers { m_vertex_buffer->getVkBuffer(),
|
||||
model_matrix_info_buffer->getVkBuffer() };
|
||||
|
||||
command_buffer.bindVertexBuffers( 0, vertex_buffers, { 0, model_matrix_info_buffer->getOffset() } );
|
||||
command_buffer.bindIndexBuffer( m_index_buffer->getVkBuffer(), 0, vk::IndexType::eUint32 );
|
||||
|
||||
command_buffer.drawIndexedIndirect(
|
||||
draw_parameter_buffer->getVkBuffer(),
|
||||
draw_parameter_buffer->getOffset(),
|
||||
draw_parameter_buffer->size(),
|
||||
draw_parameter_buffer->stride() );
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 3/11/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "concepts.hpp"
|
||||
#include "engine/FrameInfo.hpp"
|
||||
#include "engine/memory/buffers/vector/HostVector.hpp"
|
||||
#include "engine/camera/Camera.hpp"
|
||||
#include "engine/assets/model/Model.hpp"
|
||||
#include "engine/rendering/SwapChain.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
/*
|
||||
class TerrainSystem
|
||||
{
|
||||
using VertexShader = VertexShaderT< "shaders/terrain/terrain.vert.spv" >;
|
||||
using FragmentShader = FragmentShaderT< "shaders/terrain/terrain.frag.spv" >;
|
||||
using TessCShader = TesselationControlShaderT< "shaders/terrain/terrain.tesc.spv" >;
|
||||
using TessEShader = TesselationEvaluationShaderT< "shaders/terrain/terrain.tese.spv" >;
|
||||
|
||||
using Shaders = ShaderCollection< VertexShader, FragmentShader, TessCShader, TessEShader >;
|
||||
using DescriptorSets =
|
||||
descriptors::DescriptorSetCollection< GlobalDescriptorSet, CameraDescriptorSet, TextureDescriptorSet >;
|
||||
|
||||
using Pipeline = PipelineT< Shaders, DescriptorSets >;
|
||||
|
||||
std::unique_ptr< Pipeline > m_pipeline { nullptr };
|
||||
|
||||
std::unique_ptr< memory::Buffer > m_vertex_buffer { nullptr };
|
||||
std::unique_ptr< memory::Buffer > m_index_buffer { nullptr };
|
||||
|
||||
using DrawParameterBufferSuballocation = HostVector< vk::DrawIndexedIndirectCommand >;
|
||||
|
||||
using ModelMatrixInfoBufferSuballocation = HostVector< ModelMatrixInfo >;
|
||||
|
||||
std::array< std::unique_ptr< DrawParameterBufferSuballocation >, SwapChain::MAX_FRAMES_IN_FLIGHT >
|
||||
m_draw_parameter_buffers {};
|
||||
|
||||
std::array< std::unique_ptr< ModelMatrixInfoBufferSuballocation >, SwapChain::MAX_FRAMES_IN_FLIGHT >
|
||||
m_model_matrix_info_buffers {};
|
||||
|
||||
vk::raii::CommandBuffer& setupSystem( FrameInfo& info );
|
||||
|
||||
void initVertexBuffer( std::uint32_t size )
|
||||
{
|
||||
m_vertex_buffer = std::make_unique< memory::Buffer >(
|
||||
size,
|
||||
vk::BufferUsageFlagBits::eVertexBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal );
|
||||
}
|
||||
|
||||
void initIndexBuffer( std::uint32_t size )
|
||||
{
|
||||
m_index_buffer = std::make_unique< memory::Buffer >(
|
||||
size,
|
||||
vk::BufferUsageFlagBits::eIndexBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal );
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline memory::Buffer& getVertexBuffer() { return *m_vertex_buffer; }
|
||||
|
||||
inline memory::Buffer& getIndexBuffer() { return *m_index_buffer; }
|
||||
|
||||
TerrainSystem( Device& device, vk::raii::RenderPass& render_pass );
|
||||
~TerrainSystem() = default;
|
||||
|
||||
void pass( FrameInfo& info );
|
||||
};
|
||||
|
||||
static_assert( is_system< TerrainSystem > );
|
||||
*/
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "concepts.hpp"
|
||||
#include "engine/FrameInfo.hpp"
|
||||
#include "engine/systems/concepts.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "concepts.hpp"
|
||||
#include "engine/systems/concepts.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
Reference in New Issue
Block a user