Skip to content

Commit ebb62e2

Browse files
committed
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla into compute_ptr_2
2 parents 2dc3c48 + 0add2e3 commit ebb62e2

File tree

77 files changed

+7358
-2380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7358
-2380
lines changed

.vsconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Component.CoreEditor",
5+
"Microsoft.VisualStudio.Workload.CoreEditor",
6+
"Microsoft.Component.MSBuild",
7+
"Microsoft.VisualStudio.Component.VC.CoreIde",
8+
"Microsoft.VisualStudio.Component.Windows10SDK",
9+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
10+
"Microsoft.VisualStudio.Component.Graphics.Tools",
11+
"Microsoft.VisualStudio.Component.VC.DiagnosticTools",
12+
"Microsoft.VisualStudio.Component.Windows11SDK.22621",
13+
"Microsoft.VisualStudio.Component.VC.ATL",
14+
"Microsoft.VisualStudio.Component.SecurityIssueAnalysis",
15+
"Microsoft.VisualStudio.Component.VC.ATLMFC",
16+
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
17+
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.CMake",
18+
"Microsoft.VisualStudio.Component.VC.CMake.Project",
19+
"Microsoft.VisualStudio.Component.VC.ASAN",
20+
"Microsoft.VisualStudio.Workload.NativeDesktop",
21+
"Microsoft.Net.ComponentGroup.TargetingPacks.Common"
22+
],
23+
"extensions": []
24+
}

3rdparty/CMakeLists.txt

