Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan impl #10

Open
wants to merge 50 commits into
base: cpp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7c432e3
[GPU-Vulkan] Add Vulkan Memory Allocator
native-m Feb 2, 2022
a0f5f2d
[GPU-Vulkan] Add GPU job manager
native-m Feb 4, 2022
4e722c0
[GPU-Vulkan] Add buffer resource and Implement "template" descriptor.
native-m Feb 5, 2022
cf0ef6d
[GPU-Vulkan] Add render pass [WIP]
native-m Feb 6, 2022
69dd07f
[GPU] Add new texture formats and combine StorageRead and StorageWrite
native-m Feb 6, 2022
2dcfb5d
[GPU-Vulkan] Add validation for render pass creation
native-m Feb 7, 2022
f36cf99
[Misc] Fix window.hpp filename
native-m Feb 7, 2022
8c1eaf5
[Misc] Fix window.hpp filename (again)
native-m Feb 7, 2022
1ea0db5
Merge branch 'master' into vulkan-impl
native-m Feb 7, 2022
67329c3
[GPU-Vulkan] Add framebuffer creation (WIP) and completing the
native-m Feb 7, 2022
bc72806
[GPU-Vulkan] Completing framebuffer and render pass creation and
native-m Feb 8, 2022
efa75dd
[GPU] Forgot to rename the create_surface function
native-m Feb 8, 2022
8918ea2
[GPU-Vulkan] Add buffer view and fix framebuffer destroy
native-m Feb 8, 2022
5c029d3
[Logger] Fix bruh moment
native-m Feb 8, 2022
eab563f
Merge branch 'master' into vulkan-impl
native-m Feb 9, 2022
62fbec4
Merge branch 'master' into vulkan-impl
native-m Feb 9, 2022
6787eb6
[GPU-Vulkan] Add sampler and fix compile error on GCC
native-m Feb 9, 2022
5ebc2c0
Fix compile error on GCC and Clang.
native-m Feb 9, 2022
b88e8fb
Add unit test for GPU backend and rename DeviceErrorCode to ResultCode
native-m Feb 10, 2022
73580d2
Disable GPU unit test for CI
native-m Feb 10, 2022
c1f9b08
Fix GPU unit test
native-m Feb 11, 2022
1ee7dff
[GPU-Vulkan] Completing begin render pass command.
native-m Feb 11, 2022
d63189e
[GPU-Vulkan] Swapchain resizing (WIP)
native-m Feb 12, 2022
ebe7222
[Misc] Add static vector and its unit tests (WIP)
native-m Feb 14, 2022
c5719b0
Forgot to commit the unit test
native-m Feb 14, 2022
6e628a3
[GPU-Vulkan] Refactor some classes.
native-m Feb 14, 2022
997f7a2
[GPU-Vulkan] Implement resource destroyer.
native-m Feb 14, 2022
ada38c0
Add GSL submodule
native-m Feb 15, 2022
1ad5744
Update most of GPU code to match the coding convention, implementing GPU
native-m Feb 19, 2022
5838d31
Delete "boost-predef" submodule (this was accidentally re-added by me)
native-m Feb 19, 2022
f666069
[GPU-Vulkan] Fix crash when destroying resources and remove template
native-m Feb 19, 2022
cd0674c
[GPU-Vulkan] Completing color blend states
native-m Feb 21, 2022
6627461
Remove interface definition and old backend interface
native-m Feb 21, 2022
0758130
[Refactor] Remove old backend interface header on CMake
native-m Feb 21, 2022
41dd7f1
[Misc] Try to fix Github Actions
native-m Feb 21, 2022
f69c0e5
[Misc] Fix build error and fix Github Actions
native-m Feb 21, 2022
49c83da
[Misc] Forgot to change CI build cache key for Ubuntu
native-m Feb 21, 2022
38bc36a
[Misc] Fix build error
native-m Feb 22, 2022
6423ad2
Merge branch 'master' into vulkan-impl
native-m Feb 22, 2022
bff0c96
[Misc] Change CI build cache key to be more specific
native-m Feb 22, 2022
25cd769
[Misc] Rewrite static vector assign algorithm
native-m Feb 24, 2022
3706cae
[Misc] Add static vector iterator
native-m Feb 24, 2022
aa42707
Fix build error
native-m Feb 24, 2022
60b238f
[Misc] Add unit test for static vector iterator, add Clang compiler
native-m Feb 24, 2022
a7f89da
[Refactor] Refactor static vector class
native-m Feb 25, 2022
4d97ebe
Add SPIRV-Reflect submodule
native-m Feb 25, 2022
0dcea27
[GPU-Vulkan] Continue progress on graphics pipeline
native-m Mar 2, 2022
5feab90
[Refactor] Refactor vulkan backend
native-m Mar 2, 2022
6431eaa
Fix build error
native-m Mar 2, 2022
8a871b4
Many changes
native-m Mar 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ jobs:
cd external/dawn
cp scripts/standalone.gclient .gclient
gclient sync
- name: Cache
- name: Create build dir
run: |
mkdir build
- name: Fetch cache
id: cmake-cache
uses: actions/cache@v2
with:
path: |
build/
key: ${{ runner.os }}-master
- name: Create build dir
if: steps.cmake-cache.outputs.cache-hit != 'true'
run: |
mkdir build
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}
- name: Build
run: |
export MONO_PROJECT=/usr/include/mono-2.0/

