Skip to content

Commit

Permalink
Merge PR: Fix all sort of validation errors and image usage stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
devshgraphicsprogramming committed Jun 1, 2023
2 parents 684cabb + 57a69bd commit 4018e72
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@
[submodule "3rdparty/imgui"]
path = 3rdparty/imgui
url = git@github.com:ocornut/imgui.git
[submodule "3rdparty/implot"]
path = 3rdparty/implot
url = git@github.com:epezent/implot.git
18 changes: 18 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,24 @@ if(NBL_BUILD_IMGUI)
PUBLIC "imgui/backends"
)

# ImPlot
add_library(implot STATIC
"implot/implot.h"
"implot/implot_internal.h"
"implot/implot.cpp"
"implot/implot_items.cpp"
)
target_include_directories(implot
PUBLIC "imgui"
)
target_link_libraries(implot PUBLIC imgui)
target_compile_definitions(implot PUBLIC IMPLOT_DEBUG IMPLOT_DLL_EXPORT)
set_property(TARGET implot PROPERTY CXX_STANDARD 11)
if(MSVC)
target_compile_options(implot PRIVATE /MT /W4 /WX /arch:AVX2 /fp:fast /permissive-)
else()
target_compile_options(implot PRIVATE -Wall -Wextra -pedantic -Werror -mavx2 -Ofast)
endif()
endif()

