Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't update currentExtent of headless surface when swapchain attached. #2141

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Released TBD
- Ensure buffers available for buffer addresses in push constants.
- Support `libMoltenVK.dylib` for _iOS Simulator_ architecture.
- Restore support for _iOS Simulator_ destination in recent update to _Cube_ demo that uses dynamic-linking.
- Don't update `currentExtent` of headless surface when swapchain attached.



MoltenVK 1.2.7
Expand Down
1 change: 0 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,5 @@ class MVKSurface : public MVKVulkanAPIObject {
CAMetalLayer* _mtlCAMetalLayer = nil;
MVKBlockObserver* _layerObserver = nil;
MVKSwapchain* _activeSwapchain = nullptr;
VkExtent2D _headlessExtent = {0xFFFFFFFF, 0xFFFFFFFF};
};

11 changes: 7 additions & 4 deletions MoltenVK/MoltenVK/GPUObjects/MVKSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
#define STR_PLATFORM(NAME) #NAME
#define STR(NAME) STR_PLATFORM(NAME)

// As defined in the Vulkan spec, represents an undefined extent.
// Spec is currently somewhat ambiguous about whether an undefined surface extent should be updated
// once a swapchain is attached, but consensus amoung the spec authors is that it should not.
static constexpr VkExtent2D kMVKUndefinedExtent = {0xFFFFFFFF, 0xFFFFFFFF};


#pragma mark MVKSurface

Expand All @@ -50,17 +55,15 @@
}

VkExtent2D MVKSurface::getExtent() {
return _mtlCAMetalLayer ? mvkVkExtent2DFromCGSize(_mtlCAMetalLayer.drawableSize) : _headlessExtent;
return _mtlCAMetalLayer ? mvkVkExtent2DFromCGSize(_mtlCAMetalLayer.drawableSize) : kMVKUndefinedExtent;
}

VkExtent2D MVKSurface::getNaturalExtent() {
return _mtlCAMetalLayer ? mvkVkExtent2DFromCGSize(_mtlCAMetalLayer.naturalDrawableSizeMVK) : _headlessExtent;
return _mtlCAMetalLayer ? mvkVkExtent2DFromCGSize(_mtlCAMetalLayer.naturalDrawableSizeMVK) : kMVKUndefinedExtent;
}

// Per spec, headless surface extent is set from the swapchain.
void MVKSurface::setActiveSwapchain(MVKSwapchain* swapchain) {
_activeSwapchain = swapchain;
_headlessExtent = swapchain->getImageExtent();
}

MVKSurface::MVKSurface(MVKInstance* mvkInstance,
Expand Down
Loading