Skip to content

Commit

Permalink
v100 🎉🎉🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
inanevin committed Nov 19, 2023
1 parent b94bb58 commit c980ec4
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 155 deletions.
247 changes: 140 additions & 107 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ set(CMAKE_CXX_STANDARD 17)

option(LINAGX_BUILD_EXAMPLES "Builds example projects." OFF)

if(WIN32)
option(LINAGX_DISABLE_DX12 "Disables DX12 backend." OFF)
option(LINAGX_DISABLE_VK "Disables Vulkan backend." OFF)
endif()

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
Expand All @@ -53,140 +58,159 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
endif()

if(LINAGX_DISABLE_DX12 AND LINAGX_DISABLE_VK)
message(FATAL_ERROR "Error: Can not disable both DX12 and Vulkan!")
endif()
#--------------------------------------------------------------------
# Set sources
#--------------------------------------------------------------------


set(LinaGX_HEADERS
include/LinaGX/LinaGX.hpp
include/LinaGX/LinaGXExports.hpp
include/LinaGX/Common/CommonData.hpp
include/LinaGX/Common/CommonGfx.hpp
include/LinaGX/Common/Math.hpp
include/LinaGX/Common/Vectors.hpp
include/LinaGX/Core/Backend.hpp
include/LinaGX/Core/Input.hpp
include/LinaGX/Core/InputMappings.hpp
include/LinaGX/Core/Instance.hpp
include/LinaGX/Core/CommandStream.hpp
include/LinaGX/Core/Commands.hpp
include/LinaGX/Core/WindowManager.hpp
include/LinaGX/Core/Window.hpp
include/LinaGX/Utility/SPIRVUtility.hpp
include/LinaGX/Utility/PlatformUtility.hpp
include/LinaGX/Utility/ImageUtility.hpp
include/LinaGX/Utility/ModelUtility.hpp
include/LinaGX/Utility/stb/stb_image_write.h
include/LinaGX/Utility/stb/stb_image_resize.h
include/LinaGX/Utility/stb/stb_image.h
include/LinaGX/Utility/tinygltf/tiny_gltf.h
include/LinaGX/Utility/tinygltf/json.hpp
include/LinaGX/LinaGX.hpp
include/LinaGX/LinaGXExports.hpp
include/LinaGX/Common/CommonData.hpp
include/LinaGX/Common/CommonGfx.hpp
include/LinaGX/Common/Math.hpp
include/LinaGX/Common/Vectors.hpp
include/LinaGX/Core/Backend.hpp
include/LinaGX/Core/Input.hpp
include/LinaGX/Core/InputMappings.hpp
include/LinaGX/Core/Instance.hpp
include/LinaGX/Core/CommandStream.hpp
include/LinaGX/Core/Commands.hpp
include/LinaGX/Core/WindowManager.hpp
include/LinaGX/Core/Window.hpp
include/LinaGX/Utility/SPIRVUtility.hpp
include/LinaGX/Utility/PlatformUtility.hpp
include/LinaGX/Utility/ImageUtility.hpp
include/LinaGX/Utility/ModelUtility.hpp
include/LinaGX/Utility/stb/stb_image_write.h
include/LinaGX/Utility/stb/stb_image_resize.h
include/LinaGX/Utility/stb/stb_image.h
include/LinaGX/Utility/tinygltf/tiny_gltf.h
include/LinaGX/Utility/tinygltf/json.hpp
)

set(LinaGX_SOURCES
src/Common/CommonGfx.cpp
src/Common/CommonData.cpp
src/Common/Math.cpp
src/Core/Backend.cpp
src/Core/Instance.cpp
src/Core/CommandStream.cpp
src/Core/WindowManager.cpp
src/Core/Commands.cpp
src/Utility/SPIRVUtility.cpp
src/Utility/ImageUtility.cpp
src/Utility/ModelUtility.cpp
src/Utility/PlatformUtility.cpp
src/Common/CommonGfx.cpp
src/Common/CommonData.cpp
src/Common/Math.cpp
src/Core/Backend.cpp
src/Core/Instance.cpp
src/Core/CommandStream.cpp
src/Core/WindowManager.cpp
src/Core/Commands.cpp
src/Utility/SPIRVUtility.cpp
src/Utility/ImageUtility.cpp
src/Utility/ModelUtility.cpp
src/Utility/PlatformUtility.cpp
)

