Skip to content

Commit 19df6e1

Browse files
author
devsh
committed
Merge remote-tracking branch 'remotes/origin/mlBuildUpdates' into mesh_loaders
2 parents 6242357 + e419580 commit 19df6e1

File tree

11 files changed

+141
-134
lines changed

11 files changed

+141
-134
lines changed

01_HelloCoreSystemAsset/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
44

5-
// always include nabla first before std:: headers
6-
#include "nabla.h"
5+
// <nabla.h> public interface and common examples API, always include first before std:: headers
6+
#include "nbl/examples/examples.hpp"
77

88
#include "nbl/system/IApplicationFramework.h"
99

29_MeshLoaders/main.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
#include "nbl/asset/utils/CGeometryCreator.h"
77
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
88

9-
#include "SimpleWindowedApplication.hpp"
10-
11-
#include "InputSystem.hpp"
12-
#include "CEventCallback.hpp"
13-
14-
#include "CCamera.hpp"
15-
169
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
1710
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>
1811

CMakeLists.txt

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,100 @@
22
# This file is part of the "Nabla Engine".
33
# For conditions of distribution and use, see copyright notice in nabla.h
44

5-
function(NBL_HOOK_COMMON_API NBL_EXCLUDE_TARGETS_LIST)
6-
if(NOT TARGET nblExamplesAPI)
7-
message(FATAL_ERROR "nblExamplesAPI not defined!")
8-
endif()
9-
10-
NBL_GET_ALL_TARGETS(NBL_TARGETS)
11-
12-
foreach(NBL_TARGET IN LISTS NBL_TARGETS)
13-
# TODO: exclude builtin targets created by examples as well - doesn't impact anything at all now
14-
if(NOT ${NBL_TARGET} IN_LIST NBL_EXCLUDE_TARGETS_LIST)
15-
16-
target_include_directories(${NBL_TARGET} PRIVATE $<TARGET_PROPERTY:nblExamplesAPI,INTERFACE_INCLUDE_DIRECTORIES>)
17-
target_link_libraries(${NBL_TARGET} PRIVATE nblExamplesAPI)
18-
endif()
19-
endforeach()
20-
endfunction()
21-
22-
# PCH & CommonAPI library for Nabla framework examples
23-
add_subdirectory(common EXCLUDE_FROM_ALL)
24-
255
if(NBL_BUILD_EXAMPLES)
6+
project(NablaExamples)
7+
268
if(NBL_BUILD_ANDROID)
279
nbl_android_create_media_storage_apk()
2810
endif()
2911

12+
#! Common api library & precompiled headers for Nabla framework examples
13+
add_subdirectory(common EXCLUDE_FROM_ALL)
14+
15+
#! use "EXCLUDE_FROM_ALL" to exclude an example from the NablaExamples project
16+
#[[
17+
useful if we don't want the example to be tested by CI but still want
18+
the example's project to be generated
19+
20+
https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html
21+
]]
22+
3023
# showcase the use of `nbl::core`,`nbl::system` and `nbl::asset`
31-
add_subdirectory(01_HelloCoreSystemAsset EXCLUDE_FROM_ALL)
24+
add_subdirectory(01_HelloCoreSystemAsset)
3225
# showcase the use of `system::IApplicationFramework` and `nbl::video`
33-
add_subdirectory(02_HelloCompute EXCLUDE_FROM_ALL)
26+
add_subdirectory(02_HelloCompute)
3427
# showcase physical device selection, resource embedding and the use of identical headers in HLSL and C++
35-
add_subdirectory(03_DeviceSelectionAndSharedSources EXCLUDE_FROM_ALL)
28+
add_subdirectory(03_DeviceSelectionAndSharedSources)
3629
# showcase the creation of windows and polling for input
37-
add_subdirectory(04_HelloUI EXCLUDE_FROM_ALL)
30+
add_subdirectory(04_HelloUI)
3831
# showcase the semi-advanced use of Nabla's Streaming Buffers and BDA
39-
add_subdirectory(05_StreamingAndBufferDeviceAddressApp EXCLUDE_FROM_ALL)
32+
add_subdirectory(05_StreamingAndBufferDeviceAddressApp)
4033
# showcase the use of a graphics queue
41-
add_subdirectory(06_HelloGraphicsQueue EXCLUDE_FROM_ALL)
34+
add_subdirectory(06_HelloGraphicsQueue)
4235
# showcase the set-up of multiple queues
43-
add_subdirectory(07_StagingAndMultipleQueues EXCLUDE_FROM_ALL)
36+
add_subdirectory(07_StagingAndMultipleQueues)
4437
# showcase the set-up of a swapchain and picking of a matching device
45-
add_subdirectory(08_HelloSwapchain EXCLUDE_FROM_ALL)
46-
add_subdirectory(09_GeometryCreator EXCLUDE_FROM_ALL)
47-
# demonstrate the counting sort utility
48-
add_subdirectory(10_CountingSort EXCLUDE_FROM_ALL)
38+
add_subdirectory(08_HelloSwapchain)
39+
add_subdirectory(09_GeometryCreator)
40+
# demonstrate the counting sort utility
41+
add_subdirectory(10_CountingSort)
4942
# showcase use of FFT for post-FX Bloom effect
50-
add_subdirectory(11_FFT EXCLUDE_FROM_ALL)
51-
43+
add_subdirectory(11_FFT)
5244

