Skip to content

Commit de3a0c3

Browse files
committed
Merge branch 'master' into wayland-latest2
2 parents d48840c + 78aa023 commit de3a0c3

29 files changed

+1100
-144
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cmake_minimum_required(VERSION 3.10)
22

33
project(vsg
4-
VERSION 1.1.13
4+
VERSION 1.1.14
55
DESCRIPTION "VulkanSceneGraph library"
66
LANGUAGES C CXX
77
)
8-
set(VSG_SOVERSION 15)
8+
set(VSG_SOVERSION 16)
99
SET(VSG_RELEASE_CANDIDATE 0)
1010

1111
set(Vulkan_MIN_VERSION 1.1.70.0)
@@ -83,6 +83,8 @@ if (VSG_SUPPORTS_Windowing)
8383
set(FIND_DEPENDENCY_WINDOWING "find_library(COCOA_LIBRARY Cocoa)\nfind_library(QUARTZCORE_LIBRARY QuartzCore)\n")
8484
find_library(COCOA_LIBRARY Cocoa)
8585
find_library(QUARTZCORE_LIBRARY QuartzCore)
86+
elseif (DEFINED OHOS_ARCH) # OpenHarmony
87+
set(FIND_DEPENDENCY_WINDOWING "")
8688
elseif (UNIX)
8789
if(BUILD_WAYLAND)
8890
set(FIND_DEPENDENCY_WINDOWING "find_package(PkgConfig REQUIRED)\npkg_check_modules(wayland-client REQUIRED IMPORTED_TARGET wayland-client)\npkg_check_modules(wayland-cursor REQUIRED IMPORTED_TARGET wayland-cursor)\npkg_check_modules(xkbcommon REQUIRED IMPORTED_TARGET xkbcommon)\n")

include/vsg/app/CompileManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace vsg
3030
Slots maxSlots;
3131
bool containsPagedLOD = false;
3232
ResourceRequirements::Views views;
33-
ResourceRequirements::DynamicData dynamicData;
33+
DynamicData dynamicData;
3434

3535
explicit operator bool() const noexcept { return result == VK_SUCCESS; }
3636

include/vsg/app/TransferTask.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace vsg
5151

5252
ref_ptr<Device> device;
5353

54-
void assign(const ResourceRequirements::DynamicData& dynamicData);
54+
void assign(const DynamicData& dynamicData);
5555
void assign(const BufferInfoList& bufferInfoList);
5656
void assign(const ImageInfoList& imageInfoList);
5757

include/vsg/app/Viewer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namespace vsg
104104
/// pass the Events into any registered EventHandlers
105105
virtual void handleEvents();
106106

107-
virtual void compile(ref_ptr<ResourceHints> hints = {});
107+
virtual CompileResult compile(ref_ptr<ResourceHints> hints = {});
108108

109109
virtual bool acquireNextFrame();
110110

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#pragma once
2+
3+
/* <editor-fold desc="MIT License">
4+
5+
Copyright(c) 2025 Robert Osfield
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
9+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+
13+
</editor-fold> */
14+
15+
#define VK_USE_PLATFORM_OHOS
16+
17+
#include <vsg/app/Window.h>
18+
#include <vsg/ui/KeyEvent.h>
19+
20+
// Forward declaration for OHOS native window type
21+
struct NativeWindow;
22+
typedef struct NativeWindow OHNativeWindow;
23+
24+
// Forward declaration for OHOS ArkUI event type
25+
struct ArkUI_NodeEvent;
26+
27+
namespace vsgHarmony
28+
{
29+
typedef struct {
30+
bool capsLock;
31+
bool numLock;
32+
bool shiftPressed;
33+
bool ctrlPressed;
34+
bool altPressed;
35+
} KeyMetaState;
36+
37+
/// KeyboardMap maps OpenHarmony keyboard events to vsg::KeySymbol
38+
class KeyboardMap : public vsg::Object
39+
{
40+
public:
41+
KeyboardMap();
42+
43+
using KeyCodeToKeySymbolMap = std::map<uint32_t, vsg::KeySymbol>;
44+
45+
bool getKeySymbol(uint32_t keycode, KeyMetaState* KeyMetaState, vsg::KeySymbol& keySymbol, vsg::KeySymbol& modifiedKeySymbol, vsg::KeyModifier& keyModifier);
46+
47+
protected:
48+
KeyCodeToKeySymbolMap _keycodeMap;
49+
};
50+
51+
/// Harmony_Window implements OpenHarmony specific window creation, event handling and vulkan Surface setup.
52+
///
53+
/// In order to initialise the window, an OHNativeWindow* handle must be provided through WindowTraits,
54+
/// provided via the value "nativeWindow".
55+
///
56+
/// ```
57+
/// // void OH_main(struct OH_NativeActivity* activity)
58+
/// auto traits = vsg::WindowTraits::create();
59+
/// traits->setValue("nativeWindow", activity->window);
60+
/// auto window = vsg::Window::create(traits);
61+
/// ```
62+
///
63+
/// This window handle may also be provided through WindowTraits::nativeWindow however due to
64+
/// the way OpenHarmony loads shared libraries this is likely to encounter duplicate typeinfo for
65+
/// OHNativeWindow, and as a result can throw a std::bad_any_cast on later SDK versions and some
66+
/// system architectures.
67+
class Harmony_Window : public vsg::Inherit<vsg::Window, Harmony_Window>
68+
{
69+
public:
70+
Harmony_Window(vsg::ref_ptr<vsg::WindowTraits> traits);
71+
Harmony_Window() = delete;
72+
Harmony_Window(const Harmony_Window&) = delete;
73+
Harmony_Window operator=(const Harmony_Window&) = delete;
74+
75+
const char* instanceExtensionSurfaceName() const override { return "VK_OHOS_surface"; }
76+
77+
bool valid() const override { return _window; }
78+
79+
bool pollEvents(vsg::UIEvents& events) override;
80+
81+
void resize() override;
82+
83+
bool handleOHOSInputEvent(ArkUI_NodeEvent* event);
84+
85+
protected:
86+
virtual ~Harmony_Window();
87+
88+
void _initSurface() override;
89+
90+
OHNativeWindow* _window = nullptr;
91+
92+
int64_t _first_ohos_timestamp = 0;
93+
vsg::clock::time_point _first_ohos_time_point;
94+
95+
vsg::ref_ptr<KeyboardMap> _keyboard;
96+
KeyMetaState _keyMetaState;
97+
};
98+
99+
} // namespace vsgHarmony
100+
101+
EVSG_type_name(vsgHarmony::Harmony_Window);