set(LinaGX_VK_HEADERS
include/LinaGX/Platform/Vulkan/VKBackend.hpp
include/LinaGX/Platform/Vulkan/SDK/VkBootstrap.h
include/LinaGX/Platform/Vulkan/SDK/VkBootstrapDispatch.h
include/LinaGX/Platform/Vulkan/SDK/vk_mem_alloc.h
)

if(WIN32)

set(LinaGX_PLATFORM_HEADERS

# Windows
include/LinaGX/Platform/Windows/Win32Window.hpp

# Vulkan
include/LinaGX/Platform/Vulkan/VKBackend.hpp
include/LinaGX/Platform/Vulkan/SDK/VkBootstrap.h
include/LinaGX/Platform/Vulkan/SDK/VkBootstrapDispatch.h
include/LinaGX/Platform/Vulkan/SDK/vk_mem_alloc.h

## DX12
include/LinaGX/Platform/DX12/DX12Backend.hpp
include/LinaGX/Platform/DX12/DX12HeapStaging.hpp
include/LinaGX/Platform/DX12/DX12HeapGPU.hpp
include/LinaGX/Platform/DX12/DX12Common.hpp
include/LinaGX/Platform/DX12/SDK/ID3DIncludeInterface.hpp
include/LinaGX/Platform/DX12/SDK/d3d12.h
include/LinaGX/Platform/DX12/SDK/d3d12compatibility.h
include/LinaGX/Platform/DX12/SDK/d3d12sdklayers.h
include/LinaGX/Platform/DX12/SDK/d3d12shader.h
include/LinaGX/Platform/DX12/SDK/d3d12video.h
include/LinaGX/Platform/DX12/SDK/d3dcommon.h
include/LinaGX/Platform/DX12/SDK/d3dx12.h
include/LinaGX/Platform/DX12/SDK/d3dx12_barriers.h
include/LinaGX/Platform/DX12/SDK/d3dx12_check_feature_support.h
include/LinaGX/Platform/DX12/SDK/d3dx12_core.h
include/LinaGX/Platform/DX12/SDK/d3dx12_default.h
include/LinaGX/Platform/DX12/SDK/d3dx12_pipeline_state_stream.h
include/LinaGX/Platform/DX12/SDK/d3dx12_property_format_table.h
include/LinaGX/Platform/DX12/SDK/d3dx12_render_pass.h
include/LinaGX/Platform/DX12/SDK/d3dx12_resource_helpers.h
include/LinaGX/Platform/DX12/SDK/d3dx12_root_signature.h
include/LinaGX/Platform/DX12/SDK/d3dx12_state_object.h
include/LinaGX/Platform/DX12/SDK/dxcore.h
include/LinaGX/Platform/DX12/SDK/dxcore_interface.h
include/LinaGX/Platform/DX12/SDK/dxgicommon.h
include/LinaGX/Platform/DX12/SDK/dxgiformat.h
include/LinaGX/Platform/DX12/SDK/Residency/d3dx12Residency.h
include/LinaGX/Platform/DX12/SDK/D3D12MemAlloc.h
set(LinaGX_DX12_HEADERS
include/LinaGX/Platform/DX12/DX12Backend.hpp
include/LinaGX/Platform/DX12/DX12HeapStaging.hpp
include/LinaGX/Platform/DX12/DX12HeapGPU.hpp
include/LinaGX/Platform/DX12/DX12Common.hpp
include/LinaGX/Platform/DX12/SDK/ID3DIncludeInterface.hpp
include/LinaGX/Platform/DX12/SDK/d3d12.h
include/LinaGX/Platform/DX12/SDK/d3d12compatibility.h
include/LinaGX/Platform/DX12/SDK/d3d12sdklayers.h
include/LinaGX/Platform/DX12/SDK/d3d12shader.h
include/LinaGX/Platform/DX12/SDK/d3d12video.h
include/LinaGX/Platform/DX12/SDK/d3dcommon.h
include/LinaGX/Platform/DX12/SDK/d3dx12.h
include/LinaGX/Platform/DX12/SDK/d3dx12_barriers.h
include/LinaGX/Platform/DX12/SDK/d3dx12_check_feature_support.h
include/LinaGX/Platform/DX12/SDK/d3dx12_core.h
include/LinaGX/Platform/DX12/SDK/d3dx12_default.h
include/LinaGX/Platform/DX12/SDK/d3dx12_pipeline_state_stream.h
include/LinaGX/Platform/DX12/SDK/d3dx12_property_format_table.h
include/LinaGX/Platform/DX12/SDK/d3dx12_render_pass.h
include/LinaGX/Platform/DX12/SDK/d3dx12_resource_helpers.h
include/LinaGX/Platform/DX12/SDK/d3dx12_root_signature.h
include/LinaGX/Platform/DX12/SDK/d3dx12_state_object.h
include/LinaGX/Platform/DX12/SDK/dxcore.h
include/LinaGX/Platform/DX12/SDK/dxcore_interface.h
include/LinaGX/Platform/DX12/SDK/dxgicommon.h
include/LinaGX/Platform/DX12/SDK/dxgiformat.h
include/LinaGX/Platform/DX12/SDK/Residency/d3dx12Residency.h
include/LinaGX/Platform/DX12/SDK/D3D12MemAlloc.h
)

set(LinaGX_VK_SOURCES
src/Platform/Vulkan/VKBackend.cpp
src/Platform/Vulkan/SDK/VkBootstrap.cpp
)

set(LinaGX_PLATFORM_SOURCES
set(LinaGX_DX12_SOURCES
src/Platform/DX12/DX12Backend.cpp
src/Platform/DX12/DX12HeapStaging.cpp
src/Platform/DX12/DX12HeapGPU.cpp
src/Platform/DX12/SDK/D3D12MemAlloc.cpp
src/Platform/DX12/SDK/ID3DIncludeInterface.cpp
)

# Windows
src/Platform/Windows/Win32Window.cpp
src/PlatForm/Windows/Win32Input.cpp

# Vulkan
src/Platform/Vulkan/VKBackend.cpp
src/Platform/Vulkan/SDK/VkBootstrap.cpp
if(WIN32)

# DX12
src/Platform/DX12/DX12Backend.cpp
src/Platform/DX12/DX12HeapStaging.cpp
src/Platform/DX12/DX12HeapGPU.cpp
src/Platform/DX12/SDK/D3D12MemAlloc.cpp
src/Platform/DX12/SDK/ID3DIncludeInterface.cpp
)
set(LinaGX_PLATFORM_HEADERS
include/LinaGX/Platform/Windows/Win32Window.hpp
)

set(LinaGX_PLATFORM_SOURCES
src/Platform/Windows/Win32Window.cpp
src/Platform/Windows/Win32Input.cpp
)

if(NOT LINAGX_DISABLE_DX12 AND NOT LINAGX_DISABLE_VK)
set(LinaGX_API_HEADERS ${LinaGX_VK_HEADERS} ${LinaGX_DX12_HEADERS})
set(LinaGX_API_SOURCES ${LinaGX_VK_SOURCES} ${LinaGX_DX12_SOURCES})
elseif(LINAGX_DISABLE_DX12)
set(LinaGX_API_HEADERS ${LinaGX_VK_HEADERS})
set(LinaGX_API_SOURCES ${LinaGX_VK_SOURCES})
elseif(LINAGX_DISABLE_VK)
set(LinaGX_API_HEADERS ${LinaGX_DX12_HEADERS})
set(LinaGX_API_SOURCES ${LinaGX_DX12_SOURCES})
endif()

endif()

if(APPLE)

set(LinaGX_PLATFORM_HEADERS
include/LinaGX/Platform/Metal/MTLBackend.hpp
include/LinaGX/Platform/Apple/OSXWindow.hpp
include/LinaGX/Platform/Apple/OSXNSWindow.hh
)

set(LinaGX_PLATFORM_SOURCES
src/Platform/Metal/MTLBackend.mm
src/Platform/Apple/OSXWindow.mm
src/Platform/Apple/OSXNSWindow.mm
src/Platform/Apple/OSXInput.mm
)
set(LinaGX_PLATFORM_HEADERS
include/LinaGX/Platform/Apple/OSXWindow.hpp
include/LinaGX/Platform/Apple/OSXNSWindow.hh
)

set(LinaGX_PLATFORM_SOURCES
src/Platform/Apple/OSXWindow.mm
src/Platform/Apple/OSXNSWindow.mm
src/Platform/Apple/OSXInput.mm
)

set(LinaGX_API_HEADERS
include/LinaGX/Platform/Metal/MTLBackend.hpp
)

set(LinaGX_API_SOURCES
src/Platform/Metal/MTLBackend.mm
)
endif()


endif()

#--------------------------------------------------------------------
# Create project
#--------------------------------------------------------------------
add_library(${PROJECT_NAME} ${LinaGX_SOURCES} ${LinaGX_HEADERS} ${LinaGX_PLATFORM_SOURCES} ${LinaGX_PLATFORM_HEADERS})

add_library(${PROJECT_NAME} ${LinaGX_SOURCES} ${LinaGX_HEADERS} ${LinaGX_PLATFORM_SOURCES} ${LinaGX_PLATFORM_HEADERS} ${LinaGX_API_SOURCES} ${LinaGX_API_HEADERS})
add_library(Lina::GX ALIAS ${PROJECT_NAME})
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER LinaGXProject)
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/ProjectSettings.cmake)
Expand All @@ -200,6 +224,15 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC LINAGX_VERSION_MAJOR=1)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAGX_VERSION_MINOR=0)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAGX_VERSION_PATCH=0)

