Skip to content

Commit 06ce09f

Browse files
authored
Merge branch 'KhronosGroup:main' into arovir01/simple_tensor_and_data_graph
2 parents 98e67ff + 10ac965 commit 06ce09f

File tree

14 files changed

+118
-45
lines changed

14 files changed

+118
-45
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
key: ${{ github.job }}-${{ matrix.os }}
104104
- name: Configure and build
105105
run: |
106-
cmake -B"build/${{ matrix.platform }}" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON
106+
cmake -B"build/${{ matrix.platform }}" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -DCMAKE_OSX_SYSROOT=macosx -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
107107
cmake --build "build/${{ matrix.platform }}" --target vulkan_samples --config ${{ matrix.build_type }} ${{ env.PARALLEL }}
108108
109109
build_d2d:
@@ -194,5 +194,5 @@ jobs:
194194
- name: build_ios
195195
run: |
196196
source ~/VulkanSDK/iOS/setup-env.sh
197-
cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO
198-
cmake --build "build/ios" --target vulkan_samples --config ${{ matrix.build_type }} -- -sdk iphoneos -allowProvisioningUpdates
197+
cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO
198+
cmake --build "build/ios" --target vulkan_samples --config ${{ matrix.build_type }} -- -allowProvisioningUpdates

docs/build.adoc

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,26 @@ build\windows\app\bin\Release\AMD64\vulkan_samples.exe sample <sample_name>
229229
sudo apt-get install cmake g++ xorg-dev libglu1-mesa-dev libwayland-dev libxkbcommon-dev
230230
----
231231

232+
=== Selecting the window system
233+
234+
On Linux, the samples support different window systems. If not explicitly set, default is X11 Xcb. If you want to build with another window system, use the `VKB_WSI_SELECTION` CMake option like this:
235+
236+
----
237+
cmake -G "Unix Makefiles" -Bbuild/linux -DCMAKE_BUILD_TYPE=Release -DVKB_WSI_SELECTION=WAYLAND
238+
----
239+
240+
Available Linux window systems:
241+
242+
[cols="1,1"]
243+
|===
244+
| VKB_WSI_SELECTION | Window system
245+
246+
| XCB | X11 Xcb (Default)
247+
| XLIB | X11 Xlib
248+
| WAYLAND | Wayland
249+
| D2D | Direct to Display (`VK_KHR_DISPLAY`)
250+
|===
251+
232252
=== Build with CMake
233253

234254
`Step 1.` The following command will generate the project
@@ -271,15 +291,15 @@ source /PATH/TO/VULKAN/SDK/setup-env.sh
271291
`Step 1.` The following command will generate the project
272292

273293
----
274-
cmake -G Xcode -Bbuild/mac-xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=macosx
294+
cmake -G Xcode -Bbuild/mac-xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=macosx -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
275295
----
276296

277297
Open the *vulkan_samples* Xcode project inside build/mac-xcode and build with command-B. To run Vulkan Samples, use Xcode's edit-scheme selection and set the arguments to --help. Click the "Play" button and you should see the help output in the terminal. For convenience, the default setting is to run the hello_triangle sample; just edit that to your desired sample to run.
278298

279299
Alternatively, for command line builds use the steps below:
280300

281301
----
282-
cmake -Bbuild/mac -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=macosx
302+
cmake -Bbuild/mac -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=macosx -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
283303
----
284304

285305
`Step 2.` Build the project
@@ -335,7 +355,7 @@ It's recommended to open the *vulkan_samples* Xcode project that is generated in
335355
Alternatively, you can build with cmake as shown here
336356

337357
----
338-
cmake --build build/ios --config Release --target vulkan_samples -j$(sysctl -n hw.ncpu) -- -sdk iphoneos -allowProvisioningUpdates
358+
cmake --build build/ios --config Release --target vulkan_samples -j$(sysctl -n hw.ncpu) -- -allowProvisioningUpdates
339359
----
340360

341361
`Step 3.` Run the *Vulkan Samples* application

