Skip to content

Commit 59483b6

Browse files
committed
Merge branch 'master' into LoadBalancingExperiments2
2 parents e897e10 + 9bcf984 commit 59483b6

File tree

14 files changed

+173
-93
lines changed

14 files changed

+173
-93
lines changed

CMakeLists.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,10 @@ set(VSG_MAX_INSTRUMENTATION_LEVEL 1 CACHE STRING "Set the instrumentation level
4444
option(VSG_SUPPORTS_ShaderCompiler "Optional shader compiler support" ON)
4545
if (VSG_SUPPORTS_ShaderCompiler)
4646

47-
# Try looking for glslang 15 first.
48-
set(GLSLANG_MIN_VERSION "15" CACHE STRING "glslang 14 is the earliest version that we think installs itself properly on all platforms. Other platforms may be able to use an earlier version")
49-
find_package(glslang ${GLSLANG_MIN_VERSION} CONFIG QUIET)
50-
51-
if (NOT glslang_FOUND)
52-
# fallback to trying glslang 14.
53-
set(GLSLANG_MIN_VERSION "14")
54-
find_package(glslang ${GLSLANG_MIN_VERSION} CONFIG)
55-
endif()
47+
find_package(glslang CONFIG QUIET)
5648

5749
if (glslang_FOUND)
58-
set(FIND_DEPENDENCY_glslang "find_package(glslang ${GLSLANG_MIN_VERSION} CONFIG REQUIRED)")
50+
set(FIND_DEPENDENCY_glslang "find_package(glslang CONFIG REQUIRED)")
5951
else()
6052
message(WARNING "glslang not found. ShaderCompile support disabled.")
6153
set(VSG_SUPPORTS_ShaderCompiler 0)
@@ -98,7 +90,7 @@ if (VSG_SUPPORTS_Windowing)
9890
endif()
9991
endif()
10092

101-
option(VSG_USE_dynamic_cast "Use dynamic_cast in vsg::Object::cast<T>(), 0 for off, 1 for enabled." OFF)
93+
option(VSG_USE_dynamic_cast "Use dynamic_cast in vsg::Object::cast<T>(), default is OFF and uses VSG native casting which provides 2-3x faster than using dynamic_cast<>." OFF)
10294

10395
# this line needs to be after the call to setup_build_vars()
10496
configure_file("${VSG_SOURCE_DIR}/src/vsg/core/Version.h.in" "${VSG_VERSION_HEADER}")

include/vsg/app/Window.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ namespace vsg
122122
ref_ptr<ImageView> imageView;
123123
ref_ptr<Framebuffer> framebuffer;
124124
ref_ptr<Semaphore> imageAvailableSemaphore;
125+
ref_ptr<Semaphore> renderFinishedSemaphore;
125126
};
126127

127128
using Frames = std::vector<Frame>;
129+
using Semaphores = std::vector<ref_ptr<Semaphore>>;
128130

129131
Frame& frame(size_t i) { return _frames[i]; }
130132
Frames& frames() { return _frames; }
@@ -173,10 +175,11 @@ namespace vsg
173175
ref_ptr<Image> _multisampleDepthImage;
174176
ref_ptr<ImageView> _multisampleDepthImageView;
175177

176-
ref_ptr<Semaphore> _availableSemaphore;
177-
178178
Frames _frames;
179179
std::vector<size_t> _indices;
180+
181+
Semaphores _availableSemaphores;
182+
size_t _availableSemaphoreIndex = 0;
180183
};
181184
VSG_type_name(vsg::Window);
182185

include/vsg/io/convert_utf.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,46 @@ namespace vsg
2727

2828
inline void convert_utf(const std::string& src, std::string& dst) { dst = src; }
2929
inline void convert_utf(const std::wstring& src, std::wstring& dst) { dst = src; }
30+
31+
#if defined(__cpp_char8_t)
32+
inline void convert_utf(const std::u8string& src, std::u8string& dst) { dst = src; }
33+
inline void convert_utf(const std::wstring& src, std::u8string& dst)
34+
{
35+
std::string temp_dst;
36+
convert_utf(src, temp_dst);
37+
dst.assign(temp_dst.begin(), temp_dst.end());
38+
}
39+
inline void convert_utf(const std::u8string& src, std::wstring& dst)
40+
{
41+
std::string temp_src(src.begin(), src.end());
42+
convert_utf(temp_src, dst);
43+
}
44+
45+
inline void convert_utf(const char8_t c, std::u8string& dst)
46+
{
47+
dst.clear();
48+
dst.push_back(c);
49+
}
50+
inline void convert_utf(const char8_t c, std::string& dst)
51+
{
52+
dst.clear();
53+
dst.push_back(c);
54+
}
55+
inline void convert_utf(const char8_t c, std::wstring& dst)
56+
{
57+
dst.clear();
58+
dst.push_back(static_cast<wchar_t>(c));
59+
}
60+
61+
template<typename T>
62+
T convert_utf(const std::u8string& src)
63+
{
64+
T dst;
65+
convert_utf(src, dst);
66+
return dst;
67+
}
68+
#endif
69+
3070
inline void convert_utf(const char c, std::string& dst)
3171
{
3272
dst.clear();

include/vsg/maths/vec2.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ namespace vsg
118118
return *this;
119119
}
120120

