Skip to content

Commit

Permalink
[release][0.0.1] Features/cross gui (#6)
Browse files Browse the repository at this point in the history
* stall: requires further steps to be compilable with linux, namely fmt

* integrated fmt

* for testing with linux

* updated requirements

* fixed and launched for linux

* winrt finally supported

* fixed message

* Update cmake.yml

* Update cmake.yml

* Update cmake.yml

* minimal build, better platform switches

* fix vulkan

* fixed warning, fixed build
  • Loading branch information
Agrael1 authored May 21, 2023
1 parent 05f0e9b commit 08f7952
Show file tree
Hide file tree
Showing 77 changed files with 2,445 additions and 550 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,39 @@ env:
BUILD_TYPE: Debug

jobs:
build_linux:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Prepare Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Install KDUtils requirements
run: sudo apt install libxkbcommon-dev libxcb-xkb-dev libxkbcommon-x11-dev wayland-scanner++ wayland-protocols ninja-build

- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.x'

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build_dx -GNinja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER:STRING="gcc-12" -DCMAKE_CXX_COMPILER:STRING="g++-12"

- name: Build WisdomKD
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build_dx --config ${{env.BUILD_TYPE}}

build_dx:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
Expand Down Expand Up @@ -57,7 +90,26 @@ jobs:
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build_dx --config ${{env.BUILD_TYPE}}

build_uwp:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Visual Studio shell
uses: egor-tensin/vs-shell@v2

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build_dx -G"Visual Studio 17" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER:STRING="cl.exe" -DCMAKE_CXX_COMPILER:STRING="cl.exe" -DCMAKE_SYSTEM_NAME:STRING="WindowsStore" -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_BUILD_TYPE:STRING="Debug"

- name: Build WisdomUWP
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build_dx --config ${{env.BUILD_TYPE}}

#- name: Test
# working-directory: ${{github.workspace}}/build
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]uild/
[Bb]in/
[Oo]bj/
[Oo]ut/
Expand Down Expand Up @@ -360,4 +361,5 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd
/CMakeSettings.json
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CMakeList.txt : Top-level CMake project file
cmake_minimum_required (VERSION 3.22)
cmake_minimum_required (VERSION 3.25)

project ("Wisdom")

Expand All @@ -19,11 +19,24 @@ set_property(CACHE WISDOM_LOG_LEVEL PROPERTY STRINGS ${SEVERITY_LEVELS})
list(FIND SEVERITY_LEVELS "${CURR_LEVEL}" SEV_INDEX)
message("[Wisdom] Log Level is set to ${LOG_LEVEL} [${SEV_INDEX}]")

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(WTOP ON)
else()
set(WTOP OFF)
endif()

option(WISDOM_RUNTIME_ASSERTS "Turn on/off runtime assertions (turned on might slightly affect performance)" ON)
option(WISDOM_FORCE_VULKAN "Forces the default device to be vulkan, instead of platform specific" OFF)
option(WISDOM_BUILD_EXAMPLE "Build the example project." ON)
option(WISDOM_BUILD_TESTS "Build the tests." ON)
option(WISDOM_BUILD_EXAMPLES "Build the example project." ${WTOP})
option(WISDOM_BUILD_TESTS "Build the tests." ${WTOP})


if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "16")
option(WISDOM_USE_FMT "Build Wisdom with fmtlib" ON)
else()
option(WISDOM_USE_FMT "Build Wisdom with fmtlib" OFF)
endif()



Expand All @@ -35,8 +48,8 @@ include(Misc.cmake)
add_subdirectory ("plugins")
add_subdirectory ("wisdom")

if(WISDOM_BUILD_EXAMPLE)
add_subdirectory ("example")
if(WISDOM_BUILD_EXAMPLES)
add_subdirectory ("examples")
endif()

if(WISDOM_BUILD_TESTS)
Expand Down
101 changes: 0 additions & 101 deletions CMakePresets.json

This file was deleted.