framework/core/hpp_instance.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ bool enable_layer_setting(const vk::LayerSettingEXT &requested_layer_sett
148148
bool is_available =
149149
std::ranges::any_of(enabled_layers,
150150
[&requested_layer_setting](auto const &available_layer) { return strcmp(available_layer, requested_layer_setting.pLayerName) == 0; });
151+
#if defined(PLATFORM__MACOS)
152+
// On Apple platforms the MoltenVK layer is implicitly enabled and available, and cannot be explicitly added or checked via enabled_layers.
153+
is_available = is_available || strcmp(requested_layer_setting.pLayerName, "MoltenVK") == 0;
154+
#endif
155+
151156
if (!is_available)
152157
{
153158
LOGW("Layer: {} not found. Disabling layer setting: {}", requested_layer_setting.pLayerName, requested_layer_setting.pSettingName);

framework/core/instance.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ bool enable_layer_setting(const VkLayerSettingEXT &requested_layer_setti
142142
bool is_available =
143143
std::ranges::any_of(enabled_layers,
144144
[&requested_layer_setting](auto const &available_layer) { return strcmp(available_layer, requested_layer_setting.pLayerName) == 0; });
145+
#if defined(PLATFORM__MACOS)
146+
// On Apple platforms the MoltenVK layer is implicitly enabled and available, and cannot be explicitly added or checked via enabled_layers.
147+
is_available = is_available || strcmp(requested_layer_setting.pLayerName, "MoltenVK") == 0;
148+
#endif
149+
145150
if (!is_available)
146151
{
147152
LOGW("Layer: {} not found. Disabling layer setting: {}", requested_layer_setting.pLayerName, requested_layer_setting.pSettingName);

framework/gui.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#include <imgui_internal.h>
3737
#include <numeric>
3838

39+
#if defined(PLATFORM__MACOS)
40+
# include <TargetConditionals.h>
41+
#endif
42+
3943
namespace vkb
4044
{
4145

@@ -548,7 +552,9 @@ inline void
548552
push_transform = glm::scale(push_transform, glm::vec3(2.0f / io.DisplaySize.x, 2.0f / io.DisplaySize.y, 0.0f));
549553
command_buffer.pushConstants(pipeline_layout, vk::ShaderStageFlagBits::eVertex, 0, sizeof(glm::mat4), &push_transform);
550554

551-
command_buffer.bindVertexBuffers(0, vertex_buffer->get_handle(), {0});
555+
vk::DeviceSize vertex_offsets[1] = {0};
556+
vk::Buffer vertex_buffer_handle = vertex_buffer->get_handle();
557+
command_buffer.bindVertexBuffers(0, vertex_buffer_handle, vertex_offsets);
552558

553559
command_buffer.bindIndexBuffer(index_buffer->get_handle(), 0, vk::IndexType::eUint16);
554560

samples/extensions/descriptor_indexing/descriptor_indexing.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ DescriptorIndexing::DescriptorIndexing()
3232
// See: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/2350.
3333
add_device_extension(VK_KHR_MAINTENANCE1_EXTENSION_NAME);
3434

35-
#if defined(PLATFORM__MACOS) && TARGET_OS_OSX
36-
// On macOS use layer setting to configure MoltenVK for using Metal argument buffers (needed for descriptor indexing)
35+
#if defined(PLATFORM__MACOS)
36+
// On Apple use layer setting to enable MoltenVK's Metal argument buffers - needed for descriptor indexing/scaling
3737
add_instance_extension(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, /*optional*/ true);
3838

3939
VkLayerSettingEXT layerSetting;
@@ -47,10 +47,6 @@ DescriptorIndexing::DescriptorIndexing()
4747
layerSetting.pValues = &useMetalArgumentBuffers;
4848

4949
add_layer_setting(layerSetting);
50-
51-
// On macOS also set environment variable as fallback in case layer settings not available at runtime with older SDKs
52-
// Will not work in batch mode, but is the best we can do short of using the deprecated MoltenVK private config API
53-
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "1", 1);
5450
#endif
5551
}
5652

samples/performance/layout_transitions/layout_transitions.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ LayoutTransitions::LayoutTransitions()
3636

3737
config.insert<vkb::IntSetting>(0, reinterpret_cast<int &>(layout_transition_type), LayoutTransitionType::UNDEFINED);
3838
config.insert<vkb::IntSetting>(1, reinterpret_cast<int &>(layout_transition_type), LayoutTransitionType::LAST_LAYOUT);
39+
40+
#if defined(PLATFORM__MACOS) && TARGET_OS_IOS && TARGET_OS_SIMULATOR
41+
// On iOS Simulator use layer setting to disable MoltenVK's Metal argument buffers - otherwise blank display
42+
add_instance_extension(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, /*optional*/ true);
43+
44+
VkLayerSettingEXT layerSetting;
45+
layerSetting.pLayerName = "MoltenVK";
46+
layerSetting.pSettingName = "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS";
47+
layerSetting.type = VK_LAYER_SETTING_TYPE_INT32_EXT;
48+
layerSetting.valueCount = 1;
49+
50+
// Make this static so layer setting reference remains valid after leaving constructor scope
51+
static const int32_t useMetalArgumentBuffers = 0;
52+
layerSetting.pValues = &useMetalArgumentBuffers;
53+
54+
add_layer_setting(layerSetting);
55+
#endif
3956
}
4057

4158
bool LayoutTransitions::prepare(const vkb::ApplicationOptions &options)

samples/performance/pipeline_barriers/pipeline_barriers.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ PipelineBarriers::PipelineBarriers()
3838
config.insert<vkb::IntSetting>(0, reinterpret_cast<int &>(dependency_type), DependencyType::BOTTOM_TO_TOP);
3939
config.insert<vkb::IntSetting>(1, reinterpret_cast<int &>(dependency_type), DependencyType::FRAG_TO_VERT);
4040
config.insert<vkb::IntSetting>(2, reinterpret_cast<int &>(dependency_type), DependencyType::FRAG_TO_FRAG);
41+
42+
#if defined(PLATFORM__MACOS) && TARGET_OS_IOS && TARGET_OS_SIMULATOR
43+
// On iOS Simulator use layer setting to disable MoltenVK's Metal argument buffers - otherwise blank display
44+
add_instance_extension(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, /*optional*/ true);
45+
46+
VkLayerSettingEXT layerSetting;
47+
layerSetting.pLayerName = "MoltenVK";
48+
layerSetting.pSettingName = "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS";
49+
layerSetting.type = VK_LAYER_SETTING_TYPE_INT32_EXT;
50+
layerSetting.valueCount = 1;
51+
52+
// Make this static so layer setting reference remains valid after leaving constructor scope
53+
static const int32_t useMetalArgumentBuffers = 0;
54+
layerSetting.pValues = &useMetalArgumentBuffers;
55+
56+
add_layer_setting(layerSetting);
57+
#endif
4158
}
4259

4360
bool PipelineBarriers::prepare(const vkb::ApplicationOptions &options)

samples/performance/subpasses/subpasses.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ Subpasses::Subpasses()
5050
config.insert<vkb::IntSetting>(3, configs[Config::RenderTechnique].value, 0);
5151
config.insert<vkb::IntSetting>(3, configs[Config::TransientAttachments].value, 0);
5252
config.insert<vkb::IntSetting>(3, configs[Config::GBufferSize].value, 1);
53+
54+
#if defined(PLATFORM__MACOS) && TARGET_OS_IOS && TARGET_OS_SIMULATOR
55+
// On iOS Simulator use layer setting to disable MoltenVK's Metal argument buffers - otherwise blank display
56+
add_instance_extension(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, /*optional*/ true);
57+
58+
VkLayerSettingEXT layerSetting;
59+
layerSetting.pLayerName = "MoltenVK";
60+
layerSetting.pSettingName = "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS";
61+
layerSetting.type = VK_LAYER_SETTING_TYPE_INT32_EXT;
62+
layerSetting.valueCount = 1;
63+
64+
// Make this static so layer setting reference remains valid after leaving constructor scope
65+
static const int32_t useMetalArgumentBuffers = 0;
66+
layerSetting.pValues = &useMetalArgumentBuffers;
67+
68+
add_layer_setting(layerSetting);
69+
#endif
5370
}
5471

