Skip to content

Commit 2b05707

Browse files
Merge pull request #707 from Devsh-Graphics-Programming/gpgpuimgui
Gpgpuimgui
2 parents 209d600 + 10654a2 commit 2b05707

Some content is hidden

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

44 files changed

+2426
-992
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
[submodule "3rdparty/imguizmo"]
103103
path = 3rdparty/imguizmo
104104
url = [email protected]:Devsh-Graphics-Programming/ImGuizmo.git
105+
[submodule "3rdparty/imgui_test_engine"]
106+
path = 3rdparty/imgui_test_engine
107+
url = [email protected]:ocornut/imgui_test_engine.git
105108
[submodule "3rdparty/git-version-tracking"]
106109
path = 3rdparty/git-version-tracking
107110
url = [email protected]:Devsh-Graphics-Programming/cmake-git-version-tracking.git

3rdparty/CMakeLists.txt

Lines changed: 82 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ if(_NBL_COMPILE_WITH_OPEN_EXR_)
233233
set(BUILD_TESTING ${_OLD_BUILD_TESTING})
234234
endif()
235235

236-
237-
238-
239236
#gli
240237
option(_NBL_COMPILE_WITH_GLI_ "Build with GLI library" ON)
241238
if(_NBL_COMPILE_WITH_GLI_)
@@ -295,48 +292,105 @@ NBL_ADD_GIT_TRACKING_META_LIBRARY(dxc "${CMAKE_CURRENT_SOURCE_DIR}/dxc/dxc")
295292
NBL_GENERATE_GIT_TRACKING_META()
296293

