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

WIP: Implement VK_EXT_rasterization_order_attachment_access #2280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 MoltenVK/MoltenVK/API/mvk_private_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ typedef struct {
VkBool32 needsCubeGradWorkaround; /**< If true, sampling from cube textures with explicit gradients is broken and needs a workaround. */
VkBool32 nativeTextureAtomics; /**< If true, atomic operations on textures are supported natively. */
VkBool32 needsArgumentBufferEncoders; /**< If true, Metal argument buffer encoders are needed to populate argument buffer content. */
VkBool32 programmableBlending; /**< If true, the Apple "programmable blending" feature is supported. */
} MVKPhysicalDeviceMetalFeatures;


Expand Down
3 changes: 2 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ void mvkPopulateShaderConversionConfig(mvk::SPIRVToMSLConversionConfiguration& s
uint32_t count,
VkDescriptorType descType,
MVKSampler* immutableSampler,
bool usingNativeTextureAtomics);
bool usingNativeTextureAtomics,
bool usingProgrammableBlending);


#pragma mark -
Expand Down
13 changes: 10 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void mvkPopulateShaderConversionConfig(mvk::SPIRVToMSLConversionConfiguration& s
uint32_t count,
VkDescriptorType descType,
MVKSampler* immutableSampler,
bool usingNativeTextureAtomics) {
bool usingNativeTextureAtomics,
bool usingProgrammableBlending) {
if (count == 0) { return; }

#define addResourceBinding(spvRezType) \
Expand Down Expand Up @@ -156,8 +157,13 @@ void mvkPopulateShaderConversionConfig(mvk::SPIRVToMSLConversionConfiguration& s
break;
}

case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
if (!usingProgrammableBlending) {
addResourceBinding(Image);
}
break;

case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
addResourceBinding(Image);
break;
Expand Down Expand Up @@ -550,7 +556,8 @@ void mvkPopulateShaderConversionConfig(mvk::SPIRVToMSLConversionConfiguration& s
descCnt,
getDescriptorType(),
mvkSamp,
getMetalFeatures().nativeTextureAtomics);
getMetalFeatures().nativeTextureAtomics,
getMetalFeatures().programmableBlending);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
MVKShaderStageResourceBinding buffBinding,
uint32_t descSetIndex,
uint32_t descBinding,
bool usingNativeTextureAtomics) {
bool usingNativeTextureAtomics,
bool usingProgrammableBlending) {
for (uint32_t stage = kMVKShaderStageVertex; stage < kMVKShaderStageCount; stage++) {
mvkPopulateShaderConversionConfig(shaderConfig,
buffBinding,
Expand All @@ -246,7 +247,8 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
1,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
nullptr,
usingNativeTextureAtomics);
usingNativeTextureAtomics,
usingProgrammableBlending);
}
}

Expand All @@ -264,7 +266,8 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
buffBinding.bufferIndex = getBufferSizeBufferArgBuferIndex();
populateAuxBuffer(shaderConfig, buffBinding, descSetIndex,
MVK_spirv_cross::kBufferSizeBufferBinding,
getMetalFeatures().nativeTextureAtomics);
getMetalFeatures().nativeTextureAtomics,
getMetalFeatures().programmableBlending);
}

// If the app is using argument buffers, but this descriptor set is
Expand Down
16 changes: 16 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@
shaderIntFuncsFeatures->shaderIntegerFunctions2 = true;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT: {
auto* rasterOrderFeatures = (VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT*)next;
rasterOrderFeatures->rasterizationOrderColorAttachmentAccess = VK_TRUE;
// Metal doesn't support depth/stencil fetch.
rasterOrderFeatures->rasterizationOrderDepthAttachmentAccess = VK_FALSE;
rasterOrderFeatures->rasterizationOrderStencilAttachmentAccess = VK_FALSE;
break;
}
default:
break;
}
Expand Down Expand Up @@ -1436,6 +1444,9 @@
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT);
if (_metalFeatures.programmableBlending) {
surfCaps.supportedUsageFlags |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
}

// Swapchain-to-surface scaling capabilities.
if (pScalingCaps) {
Expand Down Expand Up @@ -2455,6 +2466,7 @@
}
#endif

_metalFeatures.programmableBlending = _isAppleGPU;
}

// Initializes the physical device features of this instance.
Expand Down Expand Up @@ -3419,6 +3431,10 @@ static uint32_t mvkGetEntryProperty(io_registry_entry_t entry, CFStringRef prope
pWritableExtns->vk_IMG_format_pvrtc.enabled = false;
}
#endif

if (!_metalFeatures.programmableBlending) {
pWritableExtns->vk_EXT_rasterization_order_attachment_access.enabled = false;
}
}

void MVKPhysicalDevice::initCounterSets() {
Expand Down
5 changes: 4 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
1,
VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
nullptr,
getMetalFeatures().nativeTextureAtomics);
getMetalFeatures().nativeTextureAtomics,
getMetalFeatures().programmableBlending);
}
}

Expand Down Expand Up @@ -1821,6 +1822,8 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3

shaderConfig.options.tessPatchKind = reflectData.patchKind;
shaderConfig.options.numTessControlPoints = reflectData.numControlPoints;

shaderConfig.options.mslOptions.use_framebuffer_fetch_subpasses = mtlFeats.programmableBlending;
}

uint32_t MVKGraphicsPipeline::getImplicitBufferIndex(MVKShaderStage stage, uint32_t bufferIndexOffset) {
Expand Down
1 change: 1 addition & 0 deletions MoltenVK/MoltenVK/Layers/MVKExtensions.def
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ MVK_EXTENSION(EXT_vertex_attribute_divisor, EXT_VERTEX_ATTRIBUTE_DIVIS
MVK_EXTENSION(AMD_draw_indirect_count, AMD_DRAW_INDIRECT_COUNT, DEVICE, MVK_NA, MVK_NA, MVK_NA)
MVK_EXTENSION(AMD_gpu_shader_half_float, AMD_GPU_SHADER_HALF_FLOAT, DEVICE, 10.11, 8.0, 1.0)
MVK_EXTENSION(AMD_negative_viewport_height, AMD_NEGATIVE_VIEWPORT_HEIGHT, DEVICE, 10.11, 8.0, 1.0)
MVK_EXTENSION(EXT_rasterization_order_attachment_access, EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS, DEVICE, 10.11, 8.0, 1.0)
MVK_EXTENSION(AMD_shader_image_load_store_lod, AMD_SHADER_IMAGE_LOAD_STORE_LOD, DEVICE, 11.0, 8.0, 1.0)
MVK_EXTENSION(AMD_shader_trinary_minmax, AMD_SHADER_TRINARY_MINMAX, DEVICE, 10.14, 12.0, 1.0)
MVK_EXTENSION(IMG_format_pvrtc, IMG_FORMAT_PVRTC, DEVICE, 11.0, 8.0, 1.0)
Expand Down
Loading