if(LINAGX_DISABLE_DX12)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAGX_DISABLE_DX12=1)
endif()

if(LINAGX_DISABLE_VK)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAGX_DISABLE_VK=1)
endif()


include(Dependencies/Dependencies.cmake)

if(LINAGX_BUILD_EXAMPLES)
Expand All @@ -214,7 +247,7 @@ set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT 0
endif()

if(MSVC_IDE OR APPLE)
foreach(source IN LISTS LinaGX_HEADERS LinaGX_SOURCES LinaGX_PLATFORM_HEADERS LinaGX_PLATFORM_SOURCES)
foreach(source IN LISTS LinaGX_HEADERS LinaGX_SOURCES LinaGX_PLATFORM_HEADERS LinaGX_PLATFORM_SOURCES LinaGX_API_HEADERS LinaGX_API_SOURCES)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "${LinaGX_SOURCE_DIR}" "" relative_source_path "${source_path}")

Expand Down
67 changes: 35 additions & 32 deletions Dependencies/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,45 @@

if(WIN32)

# DX12
target_link_libraries(${PROJECT_NAME}
PRIVATE d3d12.lib
PRIVATE dxgi.lib
PRIVATE dxguid.lib
)

include(Dependencies/dxc/link.cmake)
include(Dependencies/nvapi/link.cmake)
include(Dependencies/pix/link.cmake)
link_dxc()
link_nvapi()
link_pix()