5345
# Waiting for a refactor
54-
#add_subdirectory(27_PLYSTLDemo EXCLUDE_FROM_ALL)
55-
#add_subdirectory(33_Draw3DLine EXCLUDE_FROM_ALL)
46+
#add_subdirectory(27_PLYSTLDemo)
47+
#add_subdirectory(33_Draw3DLine)
5648

5749
# Unit Test Examples
58-
add_subdirectory(20_AllocatorTest EXCLUDE_FROM_ALL)
59-
add_subdirectory(21_LRUCacheUnitTest EXCLUDE_FROM_ALL)
60-
add_subdirectory(22_CppCompat EXCLUDE_FROM_ALL)
61-
add_subdirectory(23_Arithmetic2UnitTest EXCLUDE_FROM_ALL)
62-
add_subdirectory(24_ColorSpaceTest EXCLUDE_FROM_ALL)
50+
add_subdirectory(20_AllocatorTest)
51+
add_subdirectory(21_LRUCacheUnitTest)
52+
add_subdirectory(22_CppCompat)
53+
add_subdirectory(23_Arithmetic2UnitTest)
54+
add_subdirectory(24_ColorSpaceTest)
6355
add_subdirectory(25_FilterTest EXCLUDE_FROM_ALL)
64-
add_subdirectory(26_Blur EXCLUDE_FROM_ALL)
65-
add_subdirectory(27_MPMCScheduler EXCLUDE_FROM_ALL)
66-
add_subdirectory(28_FFTBloom EXCLUDE_FROM_ALL)
67-
add_subdirectory(29_Arithmetic2Bench EXCLUDE_FROM_ALL)
68-
# add_subdirectory(36_CUDAInterop EXCLUDE_FROM_ALL)
56+
add_subdirectory(26_Blur)
57+
add_subdirectory(27_MPMCScheduler)
58+
add_subdirectory(28_FFTBloom)
59+
add_subdirectory(29_Arithmetic2Bench)
60+
# add_subdirectory(36_CUDAInterop)
6961

7062
# Showcase compute pathtracing
71-
add_subdirectory(30_ComputeShaderPathTracer EXCLUDE_FROM_ALL)
63+
add_subdirectory(30_ComputeShaderPathTracer)
7264

73-
add_subdirectory(38_EXRSplit EXCLUDE_FROM_ALL)
65+
add_subdirectory(38_EXRSplit)
7466
# if (NBL_BUILD_MITSUBA_LOADER AND NBL_BUILD_OPTIX)
75-
# add_subdirectory(39_DenoiserTonemapper EXCLUDE_FROM_ALL)
67+
# add_subdirectory(39_DenoiserTonemapper)
7668
# endif()
7769

78-
#add_subdirectory(43_SumAndCDFFilters EXCLUDE_FROM_ALL)
70+
#add_subdirectory(43_SumAndCDFFilters)
7971
add_subdirectory(47_DerivMapTest EXCLUDE_FROM_ALL)
8072
add_subdirectory(54_Transformations EXCLUDE_FROM_ALL)
8173
add_subdirectory(55_RGB18E7S3 EXCLUDE_FROM_ALL)
82-
add_subdirectory(61_UI EXCLUDE_FROM_ALL)
83-
add_subdirectory(62_CAD EXCLUDE_FROM_ALL)
74+
add_subdirectory(61_UI)
75+
add_subdirectory(62_CAD)
8476
add_subdirectory(62_SchusslerTest EXCLUDE_FROM_ALL)
85-
add_subdirectory(64_EmulatedFloatTest EXCLUDE_FROM_ALL)
77+
add_subdirectory(64_EmulatedFloatTest)
8678
add_subdirectory(0_ImportanceSamplingEnvMaps EXCLUDE_FROM_ALL) #TODO: integrate back into 42
8779