add_library(aesGladman OBJECT
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/implot
Submodule implot added at 18758e
6 changes: 5 additions & 1 deletion cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ macro(nbl_create_ext_library_project EXT_NAME LIB_HEADERS LIB_SOURCES LIB_INCLUD
target_link_libraries(${LIB_NAME} PUBLIC Nabla)
target_compile_options(${LIB_NAME} PUBLIC ${LIB_OPTIONS})
target_compile_definitions(${LIB_NAME} PUBLIC ${DEF_OPTIONS})
set_target_properties(${LIB_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if(NBL_DYNAMIC_MSVC_RUNTIME)
set_target_properties(${LIB_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else()
set_target_properties(${LIB_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(
Expand Down
7 changes: 3 additions & 4 deletions include/nbl/ext/ImGui/ImGui.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#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{
class UI final : public core::IReferenceCounted{
public:

explicit UI(
UI(
core::smart_refctd_ptr<video::ILogicalDevice> device,
int maxFramesInFlight,
core::smart_refctd_ptr<video::IGPURenderpass>& renderPass,
Expand Down Expand Up @@ -52,7 +51,7 @@ namespace nbl::ext::imgui

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

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

bool Combo(
char const* label,
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/system/CFileArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CInnerArchiveFile : public CFileView<T>


//!
class CFileArchive : public IFileArchive
class NBL_API2 CFileArchive : public IFileArchive
{
static inline constexpr size_t SIZEOF_INNER_ARCHIVE_FILE = std::max(sizeof(CInnerArchiveFile<CPlainHeapAllocator>), sizeof(CInnerArchiveFile<VirtualMemoryAllocator>));
static inline constexpr size_t ALIGNOF_INNER_ARCHIVE_FILE = std::max(alignof(CInnerArchiveFile<CPlainHeapAllocator>), alignof(CInnerArchiveFile<VirtualMemoryAllocator>));
Expand Down
1 change: 1 addition & 0 deletions include/nbl/system/atomic_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _NBL_SYSTEM_ATOMIC_STATE_H_INCLUDED_

#include <atomic>
#include "assert.h"

namespace nbl::system
{
Expand Down
2 changes: 1 addition & 1 deletion src/nbl/builtin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,6 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/blit/normalization/shared_nor
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/line.hlsl")

macro(NBL_ADD_BUILTIN_RESOURCES _TARGET_) # internal & Nabla only, must be added with the macro to properly propagate scope
ADD_CUSTOM_BUILTIN_RESOURCES("${_TARGET_}" NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src")
ADD_CUSTOM_BUILTIN_RESOURCES("${_TARGET_}" NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL")
endmacro()

16 changes: 14 additions & 2 deletions src/nbl/builtin/builtinHeaderGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@

outp.write("#ifndef _" + guardSuffix + "_BUILTINRESOURCEDATA_H_\n")
outp.write("#define _" + guardSuffix + "_BUILTINRESOURCEDATA_H_\n")

outp.write("#ifdef __INTELLISENSE__\n")
outp.write("#include <codeanalysis\warnings.h>\n")
outp.write("#pragma warning( push )\n")
outp.write("#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )\n")
outp.write("#endif // __INTELLISENSE__\n")

outp.write("#include <stdlib.h>\n")
outp.write("#include <cstdint>\n")
outp.write("#include <string>\n")
Expand Down Expand Up @@ -76,7 +83,12 @@
else:
outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip())

outp.write("\n\t}")
outp.write("\n#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")
outp.write("\n\t}\n")

outp.write("#ifdef __INTELLISENSE__\n")
outp.write("#pragma warning( pop )\n")
outp.write("#endif // __INTELLISENSE__\n")

outp.write("#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")

outp.close()
3 changes: 2 additions & 1 deletion src/nbl/builtin/template/CArchive.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define _@_GUARD_SUFFIX_@_C_ARCHIVE_H_

#include "nbl/system/CFileArchive.h"
#include "nbl/core/def/smart_refctd_ptr.h"
#include "@NBL_BS_HEADER_FILENAME@"

namespace @_NAMESPACE_@
{
constexpr std::string_view pathPrefix = "@_BUNDLE_ARCHIVE_ABSOLUTE_PATH_@";
constexpr bool hasPathPrefix(std::string_view str) { return str.find(pathPrefix) == 0ull; }

class @_NBL_BR_API_@ CArchive final : public nbl::system::CFileArchive
class @NBL_BR_API@ CArchive final : public nbl::system::CFileArchive
{
public:
CArchive(nbl::system::logger_opt_smart_ptr&& logger);
Expand Down
18 changes: 17 additions & 1 deletion src/nbl/builtin/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
set(_SHARED_ False)
unset(NBL_BR_API)
endif()

if("${ARGV8}" STREQUAL "INTERNAL")
set(_NBL_INTERNAL_BR_CREATION_ ON)
else()
set(_NBL_INTERNAL_BR_CREATION_ OFF)
endif()

set(NBL_TEMPLATE_RESOURCES_ARCHIVE_HEADER "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CArchive.h.in")
set(NBL_TEMPLATE_RESOURCES_ARCHIVE_SOURCE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CArchive.cpp.in")
Expand Down Expand Up @@ -150,7 +156,17 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
)
endif()

get_target_property(_NABLA_INCLUDE_DIRECTORIES_ Nabla INCLUDE_DIRECTORIES)
if(TARGET Nabla)
get_target_property(_NABLA_INCLUDE_DIRECTORIES_ Nabla INCLUDE_DIRECTORIES)

if(NBL_STATIC_BUILD AND _LIB_TYPE_ STREQUAL SHARED)
message(FATAL_ERROR "Nabla must be built as dynamic library in order to combine this tool with SHARED setup!")
endif()

if(NOT _NBL_INTERNAL_BR_CREATION_)
target_link_libraries(${_TARGET_NAME_} Nabla) # be aware Nabla must be linked to the BRs
endif()
endif()

if(NOT DEFINED _NABLA_INCLUDE_DIRECTORIES_) # TODO, validate by populating generator expressions if any and checking whether a path to the BuildConfigOptions.h exists per config
message(ERROR "_NABLA_INCLUDE_DIRECTORIES_ has been not found. You are required to define _NABLA_INCLUDE_DIRECTORIES_ containing at least include search directory path to BuildConfigOptions.h")
Expand Down
8 changes: 4 additions & 4 deletions src/nbl/ext/ImGui/ImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,14 @@ namespace nbl::ext::imgui

//-------------------------------------------------------------------------------------------------

void UI::InputFloat3(char const* label, glm::vec3& value)
void UI::InputFloat3(char const* label, nbl::core::vector3df&value)
{
float tempValue[3]{ value.x, value.y, value.z };
float tempValue[3]{ value.X, value.Y, value.Z };
InputFloat3(label, tempValue);

if (memcmp(tempValue, &value[0], sizeof(float) * 3) != 0)
if (memcmp(tempValue, &value.X, sizeof(float) * 3) != 0)
{
memcpy(&value[0], tempValue, sizeof(float) * 3);
memcpy(&value.X, tempValue, sizeof(float) * 3);
}
}

Expand Down

0 comments on commit 4018e72

Please sign in to comment.