Lines changed: 11 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ option(WITH_JAVA "libjpeg-turbo" OFF)
175175
set(CMAKE_INSTALL_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo/install/docdir")
176176
set(CMAKE_INSTALL_MANDIR "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo/install/mandir")
177177
add_subdirectory(libjpeg-turbo libjpeg-turbo EXCLUDE_FROM_ALL)
178+
NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE(simd ASM_NASM libjpeg-turbo/simd/)
179+
178180
unset(CMAKE_INSTALL_DOCDIR)
179181
unset(CMAKE_INSTALL_MANDIR)
180182

@@ -281,14 +283,15 @@ add_library(spirv_cross OBJECT
281283
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
282284

283285
# cmake-git-version-tracking
286+
# note that checking if a repository is dirty may cost build time (especially a lot if like us you have a lot of submodules) - by default we run with all checks but if you want to increase build time iterations I recommend to exclude this check
287+
option(GIT_EXCLUDE_IS_DIRTY "Exclude IS_DIRTY from git tracking checks, will increase build time iterations at the expense of the meta information loss" OFF)
284288
add_subdirectory(git-version-tracking EXCLUDE_FROM_ALL)
285289
NBL_ADD_GIT_TRACKING_META_LIBRARY(nabla "${NBL_ROOT_PATH}")
286290
NBL_ADD_GIT_TRACKING_META_LIBRARY(dxc "${CMAKE_CURRENT_SOURCE_DIR}/dxc/dxc")
287291
NBL_GENERATE_GIT_TRACKING_META()
288292

289293
if(NBL_BUILD_IMGUI)
290294
set(NBL_IMGUI_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
291-
set(NBL_IMGUI_USER_CONFIG_ISD "${CMAKE_CURRENT_BINARY_DIR}/imgui/config/include")
292295
set(NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT "${THIRD_PARTY_SOURCE_DIR}/imgui_test_engine")
293296
set(NBL_IMGUI_TEST_ENGINE_ROOT "${NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT}/imgui_test_engine")
294297
set(NBL_IMGUI_TEST_SUITE_ROOT "${NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT}/imgui_test_suite")
@@ -376,79 +379,14 @@ if(NBL_BUILD_IMGUI)
376379

377380
set(IMGUIZMO_BUILD_EXAMPLE OFF)
378381
add_subdirectory(imguizmo EXCLUDE_FROM_ALL)
382+
383+
# note we override imgui config with our own
384+
set(NBL_IMGUI_USER_CONFIG_FILEPATH "${NBL_IMGUI_ROOT}/nabla_imconfig.h")
385+
386+
if(NOT EXISTS "${NBL_IMGUI_USER_CONFIG_FILEPATH}")
387+
message(FATAL_ERROR "\"${NBL_IMGUI_USER_CONFIG_FILEPATH}\" doesn't exist!")
388+
endif()
379389

380-
# override test engine config with our own
381-
string(APPEND NBL_IMPL_IMCONFIG_CONTENT
382-
[=[
383-
#include "imgui_test_suite_imconfig.h" // use test engine's config
384-
385-
// note we override it with default imguis (void*) type
386-
#include <cstdint>
387-
388-
//! Custom "ImTextureID" info struct for Nabla UI backend purposes about resource sampler & texture descriptor binding's array indicies
389-
//! must be 4 bytes size & alignment to pass imgui static asserts (it checks for contiguous blocks in memory to make sure it can do some memcpies)
390-
struct SImResourceInfo
391-
{
392-
//! texture descriptor binding's array index
393-
uint32_t textureID : 26;
394-
395-
//! sampler descriptor binding's array index
396-
uint32_t samplerIx : 6;
397-
398-
SImResourceInfo() : textureID(0u), samplerIx(0u) {}
399-
400-
SImResourceInfo(uint32_t texID)
401-
{
402-
textureID = texID;
403-
samplerIx = 0u;
404-
}
405-
406-
explicit operator intptr_t() const
407-
{
408-
return static_cast<intptr_t>(textureID);
409-
}
410-
411-
bool operator==(const SImResourceInfo& other) const
412-
{
413-
return textureID == other.textureID;
414-
}
415-
416-
bool operator!=(const SImResourceInfo& other) const
417-
{
418-
return textureID != other.textureID;
419-
}
420-
421-
bool operator<(const SImResourceInfo& other) const
422-
{
423-
return textureID < other.textureID;
424-
}
425-
426-
bool operator>(const SImResourceInfo& other) const
427-
{
428-
return textureID > other.textureID;
429-
}
430-
431-
bool operator<=(const SImResourceInfo& other) const
432-
{
433-
return textureID <= other.textureID;
434-
}
435-
436-
bool operator>=(const SImResourceInfo& other) const
437-
{
438-
return textureID >= other.textureID;
439-
}
440-
};
441-
442-
#define ImTextureID SImResourceInfo
443-
#define IMGUI_ENABLE_FREETYPE
444-
#define IMGUI_DISABLE_OBSOLETE_KEYIO
445-
#undef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // but remove this cuz it break things
446-
]=]
447-
)
448-
set(NBL_IMGUI_USER_CONFIG_FILEPATH "${NBL_IMGUI_USER_CONFIG_ISD}/nabla_imconfig.h")
449-
file(WRITE "${NBL_IMGUI_USER_CONFIG_FILEPATH}" "${NBL_IMPL_IMCONFIG_CONTENT}")
450-
451-
# USER DEFINED IMGUI CONFIG, IMPACTS THE BUILD
452390
target_compile_definitions(imgui PUBLIC
453391
IMGUI_USER_CONFIG="${NBL_IMGUI_USER_CONFIG_FILEPATH}"
454392
)

3rdparty/imgui

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ include(ExternalProject)
1313
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchains/android/build.cmake)
1414

1515
project(Nabla LANGUAGES CXX C)
16-
enable_language(C CXX ASM)
16+
enable_language(C CXX ASM ASM_NASM)
17+
18+
if(MSVC)
19+
enable_language(ASM_MASM)
20+
endif()
1721

1822
option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared
1923
option(NBL_DYNAMIC_MSVC_RUNTIME "" ON)
@@ -30,7 +34,7 @@ endif()
3034
if(NBL_STATIC_BUILD)
3135
message(STATUS "Static Nabla build enabled!")
3236
else()
33-
if(WIN32 AND MSVC)
37+
if(MSVC)
3438
if(NBL_DYNAMIC_MSVC_RUNTIME)
3539
message(STATUS "Shared Nabla build enabled!")
3640
else()
@@ -66,6 +70,14 @@ set(NBL_BUILTIN_RESOURCES_DIRECTORY_PATH "${NBL_ROOT_PATH}/include/nbl/builtin")
6670
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${NBL_ROOT_PATH}/cmake" CACHE PATH "")
6771
get_property(NBL_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
6872

73+
include(common)
74+
75+
option(NBL_ENABLE_VS_CONFIG_IMPORT "Request import of .vsconfig file with VS components required to build Nabla" OFF)
76+
77+
if(NBL_ENABLE_VS_CONFIG_IMPORT)
78+
NBL_IMPORT_VS_CONFIG()
79+
endif()
80+
6981
# Configure CCache if available
7082
find_program(CCACHE_FOUND ccache)
7183
if(CCACHE_FOUND)
@@ -189,7 +201,6 @@ get_filename_component(NBL_MEDIA_DIRECTORY_ABS "${NBL_MEDIA_DIRECTORY}" ABSOLUTE
189201

190202
include(submodules/update)
191203
find_package(Python3 COMPONENTS Interpreter REQUIRED)
192-
include(common)
193204

194205
add_subdirectory(${THIRD_PARTY_SOURCE_DIR})
195206

CMakePresets.json

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"minor": 29,
66
"patch": 2
77
},
8-
98
"configurePresets": [
109
{
1110
"name": "ci-configure-base",
@@ -109,21 +108,27 @@
109108
"inherits": "ci-configure-static-windows-base",
110109
"displayName": "[CI]: Static library target, Ninja multi-config generator",
111110
"description": "Configure as static library with Ninja multi-config generator",
112-
"generator": "Ninja Multi-Config"
111+
"generator": "Ninja Multi-Config",
112+
"cacheVariables": {
113+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
114+
}
113115
},
114116
{
115117
"name": "ci-configure-dynamic-ninja-multi",
116118
"inherits": "ci-configure-dynamic-windows-base",
117119
"displayName": "[CI]: Dynamic library target, Ninja multi-config generator",
118120
"description": "Configure as dynamic library with Ninja multi-config generator",
119-
"generator": "Ninja Multi-Config"
121+
"generator": "Ninja Multi-Config",
122+
"cacheVariables": {
123+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
124+
}
120125
},
121126
{
122127
"name": "user-configure-base",
123128
"hidden": true,
124129
"cacheVariables": {
125130
"NBL_CI_MODE": "OFF",
126-
"NBL_UPDATE_GIT_SUBMODULE": "ON",
131+
"NBL_UPDATE_GIT_SUBMODULE": "OFF",
127132
"NBL_RUN_TESTS": "OFF",
128133
"NBL_CPACK_CI": "OFF"
129134
}
@@ -193,14 +198,20 @@
193198
"inherits": "user-configure-static-windows-base",
194199
"displayName": "[USER]: Static library target, Ninja multi-config generator",
195200
"description": "Configure as static library with Ninja multi-config generator",
196-
"generator": "Ninja Multi-Config"
201+
"generator": "Ninja Multi-Config",
202+
"cacheVariables": {
203+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
204+
}
197205
},
198206
{
199207
"name": "user-configure-dynamic-ninja-multi",
200208
"inherits": "user-configure-dynamic-windows-base",
201209
"displayName": "[USER]: Dynamic library target, Ninja multi-config generator",
202210
"description": "Configure as dynamic library with Ninja multi-config generator",
203-
"generator": "Ninja Multi-Config"
211+
"generator": "Ninja Multi-Config",
212+
"cacheVariables": {
213+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
214+
}
204215
},
205216
{
206217
"name": "user-configure-static-ninja-release",
@@ -209,7 +220,8 @@
209220
"description": "Configure as static Release library with Ninja single-config generator",
210221
"generator": "Ninja",
211222
"cacheVariables": {
212-
"CMAKE_BUILD_TYPE": "Release"
223+
"CMAKE_BUILD_TYPE": "Release",
224+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
213225
}
214226
},
215227
{
@@ -219,7 +231,8 @@
219231
"description": "Configure as dynamic Release library with Ninja single-config generator",
220232
"generator": "Ninja",
221233
"cacheVariables": {
222-
"CMAKE_BUILD_TYPE": "Release"
234+
"CMAKE_BUILD_TYPE": "Release",
235+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
223236
}
224237
},
225238
{
@@ -229,7 +242,8 @@
229242
"description": "Configure as static RelWithDebInfo library with Ninja single-config generator",
230243
"generator": "Ninja",
231244
"cacheVariables": {
232-
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
245+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
246+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
233247
}
234248
},
235249
{
@@ -239,7 +253,8 @@
239253
"description": "Configure as dynamic RelWithDebInfo library with Ninja single-config generator",
240254
"generator": "Ninja",
241255
"cacheVariables": {
242-
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
256+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
257+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
243258
}
244259
},
245260
{
@@ -249,7 +264,8 @@
249264
"description": "Configure as static Debug library with Ninja single-config generator",
250265
"generator": "Ninja",
251266
"cacheVariables": {
252-
"CMAKE_BUILD_TYPE": "Debug"
267+
"CMAKE_BUILD_TYPE": "Debug",
268+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
253269
}
254270
},
255271
{
@@ -259,7 +275,8 @@
259275
"description": "Configure as dynamic Debug library with Ninja single-config generator",
260276
"generator": "Ninja",
261277
"cacheVariables": {
262-
"CMAKE_BUILD_TYPE": "Debug"
278+
"CMAKE_BUILD_TYPE": "Debug",
279+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
263280
}
264281
}
265282
],
@@ -413,7 +430,6 @@
413430
"displayName": "[USER]: Dynamic Debug library target, Ninja single-config generator",
414431
"description": "Build Nabla as dynamic Debug library with Ninja single-config generator"
415432
}
416-
417433
],
418434
"packagePresets": [
419435
{

cmake/common.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,4 +1298,38 @@ macro(NBL_GET_ALL_TARGETS_RECURSIVE NBL_TARGETS NBL_DIRECTORY)
12981298

12991299
get_property(NBL_GATHERED_TARGETS DIRECTORY ${NBL_DIRECTORY} PROPERTY BUILDSYSTEM_TARGETS)
13001300
list(APPEND ${NBL_TARGETS} ${NBL_GATHERED_TARGETS})
1301+
endmacro()
1302+
1303+
function(NBL_IMPORT_VS_CONFIG)
1304+
if(WIN32 AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
1305+
message(STATUS "Requesting import of .vsconfig file! Configuration will continue after Visual Studio Installer is closed.")
1306+
set(NBL_DEVENV_ISOLATION_INI_PATH "${CMAKE_GENERATOR_INSTANCE}/Common7/IDE/devenv.isolation.ini")
1307+
file(READ ${NBL_DEVENV_ISOLATION_INI_PATH} NBL_DEVENV_ISOLATION_INI_CONTENT)
1308+
string(REPLACE "/" "\\" NBL_VS_INSTALLATION_PATH ${CMAKE_GENERATOR_INSTANCE})
1309+
string(REGEX MATCH "SetupEngineFilePath=\"([^\"]*)\"" _match "${NBL_DEVENV_ISOLATION_INI_CONTENT}")
1310+
set(NBL_VS_INSTALLER_PATH "${CMAKE_MATCH_1}")
1311+
1312+
execute_process(COMMAND "${NBL_VS_INSTALLER_PATH}" modify --installPath "${NBL_VS_INSTALLATION_PATH}" --config "${NBL_ROOT_PATH}/.vsconfig" --allowUnsignedExtensions
1313+
ERROR_VARIABLE vsconfig_error
1314+
RESULT_VARIABLE vsconfig_result
1315+
)
1316+
1317+
if(NOT vsconfig_result EQUAL 0)
1318+
message(FATAL_ERROR "Visual Studio Installer error: ${vsconfig_error}")
1319+
endif()
1320+
else()
1321+
message(FATAL_ERORR "Cannot request importing VS config, doesn't meet requirements!")
1322+
endif()
1323+
1324+
endfunction()
1325+
1326+
macro(NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE _NBL_TARGET_ _NBL_ASM_DIALECT_ _NBL_PREPEND_PATH_TRANSFORM_)
1327+
get_target_property(_NBL_TARGET_SOURCES_ "${_NBL_TARGET_}" SOURCES)
1328+
list(FILTER _NBL_TARGET_SOURCES_ INCLUDE REGEX "\\.asm$")
1329+
list(TRANSFORM _NBL_TARGET_SOURCES_ PREPEND "${_NBL_PREPEND_PATH_TRANSFORM_}")
1330+
1331+
set_source_files_properties(${_NBL_TARGET_SOURCES_}
1332+
TARGET_DIRECTORY "${_NBL_TARGET_}"
1333+
PROPERTIES LANGUAGE "${_NBL_ASM_DIALECT_}"
1334+
)
13011335
endmacro()

docs/build/WINDOWS.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,23 @@ You also have options `BUILD_EXAMPLES` and `BUILD_TOOLS` which do exactly what t
4646

4747
For Windows *MSVC* required, *MinGW* build system maintenance will be delegated to the community.
4848

49-
### Ninja Multi-Config generator
49+
### Ninja Multi-Config generator & MSVC
5050

51-
The target toolset is MSVC. Before invoking CMake you need to [initialize VS's environment](https://learn.microsoft.com/en-us/cpp/build/cmake-presets-vs?view=msvc-170#sourcing-the-environment-when-building-with-command-line-generators-on-windows) by calling
51+
#### Command line
52+
53+
Open command line, init MSVC [toolset environment](https://learn.microsoft.com/en-us/cpp/build/cmake-presets-vs?view=msvc-170#sourcing-the-environment-when-building-with-command-line-generators-on-windows) by calling
5254

5355
```cmd
5456
vcvarsall.bat <platform>
5557
```
5658

57-
in your cmd (eg. `vcvarsall.bat x64` call will initialize environment for amd64, for more info go [here](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#vcvarsall-syntax)). Once initialization is done you can use Ninja CMake preset to build Nabla, eg.
59+
(eg. `vcvarsall.bat x64` call will initialize environment for amd64, for more info see [following](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#vcvarsall-syntax)). Once initialized fire a ninja preset.
5860

5961
```cmd
62+
cmake --preset user-configure-dynamic-ninja-multi
6063
cmake --build --preset user-build-dynamic-ninja-multi --config Debug -- --quiet
6164
```
6265

63-
The build preset will pick configure preset associated with it and invoke configure then build. Pay attention that if you don't initialize VS's environment the following will fail to compile with MSVC toolset.
66+
#### With Visual Studio
67+
68+
Follow VS [tutorial](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170).

examples_tests

Submodule examples_tests updated 50 files

0 commit comments

Comments
 (0)