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

Builtin Resources CMake Refactor #477

Merged
merged 52 commits into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bcc127f
add src/nbl/builtin/template/CAPKResourcesArchieve.cpp.in and src/nbl…
AnastaZIuk Feb 23, 2023
f4a8ab0
bugfix: address build issues with embedded assets for clang and gnu c…
pollend Feb 24, 2023
9cfedb9
address build problems with gnu compiler
pollend Feb 24, 2023
a4b32c6
list all created builtin libraries and link to Nabla, bring back pyth…
AnastaZIuk Feb 25, 2023
b6d5e30
move some code from common.h to autogenerated CArchive.h, update src/…
AnastaZIuk Feb 25, 2023
d667624
update examples_tests submodule with archive builtin resources test
AnastaZIuk Feb 25, 2023
0e5b7de
correct python script, fix and correct CArchive.h.in and update src/n…
AnastaZIuk Feb 28, 2023
46b2b71
correct nasty bug and make sure builtin resources works
AnastaZIuk Mar 10, 2023
51b95d5
Merge branch 'newBuiltinResources' into bugfix/address-build-problems…
AnastaZIuk Mar 10, 2023
56a524d
Merge pull request #465 from pollend/bugfix/address-build-problems-bu…
AnastaZIuk Mar 10, 2023
446e301
correct missing correspondingHeaderFile after merge and remove #inclu…
AnastaZIuk Mar 10, 2023
c110ce0
move builtin resources creation macro and function to src/nbl/builtin…
AnastaZIuk Mar 10, 2023
782b6ba
request only python interpreter and correct its variable name, add mo…
AnastaZIuk Mar 10, 2023
469483a
correct python3 variable
AnastaZIuk Mar 17, 2023
1f95857
make define.h generate again, it looks like policy of custom command …
AnastaZIuk Mar 26, 2023
e2e3adc
update scripts for generating define.h header - add `_DXC_DLL_NAME_`
AnastaZIuk Mar 28, 2023
5ab06c8
Cherry pick some of Erfan's work from master
Erfan-Ahmadi Apr 11, 2023
aef1445
resolve conflicts and merge
AnastaZIuk Apr 12, 2023
4ce34b4
bad merge - fix src/nbl/builtin/builtinDataGen.py
AnastaZIuk Apr 12, 2023
345e2e0
spot issues with ambiguity causing linker errors and lack of some spi…
AnastaZIuk Apr 12, 2023
8373b38
spot a bug thanks to my apple clang compiler - but I'm not surprised…
devshgraphicsprogrammingjenkins Apr 19, 2023
cb5450a
Mounting directories (#492)
Hazardu May 5, 2023
9daedfa
add some docs to src/nbl/builtin/utils.cmake, add new parameters for …
AnastaZIuk May 10, 2023
c847d6d
save work, don't add every builtin resource as Nabla dependency, hard…
AnastaZIuk May 12, 2023
b9435da
handle multiple builtin resource aliases with CMake
AnastaZIuk May 16, 2023
78f8bfa
patch python builtin generation scripts to handle multiple aliases. T…
AnastaZIuk May 18, 2023
3d753f5
correct all issues & compile errors regarding builtin resources targe…
AnastaZIuk May 19, 2023
0433827
add LINK_BUILTIN_RESOURCES_TO_TARGET and correct bug in macro, updat…
AnastaZIuk May 19, 2023
ba669f7
address all ISystem comments - nuke some stuff, make it compile but e…
AnastaZIuk May 19, 2023
7709a8c
Changing things in File Archive class
Hazardu May 19, 2023
38084b2
Changed type name to new entry type
Hazardu May 21, 2023
c97b67c
Update CFileArchive.h
Hazardu May 21, 2023
4767028
Updated more files to have correct archive entry type
Hazardu May 21, 2023
a7c99b6
introduce in ADD_CUSTOM_BUILTIN_RESOURCES function, correct builtin …
AnastaZIuk May 21, 2023
e8e5a4b
update docs
AnastaZIuk May 21, 2023
9cb464f
update a few lines regarding path prefix, use pathPrefix created given
AnastaZIuk May 21, 2023
763f9fb
remove getItemList() proxy function and keep resources as inline stat…
AnastaZIuk May 21, 2023
806a43e
Switched all vectors from std to core
Hazardu May 21, 2023
7a499f4
merge master and resolve conflicts
AnastaZIuk May 23, 2023
34c4cdf
correct a bug
AnastaZIuk May 23, 2023
1ecd112
include search directory of nbl builtin resources for targets created…
AnastaZIuk May 23, 2023
e73e0af
add handling DLL imports/exports for builtin resource targets, have o…
AnastaZIuk May 23, 2023
0fa3cf3
add more NBL_API2 for some classes and update builtin resource genera…
AnastaZIuk May 23, 2023
cf5fec1
reverted core to std on vector usages
Hazardu May 24, 2023
dffbed2
Split archive into header CArchive.h and source CArchive.cpp files, h…
AnastaZIuk May 26, 2023
9f6bcc2
Merge branch 'newBuiltinResources' into FileArchiveTweaks
Hazardu May 26, 2023
7f665bf
Changed back to core::vector, fixes to generated CArchives
Hazardu May 26, 2023
76d10b4
got rid of double shared ptr to a single object
Hazardu May 26, 2023
c18fc86
removed extra parenthesis
Hazardu May 26, 2023
e55b5a0
removed extra parentheses
Hazardu May 26, 2023
7bd08b7
Moved CMountDirectoryArchive.h to include, changed type to sharedptr
Hazardu May 26, 2023
d6b18e3
resolve conflicts, merge master
AnastaZIuk May 27, 2023
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@
[submodule "3rdparty/tcpp"]
path = 3rdparty/tcpp
url = git@github.com:Erfan-Ahmadi/tcpp.git
[submodule "3rdparty/imgui"]
path = 3rdparty/imgui
url = git@github.com:ocornut/imgui.git
26 changes: 26 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,29 @@ add_library(spirv_cross OBJECT
)
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)