8880
add_subdirectory(66_HLSLBxDFTests EXCLUDE_FROM_ALL)
89-
add_subdirectory(67_RayQueryGeometry EXCLUDE_FROM_ALL)
90-
add_subdirectory(68_JpegLoading EXCLUDE_FROM_ALL)
81+
add_subdirectory(67_RayQueryGeometry)
82+
add_subdirectory(68_JpegLoading)
9183

92-
add_subdirectory(70_FLIPFluids EXCLUDE_FROM_ALL)
93-
add_subdirectory(71_RayTracingPipeline EXCLUDE_FROM_ALL)
84+
add_subdirectory(70_FLIPFluids)
85+
add_subdirectory(71_RayTracingPipeline)
86+
87+
# add new examples *before* NBL_GET_ALL_TARGETS invocation, it gathers recursively all targets created so far in this subdirectory
88+
NBL_GET_ALL_TARGETS(TARGETS)
89+
90+
# we want to loop only over the examples so we exclude examples' interface libraries created in common subdirectory
91+
list(REMOVE_ITEM TARGETS ${NBL_EXAMPLES_API_TARGET} ${NBL_EXAMPLES_API_LIBRARIES})
92+
93+
# we link common example api library and force examples to reuse its PCH
94+
foreach(T IN LISTS TARGETS)
95+
target_link_libraries(${T} PUBLIC ${NBL_EXAMPLES_API_TARGET})
96+
target_include_directories(${T} PUBLIC $<TARGET_PROPERTY:${NBL_EXAMPLES_API_TARGET},INCLUDE_DIRECTORIES>)
97+
target_precompile_headers(${T} REUSE_FROM "${NBL_EXAMPLES_API_TARGET}")
98+
endforeach()
9499

95-
NBL_HOOK_COMMON_API("${NBL_EXAMPLES_API_TARGETS}")
96-
endif()
100+
NBL_ADJUST_FOLDERS(examples)
101+
endif()

common/CMakeLists.txt

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
###########################################
2-
# TODO: the way it should work is following (remove the comment once all done!)
3-
# - one top PCH which includes <nabla.h> -> currently not done
4-
# - sources used only within examples splitted into "common libraries" (optional -> with options to toggle if include them to build tree), each common library should reuse the above top PCH
5-
# - examples_tests CMake loop over example targets and hook the interface library with NBL_HOOK_COMMON_API [done]
6-
# - each common library should declare ONLY interface and never expose source definition into headers nor any 3rdparty stuff!
7-
##
8-
9-
# interface libraries don't have build rules (except custom commands however it doesn't matter here) but properties
10-
add_library(nblExamplesAPI INTERFACE)
11-
set(NBL_EXAMPLES_API_INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include")
12-
target_include_directories(nblExamplesAPI INTERFACE "${NBL_EXAMPLES_API_INCLUDE_DIRECTORY}")
1+
#! Examples API proxy library
2+
#[[
3+
We create the Nabla Examples API as a static library extension, this
4+
allows all examples to reuse a single precompiled header (PCH)
5+
instead of generating their own
136
7+
The PCH includes Nabla.h + example common interface headers and takes
8+
around 1 GB per configuration, so sharing it avoids significant disk space waste
9+
]]
10+
11+
nbl_create_ext_library_project(ExamplesAPI "" "${CMAKE_CURRENT_SOURCE_DIR}/src/nbl/examples/pch.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/include" "" "")
12+
13+
set_target_properties(${LIB_NAME} PROPERTIES DISABLE_PRECOMPILE_HEADERS OFF)
14+
target_precompile_headers(${LIB_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/nbl/examples/PCH.hpp")
15+
16+
#! Examples API common libraries
17+
#[[
18+
The rule is to avoid creating additional libraries as part of the examples' common
19+
interface in order to prevent generating another precompiled header (PCH) and wasting disk space
20+
21+
If you have new utilities that could be shared across examples then try to implement them as header only
22+
and include in the PCH or in `examples.h` *if you cannot* (open the header to see details)
23+
24+
but If you have a good reason to create library because you cannot make it header only
25+
AND you *can REUSE* the examples' PCH then go ahead anyway and put it under `src/nbl/examples`,
26+
otherwise keep it header only - a good example would be to use our embedded-whatever-you-want tool
27+
which does create library but can reuse example's PCH
28+
]]
29+
30+
#! NOTE: as I write it we don't have any targets there yet
1431
add_subdirectory("src/nbl/examples" EXCLUDE_FROM_ALL)
1532

