Fixes based on VK_EXT_extended_dynamic_state code review.

- Fix runtime failure on Metal versions that don't support dynamic attribute stride.
- Add MVKCommandEncoder::encodeVertexAttributeBuffer() consolidation function.
- Remove unnecessary validations that will be caught by Vulkan validation layers.
- To reduce memory, remove command class and pools for rendering commands that
  are not supported, and perform no validation.
- Document extension conformance limitations in MoltenVK_Runtime_UserGuide.md.
This commit is contained in:
Bill Hollings 2023-10-11 11:37:50 -04:00
parent 659b1cecd7
commit eb7cfa1006
12 changed files with 114 additions and 290 deletions

View File

@ -312,7 +312,8 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_16bit_storage` - `VK_KHR_16bit_storage`
- `VK_KHR_8bit_storage` - `VK_KHR_8bit_storage`
- `VK_KHR_bind_memory2` - `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_copy_commands2`
- `VK_KHR_create_renderpass2` - `VK_KHR_create_renderpass2`
- `VK_KHR_dedicated_allocation` - `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_device_group_creation`
- `VK_KHR_driver_properties` - `VK_KHR_driver_properties`
- `VK_KHR_dynamic_rendering` - `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_memory_requirements2`
- `VK_KHR_get_physical_device_properties2` - `VK_KHR_get_physical_device_properties2`
- `VK_KHR_get_surface_capabilities2` - `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_portability_subset`
- `VK_KHR_push_descriptor` - `VK_KHR_push_descriptor`
- `VK_KHR_relaxed_block_layout` - `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_sampler_ycbcr_conversion`
- `VK_KHR_separate_depth_stencil_layouts` - `VK_KHR_separate_depth_stencil_layouts`
- `VK_KHR_shader_draw_parameters` - `VK_KHR_shader_draw_parameters`
- `VK_KHR_shader_float_controls` - `VK_KHR_shader_float_controls`
- `VK_KHR_shader_float16_int8` - `VK_KHR_shader_float16_int8`
- `VK_KHR_shader_non_semantic_info` - `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_spirv_1_4`
- `VK_KHR_storage_buffer_storage_class` - `VK_KHR_storage_buffer_storage_class`
- `VK_KHR_surface` - `VK_KHR_surface`
@ -354,55 +358,78 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_timeline_semaphore` - `VK_KHR_timeline_semaphore`
- `VK_KHR_uniform_buffer_standard_layout` - `VK_KHR_uniform_buffer_standard_layout`
- `VK_KHR_variable_pointers` - `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_4444_formats`
- `VK_EXT_buffer_device_address` *(requires GPU Tier 2 argument buffers support)* - *Requires 16-bit formats and either native texture swizzling or manual swizzling to be enabled.*
- `VK_EXT_calibrated_timestamps` *(requires Metal 2.2)* - `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_marker`
- `VK_EXT_debug_report` - `VK_EXT_debug_report`
- `VK_EXT_debug_utils` - `VK_EXT_debug_utils`
- `VK_EXT_descriptor_indexing` *(initial release limited to Metal Tier 1: 96/128 textures, - `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 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)* 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_state`
- *Requires Metal 3.1 for `VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE`.*
- `VK_EXT_extended_dynamic_state2` - `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_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_host_query_reset`
- `VK_EXT_image_robustness` - `VK_EXT_image_robustness`
- `VK_EXT_inline_uniform_block` - `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_objects`
- `VK_EXT_metal_surface` - `VK_EXT_metal_surface`
- `VK_EXT_pipeline_creation_cache_control` - `VK_EXT_pipeline_creation_cache_control`
- `VK_EXT_pipeline_creation_feedback` - `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_private_data `
- `VK_EXT_robustness2` - `VK_EXT_robustness2`
- `VK_EXT_sample_locations` - `VK_EXT_sample_locations`
- `VK_EXT_scalar_block_layout` - `VK_EXT_scalar_block_layout`
- `VK_EXT_separate_stencil_usage` - `VK_EXT_separate_stencil_usage`
- `VK_EXT_shader_atomic_float` *(requires Metal 3.0)* - `VK_EXT_shader_atomic_float`
- `VK_EXT_shader_demote_to_helper_invocation` *(requires Metal Shading Language 2.3)* - *Requires Metal 3.0.*
- `VK_EXT_shader_stencil_export` *(requires Mac GPU family 2 or iOS GPU family 5)* - `VK_EXT_shader_demote_to_helper_invocation`
- `VK_EXT_shader_subgroup_ballot` *(requires Mac GPU family 2 or Apple GPU family 4)* - *Requires Metal Shading Language 2.3.*
- `VK_EXT_shader_subgroup_vote` *(requires Mac GPU family 2 or Apple GPU family 4)* - `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_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_surface_maintenance1`
- `VK_EXT_swapchain_colorspace` - `VK_EXT_swapchain_colorspace`
- `VK_EXT_swapchain_maintenance1` - `VK_EXT_swapchain_maintenance1`
- `VK_EXT_vertex_attribute_divisor` - `VK_EXT_vertex_attribute_divisor`
- `VK_EXT_texel_buffer_alignment` *(requires Metal 2.0)* - `VK_EXT_texel_buffer_alignment`
- `VK_EXT_texture_compression_astc_hdr` *(iOS and macOS, requires family 6 (A13) or better Apple GPU)* - *Requires Metal 2.0.*
- `VK_MVK_ios_surface` *(iOS) (Obsolete. Use `VK_EXT_metal_surface` instead.)* - `VK_EXT_texture_compression_astc_hdr`
- `VK_MVK_macos_surface` *(macOS) (Obsolete. Use `VK_EXT_metal_surface` instead.)* - *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_gpu_shader_half_float`
- `VK_AMD_negative_viewport_height` - `VK_AMD_negative_viewport_height`
- `VK_AMD_shader_image_load_store_lod` *(requires Apple GPU)* - `VK_AMD_shader_image_load_store_lod`
- `VK_AMD_shader_trinary_minmax` *(requires Metal 2.1)* - *Requires Apple GPU.*
- `VK_IMG_format_pvrtc` *(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_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` - `VK_NV_glsl_shader`
In order to visibly display your content on *macOS*, *iOS*, or *tvOS*, you must enable the In order to visibly display your content on *macOS*, *iOS*, or *tvOS*, you must enable the
@ -625,6 +652,8 @@ Known **MoltenVK** Limitations
This section documents the known limitations in this version of **MoltenVK**. 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. - 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 Because of this, changes made to `VkImage VK_MEMORY_PROPERTY_HOST_COHERENT_BIT` device memory by the CPU
or GPU will not be available to the GPU or CPU, respectively, until the memory is flushed or unmapped by or GPU will not be available to the GPU or CPU, respectively, until the memory is flushed or unmapped by
@ -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)*. 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)* Refer to the *Vulkan SDK [Getting Started](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html)*
document for more info. document for more info.

