From 8cf1b569596910b7c9d2f2766889aa527a4bc1ae Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 31 Jan 2018 14:02:44 -0700 Subject: [PATCH 1/2] icd:Handle GPDP2 extension requests Updated vkGetPhysicalDeviceProperties2KHR() implementation in the mock ICD to handle extension queries down pNext tree. This is for #2374. Note that the bug references vkGetPhysicalDeviceFeatures2KHR() which will be done in a separate CL. --- scripts/mock_icd_generator.py | 104 +++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py index 50230bbe51..53866783ab 100644 --- a/scripts/mock_icd_generator.py +++ b/scripts/mock_icd_generator.py @@ -48,6 +48,11 @@ static void DestroyDispObjHandle(void* handle) { delete reinterpret_cast(handle); } + +struct GENERIC_HEADER { + VkStructureType sType; + void *pNext; +}; ''' # Manual code at the top of the cpp source file @@ -746,6 +751,101 @@ ''', 'vkGetPhysicalDeviceProperties2KHR': ''' GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties); + // Handle any extension properties queried down pNext chain + if (pProperties->pNext) { + auto struct_header = reinterpret_cast(pProperties->pNext); + while (struct_header) { + switch (struct_header->sType) { + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR: { + VkPhysicalDeviceIDPropertiesKHR *id_prop = reinterpret_cast(struct_header); + // This is a dummy ID intended to represent "ICDGOOG" for mock ICD + uint8_t icd_id[] = {1, 0xc, 0xd, 6, 0, 0, 6}; + std::copy(icd_id, icd_id + 7, id_prop->deviceUUID); + std::copy(icd_id, icd_id + 7, id_prop->driverUUID); + id_prop->deviceLUID[0] = 0; + id_prop->deviceNodeMask = 1; + id_prop->deviceLUIDValid = VK_FALSE; // This causes the above 2 values to be ignored + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR: { + VkPhysicalDevicePushDescriptorPropertiesKHR *pd_prop = reinterpret_cast(struct_header); + pd_prop->maxPushDescriptors = 32; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHX: { + VkPhysicalDeviceMultiviewPropertiesKHX *mv_prop = reinterpret_cast(struct_header); + mv_prop->maxMultiviewViewCount = 6; + mv_prop->maxMultiviewInstanceIndex = 0x7FFFFFF; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT: { + VkPhysicalDeviceDiscardRectanglePropertiesEXT *rect_prop = reinterpret_cast(struct_header); + rect_prop->maxDiscardRectangles = 4; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT: { + VkPhysicalDeviceSampleLocationsPropertiesEXT *dsl_prop = reinterpret_cast(struct_header); + dsl_prop->sampleLocationSampleCounts = VK_SAMPLE_COUNT_4_BIT; + dsl_prop->maxSampleLocationGridSize.width = 1; + dsl_prop->maxSampleLocationGridSize.height = 1; + dsl_prop->sampleLocationCoordinateRange[0] = 0.0; + dsl_prop->sampleLocationCoordinateRange[1] = 0.9375; + dsl_prop->sampleLocationSubPixelBits = 4; + dsl_prop->variableSampleLocations = VK_FALSE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT: { + VkPhysicalDeviceExternalMemoryHostPropertiesEXT *mh_prop = reinterpret_cast(struct_header); + mh_prop->minImportedHostPointerAlignment = 65536; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX: { + VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX *mpva_prop = reinterpret_cast(struct_header); + mpva_prop->perViewPositionAllComponents = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR: { + VkPhysicalDevicePointClippingPropertiesKHR *pc_prop = reinterpret_cast(struct_header); + pc_prop->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT: { + VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *boa_prop = reinterpret_cast(struct_header); + boa_prop->advancedBlendMaxColorAttachments = 1; + boa_prop->advancedBlendIndependentBlend = VK_FALSE; + boa_prop->advancedBlendNonPremultipliedSrcColor = VK_FALSE; + boa_prop->advancedBlendNonPremultipliedDstColor = VK_FALSE; + boa_prop->advancedBlendCorrelatedOverlap = VK_FALSE; + boa_prop->advancedBlendAllOperations = VK_FALSE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: { + VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *sfm_prop = reinterpret_cast(struct_header); + sfm_prop->filterMinmaxSingleComponentFormats = VK_TRUE; + sfm_prop->filterMinmaxImageComponentMapping = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT: { + VkPhysicalDeviceConservativeRasterizationPropertiesEXT *cr_prop = reinterpret_cast(struct_header); + cr_prop->primitiveOverestimationSize = 0.0; + cr_prop->maxExtraPrimitiveOverestimationSize = 0.0; + cr_prop->extraPrimitiveOverestimationSizeGranularity = 0.0; + cr_prop->primitiveUnderestimation = VK_FALSE; + cr_prop->conservativePointAndLineRasterization = VK_FALSE; + cr_prop->degenerateTrianglesRasterized = VK_FALSE; + cr_prop->degenerateLinesRasterized = VK_FALSE; + cr_prop->fullyCoveredFragmentShaderInputVariable = VK_FALSE; + cr_prop->conservativeRasterizationPostDepthCoverage = VK_FALSE; + break; + } + default: + assert(0); + // Unknown extension property request needs to be added to mock_icd + break; + } + struct_header = reinterpret_cast(struct_header->pNext); + } + } ''', 'vkGetBufferMemoryRequirements': ''' // TODO: Just hard-coding reqs for now @@ -967,6 +1067,8 @@ def beginFile(self, genOpts): write('#include "mock_icd.h"', file=self.outFile) write('#include ', file=self.outFile) write('#include ', file=self.outFile) + write('#include ', file=self.outFile) + write('#include ', file=self.outFile) write('namespace vkmock {', file=self.outFile) if self.header: @@ -976,7 +1078,7 @@ def beginFile(self, genOpts): device_exts = [] instance_exts = [] # Ignore extensions that ICDs should not implement or are not safe to report - ignore_exts = ['VK_EXT_validation_cache', 'VK_KHR_push_descriptor'] + ignore_exts = ['VK_EXT_validation_cache'] for ext in self.registry.tree.findall("extensions/extension"): if ext.attrib['supported'] != 'disabled': # Only include enabled extensions if (ext.attrib['name'] in ignore_exts): From 779a3ae72735106dfd2f59e2666a0ce3e904710b Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 31 Jan 2018 14:27:00 -0700 Subject: [PATCH 2/2] icd:Handle GPDF2 extension requests Fixes #2374 Updated vkGetPhysicalDeviceFeatures2KHR() implementation in the mock ICD to handle extension feature queries down pNext tree. Initially returning all extension features as supported by mock icd. --- scripts/mock_icd_generator.py | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py index 53866783ab..e7eab1ffd6 100644 --- a/scripts/mock_icd_generator.py +++ b/scripts/mock_icd_generator.py @@ -710,6 +710,55 @@ ''', 'vkGetPhysicalDeviceFeatures2KHR': ''' GetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features); + // Handle any extension properties queried down pNext chain + if (pFeatures->pNext) { + auto struct_header = reinterpret_cast(pFeatures->pNext); + while (struct_header) { + switch (struct_header->sType) { + case VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_FEATURES_NVX: { + VkDeviceGeneratedCommandsFeaturesNVX *gc_feat = reinterpret_cast(struct_header); + gc_feat->computeBindingPointSupport = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR: { + VkPhysicalDeviceVariablePointerFeaturesKHR *vp_feat = reinterpret_cast(struct_header); + vp_feat->variablePointersStorageBuffer = VK_TRUE; + vp_feat->variablePointers = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHX: { + VkPhysicalDeviceMultiviewFeaturesKHX *mv_feat = reinterpret_cast(struct_header); + mv_feat->multiview = VK_TRUE; + mv_feat->multiviewGeometryShader = VK_TRUE; + mv_feat->multiviewTessellationShader = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR: { + VkPhysicalDevice16BitStorageFeaturesKHR *sbs_feat = reinterpret_cast(struct_header); + sbs_feat->storageBuffer16BitAccess = VK_TRUE; + sbs_feat->uniformAndStorageBuffer16BitAccess = VK_TRUE; + sbs_feat->storagePushConstant16 = VK_TRUE; + sbs_feat->storageInputOutput16 = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR: { + VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR *syc_feat = reinterpret_cast(struct_header); + syc_feat->samplerYcbcrConversion = VK_TRUE; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT: { + VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT *boa_feat = reinterpret_cast(struct_header); + boa_feat->advancedBlendCoherentOperations = VK_TRUE; + break; + } + default: + assert(0); + // Unknown extension feature request needs to be added to mock_icd + break; + } + struct_header = reinterpret_cast(struct_header->pNext); + } + } ''', 'vkGetPhysicalDeviceFormatProperties': ''' if (VK_FORMAT_UNDEFINED == format) {