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

iOS: Support storage images in Metal argument buffers. #2298

Merged
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
1 change: 1 addition & 0 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Released TBD
- Fix rendering issue with render pass that immediately follows a kernel dispatch.
- Ensure all MoltenVK config info set by `VK_EXT_layer_settings` is used.
- Move primitive-restart-disabled warning from renderpass to pipeline creation, to reduce voluminous log noise.
- iOS: Support storage images in _Metal_ argument buffers.


MoltenVK 1.2.10
Expand Down
7 changes: 7 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,13 @@ void mvkPopulateShaderConversionConfig(mvk::SPIRVToMSLConversionConfiguration& s
setResourceIndexOffset(textureIndex, 1);
if (!getMetalFeatures().nativeTextureAtomics) { setResourceIndexOffset(bufferIndex, 1); }

#if MVK_IOS_OR_TVOS
// iOS Tier 1 argument buffers do not support writable images.
if (getMetalFeatures().argumentBuffersTier < MTLArgumentBuffersTier2) {
_layout->_canUseMetalArgumentBuffer = false;
}
#endif

if (pBinding->descriptorCount > 1 && !mtlFeats.arrayOfTextures) {
_layout->setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "Device %s does not support arrays of textures.", _device->getName()));
}
Expand Down
1 change: 1 addition & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class MVKDescriptorSetLayout : public MVKVulkanAPIDeviceObject {
MVKShaderResourceBinding _mtlResourceCounts;
int32_t _maxBufferIndex = -1;
bool _isPushDescriptorLayout = false;
bool _canUseMetalArgumentBuffer = true;
};


Expand Down
3 changes: 2 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
}

bool MVKDescriptorSetLayout::isUsingMetalArgumentBuffers() {
return MVKDeviceTrackingMixin::isUsingMetalArgumentBuffers() && !_isPushDescriptorLayout;
return MVKDeviceTrackingMixin::isUsingMetalArgumentBuffers() && _canUseMetalArgumentBuffer;
};

// Returns an autoreleased MTLArgumentDescriptor suitable for adding an auxiliary buffer to the argument buffer.
Expand Down Expand Up @@ -354,6 +354,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
const VkDescriptorSetLayoutCreateInfo* pCreateInfo) : MVKVulkanAPIDeviceObject(device) {

_isPushDescriptorLayout = mvkIsAnyFlagEnabled(pCreateInfo->flags, VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR);
_canUseMetalArgumentBuffer = !_isPushDescriptorLayout; // Push descriptors don't use argument buffers

const VkDescriptorBindingFlags* pBindingFlags = nullptr;
for (const auto* next = (VkBaseInStructure*)pCreateInfo->pNext; next; next = next->pNext) {
Expand Down
3 changes: 3 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,7 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3
shaderConfig.options.mslOptions.argument_buffers = useMetalArgBuff;
shaderConfig.options.mslOptions.force_active_argument_buffer_resources = false;
shaderConfig.options.mslOptions.pad_argument_buffer_resources = useMetalArgBuff;
shaderConfig.options.mslOptions.argument_buffers_tier = (SPIRV_CROSS_NAMESPACE::CompilerMSL::Options::ArgumentBuffersTier)getMetalFeatures().argumentBuffersTier;
shaderConfig.options.mslOptions.agx_manual_cube_grad_fixup = mtlFeats.needsCubeGradWorkaround;

MVKPipelineLayout* layout = (MVKPipelineLayout*)pCreateInfo->layout;
Expand Down Expand Up @@ -2213,6 +2214,7 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3
shaderConfig.options.mslOptions.argument_buffers = useMetalArgBuff;
shaderConfig.options.mslOptions.force_active_argument_buffer_resources = false;
shaderConfig.options.mslOptions.pad_argument_buffer_resources = useMetalArgBuff;
shaderConfig.options.mslOptions.argument_buffers_tier = (SPIRV_CROSS_NAMESPACE::CompilerMSL::Options::ArgumentBuffersTier)getMetalFeatures().argumentBuffersTier;

#if MVK_MACOS
shaderConfig.options.mslOptions.emulate_subgroups = !mtlFeats.simdPermute;
Expand Down Expand Up @@ -2600,6 +2602,7 @@ void serialize(Archive & archive, CompilerMSL::Options& opt) {
opt.texture_buffer_native,
opt.force_active_argument_buffer_resources,
opt.pad_argument_buffer_resources,
opt.argument_buffers_tier,
opt.force_native_arrays,
opt.enable_clip_distance_user_varying,
opt.multi_patch_workgroup,
Expand Down
Loading