View File

@ -378,13 +378,13 @@ MTLMultisampleStencilResolveFilter mvkMTLMultisampleStencilResolveFilterFromVkRe
#endif #endif
/** Returns the Metal MTLViewport corresponding to the specified Vulkan VkViewport. */ /** 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. */ /** 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. */ /** 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, */ /** Returns the Metal MTLCompareFunction corresponding to the specified Vulkan VkCompareOp, */
MTLCompareFunction mvkMTLCompareFunctionFromVkCompareOp(VkCompareOp vkOp); MTLCompareFunction mvkMTLCompareFunctionFromVkCompareOp(VkCompareOp vkOp);

View File

@ -267,25 +267,6 @@ typedef MVKCmdSetScissor<1> MVKCmdSetScissor1;
typedef MVKCmdSetScissor<kMVKMaxViewportScissorCount> MVKCmdSetScissorMulti; typedef MVKCmdSetScissor<kMVKMaxViewportScissorCount> 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<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
float _lineWidth;
};
#pragma mark - #pragma mark -
#pragma mark MVKCmdSetDepthBias #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<MVKCommand>* 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<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
};
#pragma mark - #pragma mark -
#pragma mark MVKCmdSetDepthTestEnable #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<MVKCommand>* 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<MVKCommand>* getTypePool(MVKCommandPool* cmdPool) override;
bool _depthBoundsTestEnable;
};
#pragma mark - #pragma mark -
#pragma mark MVKCmdSetStencilTestEnable #pragma mark MVKCmdSetStencilTestEnable

