Skip to content

Commit

Permalink
Merge pull request #691 from billhollings/Metal-3.0
Browse files Browse the repository at this point in the history
 Merge master 1.0.36 into Metal-3.0 branch.
  • Loading branch information
billhollings authored Jul 30, 2019
2 parents 80b2068 + 4d32b66 commit 4f00810
Show file tree
Hide file tree
Showing 70 changed files with 5,162 additions and 3,852 deletions.
10 changes: 6 additions & 4 deletions Common/MVKOSExtensions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ void mvkDispatchToMainAndWait(dispatch_block_t block) {
#pragma mark Process environment

string mvkGetEnvVar(string varName, bool* pWasFound) {
NSDictionary* env = [[NSProcessInfo processInfo] environment];
NSString* envStr = env[@(varName.c_str())];
if (pWasFound) { *pWasFound = envStr != nil; }
return envStr ? envStr.UTF8String : "";
@autoreleasepool {
NSDictionary*nsEnv = [[NSProcessInfo processInfo] environment];
NSString* envStr = nsEnv[@(varName.c_str())];
if (pWasFound) { *pWasFound = envStr != nil; }
return envStr ? envStr.UTF8String : "";
}
}

int64_t mvkGetEnvVarInt64(string varName, bool* pWasFound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Initialize sample from view, and resize view in accordance with the sample.
*/
void init_window(struct sample_info &info) {
info.window = sampleView;
info.caMetalLayer = sampleView.layer;
sampleView.bounds = CGRectMake(0, 0, info.width, info.height);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Initialize sample from view, and resize view in accordance with the sample.
*/
void init_window(struct sample_info &info) {
info.window = sampleView;
info.caMetalLayer = sampleView.layer;
sampleView.bounds = CGRectMake(0, 0, info.width, info.height);
}

Expand Down
2 changes: 1 addition & 1 deletion Demos/LunarG-VulkanSamples/Cube/iOS/DemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ -(void) viewDidLoad {
self.view.contentScaleFactor = UIScreen.mainScreen.nativeScale;

const char* arg = "cube";
demo_main(&demo, self.view, 1, &arg);
demo_main(&demo, self.view.layer, 1, &arg);
demo_draw(&demo);

uint32_t fps = 60;
Expand Down
3 changes: 2 additions & 1 deletion Demos/LunarG-VulkanSamples/Cube/macOS/DemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ -(void) viewDidLoad {
[super viewDidLoad];

self.view.wantsLayer = YES; // Back the view with a layer created by the makeBackingLayer method.

const char* arg = "cube";
demo_main(&demo, self.view, 1, &arg);
demo_main(&demo, self.view.layer, 1, &arg);

CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
CVDisplayLinkSetOutputCallback(_displayLink, &DisplayLinkCallback, &demo);
Expand Down
29 changes: 7 additions & 22 deletions Demos/LunarG-VulkanSamples/Hologram/ShellMVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ ShellMVK::ShellMVK(Game& game) : Shell(game)
_profile_start_time = _current_time;
_profile_present_count = 0;

#ifdef VK_USE_PLATFORM_IOS_MVK
instance_extensions_.push_back(VK_MVK_IOS_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
instance_extensions_.push_back(VK_MVK_MACOS_SURFACE_EXTENSION_NAME);
#endif
instance_extensions_.push_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME);

init_vk();
}
Expand All @@ -78,22 +73,12 @@ VkSurfaceKHR ShellMVK::create_surface(VkInstance instance) {
VkSurfaceKHR surface;

VkResult err;
#ifdef VK_USE_PLATFORM_IOS_MVK
VkIOSSurfaceCreateInfoMVK surface_info;
surface_info.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
VkMetalSurfaceCreateInfoEXT surface_info;
surface_info.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
surface_info.pNext = NULL;
surface_info.flags = 0;
surface_info.pView = _view;
err = vkCreateIOSSurfaceMVK(instance, &surface_info, NULL, &surface);
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
VkMacOSSurfaceCreateInfoMVK surface_info;
surface_info.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
surface_info.pNext = NULL;
surface_info.flags = 0;
surface_info.pView = _view;
err = vkCreateMacOSSurfaceMVK(instance, &surface_info, NULL, &surface);
#endif
surface_info.pLayer = _caMetalLayer;
err = vkCreateMetalSurfaceEXT(instance, &surface_info, NULL, &surface);
assert(!err);

return surface;
Expand Down Expand Up @@ -124,8 +109,8 @@ void ShellMVK::update_and_draw() {
}
}

void ShellMVK::run(void* view) {
_view = view; // not retained
void ShellMVK::run(void* caMetalLayer) {
_caMetalLayer = caMetalLayer; // not retained
create_context();
resize_swapchain(settings_.initial_width, settings_.initial_height);
}
2 changes: 1 addition & 1 deletion Demos/LunarG-VulkanSamples/Hologram/ShellMVK.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ShellMVK : public Shell {
void quit() { }

protected:
void* _view;
void* _caMetalLayer;
PosixTimer _timer;
double _current_time;
double _profile_start_time;
Expand Down
4 changes: 2 additions & 2 deletions Demos/LunarG-VulkanSamples/Hologram/iOS/DemoViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ -(void) viewDidLoad {
self.view.contentScaleFactor = UIScreen.mainScreen.nativeScale;

std::vector<std::string> args;
args.push_back("-p"); // Use push constants
args.push_back("-p"); // Use push constants
// args.push_back("-s"); // Use a single thread
_game = new Hologram(args);

_shell = new ShellMVK(*_game);
_shell->run(self.view);
_shell->run(self.view.layer);

uint32_t fps = 60;
_displayLink = [CADisplayLink displayLinkWithTarget: self selector: @selector(renderLoop)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ -(void) viewDidLoad {
self.view.wantsLayer = YES; // Back the view with a layer created by the makeBackingLayer method.

std::vector<std::string> args;
// args.push_back("-p"); // Uncomment to use push constants
args.push_back("-p"); // Uncomment to use push constants
// args.push_back("-s"); // Uncomment to use a single thread
_game = new Hologram(args);

_shell = new ShellMVK(*_game);
_shell->run(self.view);
_shell->run(self.view.layer);

CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
CVDisplayLinkSetOutputCallback(_displayLink, &DisplayLinkCallback, _shell);
Expand Down
59 changes: 31 additions & 28 deletions Docs/MoltenVK_Runtime_UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,47 +240,45 @@ In addition to the core *Vulkan* API, **MoltenVK** also supports the following
- `VK_KHR_maintenance3`
- `VK_KHR_push_descriptor`
- `VK_KHR_relaxed_block_layout`
- `VK_KHR_sampler_mirror_clamp_to_edge`
- `VK_KHR_sampler_mirror_clamp_to_edge` *(macOS)*
- `VK_KHR_shader_draw_parameters`
- `VK_KHR_shader_float16_int8`
- `VK_KHR_storage_buffer_storage_class`
- `VK_KHR_surface`
- `VK_KHR_swapchain`
- `VK_KHR_swapchain_mutable_format`
- `VK_KHR_uniform_buffer_standard_layout`
- `VK_KHR_variable_pointers`
- `VK_EXT_debug_marker`
- `VK_EXT_debug_report`
- `VK_EXT_debug_utils`
- `VK_EXT_host_query_reset`
- `VK_EXT_memory_budget`
- `VK_EXT_memory_budget` *(requires Metal 2.0)*
- `VK_EXT_metal_surface`
- `VK_EXT_post_depth_coverage` *(iOS, requires GPU family 4)*
- `VK_EXT_scalar_block_layout`
- `VK_EXT_shader_stencil_export` *(requires Mac GPU family 2 or iOS GPU family 5)*
- `VK_EXT_shader_viewport_index_layer`
- `VK_EXT_swapchain_colorspace` *(macOS)*
- `VK_EXT_vertex_attribute_divisor`
- `VK_EXT_texel_buffer_alignment` *(requires Metal 2.0)*
- `VK_EXTX_portability_subset`
- `VK_MVK_ios_surface` (iOS)
- `VK_MVK_macos_surface` (macOS)
- `VK_MVK_ios_surface` *(iOS) (Obsolete. Use `VK_EXT_metal_surface` instead.)*
- `VK_MVK_macos_surface` *(macOS) (Obsolete. Use `VK_EXT_metal_surface` instead.)*
- `VK_MVK_moltenvk`
- `VK_AMD_gpu_shader_half_float`
- `VK_AMD_negative_viewport_height`
- `VK_IMG_format_pvrtc` (iOS)
- `VK_AMD_shader_image_load_store_lod` *(iOS)*
- `VK_AMD_shader_trinary_minmax` *(requires Metal 2.1)*
- `VK_IMG_format_pvrtc` *(iOS)*
- `VK_INTEL_shader_integer_functions2`
- `VK_NV_glsl_shader`

In order to visibly display your content on *iOS* or *macOS*, you must enable the `VK_MVK_ios_surface`
or `VK_MVK_macos_surface` extension, respectively, and use the functions defined for that extension
to create a *Vulkan* rendering surface.

You can enable each of these extensions by defining the `VK_USE_PLATFORM_IOS_MVK` or
`VK_USE_PLATFORM_MACOS_MVK` guard macro in your compiler build settings. See the description
of the `mvk_vulkan.h` file below for a convenient way to enable these extensions automatically.

When using the `VK_MVK_macos_surface ` extension, the `pView` member of the `VkMacOSSurfaceCreateInfoMVK`
structure passed in the `vkCreateMacOSSurfaceMVK` function can be either an `NSView` whose layer is a
`CAMetalLayer`, or the `CAMetalLayer` itself. Passing the `CAMetalLayer` itself is recommended when
calling the `vkCreateMacOSSurfaceMVK` function from outside the main application thread, as `NSView`
should only be accessed from the main application thread.

When using the `VK_MVK_ios_surface ` extension, the `pView` member of the `VkIOSSurfaceCreateInfoMVK`
structure passed in the `vkCreateIOSSurfaceMVK` function can be either a `UIView` whose layer is a
`CAMetalLayer`, or the `CAMetalLayer` itself. Passing the `CAMetalLayer` itself is recommended when
calling the `vkCreateIOSSurfaceMVK ` function from outside the main application thread, as `UIView`
should only be accessed from the main application thread.
In order to visibly display your content on *iOS* or *macOS*, you must enable the `VK_EXT_metal_surface`
extension, and use the function defined in that extension to create a *Vulkan* rendering surface.
You can enable the `VK_EXT_metal_surface` extension by defining the `VK_USE_PLATFORM_METAL_EXT`
guard macro in your compiler build settings. See the description of the `mvk_vulkan.h` file below for
a convenient way to enable this extension automatically.


<a name="moltenvk_extension"></a>
Expand All @@ -306,17 +304,22 @@ where `HEADER_FILE` is one of the following:
enabled for *iOS* or *macOS*. Use this header file in place of the `vulkan.h` header file,
where access to a **MoltenVK** platform surface extension is required.

- When building for *iOS*, the `mvk_vulkan.h` header file automatically enables the
`VK_USE_PLATFORM_IOS_MVK` build setting and `VK_MVK_ios_surface` *Vulkan* extension.
- When building for *macOS*, the `mvk_vulkan.h` header file automatically enables the
`VK_USE_PLATFORM_MACOS_MVK` build setting and `VK_MVK_macos_surface` *Vulkan* extension.
The `mvk_vulkan.h` header file automatically enables the `VK_USE_PLATFORM_METAL_EXT`
build setting and `VK_EXT_metal_surface` *Vulkan* extension.

- `mvk_datatypes.h` - Contains helpful functions for converting between *Vulkan* and *Metal* data types.
You do not need to use this functionality to use **MoltenVK**, as **MoltenVK** converts between
*Vulkan* and *Metal* datatypes automatically (using the functions declared in this header).
These functions are exposed in this header for your own purposes such as interacting with *Metal*
directly, or simply logging data values.

>***Note:*** The functions in `vk_mvk_moltenvk.h` are not supported by the *Vulkan SDK Loader and Layers*
framework. The opaque Vulkan objects used by the functions in `vk_mvk_moltenvk.h` (`VkInstance`,
`VkPhysicalDevice`, `VkShaderModule`, `VKImage`, ...), must have been retrieved directly from **MoltenVK**,
and not through the *Vulkan SDK Loader and Layers* framework. The *Vulkan SDK Loader and Layers* framework
often changes these opaque objects, and passing them from a higher layer directly to **MoltenVK** will
result in undefined behaviour.


<a name="moltenvk_config"></a>
### Configuring MoltenVK
Expand Down
109 changes: 101 additions & 8 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,107 @@ For best results, use a Markdown reader.*



MoltenVK 1.0.36
MoltenVK 1.0.37
---------------

Released TBD

- Revert to supporting host-coherent memory for linear images on macOS.
- Ensure Vulkan loader magic number is set every time before returning any dispatchable Vulkan handle.



MoltenVK 1.0.36
---------------

Released 2019/07/25

- Add support for extensions:
- `VK_KHR_device_group_creation`
- `VK_KHR_swapchain_mutable_format`
- `VK_KHR_uniform_buffer_standard_layout`
- `VK_EXT_metal_surface`
- `VK_EXT_post_depth_coverage`
- `VK_EXT_scalar_block_layout`
- `VK_EXT_shader_stencil_export`
- `VK_EXT_swapchain_colorspace`
- `VK_EXT_texel_buffer_alignment`
- `VK_AMD_shader_image_load_store_lod`
- `VK_AMD_shader_trinary_minmax`
- `VK_INTEL_shader_integer_functions2`
- Support `VK_FORMAT_A2R10G10B10_UNORM_PACK32` as a surface format and view format.
- For shaders created directly from MSL, set function name from
`VkPipelineShaderStageCreateInfo::pName`.
- On iOS GPU family 2 and earlier, support immutable depth-compare samplers
as constexpr samplers hardcoded in MSL.
- Skip SPIRV-Tools build in Travis.
as `constexpr` samplers hardcoded in MSL.
- `vkCmdCopyImage()` support copying between compressed and uncompressed formats
and validate that formats are compatible for copying.
- `vkCmdBufferImageCopy()` fix crash when setting bytes per image in non-arrayed images.
- `vkCmdBlitImage()` supports blit between different texture formats, and multisampled images.
- `vkCmdResolveImage()` supports textures of different sizes.
- `vkCmdClearImage()` returns error if texture is not renderable.
- Move push constant binding to `vkCmdBindPipeline()` from `vkCmdBindDescriptorSet()`.
- `MVKDeviceMemory` keep `MTLResourceOptions` aligned with `MTLStorageMode` & `MTLCPUCacheMode`.
- Texture memory requirements don't use shared storage on macOS.
- Add `MTLCommandBuffer` completion timing performance tracking option.
- Expand `MVK_CONFIG_TRACE_VULKAN_CALLS` to optionally log Vulkan call timings.
- Skip `SPIRV-Tools` build in Travis because Travis does not support the required Python 3.
- Separate `SPIRVToMSLConverterContext` into input config and output results.
- Use native Metal texture buffers when available.
- Fix issue with push constants used across multiple draw calls not being applied.
- Fix memory leak in debug marker and debug utils labelling.
- Reduce memory leaks when autorelease pools are not available.
- Fix pipeline cache lookups.
- Fix race condition between swapchain image destruction and presentation completion callback.
- Set Metal texture usage to allow texture copy via view.
- Fix memory leak in debug marker and debug utils labelling.
- Fix issue with push constants used across multiple draw calls not being applied.
- Fix crash when binding descriptor set to layout that has been destroyed and recreated.
- Return error when `MVKImage` created as 1D attachment.
- Reduce use of autoreleased Obj-C objects, and ensure those remaining are
covered by deliberate autorelease pools.
- Document that the functions in `vk_mvk_moltenvk.h` cannot be used with objects
retrieved through the *Vulkan SDK Loader and Layers* framework.
- Update `VK_MVK_MOLTENVK_SPEC_VERSION` to 21.
- Update dependency libraries to match Vulkan SDK 1.1.114.
- Update to latest SPIRV-Cross version:
- MSL: Support `SPV_KHR_multiview` extension.
- MSL: Support the `SPV_KHR_post_depth_coverage` extension.
- MSL: Support the `SPV_AMD_shader_trinary_minmax` extension.
- MSL: Support the `SPV_KHR_device_group` extension.
- MSL: Support the `SPV_INTEL_shader_integer_functions2` extension.
- MSL: Support `SubgroupSize` / `SubgroupInvocationID` in fragment.
- MSL: Support `OpImageQueryLod`.
- MSL: Support `MinLod` operand.
- MSL: Support `PrimitiveID` in fragment and barycentrics.
- MSL: Support 64-bit integers.
- MSL: Support `OpOuterProduct`.
- MSL: Support `SubgroupLocalInvocationId` and `SubgroupSize` in all stages.
- MSL: Support scalar reflect and refract.
- MSL: Support scalar block layout.
- MSL: Use the `select()` function for `OpSelect`.
- MSL: Handle `coherent`, `volatile`, and `restrict`.
- MSL: Refactor buffer packing logic from ground up.
- MSL: Fix alignment of packed types.
- MSL: Handle packed matrices.
- MSL: Conditionally validate MSL 2.2 shaders.
- MSL: Rewrite how resource indices are fallback-assigned.
- MSL: Support custom bindings for argument buffers.
- MSL: Fix sampling with `FP16` coordinates.
- MSL: Deal with scalar input values for distance/length/normalize.
- MSL: Error out on `int64_t/uint64_t` buffer members as unsupported by Metal.
- MSL: Deal with scalar input values for distance/length/normalize.
- MSL: Re-roll array expressions in initializers.
- MSL: New SDK errors out on cull distance.
- Rewrite how switch block case labels are emitted.
- Fixes to handling of `OpPhi` and case fallthrough.
- Fix declaration of loop variables with a `OpPhi` helper copy.
- Handle more cases with FP16 and texture sampling.
- Fix variable scope when an `if` or `else` block dominates a variable.
- Fall back to complex loop if non-trivial continue block is found.
- Remove unreasonable assertion for `OpTypeImage Sampled` parameter.
- Propagate NonUniformEXT to dependent expressions.
- Deal correctly with return sign of bitscan operations.



Expand All @@ -44,7 +137,7 @@ Released 2019/06/13
- Fix tessellated indirect draws using wrong kernels to map parameters.
- Work around potential Metal bug with stage-in indirect buffers.
- Fix zero local threadgroup size in indirect tessellated rendering.
- Fix [[attribute]] assignment for tessellation evaluation shaders.
- Fix `[[attribute]]` assignment for tessellation evaluation shaders.
- `VkSemaphore` optionally uses `MTLEvent`, if available and
`MVK_ALLOW_METAL_EVENTS` environment variable is enabled.
- Add `vkSetWorkgroupSizeMVK()` to set compute kernel workgroup size
Expand All @@ -69,7 +162,7 @@ Released 2019/06/13
- Fix unused attachments terminating loop early.
- Fix offset of buffer view relative to buffer offset within device memory.
- Guard against missing Metal pipeline states when pipeline compilation fails.
- MVKBuffer: Force managed storage for linear textures on shared buffers.
- `MVKBuffer`: Force managed storage for linear textures on shared buffers.
- Use device address space when decompressing DXT image data.
- Added missing `texelBufferTextureWidth` setting in `MVKComputePipeline::getMTLFunction()`.
- Fixes and consolidation of external library header references.
Expand Down Expand Up @@ -97,7 +190,7 @@ Released 2019/06/13
- MSL: Support Invariant qualifier on position.
- MSL: Support stencil export.
- Deal with case where a block is somehow emitted in a duplicated fashion.
- Fix infinite loop when OpAtomic* temporaries are used in other blocks.
- Fix infinite loop when `OpAtomic*` temporaries are used in other blocks.
- Fix tests for device->constant address space change in MSL tessellation control shader generation.
- Accept SPIR-V 1.4 version.

Expand Down Expand Up @@ -241,7 +334,7 @@ Released 2019/01/28
- Allow default GPU Capture scope to be assigned to any queue in any queue family.
- VkPhysicalDevice: Correct some features and limits.
- Stop advertising atomic image support.
- vkSetMTLTextureMVK() function retains texture object.
- `vkSetMTLTextureMVK()` function retains texture object.
- Log to stderr instead of stdout.
- `fetchDependencies`: build `spirv-tools` when attached via symlink.
- Enhancements to `MVKVector`, and set appropriate inline sizing usages.
Expand Down Expand Up @@ -568,7 +661,7 @@ MoltenVK 1.0.17
Released 2018/07/31

- Disable rasterization and return void from vertex shaders that write to resources.
- Add SPIRVToMSLConverterOptions::isRasterizationDisabled to allow pipeline and
- Add SPIRVToMSLConversionOptions::isRasterizationDisabled to allow pipeline and
vertex shader to communicate rasterization status.
- Track layered rendering capability.
- Add MVKPhysicalDeviceMetalFeatures::layeredRendering.
Expand Down
Loading

0 comments on commit 4f00810

Please sign in to comment.