49 changes: 41 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![CMake Windows](https://github.com/Agrael1/Wisdom/actions/workflows/cmake.yml/badge.svg)

**Low-level thin Graphics API layer for high perfrormance and better coding experience**
**Low-level thin Graphics API layer. Easy to learn, easy to extend, high performance enabled, multiplatform!**

# Why?

Expand All @@ -19,40 +19,73 @@ The API is designed for game-ready and heavy computations use. It is done in low
The API is structured like this:
- The basic types are defined, depending on platform of choice. They are **Factory**, **Adapter**, **Device** etc. They are directly implemented, this eliminates memory indirection and potential cache misses.
- The the platform is selected the most suitable to the system: Windows - DirectX 12, MacOS - Metal __[TBD]__
- You can override the platform selection with `WISDOM_FORCE_VULKAN` option on CMake configuration. This will force the library to use Vulkan as a base API. This is useful for debugging Vulkan extensions.
- All calls are done directly, without usage of interfaces/virtual functions. This eliminates call indirection and the projection is direct as if you wrote the code directly inside your functions.
- Underlying accessibility, all of the internals are accessible using `GetInternal()` and can be used to bridge functionality or to create extensions. All the internal state is immutable for the stability of work between library and extensions. However it's not advised to use internal state directly, since it is platform dependent.

Vulkan is compiled on compatible systems and used as default only if there is no other alternative. Vulkan can still be used under supported operating system with explicit types `wis::VKFactory`, `wis::VKDevice` etc. Vulkan can also be manually selected upon build with `FORCE_VULKAN` option on CMake configuration.
Vulkan is compiled on compatible systems and used as default only if there is no other alternative. Vulkan can still be used under supported operating system with explicit types `wis::VKFactory`, `wis::VKDevice` etc.

# Platforms

Supported platforms are:
- Windows API (Win32) - DirectX 12 and Vulkan
- Windows Store (UWP) - Microsoft Store certified applications. DirectX 12 only.
- Linux (X11) (Wayland to be implemented) - Vulkan only

# Build

This is a CMake project, all the plugins are ensured to download beforehand, so it's enough to just configure the project, everything is going to be downloaded with respect to platform.
The later reconfigurations are not reloading the plugins for easy expansion of the library, but if the plugin reload is required, the cache deletion should be done, or change `PLUGINS_LOADED` CMakeCache entry to `FALSE`.

Right now the build works only on Windows, but others will be available soon.

# CMake Options

- `WISDOM_LOG_LEVEL=debug/warn` set the log level for the library, values are `debug,trace,info,warn,error,critical` log calls under current level are not compiled
- `WISDOM_RUNTIME_ASSERTS=ON` enable/disable runtime validation checks from compile time
- `WISDOM_FORCE_VULKAN=OFF` if set ON forces base types to be Vulkan, useful for debugging Vulkan extensions
- `WISDOM_FORCE_VULKAN=OFF` if set `ON` forces base types to be Vulkan, useful for debugging Vulkan extensions
- `WISDOM_BUILD_EXAMPLES=ON` enable/disable example compilation
- `WISDOM_BUILD_TESTS=ON` enable/disable test compilation
- `WISDOM_USE_FMT=ON/OFF` use fmt instead of `std::format` (`ON` for Linux build for GCC<13 and Clang<16)


# System Requirements

**Windows:**
- Windows 10/11
- DirectX 12 capable video card
- CMake 3.22+ (several features are 3.25+, but they are not mandatory)
- CMake 3.25+

Tested on MSVC v143, Visual Studio 2022

for Vulkan:
- Vulkan 1.3.x+
- Vulkan 1.3.2xx+

**Windows Store:**

To Compile for Windows Store, the following requirements are needed:
- CMakeSettings: `-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=Debug/Release/RelWithDebInfo/MinSizeRel`
- Windows 10 SDK 10.0.19041.0+
- Visual Studio Generator, tested on Visual Studio 2022 (v143) - Ninja generator is not supported
- Installed UWP SDK

To launch a project find generated .sln in build `out/build/{BuildName}/examples/hello-triangle-winrt` folder and launch it with Visual Studio. This is due to deployment requirements of UWP applications, which is performed with Visual Studio.

After the first launch, the project can be launched from the Start Menu.

This type of project does not support Vulkan, since Vulkan does not have UWP surface.

**Linux**
- TBD...

- CMake 3.25+
- GCC 12+ or Clang 15+ Tested on GCC 12.0.1
- Vulkan 1.3.2xx+ for dynamic vertex buffers and some latest features

KDUils for the example need some packages to be installed:
`sudo apt install libxkbcommon-dev libxcb-xkb-dev libxkbcommon-x11-dev wayland-scanner++ wayland-protocols`

Visit https://github.com/KDAB/KDUtils to see more details.

**MacOS**
- TBD... When I get my hands on a Mac

# Roadmap and tasks

Expand Down
62 changes: 62 additions & 0 deletions cmake/Functions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Function for installing DirectX SDK
function(wis_install_dx PROJECT)
message("Installing DirectX Agility SDK Dependency")

get_property(DX12SDKVER TARGET DX12Agility PROPERTY DX12SDKVER)

set(EXPORT_AGILITY "extern \"C\" { _declspec(dllexport) extern const unsigned D3D12SDKVersion = ${DX12SDKVER}; }
extern \"C\" { _declspec(dllexport) extern const char* D3D12SDKPath = \".\\\\D3D12\\\\\"; }"
)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/exports.cpp" "${EXPORT_AGILITY}")

target_sources(${PROJECT} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/exports.cpp
)

add_custom_command(TARGET ${PROJECT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:DX12AgilityCore> $<TARGET_FILE_DIR:${PROJECT}>/D3D12/$<TARGET_FILE_NAME:DX12AgilityCore>
COMMAND_EXPAND_LISTS
COMMENT "Copying DX12 Agility Core..."
)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_custom_command(TARGET ${PROJECT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:DX12AgilitySDKLayers> $<TARGET_FILE_DIR:${PROJECT}>/D3D12/$<TARGET_FILE_NAME:DX12AgilitySDKLayers>
COMMAND_EXPAND_LISTS
COMMENT "Copying DX12 Agility SDKLayers..."
)
endif()
endfunction()

# Function for installing DirectX SDK for UWP
function(wis_install_dx_uwp PROJECT)
message("Installing DirectX Agility SDK Dependency")

get_property(DX12SDKVER TARGET DX12Agility PROPERTY DX12SDKVER)

set(EXPORT_AGILITY "extern \"C\" { _declspec(dllexport) extern const unsigned D3D12SDKVersion = ${DX12SDKVER}; }
extern \"C\" { _declspec(dllexport) extern const char* D3D12SDKPath = \".\\\\D3D12\\\\\"; }"
)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/exports.cpp" "${EXPORT_AGILITY}")

target_sources(${PROJECT} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/exports.cpp
)

get_target_property(dxadll DX12AgilityCore IMPORTED_LOCATION)
message("DX12AgilityCore: ${dxadll}")
set_property(SOURCE ${dxadll} PROPERTY VS_DEPLOYMENT_CONTENT 1)
set_property(SOURCE ${dxadll} PROPERTY VS_DEPLOYMENT_LOCATION "D3D12")
target_sources(${PROJECT} PRIVATE ${dxadll})

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_target_property(dxalayersdll DX12AgilitySDKLayers IMPORTED_LOCATION)
message("DX12AgilitySDKLayers: ${dxalayersdll}")
set_property(SOURCE ${dxalayersdll} PROPERTY VS_DEPLOYMENT_CONTENT 1)
set_property(SOURCE ${dxalayersdll} PROPERTY VS_DEPLOYMENT_LOCATION "D3D12")
target_sources(${PROJECT} PRIVATE ${dxalayersdll})
endif()

endfunction()
File renamed without changes.
Loading

0 comments on commit 08f7952

Please sign in to comment.