From f9030253e9c4bf60789161c1487ac6311401a5aa Mon Sep 17 00:00:00 2001 From: kj16609 Date: Mon, 17 Jun 2024 04:08:34 -0400 Subject: [PATCH] Moves around assets stuff in cmake --- CMakeLists.txt | 22 +++++++++++++++------- src/engine/EngineContext.cpp | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf63d65..31d4d37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,10 +59,14 @@ foreach (ASSET IN LISTS ASSETS) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/${REL_PATH}) endif () + set(OUT_PATH ${CMAKE_BINARY_DIR}/bin/assets/${REL_PATH}${FILENAME}) + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/assets/${FILENAME} - COMMAND ${CMAKE_COMMAND} -E copy ${ASSET} ${CMAKE_BINARY_DIR}/bin/assets/${FILENAME} - COMMENT " Copying ${ASSET} ") + COMMAND ${CMAKE_COMMAND} -E copy ${ASSET} ${OUT_PATH} + COMMENT " Copying ${ASSET} to ${OUT_PATH}") + list(APPEND OUT_ASSETS ${CMAKE_BINARY_DIR}/bin/assets/${FILENAME}) + list(APPEND ADDITIONAL_CLEAN_FILES ${OUT_PATH}) endforeach () file(GLOB_RECURSE SHADERS @@ -81,12 +85,16 @@ foreach (SHADER IN LISTS SHADERS) set(REL_PATH ${REL_PATH}/) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/shaders/${REL_PATH}) endif () - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/shaders/${FILENAME}.spv - COMMAND ${Vulkan_GLSLC_EXECUTABLE} ${SHADER_DEBUG_FLAGS} ${SHADER} -o ${CMAKE_BINARY_DIR}/bin/shaders/${REL_PATH}${FILENAME}.spv DEPENDS ${SHADER} - COMMENT " Compiling ${SHADER} ") - list(APPEND SPV_SHADERS ${CMAKE_BINARY_DIR}/bin/shaders/${FILENAME}.spv) -endforeach () + set(OUT_PATH ${CMAKE_BINARY_DIR}/bin/shaders/${REL_PATH}${FILENAME}.spv) + + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/shaders/${FILENAME}.spv + COMMAND ${Vulkan_GLSLC_EXECUTABLE} ${SHADER_DEBUG_FLAGS} ${SHADER} -o ${OUT_PATH} DEPENDS ${SHADER} + COMMENT " Compiling ${SHADER} ") + + list(APPEND SPV_SHADERS ${CMAKE_BINARY_DIR}/bin/shaders/${FILENAME}.spv) + list(APPEND ADDITIONAL_CLEAN_FILES ${OUT_PATH}) +endforeach () add_custom_target(shaders ALL DEPENDS ${SPV_SHADERS}) add_custom_target(assets ALL DEPENDS ${OUT_ASSETS}) diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index aaf1197..67aa310 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -69,7 +69,7 @@ namespace fgl::engine SwapChain::MAX_FRAMES_IN_FLIGHT }; std::shared_ptr< Texture > debug_tex { - getTextureStore().load( "models/textures/DebugTexture.png", vk::Format::eR8G8B8A8Unorm ) + getTextureStore().load( "assets/textures/DebugTexture.png", vk::Format::eR8G8B8A8Unorm ) }; constexpr std::uint32_t matrix_default_size { 64_MiB }; @@ -224,7 +224,7 @@ namespace fgl::engine { std::shared_ptr< Model > model { Model::createModel( Device::getInstance(), - "models/night_heron8.obj", + "assets/night_heron8.obj", m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) }; @@ -246,7 +246,7 @@ namespace fgl::engine { std::shared_ptr< Model > model { Model::createModel( Device::getInstance(), - "models/khronos-sponza/Sponza.gltf", + "assets/khronos-sponza/Sponza.gltf", m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) }; @@ -277,13 +277,13 @@ namespace fgl::engine /* { ZoneScopedN( "Load phyiscs test" ); - std::vector< std::shared_ptr< Model > > models { Model::createModelsFromScene( + std::vector< std::shared_ptr< Model > > assets { Model::createModelsFromScene( Device::getInstance(), - "models/PhysicsTest.glb", + "assets/PhysicsTest.glb", m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) }; - for ( auto& model : models ) + for ( auto& model : assets ) { GameObject object { GameObject::createGameObject() }; object.m_model = std::move( model ); @@ -303,7 +303,7 @@ namespace fgl::engine generateTerrainModel( m_terrain_system.getVertexBuffer(), m_terrain_system.getIndexBuffer() ) }; - //Texture texture { Texture::loadFromFile( "models/Vally/textures/heightmap.png" ) }; + //Texture texture { Texture::loadFromFile( "assets/Vally/textures/heightmap.png" ) }; Texture texture { Texture::generateFromPerlinNoise( 1024, 1024, 120 ) }; Sampler sampler { vk::Filter::eLinear, @@ -334,7 +334,7 @@ namespace fgl::engine { std::shared_ptr< Model > model { Model::createModel( Device::getInstance(), - "models/smooth_vase.obj", + "assets/smooth_vase.obj", m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) }; @@ -352,7 +352,7 @@ namespace fgl::engine { std::shared_ptr< Model > flat_model { Model::createModel( Device::getInstance(), - "models/flat_vase.obj", + "assets/flat_vase.obj", m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) }; @@ -369,7 +369,7 @@ namespace fgl::engine { std::shared_ptr< Model > quad_model { Model::createModel( Device::getInstance(), - "models/quad.obj", + "assets/quad.obj", m_entity_renderer.getVertexBuffer(), m_entity_renderer.getIndexBuffer() ) };