297294
if(NBL_BUILD_IMGUI)
295+
set(NBL_IMGUI_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
296+
set(NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT "${THIRD_PARTY_SOURCE_DIR}/imgui_test_engine")
297+
set(NBL_IMGUI_TEST_ENGINE_ROOT "${NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT}/imgui_test_engine")
298+
set(NBL_IMGUI_TEST_SUITE_ROOT "${NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT}/imgui_test_suite")
299+
set(NBL_IMPLOT_ROOT "${NBL_IMGUI_TEST_SUITE_ROOT}/thirdparty/implot")
300+
298301
add_library(imgui STATIC
299-
"imgui/imconfig.h"
300-
"imgui/imgui_demo.cpp"
301-
"imgui/imgui_draw.cpp"
302-
"imgui/imgui_internal.h"
303-
"imgui/imgui_tables.cpp"
304-
"imgui/imgui_widgets.cpp"
305-
"imgui/imgui.cpp"
306-
"imgui/imgui.h"
307-
"imgui/misc/cpp/imgui_stdlib.cpp"
308-
"imgui/misc/cpp/imgui_stdlib.h"
309-
"imgui/imstb_rectpack.h"
310-
"imgui/imstb_textedit.h"
311-
"imgui/imstb_truetype.h"
302+
"${NBL_IMGUI_ROOT}/imconfig.h"
303+
"${NBL_IMGUI_ROOT}/imgui_demo.cpp"
304+
"${NBL_IMGUI_ROOT}/imgui_draw.cpp"
305+
"${NBL_IMGUI_ROOT}/imgui_internal.h"
306+
"${NBL_IMGUI_ROOT}/imgui_tables.cpp"
307+
"${NBL_IMGUI_ROOT}/imgui_widgets.cpp"
308+
"${NBL_IMGUI_ROOT}/imgui.cpp"
309+
"${NBL_IMGUI_ROOT}/misc/freetype/imgui_freetype.cpp"
310+
"${NBL_IMGUI_ROOT}/imgui.h"
311+
"${NBL_IMGUI_ROOT}/misc/cpp/imgui_stdlib.cpp"
312+
"${NBL_IMGUI_ROOT}/misc/cpp/imgui_stdlib.h"
313+
"${NBL_IMGUI_ROOT}/imstb_rectpack.h"
314+
"${NBL_IMGUI_ROOT}/imstb_textedit.h"
315+
"${NBL_IMGUI_ROOT}/imstb_truetype.h"
312316
)
313-
target_include_directories(imgui
314-
PUBLIC "imgui"
315-
PUBLIC "imgui/misc/cpp"
316-
PUBLIC "imgui/backends"
317+
318+
target_link_libraries(imgui PUBLIC freetype)
319+
320+
target_include_directories(imgui PUBLIC
321+
"${NBL_IMGUI_ROOT}"
322+
"${NBL_IMGUI_ROOT}/misc/cpp"
323+
"${NBL_IMGUI_ROOT}/backends"
324+
"${NBL_IMGUI_TEST_SUITE_ROOT}"
325+
$<TARGET_PROPERTY:freetype,INCLUDE_DIRECTORIES>
317326
)
318327

319-
# ImPlot
320328
add_library(implot STATIC
321-
"implot/implot.h"
322-
"implot/implot_internal.h"
323-
"implot/implot.cpp"
324-
"implot/implot_items.cpp"
329+
"${NBL_IMPLOT_ROOT}/implot.h"
330+
"${NBL_IMPLOT_ROOT}/implot_internal.h"
331+
"${NBL_IMPLOT_ROOT}/implot.cpp"
332+
"${NBL_IMPLOT_ROOT}/implot_items.cpp"
333+
"${NBL_IMPLOT_ROOT}/implot_demo.cpp"
325334
)
335+
326336
target_include_directories(implot
327-
PUBLIC "imgui"
337+
PUBLIC $<TARGET_PROPERTY:imgui,INCLUDE_DIRECTORIES>
338+
PUBLIC "${NBL_IMPLOT_ROOT}"
328339
)
340+
329341
target_link_libraries(implot PUBLIC imgui)
330342
target_compile_definitions(implot PUBLIC IMPLOT_DEBUG IMPLOT_DLL_EXPORT)
331-
set_property(TARGET implot PROPERTY CXX_STANDARD 11)
343+
set_target_properties(implot PROPERTIES CXX_STANDARD 20)
344+
332345
if(MSVC)
333346
target_compile_options(implot PRIVATE /MT /W4 /WX /arch:AVX2 /fp:fast /permissive-)
334347
else()
335348
target_compile_options(implot PRIVATE -Wall -Wextra -pedantic -Werror -mavx2 -Ofast)
336349
endif()
350+
351+
file(GLOB_RECURSE NBL_TEST_SUITE_SOURCES CONFIGURE_DEPENDS "${NBL_IMGUI_TEST_SUITE_ROOT}/imgui_test*.cpp")
352+
file(GLOB_RECURSE NBL_TEST_SUITE_SOURCES CONFIGURE_DEPENDS "${NBL_IMGUI_TEST_SUITE_ROOT}/imgui_test*.cpp")
353+
354+
add_library(imtestsuite STATIC
355+
${NBL_TEST_SUITE_SOURCES}
356+
)
357+
358+
target_include_directories(imtestsuite PUBLIC
359+
"${NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT}"
360+
"${NBL_IMGUI_TEST_ENGINE_ROOT}"
361+
"${NBL_IMGUI_TEST_SUITE_ROOT}"
362+
$<TARGET_PROPERTY:imgui,INCLUDE_DIRECTORIES>
363+
$<TARGET_PROPERTY:implot,INCLUDE_DIRECTORIES>
364+
)
365+
366+
set_target_properties(imtestsuite PROPERTIES CXX_STANDARD 14) # NOTE! THOSE TESTS DO NOT COMPILE WITH HIGHER STANDARDS SO WE WRAP SOURCES INTO LIBRARY COMPILED WITH LOWER ONE
367+
target_link_libraries(imtestsuite PUBLIC implot)
368+
369+
file(GLOB_RECURSE NBL_TEST_ENGINE_SOURCES CONFIGURE_DEPENDS "${NBL_IMGUI_TEST_ENGINE_ROOT}/*.cpp")
370+
371+
add_library(imtestengine STATIC
372+
${NBL_TEST_ENGINE_SOURCES}
373+
)
374+
375+
target_include_directories(imtestengine PUBLIC
376+
$<TARGET_PROPERTY:imtestsuite,INCLUDE_DIRECTORIES>
377+
)
378+
379+
target_link_libraries(imtestengine PUBLIC imtestsuite)
337380

338381
set(IMGUIZMO_BUILD_EXAMPLE OFF)
339382
add_subdirectory(imguizmo EXCLUDE_FROM_ALL)
383+
384+
# note we override imgui config with our own
385+
set(NBL_IMGUI_USER_CONFIG_FILEPATH "${NBL_IMGUI_ROOT}/nabla_imconfig.h")
386+
387+
if(NOT EXISTS "${NBL_IMGUI_USER_CONFIG_FILEPATH}")
388+
message(FATAL_ERROR "\"${NBL_IMGUI_USER_CONFIG_FILEPATH}\" doesn't exist!")
389+
endif()
390+
391+
target_compile_definitions(imgui PUBLIC
392+
IMGUI_USER_CONFIG="${NBL_IMGUI_USER_CONFIG_FILEPATH}"
393+
)
340394
endif()
341395

342396
add_library(aesGladman OBJECT
@@ -427,7 +481,7 @@ if (NBL_BUILD_MITSUBA_LOADER)
427481
list(APPEND NBL_3RDPARTY_TARGETS expat)
428482
endif()
429483
if (NBL_BUILD_IMGUI)
430-
list(APPEND NBL_3RDPARTY_TARGETS imgui implot imguizmo)
484+
list(APPEND NBL_3RDPARTY_TARGETS imgui implot imtestsuite imtestengine imguizmo)
431485
endif()
432486
if(ENABLE_HLSL)
433487
list(APPEND NBL_3RDPARTY_TARGETS HLSL)

3rdparty/imgui

Submodule imgui updated 115 files

3rdparty/imgui_test_engine

Submodule imgui_test_engine added at 60b295c

cmake/common.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
258258
nbl_project_process_test_module()
259259
endmacro()
260260

261+
# TODO this macro needs more love
261262
macro(nbl_create_ext_library_project EXT_NAME LIB_HEADERS LIB_SOURCES LIB_INCLUDES LIB_OPTIONS DEF_OPTIONS)
262263
set(LIB_NAME "NblExt${EXT_NAME}")
263264
project(${LIB_NAME})
@@ -1281,4 +1282,20 @@ endmacro()
12811282

12821283
macro(write_source_definitions NBL_FILE NBL_WRAPPER_CODE_TO_WRITE)
12831284
file(WRITE "${NBL_FILE}" "${NBL_WRAPPER_CODE_TO_WRITE}")
1285+
endmacro()
1286+
1287+
function(NBL_GET_ALL_TARGETS NBL_OUTPUT_VAR)
1288+
set(NBL_TARGETS)
1289+
NBL_GET_ALL_TARGETS_RECURSIVE(NBL_TARGETS ${CMAKE_CURRENT_SOURCE_DIR})
1290+
set(${NBL_OUTPUT_VAR} ${NBL_TARGETS} PARENT_SCOPE)
1291+
endfunction()
1292+
1293+
macro(NBL_GET_ALL_TARGETS_RECURSIVE NBL_TARGETS NBL_DIRECTORY)
1294+
get_property(NBL_SUBDIRECTORIES DIRECTORY ${NBL_DIRECTORY} PROPERTY SUBDIRECTORIES)
1295+
foreach(NBL_SUBDIRECTORY ${NBL_SUBDIRECTORIES})
1296+
NBL_GET_ALL_TARGETS_RECURSIVE(${NBL_TARGETS} ${NBL_SUBDIRECTORY})
1297+
endforeach()
1298+
1299+
get_property(NBL_GATHERED_TARGETS DIRECTORY ${NBL_DIRECTORY} PROPERTY BUILDSYSTEM_TARGETS)
1300+
list(APPEND ${NBL_TARGETS} ${NBL_GATHERED_TARGETS})
12841301
endmacro()

examples_tests

Submodule examples_tests updated 65 files

include/nbl/asset/ICPUDescriptorSetLayout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
2424
public:
2525
_NBL_STATIC_INLINE_CONSTEXPR uint32_t IMMUTABLE_SAMPLER_HIERARCHYLEVELS_BELOW = 1u;
2626

27-
ICPUDescriptorSetLayout(const SBinding* const _begin, const SBinding* const _end) : base_t({_begin,_end}) {}
27+
[[deprecated("Use contructor with std::span!")]] ICPUDescriptorSetLayout(const SBinding* const _begin, const SBinding* const _end) : base_t({_begin,_end}) {}
28+
ICPUDescriptorSetLayout(const std::span<const SBinding> bindings) : base_t(bindings) {}
2829

2930
core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const override
3031
{

include/nbl/asset/ICPURenderpass.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#ifndef _NBL_I_CPU_RENDERPASS_H_INCLUDED_
22
#define _NBL_I_CPU_RENDERPASS_H_INCLUDED_
33

4-
54
#include "nbl/asset/IAsset.h"
65
#include "nbl/asset/IRenderpass.h"
76

8-
97
namespace nbl::asset
108
{
119

@@ -17,7 +15,8 @@ class ICPURenderpass : public IRenderpass, public IAsset
1715
const SCreationParamValidationResult validation = validateCreationParams(_params);
1816
if (!validation)
1917
return nullptr;
20-
return core::smart_refctd_ptr<ICPURenderpass>(new ICPURenderpass(_params,validation), core::dont_grab);
18+
19+
return core::smart_refctd_ptr<ICPURenderpass>(new ICPURenderpass(_params, validation), core::dont_grab);
2120
}
2221

2322
inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const override
@@ -42,7 +41,7 @@ class ICPURenderpass : public IRenderpass, public IAsset
4241
inline size_t getDependantCount() const override {return 0ull;}
4342

4443
protected:
45-
using IRenderpass::IRenderpass;
44+
inline ICPURenderpass(const SCreationParams& _params, const SCreationParamValidationResult& _validation) : IRenderpass(_params, _validation) {}
4645
inline ~ICPURenderpass() = default;
4746

4847
inline IAsset* getDependant_impl(const size_t ix) override {return nullptr;}

include/nbl/asset/IRenderpass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace nbl::asset
1212
{
1313

14-
class IRenderpass
14+
class NBL_API2 IRenderpass
1515
{
1616
public:
1717
enum class LOAD_OP : uint8_t
@@ -356,6 +356,7 @@ class IRenderpass
356356

357357
protected:
358358
IRenderpass(const SCreationParams& params, const SCreationParamValidationResult& counts);
359+
359360
virtual ~IRenderpass() {}
360361

361362
SCreationParams m_params;

include/nbl/asset/utils/CHLSLCompiler.h

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class NBL_API2 CHLSLCompiler final : public IShaderCompiler
3232

3333
struct SOptions : IShaderCompiler::SCompilerOptions
3434
{
35-
std::span<const std::string> dxcOptions;
35+
std::span<const std::string> dxcOptions; // TODO: span is a VIEW to memory, so to something which we should treat immutable - why not span of string_view then? Since its span we force users to keep those std::strings alive anyway but now we cannnot even make nice constexpr & pass such expression here directly
3636
IShader::E_CONTENT_TYPE getCodeContentType() const override { return IShader::E_CONTENT_TYPE::ECT_HLSL; };
3737
};
3838

@@ -54,18 +54,11 @@ class NBL_API2 CHLSLCompiler final : public IShaderCompiler
5454
std::string preprocessShader(std::string&& code, IShader::E_SHADER_STAGE& stage, const SPreprocessorOptions& preprocessOptions, std::vector<std::string>& dxc_compile_flags_override, std::vector<CCache::SEntry::SPreprocessingDependency>* dependencies = nullptr) const;
5555

5656
void insertIntoStart(std::string& code, std::ostringstream&& ins) const override;
57-
constexpr static inline const wchar_t* RequiredArguments[] = {
58-
L"-spirv",
59-
L"-Zpr",
60-
L"-enable-16bit-types",
61-
L"-fvk-use-scalar-layout",
62-
L"-Wno-c++11-extensions",
63-
L"-Wno-c++1z-extensions",
64-
L"-Wno-c++14-extensions",
65-
L"-Wno-gnu-static-float-init",
66-
L"-fspv-target-env=vulkan1.3"
67-
};
68-
constexpr static inline uint32_t RequiredArgumentCount = sizeof(RequiredArguments) / sizeof(RequiredArguments[0]);
57+
58+
static constexpr auto getRequiredArguments() //! returns required arguments for the compiler's backend
59+
{
60+
return std::span(RequiredArguments);
61+
}
6962

7063
protected:
7164
// This can't be a unique_ptr due to it being an undefined type
@@ -81,6 +74,23 @@ class NBL_API2 CHLSLCompiler final : public IShaderCompiler
8174
ret.setCommonData(options);
8275
return ret;
8376
}
77+
78+
private:
79+
// we cannot have PUBLIC data symbol in header we do export - endpoint application will fail on linker with delayed DLL loading mechanism (thats why we trick it with private member hidden from the export + provide exported getter)
80+
// https://learn.microsoft.com/en-us/previous-versions/w59k653y(v=vs.100)?redirectedfrom=MSDN
81+
constexpr static inline auto RequiredArguments = std::to_array<const wchar_t*> // TODO: and if dxcOptions is span of std::string then why w_chars there? https://en.cppreference.com/w/cpp/string/basic_string
82+
({
83+
L"-spirv",
84+
L"-Zpr",
85+
L"-enable-16bit-types",
86+
L"-fvk-use-scalar-layout",
87+
L"-Wno-c++11-extensions",
88+
L"-Wno-c++1z-extensions",
89+
L"-Wno-c++14-extensions",
90+
L"-Wno-gnu-static-float-init",
91+
L"-fspv-target-env=vulkan1.3",
92+
L"-HV", L"202x"
93+
});
8494
};
8595

8696
}

0 commit comments

Comments
 (0)