121+
friend constexpr t_vec2<T> operator*(const t_vec2<T>& lhs, T rhs)
122+
{
123+
return t_vec2<T>(lhs[0] * rhs, lhs[1] * rhs);
124+
}
125+
126+
friend constexpr t_vec2<T> operator*(T lhs, const t_vec2<T>& rhs)
127+
{
128+
return t_vec2<T>(lhs * rhs[0], lhs * rhs[1]);
129+
}
130+
121131
inline t_vec2& operator/=(value_type rhs)
122132
{
123133
if constexpr (std::is_floating_point_v<value_type>)
@@ -194,12 +204,6 @@ namespace vsg
194204
return t_vec2<T>(lhs[0] + rhs[0], lhs[1] + rhs[1]);
195205
}
196206

197-
template<typename T>
198-
constexpr t_vec2<T> operator*(const t_vec2<T>& lhs, T rhs)
199-
{
200-
return t_vec2<T>(lhs[0] * rhs, lhs[1] * rhs);
201-
}
202-
203207
template<typename T>
204208
constexpr t_vec2<T> operator*(const t_vec2<T>& lhs, const t_vec2<T>& rhs)
205209
{

include/vsg/maths/vec3.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ namespace vsg
115115
return *this;
116116
}
117117

118+
friend constexpr t_vec3<T> operator*(const t_vec3<T>& lhs, T rhs)
119+
{
120+
return t_vec3<T>(lhs[0] * rhs, lhs[1] * rhs, lhs[2] * rhs);
121+
}
122+
123+
friend constexpr t_vec3<T> operator*(T lhs, const t_vec3<T>& rhs)
124+
{
125+
return t_vec3<T>(lhs * rhs[0], lhs * rhs[1], lhs * rhs[2]);
126+
}
127+
118128
inline t_vec3& operator*=(const t_vec3& rhs)
119129
{
120130
value[0] *= rhs.value[0];
@@ -204,12 +214,6 @@ namespace vsg
204214
return t_vec3<T>(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2]);
205215
}
206216

207-
template<typename T>
208-
constexpr t_vec3<T> operator*(const t_vec3<T>& lhs, T rhs)
209-
{
210-
return t_vec3<T>(lhs[0] * rhs, lhs[1] * rhs, lhs[2] * rhs);
211-
}
212-
213217
template<typename T>
214218
constexpr t_vec3<T> operator*(const t_vec3<T>& lhs, const t_vec3<T>& rhs)
215219
{

include/vsg/maths/vec4.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ namespace vsg
149149
return *this;
150150
}
151151

152+
friend constexpr t_vec4<T> operator*(const t_vec4<T>& lhs, T rhs)
153+
{
154+
return t_vec4<T>(lhs[0] * rhs, lhs[1] * rhs, lhs[2] * rhs, lhs[3] * rhs);
155+
}
156+
157+
friend constexpr t_vec4<T> operator*(T lhs, const t_vec4<T>& rhs)
158+
{
159+
return t_vec4<T>(lhs * rhs[0], lhs * rhs[1], lhs * rhs[2], lhs * rhs[3]);
160+
}
161+
152162
inline t_vec4& operator/=(value_type rhs)
153163
{
154164
if constexpr (std::is_floating_point_v<value_type>)
@@ -236,12 +246,6 @@ namespace vsg
236246
return t_vec4<T>(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2], lhs[3] + rhs[3]);
237247
}
238248