5572
std::unique_ptr<vkb::RenderTarget> Subpasses::create_render_target(vkb::core::Image &&swapchain_image)

samples/tooling/profiles/profiles.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -165,37 +165,27 @@ std::unique_ptr<vkb::Instance> Profiles::create_instance()
165165
enabled_extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
166166
create_info.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
167167
}
168+
#endif
168169

169-
# if defined(PLATFORM__MACOS) && TARGET_OS_OSX
170-
// On macOS use layer setting to configure MoltenVK for using Metal argument buffers (needed for descriptor indexing/scaling)
171-
VkLayerSettingEXT layerSetting{};
172-
const int32_t useMetalArgumentBuffers = 1;
173-
VkLayerSettingsCreateInfoEXT layerSettingsCreateInfo{};
170+
#if defined(PLATFORM__MACOS)
171+
// On Apple use layer setting to enable MoltenVK's Metal argument buffers - needed for descriptor indexing/scaling
172+
enabled_extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);
174173

175-
if (std::ranges::any_of(available_instance_extensions,
176-
[](VkExtensionProperties const &extension) { return strcmp(extension.extensionName, VK_EXT_LAYER_SETTINGS_EXTENSION_NAME) == 0; }))
177-
{
178-
enabled_extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);
174+
VkLayerSettingEXT layerSetting{};
175+
layerSetting.pLayerName = "MoltenVK";
176+
layerSetting.pSettingName = "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS";
177+
layerSetting.type = VK_LAYER_SETTING_TYPE_INT32_EXT;
178+
layerSetting.valueCount = 1;
179179

180-
layerSetting.pLayerName = "MoltenVK";
181-
layerSetting.pSettingName = "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS";
182-
layerSetting.type = VK_LAYER_SETTING_TYPE_INT32_EXT;
183-
layerSetting.valueCount = 1;
184-
layerSetting.pValues = &useMetalArgumentBuffers;
180+
const int32_t useMetalArgumentBuffers = 1;
181+
layerSetting.pValues = &useMetalArgumentBuffers;
185182

186-
layerSettingsCreateInfo.sType = VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT;
187-
layerSettingsCreateInfo.settingCount = 1;
188-
layerSettingsCreateInfo.pSettings = &layerSetting;
183+
VkLayerSettingsCreateInfoEXT layerSettingsCreateInfo{};
184+
layerSettingsCreateInfo.sType = VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT;
185+
layerSettingsCreateInfo.settingCount = 1;
186+
layerSettingsCreateInfo.pSettings = &layerSetting;
189187

190-
create_info.pNext = &layerSettingsCreateInfo;
191-
}
192-
else
193-
{
194-
// If layer settings is not available at runtime, set macOS environment variable for support of older Vulkan SDKs
195-
// Will not work in batch mode, but is the best we can do short of using the deprecated MoltenVK private config API
196-
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "1", 1);
197-
}
198-
# endif
188+
create_info.pNext = &layerSettingsCreateInfo;
199189
#endif
200190

201191
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;

0 commit comments

Comments
 (0)