cd build
cmake .. -DTEMPEH_ENABLE_TEST=ON
cmake --build .
cmake .. -DTEMPEH_ENABLE_TEST=ON -DTEMPEH_ENABLE_GPU_TEST=ON
cmake --build . -j 4
- name: Run test
run: |
./build/test/tempeh_core_test
echo "No test at the moment"
#./build/test/tempeh_core_test
build_windows:
name: Build Windows
runs-on: windows-latest
Expand All @@ -74,24 +74,24 @@ jobs:
cd external\dawn
copy scripts\standalone.gclient .gclient
gclient sync
- name: Cache
- name: Create build dir
run: |
New-Item -ItemType Directory -Force -Path build
- name: Fetch cache
id: cmake-cache
uses: actions/cache@v2
with:
path: |
build/
key: ${{ runner.os }}-master
- name: Create build dir
if: steps.cmake-cache.outputs.cache-hit != 'true'
run: |
mkdir build
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}
- name: Build
run: |
$env:MONO_INCLUDE_DIR = "C:\Program Files\Mono\include\mono-2.0\"

cd build
cmake .. -DTEMPEH_ENABLE_TEST=ON -G "Ninja"
cmake --build .
cmake .. -DTEMPEH_ENABLE_TEST=ON -DTEMPEH_ENABLE_GPU_TEST=ON -G "Ninja"
cmake --build . -j 4
- name: Run test
run: |
.\build\test\tempeh_core_test.exe
echo "No test at the moment"
#.\build\test\tempeh_core_test.exe
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@
[submodule "external/SPIRV-Cross"]
path = external/SPIRV-Cross
url = https://github.com/KhronosGroup/SPIRV-Cross.git
[submodule "external/GSL"]
path = external/GSL
url = https://github.com/microsoft/GSL.git
[submodule "external/SPIRV-Reflect"]
path = external/SPIRV-Reflect
url = https://github.com/KhronosGroup/SPIRV-Reflect.git
83 changes: 46 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,60 @@
project("tempeh_engine"
LANGUAGES C CXX)

include(Macros.cmake)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(TEMPEH_ENABLE_TEST "Test" OFF)
option(TEMPEH_ENABLE_TEST "Enable unit test" OFF)
option(TEMPEH_ENABLE_GPU_TEST "Enable unit test for GPU backends (requires TEMPEH_ENABLE_TEST to be enabled)" OFF)