16-
# TODO: Arek what was `NBL_EXECUTABLE_COMMON_API_TARGET` ? I removed it.
17-
set(NBL_EXAMPLES_API_TARGETS nblExamplesAPI ${NBL_EXAMPLES_API_TARGETS} PARENT_SCOPE)
33+
NBL_GET_ALL_TARGETS(TARGETS)
34+
list(REMOVE_ITEM TARGETS ${LIB_NAME})
35+
36+
# the Examples API proxy library CMake target name
37+
#[[
38+
this one gets linked to each executable automatically
39+
]]
40+
set(NBL_EXAMPLES_API_TARGET ${LIB_NAME} PARENT_SCOPE)
41+
42+
#! names of CMake targets created in src/nbl/examples
43+
#[[
44+
if your example wants to use anything from src/nbl/examples
45+
then you must target_link_libraries() the lib you want as we
46+
don't link all those libraries to each executable automatically
47+
]]
48+
set(NBL_EXAMPLES_API_LIBRARIES ${TARGETS} PARENT_SCOPE)

common/include/nbl/examples/PCH.hpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,29 @@
44
#ifndef _NBL_EXAMPLES_PCH_HPP_
55
#define _NBL_EXAMPLES_PCH_HPP_
66

7+
//! Precompiled header (PCH) for Nabla Examples
8+
/*
9+
NOTE: currently our whole public and private interface is broken
10+
and private headers leak to public includes
11+
*/
12+
13+
//! Nabla declarations
14+
#include "nabla.h"
15+
16+
//! Common example interface headers
717

8-
#include <nabla.h>
918
// why isnt this in `nabla.h` ?
10-
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
19+
/*
20+
because it does stuff like
21+
22+
#ifdef NBL_EMBED_BUILTIN_RESOURCES
23+
#include "nbl/this_example/builtin/CArchive.h"
24+
#endif
1125
12-
// #include "nbl/ui/CGraphicalApplicationAndroid.h"
13-
// #include "nbl/ui/CWindowManagerAndroid.h"
26+
hence also cannot be there in PCH but rather in examples.h -> compile errors
27+
but only *if* we decide each example handles builtins on NBL_EMBED_BUILTIN_RESOURCES
28+
*/
29+
// #include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
1430

1531
#include "nbl/examples/common/SimpleWindowedApplication.hpp"
1632
#include "nbl/examples/common/MonoWindowApplication.hpp"

common/include/nbl/examples/examples.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
#ifndef _NBL_EXAMPLES_HPP_
55
#define _NBL_EXAMPLES_HPP_
66

7-
7+
//! Precompiled header shared across all examples
88
#include "nbl/examples/PCH.hpp"
99

10+
//! Example specific headers that must not be included in the PCH
11+
/*
12+
NOTE: Add here if they depend on preprocessor definitions
13+
or macros that are specific to individual example targets
14+
(eg. defined in CMake)
15+
*/
16+
17+
// #include "..."
1018

1119
#endif // _NBL_EXAMPLES_HPP_
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
# we add common libraries
2-
# add_subdirectory(cameras EXCLUDE_FROM_ALL) # header only currently
3-
41
# TODO builtin SPIR-V shaders
52
# add_subdirectory(geometry EXCLUDE_FROM_ALL)
63

7-
# we get all available targets inclusive & below this directory
8-
NBL_GET_ALL_TARGETS(NBL_SUBDIRECTORY_TARGETS)
9-
10-
# then we expose common include search directories to all common libraries + create link interface
11-
foreach(NBL_TARGET IN LISTS NBL_SUBDIRECTORY_TARGETS)
12-
target_include_directories(${NBL_TARGET} PUBLIC $<TARGET_PROPERTY:nblExamplesAPI,INTERFACE_INCLUDE_DIRECTORIES>)
13-
target_link_libraries(nblExamplesAPI INTERFACE ${NBL_TARGET})
14-
endforeach()
15-
16-
#
17-
set(NBL_COMMON_API_TARGETS ${NBL_SUBDIRECTORY_TARGETS} PARENT_SCOPE)
4+
# TODO: make docs once I get n4ce embed SPIRV tool to build system and then use the tool with Matts new shader

common/src/nbl/examples/cameras/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

common/src/nbl/examples/pch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "nbl/examples/PCH.hpp"

common/src/nbl/examples/pch/CMakeLists.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)