find_package(Vulkan REQUIRED FATAL_ERROR)

target_link_libraries(${PROJECT_NAME}
PRIVATE Vulkan::Vulkan
)

target_link_libraries(${PROJECT_NAME}
PUBLIC user32.lib
PUBLIC Shcore.lib
)
# DX12
if(NOT LINAGX_DISABLE_DX12)
target_link_libraries(${PROJECT_NAME}
PRIVATE d3d12.lib
PRIVATE dxgi.lib
PRIVATE dxguid.lib
)

include(Dependencies/dxc/link.cmake)
include(Dependencies/nvapi/link.cmake)
include(Dependencies/pix/link.cmake)
link_dxc()
link_nvapi()
link_pix()
endif()

if(NOT LINAGX_DISABLE_VK)
find_package(Vulkan REQUIRED FATAL_ERROR)

target_link_libraries(${PROJECT_NAME}
PRIVATE Vulkan::Vulkan
)
endif()

target_link_libraries(${PROJECT_NAME}
PUBLIC user32.lib
PUBLIC Shcore.lib
)

endif()

if(APPLE)
target_link_libraries(${PROJECT_NAME}
PUBLIC "-framework Metal"
PUBLIC "-framework MetalKit"
PUBLIC "-framework AppKit"
PUBLIC "-framework Foundation"
PUBLIC "-framework QuartzCore"
)
target_link_libraries(${PROJECT_NAME}
PUBLIC "-framework Metal"
PUBLIC "-framework MetalKit"
PUBLIC "-framework AppKit"
PUBLIC "-framework Foundation"
PUBLIC "-framework QuartzCore"
)
endif()

add_subdirectory(Dependencies/glslang-12.2.0)
Expand Down
2 changes: 1 addition & 1 deletion Examples/03-RenderTargetsGLTF/src/RenderTargetsGLTF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace LinaGX::Examples

//******************* CONFIGURATION & INITIALIZATION
{
BackendAPI api = BackendAPI::Vulkan;
BackendAPI api = BackendAPI::DX12;

#ifdef LINAGX_PLATFORM_APPLE
api = BackendAPI::Metal;
Expand Down
Loading

0 comments on commit c980ec4

Please sign in to comment.