if(NBL_BUILD_IMGUI)
add_library(imgui STATIC
"imgui/imconfig.h"
"imgui/imgui_demo.cpp"
"imgui/imgui_draw.cpp"
"imgui/imgui_internal.h"
"imgui/imgui_tables.cpp"
"imgui/imgui_widgets.cpp"
"imgui/imgui.cpp"
"imgui/imgui.h"
"imgui/misc/cpp/imgui_stdlib.cpp"
"imgui/misc/cpp/imgui_stdlib.h"
"imgui/imstb_rectpack.h"
"imgui/imstb_textedit.h"
"imgui/imstb_truetype.h"
)
target_include_directories(imgui
PUBLIC "imgui"
PUBLIC "imgui/misc/cpp"
PUBLIC "imgui/backends"
)

endif()

add_library(aesGladman OBJECT
aesGladman/aes_ni.c
Expand Down Expand Up @@ -336,6 +359,9 @@ endif()
if (NBL_BUILD_MITSUBA_LOADER)
list(APPEND NBL_3RDPARTY_TARGETS expat)
endif()
if (NBL_BUILD_IMGUI)
list(APPEND NBL_3RDPARTY_TARGETS imgui)
endif()
if(ENABLE_HLSL)
list(APPEND NBL_3RDPARTY_TARGETS HLSL)
endif()
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/bullet3
Submodule bullet3 updated 1529 files
1 change: 1 addition & 0 deletions 3rdparty/imgui
Submodule imgui added at e489e4
2 changes: 2 additions & 0 deletions CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ option(NBL_BUILD_TOOLS "Enable building tools (just convert2BAW as for now)" ON)

option(NBL_BUILD_MITSUBA_LOADER "Enable nbl::ext::MitsubaLoader?" OFF) # TODO: once it compies turn this ON by default!

option(NBL_BUILD_IMGUI "Enable nbl::ext::ImGui?" ON)

option(NBL_BUILD_OPTIX "Enable nbl::ext::OptiX?" OFF)
if(NBL_COMPILE_WITH_CUDA)
find_package(OPTIX REQUIRED)
Expand Down
11 changes: 11 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
stage('CMake')
{
bat returnStatus: true, script: "cmake -DNBL_COMPILE_WITH_CUDA:BOOL=ON -DNBL_BUILD_OPTIX:BOOL=ON -DNBL_BUILD_MITSUBA_LOADER:BOOL=ON -DNBL_BUILD_RADEON_RAYS:BOOL=ON -DNBL_RUN_TESTS:BOOL=ON -S ./ -B ./build -T v143"
bat "git -C ./3rdparty/gli reset --hard" // due to gli build system bug
bat "cmake -DNBL_COMPILE_WITH_CUDA:BOOL=ON -DNBL_BUILD_OPTIX:BOOL=ON -DNBL_BUILD_MITSUBA_LOADER:BOOL=ON -DNBL_BUILD_RADEON_RAYS:BOOL=ON -DNBL_RUN_TESTS:BOOL=ON -S ./ -B ./build -T v143"
}

stage('Compile Nabla')
{
bat "cmake --build ./build --target Nabla --config Release -j12 -v"
}
6 changes: 4 additions & 2 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ macro(nbl_create_ext_library_project EXT_NAME LIB_HEADERS LIB_SOURCES LIB_INCLUD
add_dependencies(${LIB_NAME} Nabla)

get_target_property(_NBL_NABLA_TARGET_BINARY_DIR_ Nabla BINARY_DIR)
get_target_property(_BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY_ nblBuiltinResourceData BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY)

target_include_directories(${LIB_NAME}
PUBLIC ${_NBL_NABLA_TARGET_BINARY_DIR_}/build/import
Expand All @@ -230,6 +231,7 @@ macro(nbl_create_ext_library_project EXT_NAME LIB_HEADERS LIB_SOURCES LIB_INCLUD
PUBLIC ${CMAKE_SOURCE_DIR}/include
PUBLIC ${CMAKE_SOURCE_DIR}/src
PUBLIC ${CMAKE_SOURCE_DIR}/source/Nabla
PUBLIC ${_BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY_}
PRIVATE ${LIB_INCLUDES}
)
add_dependencies(${LIB_NAME} Nabla)
Expand Down Expand Up @@ -363,8 +365,8 @@ endfunction()
# @_BS_TARGET_@ is a builtin resource target

function(LINK_BUILTIN_RESOURCES_TO_TARGET _TARGET_ _BS_TARGET_)
add_dependencies(${EXECUTABLE_NAME} systemTestBuiltinResourceData)
target_link_libraries(${EXECUTABLE_NAME} PUBLIC systemTestBuiltinResourceData)
add_dependencies(${EXECUTABLE_NAME} ${_BS_TARGET_})
target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${_BS_TARGET_})

get_target_property(_BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY_ ${_BS_TARGET_} BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY)
target_include_directories(${EXECUTABLE_NAME} PUBLIC "${_BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY_}")
Expand Down
1 change: 0 additions & 1 deletion include/nbl/core/decl/smart_refctd_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class smart_refctd_ptr
inline I_REFERENCE_COUNTED& operator[](size_t idx) { return ptr[idx]; }
inline const I_REFERENCE_COUNTED& operator[](size_t idx) const { return ptr[idx]; }


inline explicit operator bool() const { return ptr; }
inline bool operator!() const { return !ptr; }

Expand Down
158 changes: 158 additions & 0 deletions include/nbl/ext/ImGui/ImGui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#ifndef NBL_EXT_IMGUI_UI_H
#define NBL_EXT_IMGUI_UI_H

#include <glm/vec3.hpp>

namespace nbl::ext::imgui
{
class NBL_API2 UI final : public core::IReferenceCounted{
public:

explicit UI(
core::smart_refctd_ptr<video::ILogicalDevice> device,
int maxFramesInFlight,
core::smart_refctd_ptr<video::IGPURenderpass>& renderPass,
video::IGPUPipelineCache* pipelineCache,
video::IGPUObjectFromAssetConverter::SParams& cpu2GpuParams,
core::smart_refctd_ptr<ui::IWindow> window
);

~UI() override;

bool Render(nbl::video::IGPUCommandBuffer& commandBuffer, int frameIndex);

void Update(
float deltaTimeInSec,
float mousePosX,
float mousePosY,
size_t mouseEventsCount,
ui::SMouseEvent const * mouseEvents
// TODO: Keyboard events
);

void BeginWindow(char const* windowName);

void EndWindow();

int Register(std::function<void()> const& listener);

bool UnRegister(int listenerId);

void SetNextItemWidth(float nextItemWidth);

void SetWindowSize(float width, float height);

void Text(char const* label, ...);

void InputFloat(char const* label, float* value);

void InputFloat2(char const* label, float* value);

void InputFloat3(char const* label, float* value);

void InputFloat4(char const* label, float* value);

void InputFloat3(char const* label, glm::vec3& value);

bool Combo(
char const* label,
int32_t* selectedItemIndex,
char const** items,
int32_t itemsCount
);

bool Combo(
const char* label,
int* selectedItemIndex,
std::vector<std::string>& values
);

void SliderInt(
char const* label,
int* value,
int minValue,
int maxValue
);

void SliderFloat(
char const* label,
float* value,
float minValue,
float maxValue
);

void Checkbox(
char const* label,
bool* value
);

void Spacing();

void Button(
char const* label,
std::function<void()> const& onPress
);

void InputText(
char const* label,
std::string& outValue
);

[[nodiscard]]
bool HasFocus();

[[nodiscard]]
bool IsItemActive();

[[nodiscard]]
bool TreeNode(char const* name);

void TreePop();

private:

core::smart_refctd_ptr<video::IGPUDescriptorSetLayout> CreateDescriptorSetLayout();

void CreatePipeline(
core::smart_refctd_ptr<video::IGPURenderpass>& renderPass,
video::IGPUPipelineCache* pipelineCache
);

void CreateFontTexture(video::IGPUObjectFromAssetConverter::SParams& cpu2GpuParams);

void UpdateDescriptorSets();

void CreateFontSampler();

void CreateDescriptorPool();

void HandleMouseEvents(
float mousePosX,
float mousePosY,
size_t mouseEventsCount,
ui::SMouseEvent const * mouseEvents
) const;

core::smart_refctd_ptr<video::ILogicalDevice> m_device{};
core::smart_refctd_ptr<video::IGPUSampler> m_fontSampler{};
core::smart_refctd_ptr<video::IDescriptorPool> m_descriptorPool{};
core::smart_refctd_ptr<video::IGPUDescriptorSet> m_gpuDescriptorSet{};
core::smart_refctd_ptr<video::IGPURenderpassIndependentPipeline> m_independentPipeline{};
core::smart_refctd_ptr<video::IGPUGraphicsPipeline> m_pipeline{};
core::smart_refctd_ptr<video::IGPUImageView> m_fontTexture{};
core::smart_refctd_ptr<ui::IWindow> m_window{};
std::vector<core::smart_refctd_ptr<video::IGPUBuffer>> m_vertexBuffers{};
std::vector<core::smart_refctd_ptr<video::IGPUBuffer>> m_indexBuffers{};
bool hasFocus = false;

// TODO: Use a signal class instead like Signal<> UIRecordSignal{};
struct Subscriber {
int id = -1;
std::function<void()> listener = nullptr;
};
std::vector<Subscriber> m_subscribers{};

};
};

#endif // NBL_EXT_IMGUI_UI_H
2 changes: 1 addition & 1 deletion include/nbl/system/CFileViewVirtualAllocatorWin32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace nbl::system
{
#ifdef _NBL_PLATFORM_WINDOWS_
class CFileViewVirtualAllocatorWin32 : public IFileViewAllocator
class NBL_API2 CFileViewVirtualAllocatorWin32 : public IFileViewAllocator
{
public:
using IFileViewAllocator::IFileViewAllocator;
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/system/IFileArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace nbl::system
class IFile;

//! The FileArchive manages archives and provides access to files inside them.
class IFileArchive : public core::IReferenceCounted
class NBL_API2 IFileArchive : public core::IReferenceCounted
{
public:
enum E_ALLOCATOR_TYPE
Expand Down
6 changes: 5 additions & 1 deletion src/nbl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,15 @@ file(GLOB_RECURSE NABLA_HEADERS_PRIV1 "*.h")
file(GLOB_RECURSE NABLA_HEADERS_PRIV2 "${NBL_ROOT_PATH}/src/nbl/*.h")

#always install builtins (some may be included in cpp regardless if embedded or not)

get_target_property(_BUILTIN_RESOURCES_BUNDLE_ARCHIVE_ABSOLUTE_PATH_ nblBuiltinResourceData BUILTIN_RESOURCES_BUNDLE_ARCHIVE_ABSOLUTE_PATH)
foreach(X IN LISTS NBL_RESOURCES_TO_EMBED)
list(APPEND NABLA_RESOURCES_TO_EMBED_PUBLIC "${NBL_ROOT_PATH}/include/${X}")
list(APPEND NABLA_RESOURCES_TO_EMBED_PUBLIC "${NBL_ROOT_PATH}/include/${_BUILTIN_RESOURCES_BUNDLE_ARCHIVE_ABSOLUTE_PATH_}/${X}")
endforeach()
list(APPEND NABLA_HEADERS_PUBLIC ${NABLA_RESOURCES_TO_EMBED_PUBLIC})
source_group("Resources to embed" FILES ${NABLA_RESOURCES_TO_EMBED_PUBLIC})
set_source_files_properties(${NABLA_RESOURCES_TO_EMBED_PUBLIC}
PROPERTIES HEADER_FILE_ONLY TRUE)

set(NABLA_HEADERS "${NBL_ROOT_PATH}/include/nabla.h" ${NABLA_HEADERS_PUBLIC} ${NABLA_HEADERS_PIRV1} ${NABLA_HEADERS_PRIV2})

Expand Down
Loading