Skip to content

Commit e419580

Browse files
committed
docs docs docs, adjust to comments and test on 01 after updates
1 parent 312ca61 commit e419580

File tree

8 files changed

+90
-60
lines changed

8 files changed

+90
-60
lines changed

01_HelloCoreSystemAsset/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44

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

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

CMakeLists.txt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ if(NBL_BUILD_EXAMPLES)
99
nbl_android_create_media_storage_apk()
1010
endif()
1111

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+
1223
# showcase the use of `nbl::core`,`nbl::system` and `nbl::asset`
1324
add_subdirectory(01_HelloCoreSystemAsset)
1425
# showcase the use of `system::IApplicationFramework` and `nbl::video`
@@ -31,7 +42,6 @@ if(NBL_BUILD_EXAMPLES)
3142
# showcase use of FFT for post-FX Bloom effect
3243
add_subdirectory(11_FFT)
3344

34-
3545
# Waiting for a refactor
3646
#add_subdirectory(27_PLYSTLDemo)
3747
#add_subdirectory(33_Draw3DLine)
@@ -42,7 +52,7 @@ if(NBL_BUILD_EXAMPLES)
4252
add_subdirectory(22_CppCompat)
4353
add_subdirectory(23_Arithmetic2UnitTest)
4454
add_subdirectory(24_ColorSpaceTest)
45-
add_subdirectory(25_FilterTest)
55+
add_subdirectory(25_FilterTest EXCLUDE_FROM_ALL)
4656
add_subdirectory(26_Blur)
4757
add_subdirectory(27_MPMCScheduler)
4858
add_subdirectory(28_FFTBloom)
@@ -58,27 +68,29 @@ if(NBL_BUILD_EXAMPLES)
5868
# endif()
5969

6070
#add_subdirectory(43_SumAndCDFFilters)
61-
add_subdirectory(47_DerivMapTest)
62-
add_subdirectory(54_Transformations)
63-
add_subdirectory(55_RGB18E7S3)
71+
add_subdirectory(47_DerivMapTest EXCLUDE_FROM_ALL)
72+
add_subdirectory(54_Transformations EXCLUDE_FROM_ALL)
73+
add_subdirectory(55_RGB18E7S3 EXCLUDE_FROM_ALL)
6474
add_subdirectory(61_UI)
6575
add_subdirectory(62_CAD)
66-
add_subdirectory(62_SchusslerTest)
76+
add_subdirectory(62_SchusslerTest EXCLUDE_FROM_ALL)
6777
add_subdirectory(64_EmulatedFloatTest)
68-
add_subdirectory(0_ImportanceSamplingEnvMaps) #TODO: integrate back into 42
78+
add_subdirectory(0_ImportanceSamplingEnvMaps EXCLUDE_FROM_ALL) #TODO: integrate back into 42
6979

70-
add_subdirectory(66_HLSLBxDFTests)
80+
add_subdirectory(66_HLSLBxDFTests EXCLUDE_FROM_ALL)
7181
add_subdirectory(67_RayQueryGeometry)
7282
add_subdirectory(68_JpegLoading)
7383

7484
add_subdirectory(70_FLIPFluids)
7585
add_subdirectory(71_RayTracingPipeline)
7686

87+
# add new examples *before* NBL_GET_ALL_TARGETS invocation, it gathers recursively all targets created so far in this subdirectory
7788
NBL_GET_ALL_TARGETS(TARGETS)
7889

79-
# PCH & CommonAPI library for Nabla framework examples
80-
add_subdirectory(common EXCLUDE_FROM_ALL)
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})
8192

93+
# we link common example api library and force examples to reuse its PCH
8294
foreach(T IN LISTS TARGETS)
8395
target_link_libraries(${T} PUBLIC ${NBL_EXAMPLES_API_TARGET})
8496
target_include_directories(${T} PUBLIC $<TARGET_PROPERTY:${NBL_EXAMPLES_API_TARGET},INCLUDE_DIRECTORIES>)

common/CMakeLists.txt

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,48 @@
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
6+
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+
111
nbl_create_ext_library_project(ExamplesAPI "" "${CMAKE_CURRENT_SOURCE_DIR}/src/nbl/examples/pch.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/include" "" "")
212

313
set_target_properties(${LIB_NAME} PROPERTIES DISABLE_PRECOMPILE_HEADERS OFF)
414
target_precompile_headers(${LIB_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/nbl/examples/PCH.hpp")
515

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
631
add_subdirectory("src/nbl/examples" EXCLUDE_FROM_ALL)
7-
set(NBL_EXAMPLES_API_TARGET ${LIB_NAME} PARENT_SCOPE)
32+
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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@
44
#ifndef _NBL_EXAMPLES_PCH_HPP_
55
#define _NBL_EXAMPLES_PCH_HPP_
66

7-
//! public Nabla declarations
7+
//! Precompiled header (PCH) for Nabla Examples
88
/*
99
NOTE: currently our whole public and private interface is broken
1010
and private headers leak to public includes
1111
*/
12+
13+
//! Nabla declarations
1214
#include "nabla.h"
1315

14-
//! common example headers
16+
//! Common example interface headers
1517

1618
// why isnt this in `nabla.h` ?
17-
#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
25+
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"
1830

1931
#include "nbl/examples/common/SimpleWindowedApplication.hpp"
2032
#include "nbl/examples/common/MonoWindowApplication.hpp"

common/include/nbl/examples/api.hpp

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

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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
# TODO builtin SPIR-V shaders
22
# add_subdirectory(geometry EXCLUDE_FROM_ALL)
33

4-
# TODO: slightly redo and make docs once I get n4ce embed SPIRV tool to build system
5-
6-
# we get all available targets inclusive & below this directory
7-
# NBL_GET_ALL_TARGETS(NBL_SUBDIRECTORY_TARGETS)
8-
9-
# then we expose common include search directories to all common libraries + create link interface
10-
# foreach(NBL_TARGET IN LISTS NBL_SUBDIRECTORY_TARGETS)
11-
# target_include_directories(${NBL_TARGET} PUBLIC $<TARGET_PROPERTY:nblExamplesAPI,INTERFACE_INCLUDE_DIRECTORIES>)
12-
# target_link_libraries(nblExamplesAPI INTERFACE ${NBL_TARGET})
13-
#endforeach()
14-
15-
#
16-
# 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.

0 commit comments

Comments
 (0)