diff --git a/Docs/MoltenVK_Runtime_UserGuide.md b/Docs/MoltenVK_Runtime_UserGuide.md index 79f3f1a5..080b4d0c 100644 --- a/Docs/MoltenVK_Runtime_UserGuide.md +++ b/Docs/MoltenVK_Runtime_UserGuide.md @@ -312,7 +312,8 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll - `VK_KHR_16bit_storage` - `VK_KHR_8bit_storage` - `VK_KHR_bind_memory2` -- `VK_KHR_buffer_device_address` *(requires GPU Tier 2 argument buffers support)* +- `VK_KHR_buffer_device_address` + - *Requires GPU Tier 2 argument buffers support.* - `VK_KHR_copy_commands2` - `VK_KHR_create_renderpass2` - `VK_KHR_dedicated_allocation` @@ -322,7 +323,8 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll - `VK_KHR_device_group_creation` - `VK_KHR_driver_properties` - `VK_KHR_dynamic_rendering` -- `VK_KHR_fragment_shader_barycentric` *(requires Metal 2.2 on Mac or Metal 2.3 on iOS)* +- `VK_KHR_fragment_shader_barycentric` + - *Requires Metal 2.2 on Mac or Metal 2.3 on iOS.* - `VK_KHR_get_memory_requirements2` - `VK_KHR_get_physical_device_properties2` - `VK_KHR_get_surface_capabilities2` @@ -337,14 +339,16 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll - `VK_KHR_portability_subset` - `VK_KHR_push_descriptor` - `VK_KHR_relaxed_block_layout` -- `VK_KHR_sampler_mirror_clamp_to_edge` *(requires a Mac GPU or Apple family 7 GPU)* +- `VK_KHR_sampler_mirror_clamp_to_edge` + - *Requires a Mac GPU or Apple family 7 GPU.* - `VK_KHR_sampler_ycbcr_conversion` - `VK_KHR_separate_depth_stencil_layouts` - `VK_KHR_shader_draw_parameters` - `VK_KHR_shader_float_controls` - `VK_KHR_shader_float16_int8` - `VK_KHR_shader_non_semantic_info` -- `VK_KHR_shader_subgroup_extended_types` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)* +- `VK_KHR_shader_subgroup_extended_types` + - *Requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS.* - `VK_KHR_spirv_1_4` - `VK_KHR_storage_buffer_storage_class` - `VK_KHR_surface` @@ -354,55 +358,78 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll - `VK_KHR_timeline_semaphore` - `VK_KHR_uniform_buffer_standard_layout` - `VK_KHR_variable_pointers` -- `VK_EXT_4444_formats` *(requires 16-bit formats and either native texture swizzling or manual swizzling to be enabled)* -- `VK_EXT_buffer_device_address` *(requires GPU Tier 2 argument buffers support)* -- `VK_EXT_calibrated_timestamps` *(requires Metal 2.2)* +- `VK_EXT_4444_formats` + - *Requires 16-bit formats and either native texture swizzling or manual swizzling to be enabled.* +- `VK_EXT_buffer_device_address` + - *Requires GPU Tier 2 argument buffers support.* +- `VK_EXT_calibrated_timestamps` + - *Requires Metal 2.2.* - `VK_EXT_debug_marker` - `VK_EXT_debug_report` - `VK_EXT_debug_utils` -- `VK_EXT_descriptor_indexing` *(initial release limited to Metal Tier 1: 96/128 textures, - 16 samplers, except macOS 11.0 (Big Sur) or later, or on older versions of macOS using - an Intel GPU, and if Metal argument buffers enabled in config)* -- `VK_EXT_extended_dynamic_state` *(requires Metal 3.1 for `VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE`)* +- `VK_EXT_descriptor_indexing` + - *Initial release limited to Metal Tier 1: 96/128 textures, + 16 samplers, except macOS 11.0 (Big Sur) or later, or on older versions of macOS using + an Intel GPU, and if Metal argument buffers enabled in config.* +- `VK_EXT_extended_dynamic_state` + - *Requires Metal 3.1 for `VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE`.* - `VK_EXT_extended_dynamic_state2` + - *Primitive restart is always enabled, as Metal does not support disabling it (`VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT`).* - `VK_EXT_external_memory_host` -- `VK_EXT_fragment_shader_interlock` *(requires Metal 2.0 and Raster Order Groups)* +- `VK_EXT_fragment_shader_interlock` + - *Requires Metal 2.0 and Raster Order Groups.* - `VK_EXT_host_query_reset` - `VK_EXT_image_robustness` - `VK_EXT_inline_uniform_block` -- `VK_EXT_memory_budget` *(requires Metal 2.0)* +- `VK_EXT_memory_budget` + - *Requires Metal 2.0.* - `VK_EXT_metal_objects` - `VK_EXT_metal_surface` - `VK_EXT_pipeline_creation_cache_control` - `VK_EXT_pipeline_creation_feedback` -- `VK_EXT_post_depth_coverage` *(iOS and macOS, requires family 4 (A11) or better Apple GPU)* +- `VK_EXT_post_depth_coverage` + - *iOS and macOS, requires family 4 (A11) or better Apple GPU.* - `VK_EXT_private_data ` - `VK_EXT_robustness2` - `VK_EXT_sample_locations` - `VK_EXT_scalar_block_layout` - `VK_EXT_separate_stencil_usage` -- `VK_EXT_shader_atomic_float` *(requires Metal 3.0)* -- `VK_EXT_shader_demote_to_helper_invocation` *(requires Metal Shading Language 2.3)* -- `VK_EXT_shader_stencil_export` *(requires Mac GPU family 2 or iOS GPU family 5)* -- `VK_EXT_shader_subgroup_ballot` *(requires Mac GPU family 2 or Apple GPU family 4)* -- `VK_EXT_shader_subgroup_vote` *(requires Mac GPU family 2 or Apple GPU family 4)* +- `VK_EXT_shader_atomic_float` + - *Requires Metal 3.0.* +- `VK_EXT_shader_demote_to_helper_invocation` + - *Requires Metal Shading Language 2.3.* +- `VK_EXT_shader_stencil_export` + - *Requires Mac GPU family 2 or iOS GPU family 5.* +- `VK_EXT_shader_subgroup_ballot` + - *Requires Mac GPU family 2 or Apple GPU family 4.* +- `VK_EXT_shader_subgroup_vote` + - *Requires Mac GPU family 2 or Apple GPU family 4.* - `VK_EXT_shader_viewport_index_layer` -- `VK_EXT_subgroup_size_control` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)* +- `VK_EXT_subgroup_size_control` + - *Requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS.* - `VK_EXT_surface_maintenance1` - `VK_EXT_swapchain_colorspace` - `VK_EXT_swapchain_maintenance1` - `VK_EXT_vertex_attribute_divisor` -- `VK_EXT_texel_buffer_alignment` *(requires Metal 2.0)* -- `VK_EXT_texture_compression_astc_hdr` *(iOS and macOS, requires family 6 (A13) or better Apple GPU)* -- `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_EXT_texel_buffer_alignment` + - *Requires Metal 2.0.* +- `VK_EXT_texture_compression_astc_hdr` + - *iOS and macOS, requires family 6 (A13) or better Apple GPU.* +- `VK_MVK_ios_surface` + - *Obsolete. Use `VK_EXT_metal_surface` instead.* +- `VK_MVK_macos_surface` + - *Obsolete. Use `VK_EXT_metal_surface` instead.* - `VK_AMD_gpu_shader_half_float` - `VK_AMD_negative_viewport_height` -- `VK_AMD_shader_image_load_store_lod` *(requires Apple GPU)* -- `VK_AMD_shader_trinary_minmax` *(requires Metal 2.1)* -- `VK_IMG_format_pvrtc` *(requires Apple GPU)* +- `VK_AMD_shader_image_load_store_lod` + - *Requires Apple GPU.* +- `VK_AMD_shader_trinary_minmax` + - *Requires Metal 2.1.* +- `VK_IMG_format_pvrtc` + - *Requires Apple GPU.* - `VK_INTEL_shader_integer_functions2` -- `VK_NV_fragment_shader_barycentric` *(requires Metal 2.2 on Mac or Metal 2.3 on iOS)* +- `VK_NV_fragment_shader_barycentric` + - *Requires Metal 2.2 on Mac or Metal 2.3 on iOS.* - `VK_NV_glsl_shader` In order to visibly display your content on *macOS*, *iOS*, or *tvOS*, you must enable the @@ -624,6 +651,8 @@ Known **MoltenVK** Limitations ------------------------------ This section documents the known limitations in this version of **MoltenVK**. + +- See [above](#interaction) for known limitations for specific Vulkan extensions. - On *macOS* versions prior to *macOS 10.15.6*, native host-coherent image device memory is not available. Because of this, changes made to `VkImage VK_MEMORY_PROPERTY_HOST_COHERENT_BIT` device memory by the CPU @@ -647,4 +676,3 @@ This section documents the known limitations in this version of **MoltenVK**. use the *Vulkan Loader and Layers* from the *[Vulkan SDK](https://vulkan.lunarg.com/sdk/home)*. Refer to the *Vulkan SDK [Getting Started](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html)* document for more info. - diff --git a/MoltenVK/MoltenVK/API/mvk_datatypes.h b/MoltenVK/MoltenVK/API/mvk_datatypes.h index 4bbed323..eabb5aa3 100644 --- a/MoltenVK/MoltenVK/API/mvk_datatypes.h +++ b/MoltenVK/MoltenVK/API/mvk_datatypes.h @@ -378,13 +378,13 @@ MTLMultisampleStencilResolveFilter mvkMTLMultisampleStencilResolveFilterFromVkRe #endif /** Returns the Metal MTLViewport corresponding to the specified Vulkan VkViewport. */ -MTLViewport mvkMTLViewportFromVkViewport(const VkViewport vkViewport); +MTLViewport mvkMTLViewportFromVkViewport(VkViewport vkViewport); /** Returns the Metal MTLScissorRect corresponding to the specified Vulkan VkRect2D. */ -MTLScissorRect mvkMTLScissorRectFromVkRect2D(const VkRect2D vkRect); +MTLScissorRect mvkMTLScissorRectFromVkRect2D(VkRect2D vkRect); /** Returns the Vulkan VkRect2D corresponding to the specified Metal MTLScissorRect. */ -VkRect2D mvkVkRect2DFromMTLScissorRect(const MTLScissorRect mtlScissorRect); +VkRect2D mvkVkRect2DFromMTLScissorRect(MTLScissorRect mtlScissorRect); /** Returns the Metal MTLCompareFunction corresponding to the specified Vulkan VkCompareOp, */ MTLCompareFunction mvkMTLCompareFunctionFromVkCompareOp(VkCompareOp vkOp); diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdRendering.h b/MoltenVK/MoltenVK/Commands/MVKCmdRendering.h index 2b11ae8e..fc67422e 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdRendering.h +++ b/MoltenVK/MoltenVK/Commands/MVKCmdRendering.h @@ -267,25 +267,6 @@ typedef MVKCmdSetScissor<1> MVKCmdSetScissor1; typedef MVKCmdSetScissor MVKCmdSetScissorMulti; -#pragma mark - -#pragma mark MVKCmdSetLineWidth - -/** Vulkan command to set the line width. */ -class MVKCmdSetLineWidth : public MVKCommand { - -public: - VkResult setContent(MVKCommandBuffer* cmdBuff, - float lineWidth); - - void encode(MVKCommandEncoder* cmdEncoder) override; - -protected: - MVKCommandTypePool* getTypePool(MVKCommandPool* cmdPool) override; - - float _lineWidth; -}; - - #pragma mark - #pragma mark MVKCmdSetDepthBias @@ -347,40 +328,6 @@ protected: }; -#pragma mark - -#pragma mark MVKCmdSetLogicOp - -/** Vulkan command to dynamically set the blending logic operation. */ -class MVKCmdSetLogicOp : public MVKCommand { - -public: - VkResult setContent(MVKCommandBuffer* cmdBuff, - VkLogicOp logicOp); - - void encode(MVKCommandEncoder* cmdEncoder) override; - -protected: - MVKCommandTypePool* getTypePool(MVKCommandPool* cmdPool) override; -}; - - -#pragma mark - -#pragma mark MVKCmdSetLogicOpEnable - -/** Vulkan command to dynamically enable or disable the blending logic operation. */ -class MVKCmdSetLogicOpEnable : public MVKCommand { - -public: - VkResult setContent(MVKCommandBuffer* cmdBuff, - VkBool32 logicOpEnable); - - void encode(MVKCommandEncoder* cmdEncoder) override; - -protected: - MVKCommandTypePool* getTypePool(MVKCommandPool* cmdPool) override; -}; - - #pragma mark - #pragma mark MVKCmdSetDepthTestEnable @@ -438,46 +385,6 @@ protected: }; -#pragma mark - -#pragma mark MVKCmdSetDepthBounds - -/** Vulkan command to set depth bounds. */ -class MVKCmdSetDepthBounds : public MVKCommand { - -public: - VkResult setContent(MVKCommandBuffer* cmdBuff, - float minDepthBounds, - float maxDepthBounds); - - void encode(MVKCommandEncoder* cmdEncoder) override; - -protected: - MVKCommandTypePool* getTypePool(MVKCommandPool* cmdPool) override; - - float _minDepthBounds; - float _maxDepthBounds; -}; - - -#pragma mark - -#pragma mark MVKCmdSetDepthBoundsTestEnable - -/** Vulkan command to enable depth bounds testing. */ -class MVKCmdSetDepthBoundsTestEnable : public MVKCommand { - -public: - VkResult setContent(MVKCommandBuffer* cmdBuff, - VkBool32 depthBoundsTestEnable); - - void encode(MVKCommandEncoder* cmdEncoder) override; - -protected: - MVKCommandTypePool* getTypePool(MVKCommandPool* cmdPool) override; - - bool _depthBoundsTestEnable; -}; - - #pragma mark - #pragma mark MVKCmdSetStencilTestEnable diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdRendering.mm b/MoltenVK/MoltenVK/Commands/MVKCmdRendering.mm index 33078a02..1aa4aa5c 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdRendering.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdRendering.mm @@ -285,24 +285,6 @@ template class MVKCmdSetScissor<1>; template class MVKCmdSetScissor; -#pragma mark - -#pragma mark MVKCmdSetLineWidth - -VkResult MVKCmdSetLineWidth::setContent(MVKCommandBuffer* cmdBuff, - float lineWidth) { - _lineWidth = lineWidth; - - // Validate - if (_lineWidth != 1.0 || cmdBuff->getDevice()->_enabledFeatures.wideLines) { - return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdSetLineWidth(): The current device does not support wide lines."); - } - - return VK_SUCCESS; -} - -void MVKCmdSetLineWidth::encode(MVKCommandEncoder* cmdEncoder) {} - - #pragma mark - #pragma mark MVKCmdSetDepthBias @@ -352,38 +334,6 @@ void MVKCmdSetBlendConstants::encode(MVKCommandEncoder* cmdEncoder) { } -#pragma mark - -#pragma mark MVKCmdSetLogicOp - -VkResult MVKCmdSetLogicOp::setContent(MVKCommandBuffer* cmdBuff, - VkLogicOp logicOp) { - // Validate - if (logicOp != VK_LOGIC_OP_COPY) { - return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "Metal does not support blending using logic operations."); - } - - return VK_SUCCESS; -} - -void MVKCmdSetLogicOp::encode(MVKCommandEncoder* cmdEncoder) {} - - -#pragma mark - -#pragma mark MVKCmdSetLogicOpEnable - -VkResult MVKCmdSetLogicOpEnable::setContent(MVKCommandBuffer* cmdBuff, - VkBool32 logicOpEnable) { - // Validate - if (logicOpEnable) { - return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "Metal does not support blending using logic operations."); - } - - return VK_SUCCESS; -} - -void MVKCmdSetLogicOpEnable::encode(MVKCommandEncoder* cmdEncoder) {} - - #pragma mark - #pragma mark MVKCmdSetDepthTestEnable @@ -426,44 +376,6 @@ void MVKCmdSetDepthCompareOp::encode(MVKCommandEncoder* cmdEncoder) { } -#pragma mark - -#pragma mark MVKCmdSetDepthBounds - -VkResult MVKCmdSetDepthBounds::setContent(MVKCommandBuffer* cmdBuff, - float minDepthBounds, - float maxDepthBounds) { - _minDepthBounds = minDepthBounds; - _maxDepthBounds = maxDepthBounds; - - // Validate - if (cmdBuff->getDevice()->_enabledFeatures.depthBounds) { - return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdSetDepthBounds(): The current device does not support setting depth bounds."); - } - - return VK_SUCCESS; -} - -void MVKCmdSetDepthBounds::encode(MVKCommandEncoder* cmdEncoder) {} - - -#pragma mark - -#pragma mark MVKCmdSetDepthBoundsTestEnable - -VkResult MVKCmdSetDepthBoundsTestEnable::setContent(MVKCommandBuffer* cmdBuff, - VkBool32 depthBoundsTestEnable) { - _depthBoundsTestEnable = static_cast(depthBoundsTestEnable); - - // Validate - if (cmdBuff->getDevice()->_enabledFeatures.depthBounds) { - return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdSetDepthBoundsTestEnable(): The current device does not support testing depth bounds."); - } - - return VK_SUCCESS; -} - -void MVKCmdSetDepthBoundsTestEnable::encode(MVKCommandEncoder* cmdEncoder) {} - - #pragma mark - #pragma mark MVKCmdSetStencilTestEnable diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h index 94f4585c..39580131 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h +++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h @@ -358,6 +358,9 @@ public: /** Returns the push constants associated with the specified shader stage. */ MVKPushConstantsCommandEncoderState* getPushConstants(VkShaderStageFlagBits shaderStage); + /** Encode the buffer binding as a vertex attribute buffer. */ + void encodeVertexAttributeBuffer(MVKMTLBufferBinding& b, bool isDynamicStride); + /** * Copy bytes into the Metal encoder at a Metal vertex buffer index, and optionally indicate * that this binding might override a desriptor binding. If so, the descriptor binding will diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm index 55127489..9575bb76 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm @@ -919,6 +919,42 @@ void MVKCommandEncoder::setVertexBytes(id mtlEncoder, } } +void MVKCommandEncoder::encodeVertexAttributeBuffer(MVKMTLBufferBinding& b, bool isDynamicStride) { + if (_device->_pMetalFeatures->dynamicVertexStride) { +#if MVK_XCODE_15 + NSUInteger mtlStride = isDynamicStride ? b.stride : MTLAttributeStrideStatic; + if (b.isInline) { + [_mtlRenderEncoder setVertexBytes: b.mtlBytes + length: b.size + attributeStride: mtlStride + atIndex: b.index]; + } else if (b.justOffset) { + [_mtlRenderEncoder setVertexBufferOffset: b.offset + attributeStride: mtlStride + atIndex: b.index]; + } else { + [_mtlRenderEncoder setVertexBuffer: b.mtlBuffer + offset: b.offset + attributeStride: mtlStride + atIndex: b.index]; + } +#endif + } else { + if (b.isInline) { + [_mtlRenderEncoder setVertexBytes: b.mtlBytes + length: b.size + atIndex: b.index]; + } else if (b.justOffset) { + [_mtlRenderEncoder setVertexBufferOffset: b.offset + atIndex: b.index]; + } else { + [_mtlRenderEncoder setVertexBuffer: b.mtlBuffer + offset: b.offset + atIndex: b.index]; + } + } +} + void MVKCommandEncoder::setFragmentBytes(id mtlEncoder, const void* bytes, NSUInteger length, diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm index d01dc5ef..35f0b6e8 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm @@ -464,7 +464,7 @@ void MVKRenderingCommandEncoderState::encodeImpl(uint32_t stage) { [rendEnc setDepthBias: 0 slopeScale: 0 clamp: 0]; } } - if (isDirty(DepthClipEnable) && getDevice()->_enabledFeatures.depthClamp) { + if (isDirty(DepthClipEnable) && _cmdEncoder->_pDeviceFeatures->depthClamp) { [rendEnc setDepthClipMode: getContent(DepthClipEnable)]; } @@ -876,40 +876,19 @@ void MVKGraphicsResourcesCommandEncoderState::encodeImpl(uint32_t stage) { // We must not bind those extra buffers to the shader because they might overwrite // any implicit buffers used by the pipeline. if (pipeline->isValidVertexBufferIndex(kMVKShaderStageVertex, b.index)) { - NSUInteger mtlStride = isDynamicVertexStride ? b.stride : MTLAttributeStrideStatic; - if (b.isInline) { - [cmdEncoder->_mtlRenderEncoder setVertexBytes: b.mtlBytes - length: b.size -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: b.index]; - } else { - if (b.justOffset) { - [cmdEncoder->_mtlRenderEncoder setVertexBufferOffset: b.offset -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: b.index]; - } else { - [cmdEncoder->_mtlRenderEncoder setVertexBuffer: b.mtlBuffer - offset: b.offset -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: b.index]; - } + cmdEncoder->encodeVertexAttributeBuffer(b, isDynamicVertexStride); - // Add any translated vertex bindings for this binding + // Add any translated vertex bindings for this binding + if ( !b.isInline ) { auto xltdVtxBindings = pipeline->getTranslatedVertexBindings(); for (auto& xltdBind : xltdVtxBindings) { if (b.index == pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.binding)) { - [cmdEncoder->_mtlRenderEncoder setVertexBuffer: b.mtlBuffer - offset: b.offset + xltdBind.translationOffset -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.translationBinding)]; + MVKMTLBufferBinding bx = { + .mtlBuffer = b.mtlBuffer, + .offset = b.offset + xltdBind.translationOffset, + .stride = b.stride, + .index = static_cast(pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.translationBinding)) }; + cmdEncoder->encodeVertexAttributeBuffer(bx, isDynamicVertexStride); } } } @@ -970,28 +949,7 @@ void MVKGraphicsResourcesCommandEncoderState::encodeImpl(uint32_t stage) { if (forTessellation && stage == kMVKGraphicsStageRasterization) { encodeBindings(kMVKShaderStageTessEval, "tessellation evaluation", fullImageViewSwizzle, [isDynamicVertexStride](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b)->void { - NSUInteger mtlStride = isDynamicVertexStride ? b.stride : MTLAttributeStrideStatic; - if (b.isInline) { - [cmdEncoder->_mtlRenderEncoder setVertexBytes: b.mtlBytes - length: b.size -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: b.index]; - } else if (b.justOffset) { - [cmdEncoder->_mtlRenderEncoder setVertexBufferOffset: b.offset -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: b.index]; - } else { - [cmdEncoder->_mtlRenderEncoder setVertexBuffer: b.mtlBuffer - offset: b.offset -#if MVK_XCODE_15 - attributeStride: mtlStride -#endif - atIndex: b.index]; - } + cmdEncoder->encodeVertexAttributeBuffer(b, isDynamicVertexStride); }, [](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b, MVKArrayRef s)->void { cmdEncoder->setVertexBytes(cmdEncoder->_mtlRenderEncoder, diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandTypePools.def b/MoltenVK/MoltenVK/Commands/MVKCommandTypePools.def index 880f5551..65683f84 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandTypePools.def +++ b/MoltenVK/MoltenVK/Commands/MVKCommandTypePools.def @@ -86,17 +86,12 @@ MVK_CMD_TYPE_POOLS_FROM_2_THRESHOLDS(BindDescriptorSetsStatic, 1, 4) MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(BindDescriptorSetsDynamic, 4) MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(SetViewport, 1) MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(SetScissor, 1) -MVK_CMD_TYPE_POOL(SetLineWidth) MVK_CMD_TYPE_POOL(SetBlendConstants) -MVK_CMD_TYPE_POOL(SetLogicOp) -MVK_CMD_TYPE_POOL(SetLogicOpEnable) MVK_CMD_TYPE_POOL(SetDepthBias) MVK_CMD_TYPE_POOL(SetDepthBiasEnable) MVK_CMD_TYPE_POOL(SetDepthTestEnable) MVK_CMD_TYPE_POOL(SetDepthWriteEnable) MVK_CMD_TYPE_POOL(SetDepthCompareOp) -MVK_CMD_TYPE_POOL(SetDepthBounds) -MVK_CMD_TYPE_POOL(SetDepthBoundsTestEnable) MVK_CMD_TYPE_POOL(SetStencilTestEnable) MVK_CMD_TYPE_POOL(SetStencilOp) MVK_CMD_TYPE_POOL(SetStencilCompareMask) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index 6660e9b7..cb0acac2 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -497,11 +497,6 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device, // Blending - must ignore allowed bad pColorBlendState pointer if rasterization disabled or no color attachments if (_isRasterizingColor && pCreateInfo->pColorBlendState) { mvkCopy(_blendConstants, pCreateInfo->pColorBlendState->blendConstants, 4); - - // Metal does not support blending with logic operations. - if (pCreateInfo->pColorBlendState->logicOpEnable && pCreateInfo->pColorBlendState->logicOp != VK_LOGIC_OP_COPY) { - setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "Metal does not support blending using logic operations.")); - } } else { static float defaultBlendConstants[4] = { 0, 0.0, 0.0, 1.0 }; mvkCopy(_blendConstants, defaultBlendConstants, 4); @@ -522,11 +517,6 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device, // Rasterization _hasRasterInfo = mvkSetOrClear(&_rasterInfo, pCreateInfo->pRasterizationState); - if (_hasRasterInfo) { - if (_rasterInfo.depthClampEnable && !_device->_enabledFeatures.depthClamp) { - setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "This device does not support depth clamping.")); - } - } // Must run after _isRasterizing and _dynamicState are populated initCustomSamplePositions(pCreateInfo); diff --git a/MoltenVK/MoltenVK/Utility/MVKFoundation.h b/MoltenVK/MoltenVK/Utility/MVKFoundation.h index c729c153..f5820721 100644 --- a/MoltenVK/MoltenVK/Utility/MVKFoundation.h +++ b/MoltenVK/MoltenVK/Utility/MVKFoundation.h @@ -392,7 +392,7 @@ static inline double mvkRoundHalfToEven(const double val) { /** Returns whether the value will fit inside the numeric type. */ template -static constexpr const bool mvkFits(const Tval& val) { +static constexpr bool mvkFits(const Tval& val) { return val <= std::numeric_limits::max(); } diff --git a/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm b/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm index ef3cf1ca..7644f49c 100644 --- a/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm +++ b/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm @@ -583,7 +583,7 @@ MTLMultisampleStencilResolveFilter mvkMTLMultisampleStencilResolveFilterFromVkRe } #endif -MVK_PUBLIC_SYMBOL MTLViewport mvkMTLViewportFromVkViewport(const VkViewport vkViewport) { +MVK_PUBLIC_SYMBOL MTLViewport mvkMTLViewportFromVkViewport(VkViewport vkViewport) { return { .originX = vkViewport.x, .originY = vkViewport.y, @@ -594,7 +594,7 @@ MVK_PUBLIC_SYMBOL MTLViewport mvkMTLViewportFromVkViewport(const VkViewport vkVi }; } -MVK_PUBLIC_SYMBOL MTLScissorRect mvkMTLScissorRectFromVkRect2D(const VkRect2D vkRect) { +MVK_PUBLIC_SYMBOL MTLScissorRect mvkMTLScissorRectFromVkRect2D(VkRect2D vkRect) { return { .x = (NSUInteger)max(vkRect.offset.x, 0), .y = (NSUInteger)max(vkRect.offset.y, 0), @@ -603,7 +603,7 @@ MVK_PUBLIC_SYMBOL MTLScissorRect mvkMTLScissorRectFromVkRect2D(const VkRect2D vk }; } -MVK_PUBLIC_SYMBOL VkRect2D mvkVkRect2DFromMTLScissorRect(const MTLScissorRect mtlScissorRect) { +MVK_PUBLIC_SYMBOL VkRect2D mvkVkRect2DFromMTLScissorRect(MTLScissorRect mtlScissorRect) { return { .offset = { .x = (int32_t)mtlScissorRect.x, .y = (int32_t)mtlScissorRect.y }, diff --git a/MoltenVK/MoltenVK/Vulkan/vulkan.mm b/MoltenVK/MoltenVK/Vulkan/vulkan.mm index 642ad040..d1c6fbbe 100644 --- a/MoltenVK/MoltenVK/Vulkan/vulkan.mm +++ b/MoltenVK/MoltenVK/Vulkan/vulkan.mm @@ -1466,7 +1466,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetLineWidth( float lineWidth) { MVKTraceVulkanCallStart(); - MVKAddCmd(SetLineWidth, commandBuffer, lineWidth); MVKTraceVulkanCallEnd(); } @@ -1496,7 +1495,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetDepthBounds( float maxDepthBounds) { MVKTraceVulkanCallStart(); - MVKAddCmd(SetDepthBounds, commandBuffer, minDepthBounds, maxDepthBounds); MVKTraceVulkanCallEnd(); } @@ -2652,7 +2650,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetDepthBoundsTestEnable( VkBool32 depthBoundsTestEnable) { MVKTraceVulkanCallStart(); - MVKAddCmd(SetDepthBoundsTestEnable, commandBuffer, depthBoundsTestEnable); MVKTraceVulkanCallEnd(); } @@ -3636,7 +3633,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetLogicOpEXT( VkLogicOp logicOp) { MVKTraceVulkanCallStart(); - MVKAddCmd(SetLogicOp, commandBuffer, logicOp); MVKTraceVulkanCallEnd(); } @@ -3661,7 +3657,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetLogicOpEnableEXT( VkBool32 logicOpEnable) { MVKTraceVulkanCallStart(); - MVKAddCmd(SetLogicOpEnable, commandBuffer, logicOpEnable); MVKTraceVulkanCallEnd(); }