include/vsg/state/BufferInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ namespace vsg
3838

3939
void release();
4040

41+
/// compute size of associated data
42+
VkDeviceSize computeDataSize() const;
43+
4144
/// Copy data to the VkBuffer(s) for all Devices associated with vsg::Buffer
4245
/// Requires associated buffer memory to be host visible, for non host visible buffers you must use a staging buffer
4346
void copyDataToBuffer();

include/vsg/state/Image.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ namespace vsg
6767
/// return true if the Image's data has been modified and should be copied to the buffer, updating the device specific ModifiedCount to the Data's ModifiedCount.
6868
bool syncModifiedCount(uint32_t deviceID) { return data && data->getModifiedCount(_vulkanData[deviceID].copiedModifiedCount); }
6969

70-
virtual void compile(Device* device);
71-
virtual void compile(Context& context);
70+
virtual VkResult compile(Device* device);
71+
virtual VkResult compile(Context& context);
72+
virtual VkResult compile(MemoryBufferPools& memoryBufferPools);
7273

7374
protected:
7475
virtual ~Image();

include/vsg/state/ImageInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ namespace vsg
4747
ref_ptr<ImageView> imageView;
4848
VkImageLayout imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
4949

50+
/// compute size of associated data
51+
VkDeviceSize computeDataSize() const;
52+
5053
/// return true if the ImageInfo's data has been modified and should be copied to the buffer
5154
bool requiresCopy(uint32_t deviceID) const
5255
{

include/vsg/state/ResourceHints.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1313
</editor-fold> */
1414

1515
#include <vsg/maths/vec2.h>
16+
#include <vsg/state/BufferInfo.h>
17+
#include <vsg/state/ImageInfo.h>
1618
#include <vsg/vk/DescriptorPool.h>
1719

1820
namespace vsg
@@ -30,6 +32,26 @@ namespace vsg
3032
DYNAMIC_VIEWPORTSTATE = 1 << 1
3133
};
3234

35+
struct DynamicData
36+
{
37+
BufferInfoList bufferInfos;
38+
ImageInfoList imageInfos;
39+
40+
explicit operator bool() const noexcept { return !bufferInfos.empty() || !imageInfos.empty(); }
41+
42+
void clear()
43+
{
44+
bufferInfos.clear();
45+
imageInfos.clear();
46+
}
47+
48+
void add(const DynamicData& dd)
49+
{
50+
bufferInfos.insert(bufferInfos.end(), dd.bufferInfos.begin(), dd.bufferInfos.end());
51+
imageInfos.insert(imageInfos.end(), dd.imageInfos.begin(), dd.imageInfos.end());
52+
}
53+
};
54+
3355
/// ResourceHints provides settings that help preallocation of Vulkan resources and memory.
3456
class VSG_DECLSPEC ResourceHints : public Inherit<Object, ResourceHints>
3557
{
@@ -56,6 +78,15 @@ namespace vsg
5678
DataTransferHint dataTransferHint = COMPILE_TRAVERSAL_USE_TRANSFER_TASK;
5779
uint32_t viewportStateHint = DYNAMIC_VIEWPORTSTATE;
5880

81+
DynamicData dynamicData;
82+
83+
bool containsPagedLOD = false;
84+
85+
/// Ratio of available device memory that can be allocated.
86+
/// Ratios less than 1.0 require VK_EXT_memory_budget extension to be supported.
87+
/// Ratio of 1.0 (or greater) will switch off checks for available memory and keep allocating till Vulkan memory allocations fail.
88+
double allocatedMemoryLimit = 1.0;
89+
5990
public:
6091
void read(Input& input) override;
6192
void write(Output& output) const override;

include/vsg/vk/Context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace vsg
8787
ref_ptr<CommandBuffer> getOrCreateCommandBuffer();
8888

8989
/// reserve resources that may be needed during compile traversal.
90-
void reserve(const ResourceRequirements& requirements);
90+
VkResult reserve(ResourceRequirements& requirements);
9191

9292
ref_ptr<DescriptorSet::Implementation> allocateDescriptorSet(DescriptorSetLayout* descriptorSetLayout);
9393

0 commit comments

Comments
 (0)