239-
template<typename T>
240-
constexpr t_vec4<T> operator*(const t_vec4<T>& lhs, T rhs)
241-
{
242-
return t_vec4<T>(lhs[0] * rhs, lhs[1] * rhs, lhs[2] * rhs, lhs[3] * rhs);
243-
}
244-
245249
template<typename T>
246250
constexpr t_vec4<T> operator*(const t_vec4<T>& lhs, const t_vec4<T>& rhs)
247251
{

src/vsg/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,24 @@ ASSIGN_SOURCE_GROUPS("Header Files" "${VSG_SOURCE_DIR}/include/vsg" ${HEADERS})
411411
set_property(TARGET vsg PROPERTY VERSION ${VSG_VERSION_MAJOR}.${VSG_VERSION_MINOR}.${VSG_VERSION_PATCH})
412412
set_property(TARGET vsg PROPERTY SOVERSION ${VSG_SOVERSION})
413413
set_property(TARGET vsg PROPERTY POSITION_INDEPENDENT_CODE ON)
414-
target_compile_features(vsg PUBLIC cxx_std_17)
414+
415+
# set up the C++ Standard used
416+
if (NOT CMAKE_CXX_STANDARD)
417+
# no CMAKE_CXX_STANDARD explicitly defined so default to 17
418+
target_compile_features(vsg PUBLIC cxx_std_17)
419+
elseif (${CMAKE_CXX_STANDARD} EQUAL 17)
420+
target_compile_features(vsg PUBLIC cxx_std_17)
421+
elseif (${CMAKE_CXX_STANDARD} EQUAL 20)
422+
target_compile_features(vsg PUBLIC cxx_std_20) # CMake minimum version 3.12
423+
elseif (${CMAKE_CXX_STANDARD} EQUAL 23)
424+
target_compile_features(vsg PUBLIC cxx_std_23) # CMake minimum version 3.20
425+
elseif (${CMAKE_CXX_STANDARD} EQUAL 26)
426+
target_compile_features(vsg PUBLIC cxx_std_26) # CMake minimum version 3.30
427+
else()
428+
message(FATAL_ERROR "Invalid CMAKE_CXX_STANDARD value of " ${CMAKE_CXX_STANDARD} ", supported values are 17, 20 or 23.")
429+
endif()
430+
431+
415432
if(WIN32)
416433
set_property(TARGET vsg PROPERTY RUNTIME_OUTPUT_NAME vsg-${VSG_SOVERSION})
417434
endif()

src/vsg/app/Presentation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ VkResult Presentation::present()
3434
{
3535
vk_swapchains.emplace_back(*(window->getOrCreateSwapchain()));
3636
indices.emplace_back(static_cast<uint32_t>(imageIndex));
37+
38+
auto& renderFinishedSemaphore = window->frame(imageIndex).renderFinishedSemaphore;
39+
vk_semaphores.push_back(renderFinishedSemaphore->vk());
3740
}
3841
}
3942

src/vsg/app/RecordAndSubmitTask.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,27 +215,33 @@ VkResult RecordAndSubmitTask::finish(ref_ptr<RecordedCommandBuffers> recordedCom
215215
if (earlyDataTransferredSemaphore) transferTask->assignTransferConsumedCompletedSemaphore(TransferTask::TRANSFER_BEFORE_RECORD_TRAVERSAL, earlyTransferConsumerCompletedSemaphore);
216216
if (lateDataTransferredSemaphore) transferTask->assignTransferConsumedCompletedSemaphore(TransferTask::TRANSFER_AFTER_RECORD_TRAVERSAL, lateTransferConsumerCompletedSemaphore);
217217

218+
current_fence->dependentSemaphores().clear();
219+
218220
for (auto& window : windows)
219221
{
220222
auto imageIndex = window->imageIndex();
221223
if (imageIndex >= window->numFrames()) continue;
222224

223-
auto& semaphore = window->frame(imageIndex).imageAvailableSemaphore;
225+
auto& frame = window->frame(imageIndex);
224226

225-
vk_waitSemaphores.emplace_back(*semaphore);
226-
vk_waitStages.emplace_back(semaphore->pipelineStageFlags());
227+
vk_waitSemaphores.emplace_back(frame.imageAvailableSemaphore->vk());
228+
vk_waitStages.emplace_back(frame.imageAvailableSemaphore->pipelineStageFlags());
229+
230+
vk_signalSemaphores.emplace_back(frame.renderFinishedSemaphore->vk());
231+
current_fence->dependentSemaphores().push_back(frame.renderFinishedSemaphore);
227232
}
228233

229234
for (auto& semaphore : waitSemaphores)
230235
{
231-
vk_waitSemaphores.emplace_back(*(semaphore));
236+
vk_waitSemaphores.emplace_back(semaphore->vk());
232237
vk_waitStages.emplace_back(semaphore->pipelineStageFlags());
233238
}
234239

235240
current_fence->dependentSemaphores() = signalSemaphores;
236241
for (auto& semaphore : signalSemaphores)
237242
{
238-
vk_signalSemaphores.emplace_back(*(semaphore));
243+
vk_signalSemaphores.emplace_back(semaphore->vk());
244+
current_fence->dependentSemaphores().push_back(semaphore);
239245
}
240246

241247
if (earlyDataTransferredSemaphore)

src/vsg/app/RecordTraversal.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,6 @@ void RecordTraversal::apply(const View& view)
569569
state->_commandBuffer->viewID = view.viewID;
570570
state->_commandBuffer->viewDependentState = view.viewDependentState.get();
571571

572-
573-
574572
// cache the previous bins
575573
int32_t cached_minimumBinNumber = minimumBinNumber;
576574

0 commit comments

Comments
 (0)