View File

@ -285,24 +285,6 @@ template class MVKCmdSetScissor<1>;
template class MVKCmdSetScissor<kMVKMaxViewportScissorCount>; template class MVKCmdSetScissor<kMVKMaxViewportScissorCount>;
#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 -
#pragma mark MVKCmdSetDepthBias #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 -
#pragma mark MVKCmdSetDepthTestEnable #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<bool>(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 -
#pragma mark MVKCmdSetStencilTestEnable #pragma mark MVKCmdSetStencilTestEnable

View File

@ -358,6 +358,9 @@ public:
/** Returns the push constants associated with the specified shader stage. */ /** Returns the push constants associated with the specified shader stage. */
MVKPushConstantsCommandEncoderState* getPushConstants(VkShaderStageFlagBits shaderStage); 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 * 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 * that this binding might override a desriptor binding. If so, the descriptor binding will

View File

@ -919,6 +919,42 @@ void MVKCommandEncoder::setVertexBytes(id<MTLRenderCommandEncoder> 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<MTLRenderCommandEncoder> mtlEncoder, void MVKCommandEncoder::setFragmentBytes(id<MTLRenderCommandEncoder> mtlEncoder,
const void* bytes, const void* bytes,
NSUInteger length, NSUInteger length,

View File

@ -464,7 +464,7 @@ void MVKRenderingCommandEncoderState::encodeImpl(uint32_t stage) {
[rendEnc setDepthBias: 0 slopeScale: 0 clamp: 0]; [rendEnc setDepthBias: 0 slopeScale: 0 clamp: 0];
} }
} }
if (isDirty(DepthClipEnable) && getDevice()->_enabledFeatures.depthClamp) { if (isDirty(DepthClipEnable) && _cmdEncoder->_pDeviceFeatures->depthClamp) {
[rendEnc setDepthClipMode: getContent(DepthClipEnable)]; [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 // We must not bind those extra buffers to the shader because they might overwrite
// any implicit buffers used by the pipeline. // any implicit buffers used by the pipeline.
if (pipeline->isValidVertexBufferIndex(kMVKShaderStageVertex, b.index)) { if (pipeline->isValidVertexBufferIndex(kMVKShaderStageVertex, b.index)) {
NSUInteger mtlStride = isDynamicVertexStride ? b.stride : MTLAttributeStrideStatic; cmdEncoder->encodeVertexAttributeBuffer(b, isDynamicVertexStride);
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];
}
// Add any translated vertex bindings for this binding // Add any translated vertex bindings for this binding
if ( !b.isInline ) {
auto xltdVtxBindings = pipeline->getTranslatedVertexBindings(); auto xltdVtxBindings = pipeline->getTranslatedVertexBindings();
for (auto& xltdBind : xltdVtxBindings) { for (auto& xltdBind : xltdVtxBindings) {
if (b.index == pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.binding)) { if (b.index == pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.binding)) {
[cmdEncoder->_mtlRenderEncoder setVertexBuffer: b.mtlBuffer MVKMTLBufferBinding bx = {
offset: b.offset + xltdBind.translationOffset .mtlBuffer = b.mtlBuffer,
#if MVK_XCODE_15 .offset = b.offset + xltdBind.translationOffset,
attributeStride: mtlStride .stride = b.stride,
#endif .index = static_cast<uint16_t>(pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.translationBinding)) };
atIndex: pipeline->getMetalBufferIndexForVertexAttributeBinding(xltdBind.translationBinding)]; cmdEncoder->encodeVertexAttributeBuffer(bx, isDynamicVertexStride);
} }
} }
} }
@ -970,28 +949,7 @@ void MVKGraphicsResourcesCommandEncoderState::encodeImpl(uint32_t stage) {
if (forTessellation && stage == kMVKGraphicsStageRasterization) { if (forTessellation && stage == kMVKGraphicsStageRasterization) {
encodeBindings(kMVKShaderStageTessEval, "tessellation evaluation", fullImageViewSwizzle, encodeBindings(kMVKShaderStageTessEval, "tessellation evaluation", fullImageViewSwizzle,
[isDynamicVertexStride](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b)->void { [isDynamicVertexStride](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b)->void {
NSUInteger mtlStride = isDynamicVertexStride ? b.stride : MTLAttributeStrideStatic; cmdEncoder->encodeVertexAttributeBuffer(b, isDynamicVertexStride);
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];
}
}, },
[](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b, MVKArrayRef<const uint32_t> s)->void { [](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b, MVKArrayRef<const uint32_t> s)->void {
cmdEncoder->setVertexBytes(cmdEncoder->_mtlRenderEncoder, cmdEncoder->setVertexBytes(cmdEncoder->_mtlRenderEncoder,

View File

@ -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(BindDescriptorSetsDynamic, 4)
MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(SetViewport, 1) MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(SetViewport, 1)
MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(SetScissor, 1) MVK_CMD_TYPE_POOLS_FROM_THRESHOLD(SetScissor, 1)
MVK_CMD_TYPE_POOL(SetLineWidth)
MVK_CMD_TYPE_POOL(SetBlendConstants) MVK_CMD_TYPE_POOL(SetBlendConstants)
MVK_CMD_TYPE_POOL(SetLogicOp)
MVK_CMD_TYPE_POOL(SetLogicOpEnable)
MVK_CMD_TYPE_POOL(SetDepthBias) MVK_CMD_TYPE_POOL(SetDepthBias)
MVK_CMD_TYPE_POOL(SetDepthBiasEnable) MVK_CMD_TYPE_POOL(SetDepthBiasEnable)
MVK_CMD_TYPE_POOL(SetDepthTestEnable) MVK_CMD_TYPE_POOL(SetDepthTestEnable)
MVK_CMD_TYPE_POOL(SetDepthWriteEnable) MVK_CMD_TYPE_POOL(SetDepthWriteEnable)
MVK_CMD_TYPE_POOL(SetDepthCompareOp) MVK_CMD_TYPE_POOL(SetDepthCompareOp)
MVK_CMD_TYPE_POOL(SetDepthBounds)
MVK_CMD_TYPE_POOL(SetDepthBoundsTestEnable)
MVK_CMD_TYPE_POOL(SetStencilTestEnable) MVK_CMD_TYPE_POOL(SetStencilTestEnable)
MVK_CMD_TYPE_POOL(SetStencilOp) MVK_CMD_TYPE_POOL(SetStencilOp)
MVK_CMD_TYPE_POOL(SetStencilCompareMask) MVK_CMD_TYPE_POOL(SetStencilCompareMask)

View File

@ -497,11 +497,6 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device,
// Blending - must ignore allowed bad pColorBlendState pointer if rasterization disabled or no color attachments // Blending - must ignore allowed bad pColorBlendState pointer if rasterization disabled or no color attachments
if (_isRasterizingColor && pCreateInfo->pColorBlendState) { if (_isRasterizingColor && pCreateInfo->pColorBlendState) {
mvkCopy(_blendConstants, pCreateInfo->pColorBlendState->blendConstants, 4); 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 { } else {
static float defaultBlendConstants[4] = { 0, 0.0, 0.0, 1.0 }; static float defaultBlendConstants[4] = { 0, 0.0, 0.0, 1.0 };
mvkCopy(_blendConstants, defaultBlendConstants, 4); mvkCopy(_blendConstants, defaultBlendConstants, 4);
@ -522,11 +517,6 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device,
// Rasterization // Rasterization
_hasRasterInfo = mvkSetOrClear(&_rasterInfo, pCreateInfo->pRasterizationState); _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 // Must run after _isRasterizing and _dynamicState are populated
initCustomSamplePositions(pCreateInfo); initCustomSamplePositions(pCreateInfo);

View File

@ -392,7 +392,7 @@ static inline double mvkRoundHalfToEven(const double val) {
/** Returns whether the value will fit inside the numeric type. */ /** Returns whether the value will fit inside the numeric type. */
template<typename T, typename Tval> template<typename T, typename Tval>
static constexpr const bool mvkFits(const Tval& val) { static constexpr bool mvkFits(const Tval& val) {
return val <= std::numeric_limits<T>::max(); return val <= std::numeric_limits<T>::max();
} }

View File

@ -583,7 +583,7 @@ MTLMultisampleStencilResolveFilter mvkMTLMultisampleStencilResolveFilterFromVkRe
} }
#endif #endif
MVK_PUBLIC_SYMBOL MTLViewport mvkMTLViewportFromVkViewport(const VkViewport vkViewport) { MVK_PUBLIC_SYMBOL MTLViewport mvkMTLViewportFromVkViewport(VkViewport vkViewport) {
return { return {
.originX = vkViewport.x, .originX = vkViewport.x,
.originY = vkViewport.y, .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 { return {
.x = (NSUInteger)max(vkRect.offset.x, 0), .x = (NSUInteger)max(vkRect.offset.x, 0),
.y = (NSUInteger)max(vkRect.offset.y, 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 { return {
.offset = { .x = (int32_t)mtlScissorRect.x, .offset = { .x = (int32_t)mtlScissorRect.x,
.y = (int32_t)mtlScissorRect.y }, .y = (int32_t)mtlScissorRect.y },

View File

@ -1466,7 +1466,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetLineWidth(
float lineWidth) { float lineWidth) {
MVKTraceVulkanCallStart(); MVKTraceVulkanCallStart();
MVKAddCmd(SetLineWidth, commandBuffer, lineWidth);
MVKTraceVulkanCallEnd(); MVKTraceVulkanCallEnd();
} }
@ -1496,7 +1495,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetDepthBounds(
float maxDepthBounds) { float maxDepthBounds) {
MVKTraceVulkanCallStart(); MVKTraceVulkanCallStart();
MVKAddCmd(SetDepthBounds, commandBuffer, minDepthBounds, maxDepthBounds);
MVKTraceVulkanCallEnd(); MVKTraceVulkanCallEnd();
} }
@ -2652,7 +2650,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetDepthBoundsTestEnable(
VkBool32 depthBoundsTestEnable) { VkBool32 depthBoundsTestEnable) {
MVKTraceVulkanCallStart(); MVKTraceVulkanCallStart();
MVKAddCmd(SetDepthBoundsTestEnable, commandBuffer, depthBoundsTestEnable);
MVKTraceVulkanCallEnd(); MVKTraceVulkanCallEnd();
} }
@ -3636,7 +3633,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetLogicOpEXT(
VkLogicOp logicOp) { VkLogicOp logicOp) {
MVKTraceVulkanCallStart(); MVKTraceVulkanCallStart();
MVKAddCmd(SetLogicOp, commandBuffer, logicOp);
MVKTraceVulkanCallEnd(); MVKTraceVulkanCallEnd();
} }
@ -3661,7 +3657,6 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkCmdSetLogicOpEnableEXT(
VkBool32 logicOpEnable) { VkBool32 logicOpEnable) {
MVKTraceVulkanCallStart(); MVKTraceVulkanCallStart();
MVKAddCmd(SetLogicOpEnable, commandBuffer, logicOpEnable);
MVKTraceVulkanCallEnd(); MVKTraceVulkanCallEnd();
} }