add_subdirectory("external")

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Vulkan)

# https://github.com/izenecloud/cmake/blob/master/SetCompilerWarningAll.cmake
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use the highest warning level for Visual Studio.
set(CMAKE_CXX_WARNING_LEVEL 4)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
# Disable C++ exceptions.
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# Disable RTTI.
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use -Wall for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
# Use -Wextra for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
# Use -Werror for clang and gcc.
#if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
#endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
# Disable C++ exceptions.
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
# Disable RTTI.
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use the highest warning level for Visual Studio.
set(CMAKE_CXX_WARNING_LEVEL 4)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")

# Ensure compiler conformance compatibility.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")

# Disable C++ exceptions.
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")

# Disable RTTI.
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use -Wall for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
# Use -Wextra for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
# Disable C++ exceptions.
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
# Disable RTTI.
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif()

add_subdirectory("engine")
add_subdirectory("editor")
add_subdirectory("test/vulkan_backend")
add_subdirectory("test")

if(TEMPEH_ENABLE_TEST)
add_subdirectory("test")
endif()
31 changes: 30 additions & 1 deletion CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,40 @@
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"buildCommandArgs": "-j 4",
"ctestCommandArgs": "",
"addressSanitizerEnabled": false,
"variables": [
{
"name": "TEMPEH_TEST",
"value": "False",
"type": "BOOL"
},
{
"name": "TEMPEH_ENABLE_TEST",
"value": "True",
"type": "BOOL"
},
{
"name": "TEMPEH_ENABLE_GPU_TEST",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-j 4",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "TEMPEH_ENABLE_GPU_TEST",
"value": "True",
"type": "BOOL"
},
Expand Down
34 changes: 34 additions & 0 deletions Macros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function(tempeh_add_shader_module _TARGET_NAME _STAGE _SRC)
if(_STAGE STREQUAL "VERTEX")
set(_STAGE "vert")
elseif(_STAGE STREQUAL "FRAGMENT")
set(_STAGE "frag")
else()
message(FATAL_ERROR "Unknown shader stage")
endif()
get_filename_component(_SRC_FILE "${_SRC}" ABSOLUTE)
# message("${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -S ${_STAGE} --target-env spirv1.0 -o ${CMAKE_BINARY_DIR} ${_SRC_FILE}")
add_custom_target(${_TARGET_NAME}
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V -S ${_STAGE} --target-env spirv1.0 -o "${CMAKE_CURRENT_BINARY_DIR}/${_TARGET_NAME}.spv" "${_SRC_FILE}"
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/${_TARGET_NAME}.spv"
DEPENDS "${_SRC_FILE}"
SOURCES "${_SRC_FILE}")
endfunction()

function(tempeh_add_dependency_group)
if(ARGC EQUAL 0)
message(FATAL_ERROR "No name given for dependency group")
endif()

if(ARGC LESS 2)
message(FATAL_ERROR "Dependency group must at least contain 1 dependency")
endif()

set(_GROUP_NAME ${ARGV0})
add_custom_target(${_GROUP_NAME})
list(POP_FRONT ARGN) # pop the first argument

foreach(_I IN LISTS ARGN)
add_dependencies(${_GROUP_NAME} ${_I})
endforeach()
endfunction()
36 changes: 18 additions & 18 deletions editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(TEMPEH_ENGINE_EDITOR_SOURCES
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp"
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp")

add_executable("tempeh_engine_editor"
add_executable(tempeh_engine_editor
${TEMPEH_ENGINE_EDITOR_SOURCES}
${TEMPEH_ENGINE_EDITOR_HEADERS}
"src/gui/panel.hpp"
Expand All @@ -27,30 +27,30 @@ add_executable("tempeh_engine_editor"
"src/gui/window_menubar_panel.cpp"
"src/gui/window_menubar_panel.hpp")

target_compile_definitions("tempeh_engine_editor"
target_compile_definitions(tempeh_engine_editor
PUBLIC SENTRY_DSN="https://[email protected]/6143604")

target_include_directories("tempeh_engine_editor"
target_include_directories(tempeh_engine_editor
#PUBLIC "../common"
PUBLIC "${CMAKE_SOURCE_DIR}/external/dawn/src"
PUBLIC "$ENV{MONO_INCLUDE_DIR}"
PUBLIC ${TEMPEH_COMMON_INCLUDE})

target_link_libraries("tempeh_engine_editor"
target_link_libraries(tempeh_engine_editor
# Private, because anyone ain't gonna touch the editor
PRIVATE "glfw"
PRIVATE "tempeh_common"
PRIVATE "tempeh_core"
PRIVATE "tempeh_log"
PRIVATE "tempeh_math"
PRIVATE "spdlog::spdlog"
#PUBLIC "sentry::sentry"
PRIVATE "webgpu_dawn"
PRIVATE "dawn_native"
PRIVATE "dawn_utils"
PRIVATE "dawn_proc"
PRIVATE "dawncpp"
PRIVATE "dawncpp_headers"
PRIVATE "imgui")
PRIVATE glfw
PRIVATE tempeh_common
PRIVATE tempeh_core
PRIVATE tempeh_log
PRIVATE tempeh_math
PRIVATE spdlog::spdlog
#PUBLIC sentry::sentry
PRIVATE webgpu_dawn
PRIVATE dawn_native
PRIVATE dawn_utils
PRIVATE dawn_proc
PRIVATE dawncpp
PRIVATE dawncpp_headers
PRIVATE imgui)

add_dependencies(tempeh_engine_editor webgpu_headers_gen)
2 changes: 1 addition & 1 deletion editor/src/gui/panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <tempeh/common/typedefs.hpp>

INTERFACE class Panel
class Panel
{
public:
virtual void draw() = 0;
Expand Down
5 changes: 3 additions & 2 deletions engine/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
add_library(tempeh_common INTERFACE)

target_include_directories(
tempeh_common
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

target_link_libraries(
tempeh_common
INTERFACE "magic_enum"
)
INTERFACE "magic_enum")
14 changes: 7 additions & 7 deletions engine/common/include/tempeh/common/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
#elif __APPLE__
# include <TargetConditionals.h>
# if TARGET_IPHONE_SIMULATOR
# error "Unimplemented"
# error "Unimplemented target operating system"
# elif TARGET_OS_MACCATALYST
# error "Unimplemented"
# error "Unimplemented target operating system"
# elif TARGET_OS_IPHONE
# error "Unimplemented"
# error "Unimplemented target operating system"
# elif TARGET_OS_MAC
# error "Unimplemented"
# error "Unimplemented target operating system"
# else
# error "Unknown Apple platform"
# endif
#elif __linux__
# define TEMPEH_OS_LINUX
#elif __unix__
# error "Unimplemented"
# error "Unimplemented target operating system"
#elif defined(_POSIX_VERSION)
# error "Unimplemented"
# error "Unimplemented target operating system"
#else
# error "Unknown compiler"
# error "Unknown OS"
#endif

#endif
21 changes: 21 additions & 0 deletions engine/common/include/tempeh/common/traits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef _TEMPEH_UTIL_TRAITS_HPP
#define _TEMPEH_UTIL_TRAITS_HPP

#include <type_traits>

namespace Tempeh
{
template<bool Condition>
using Requires = std::enable_if_t<Condition, bool>;

template<typename T>
using RequiresDefaultConstructible = Requires<std::is_default_constructible_v<T>>;

template<typename T>
using RequiresCopyConstructible = Requires<std::is_copy_constructible_v<T>>;

template<typename T>
using RequiresMoveConstructible = Requires<std::is_move_constructible_v<T>>;
}

#endif
Loading