Skip to content

Commit

Permalink
Merge pull request #7 from alfonsmagd/feature/CreateContextVK
Browse files Browse the repository at this point in the history
Feature/create context vk
  • Loading branch information
alfonsmagd authored Oct 6, 2024
2 parents 6cc775a + bf587fb commit 49e52cd
Show file tree
Hide file tree
Showing 74 changed files with 37,994 additions and 139 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ yarn-error.log
# Build directory
/build/
/Logos
/Ifnity/Ifnity/vendor/imgui/examples
2 changes: 2 additions & 0 deletions Ifnity/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(IFNITYPROYECT)

# Define la opción y propágala a los subdirectorios
option(BUILD_SHARED_IFNITY "Build Ifnity as a shared library dll" OFF)
# Asegurar modulos cmake
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

Expand Down
38 changes: 0 additions & 38 deletions Ifnity/CMakeSettings.json

This file was deleted.

37 changes: 33 additions & 4 deletions Ifnity/Ifnity/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.8)
project(Ifnity)


#Options


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand All @@ -14,6 +18,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DIST ${CMAKE_BINARY_DIR}/Dist)



# Buscar nvml.dll en el sistema
find_file(NVML_LIBRARY
NAMES nvml.dll
Expand All @@ -28,6 +33,9 @@ else()
endif()


#Test if the system has vulkan,d3d11,d3d12,opengl.
include(${PROJECT_SOURCE_DIR}/FindGraphicsAPIs.cmake)

#Rutas nvml.lib
set(NVML_LIB_PATH "${PROJECT_SOURCE_DIR}/vendor/nvml/nvml.lib")

Expand All @@ -37,7 +45,8 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/glfw)
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor)
# add D3D12MemoryAllocator
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/D3D12MemoryAllocator)

# add vulkan bootstrap
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/vk-bootstrap)


# Include directories
Expand All @@ -56,8 +65,12 @@ include_directories(${PROJECT_SOURCE_DIR}/vendor/imgui)
include_directories(${PROJECT_SOURCE_DIR}/vendor/implot)
#include stb_image
include_directories(${PROJECT_SOURCE_DIR}/vendor/stb_image)
#include d3d12mmemoryallocator
#include d3d12mmemoryallocator and vkmemoryallocator
include_directories(${PROJECT_SOURCE_DIR}/vendor/D3D12MemoryAllocator/include)
# Include Vulkan directories
include_directories(${Vulkan_INCLUDE_DIRS})
# Include VK-Bootstrap
include_directories(${PROJECT_SOURCE_DIR}/vendor/vk-bootstrap)


message("Ruta del directorio de origen del proyecto: ${PROJECT_SOURCE_DIR}")
Expand All @@ -66,6 +79,7 @@ file(GLOB_RECURSE SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/*.h
${PROJECT_SOURCE_DIR}/src/*.hpp
${PROJECT_SOURCE_DIR}/src/*.cpp
${PROJECT_SOURCE_DIR}/src/*.c
)

# Vendor Source Files
Expand All @@ -78,7 +92,14 @@ set(GLAD_SOURCE ${PROJECT_SOURCE_DIR}/vendor/glad/src/glad.cpp)
set(PCH_SOURCES ${PROJECT_SOURCE_DIR}/src/pch.cpp)

# Add library
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${PCH_SOURCES} ${GLAD_SOURCE})
if(BUILD_SHARED_IFNITY)
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${PCH_SOURCES} ${GLAD_SOURCE})
target_compile_definitions(${PROJECT_NAME} PRIVATE IFNITY_PLATFORM_WINDOWS BUILD_SHARED_IFNITY)
message("IFNITY LIKE DLL BUILD SHARED IFNITY = ON ")
else()
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${PCH_SOURCES} ${GLAD_SOURCE})
endif()


target_precompile_headers(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/pch.h)

Expand All @@ -95,7 +116,13 @@ target_link_libraries(${PROJECT_NAME} PUBLIC implot)
target_link_libraries(${PROJECT_NAME} INTERFACE glm)
target_link_libraries(${PROJECT_NAME} INTERFACE stb_image)
target_link_libraries(${PROJECT_NAME} PUBLIC D3D12MemoryAllocator)
# Link Vulkan libraries
target_link_libraries(${PROJECT_NAME} PUBLIC ${Vulkan_LIBRARIES})
# Link VK-Bootstrap
target_link_libraries(${PROJECT_NAME} PUBLIC vk-bootstrap::vk-bootstrap)

# Include Target Directories
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/src/vma)

if(NVML_LIBRARY)
message(STATUS "Enlazando nvml.lib ya que nvml.dll .")
Expand Down Expand Up @@ -127,7 +154,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES

# Copiar nvml.lib al directorio de enlace
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_SOURCE_DIR}/vendor/nvml/nvml.lib
${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
Expand All @@ -139,3 +166,5 @@ add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
)




6 changes: 6 additions & 0 deletions Ifnity/Ifnity/CmakeCheck/CheckD3D11.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <d3d11.h>

int main()
{
return 0;
}
6 changes: 6 additions & 0 deletions Ifnity/Ifnity/CmakeCheck/CheckD3D12.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <d3d12.h>

int main()
{
return 0;
}
47 changes: 47 additions & 0 deletions Ifnity/Ifnity/FindGraphicsAPIs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# FindGraphicsAPIs.cmake


#Try compile D3D12 example
if(WIN32)
try_compile(D3D12_COMPILE_SUCCEEDED
"${PROJECT_SOURCE_DIR}/CmakeCheck"
"${PROJECT_SOURCE_DIR}/CmakeCheck/CheckD3D12.cpp"
OUTPUT_VARIABLE D3D12_COMPILE_OUTPUT
)
try_compile(D3D11_COMPILE_SUCCEEDED
"${PROJECT_SOURCE_DIR}/CmakeCheck"
"${PROJECT_SOURCE_DIR}/CmakeCheck/CheckD3D11.cpp"
OUTPUT_VARIABLE D3D11_COMPILE_OUTPUT
)
if(D3D12_COMPILE_SUCCEEDED)
message(STATUS "D3D12 is supported.")
else()
message(STATUS "D3D12 IS NOT SUPPORTED. ${D3D12_COMPILE_OUTPUT}")
endif()

if(D3D11_COMPILE_SUCCEEDED)
message(STATUS "D3D11 is supported")
else()
message(STATUS "D3D11 IS NOT SUPPORTED. ${D3D11_COMPILE_OUTPUT}")
endif()
endif()

# Find Vulkan
find_package(Vulkan REQUIRED)

# Find OpenGL
find_package(OpenGL REQUIRED)



if(NOT Vulkan_FOUND)
message(FATAL_ERROR "Vulkan was not found on the system.")
else()
message(STATUS "Vulkan found: ${Vulkan_LIBRARY}")
endif()

if(NOT OpenGL_FOUND)
message(FATAL_ERROR "OpenGL was not found on the system.")
else()
message(STATUS "OpenGL found: ${OpenGL_LIBRARY}")
endif()
3 changes: 0 additions & 3 deletions Ifnity/Ifnity/src/Ifnity.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

#include "Ifnity/App.h"
#include "Ifnity/Layer.hpp"
#include "Ifnity/Event/WindowEvent.h"
#include "Ifnity/Layers/ImguiLayer.h"
#include "Ifnity/Layers/NVML_Layer.hpp"
#include "Ifnity/Layers/ExampleLayer.h"
#include "Ifnity/Log.h"


//wOMDPW
#include "BenchMark/NvmlMonitor.hpp"
//Entry Point this include have put at the end of the file.
#include "Ifnity/EntryPoint.h"

Expand Down
Loading

0 comments on commit 49e52cd

Please sign in to comment.