Skip to content
This repository was archived by the owner on Jul 19, 2018. It is now read-only.

Commit 8cf1b56

Browse files
committed
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.
1 parent 3b13ef6 commit 8cf1b56

1 file changed

Lines changed: 103 additions & 1 deletion

File tree

scripts/mock_icd_generator.py

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
static void DestroyDispObjHandle(void* handle) {
4949
delete reinterpret_cast<VK_LOADER_DATA*>(handle);
5050
}
51+
52+
struct GENERIC_HEADER {
53+
VkStructureType sType;
54+
void *pNext;
55+
};
5156
'''
5257

5358
# Manual code at the top of the cpp source file
@@ -746,6 +751,101 @@
746751
''',
747752
'vkGetPhysicalDeviceProperties2KHR': '''
748753
GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
754+
// Handle any extension properties queried down pNext chain
755+
if (pProperties->pNext) {
756+
auto struct_header = reinterpret_cast<GENERIC_HEADER *>(pProperties->pNext);
757+
while (struct_header) {
758+
switch (struct_header->sType) {
759+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR: {
760+
VkPhysicalDeviceIDPropertiesKHR *id_prop = reinterpret_cast<VkPhysicalDeviceIDPropertiesKHR *>(struct_header);
761+
// This is a dummy ID intended to represent "ICDGOOG" for mock ICD
762+
uint8_t icd_id[] = {1, 0xc, 0xd, 6, 0, 0, 6};
763+
std::copy(icd_id, icd_id + 7, id_prop->deviceUUID);
764+
std::copy(icd_id, icd_id + 7, id_prop->driverUUID);
765+
id_prop->deviceLUID[0] = 0;
766+
id_prop->deviceNodeMask = 1;
767+
id_prop->deviceLUIDValid = VK_FALSE; // This causes the above 2 values to be ignored
768+
break;
769+
}
770+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR: {
771+
VkPhysicalDevicePushDescriptorPropertiesKHR *pd_prop = reinterpret_cast<VkPhysicalDevicePushDescriptorPropertiesKHR *>(struct_header);
772+
pd_prop->maxPushDescriptors = 32;
773+
break;
774+
}
775+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHX: {
776+
VkPhysicalDeviceMultiviewPropertiesKHX *mv_prop = reinterpret_cast<VkPhysicalDeviceMultiviewPropertiesKHX *>(struct_header);
777+
mv_prop->maxMultiviewViewCount = 6;
778+
mv_prop->maxMultiviewInstanceIndex = 0x7FFFFFF;
779+
break;
780+
}
781+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT: {
782+
VkPhysicalDeviceDiscardRectanglePropertiesEXT *rect_prop = reinterpret_cast<VkPhysicalDeviceDiscardRectanglePropertiesEXT *>(struct_header);
783+
rect_prop->maxDiscardRectangles = 4;
784+
break;
785+
}
786+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT: {
787+
VkPhysicalDeviceSampleLocationsPropertiesEXT *dsl_prop = reinterpret_cast<VkPhysicalDeviceSampleLocationsPropertiesEXT *>(struct_header);
788+
dsl_prop->sampleLocationSampleCounts = VK_SAMPLE_COUNT_4_BIT;
789+
dsl_prop->maxSampleLocationGridSize.width = 1;
790+
dsl_prop->maxSampleLocationGridSize.height = 1;
791+
dsl_prop->sampleLocationCoordinateRange[0] = 0.0;
792+
dsl_prop->sampleLocationCoordinateRange[1] = 0.9375;
793+
dsl_prop->sampleLocationSubPixelBits = 4;
794+
dsl_prop->variableSampleLocations = VK_FALSE;
795+
break;
796+
}
797+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT: {
798+
VkPhysicalDeviceExternalMemoryHostPropertiesEXT *mh_prop = reinterpret_cast<VkPhysicalDeviceExternalMemoryHostPropertiesEXT *>(struct_header);
799+
mh_prop->minImportedHostPointerAlignment = 65536;
800+
break;
801+
}
802+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX: {
803+
VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX *mpva_prop = reinterpret_cast<VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX *>(struct_header);
804+
mpva_prop->perViewPositionAllComponents = VK_TRUE;
805+
break;
806+
}
807+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR: {
808+
VkPhysicalDevicePointClippingPropertiesKHR *pc_prop = reinterpret_cast<VkPhysicalDevicePointClippingPropertiesKHR *>(struct_header);
809+
pc_prop->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR;
810+
break;
811+
}
812+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT: {
813+
VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *boa_prop = reinterpret_cast<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *>(struct_header);
814+
boa_prop->advancedBlendMaxColorAttachments = 1;
815+
boa_prop->advancedBlendIndependentBlend = VK_FALSE;
816+
boa_prop->advancedBlendNonPremultipliedSrcColor = VK_FALSE;
817+
boa_prop->advancedBlendNonPremultipliedDstColor = VK_FALSE;
818+
boa_prop->advancedBlendCorrelatedOverlap = VK_FALSE;
819+
boa_prop->advancedBlendAllOperations = VK_FALSE;
820+
break;
821+
}
822+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: {
823+
VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *sfm_prop = reinterpret_cast<VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *>(struct_header);
824+
sfm_prop->filterMinmaxSingleComponentFormats = VK_TRUE;
825+
sfm_prop->filterMinmaxImageComponentMapping = VK_TRUE;
826+
break;
827+
}
828+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT: {
829+
VkPhysicalDeviceConservativeRasterizationPropertiesEXT *cr_prop = reinterpret_cast<VkPhysicalDeviceConservativeRasterizationPropertiesEXT *>(struct_header);
830+
cr_prop->primitiveOverestimationSize = 0.0;
831+
cr_prop->maxExtraPrimitiveOverestimationSize = 0.0;
832+
cr_prop->extraPrimitiveOverestimationSizeGranularity = 0.0;
833+
cr_prop->primitiveUnderestimation = VK_FALSE;
834+
cr_prop->conservativePointAndLineRasterization = VK_FALSE;
835+
cr_prop->degenerateTrianglesRasterized = VK_FALSE;
836+
cr_prop->degenerateLinesRasterized = VK_FALSE;
837+
cr_prop->fullyCoveredFragmentShaderInputVariable = VK_FALSE;
838+
cr_prop->conservativeRasterizationPostDepthCoverage = VK_FALSE;
839+
break;
840+
}
841+
default:
842+
assert(0);
843+
// Unknown extension property request needs to be added to mock_icd
844+
break;
845+
}
846+
struct_header = reinterpret_cast<GENERIC_HEADER *>(struct_header->pNext);
847+
}
848+
}
749849
''',
750850
'vkGetBufferMemoryRequirements': '''
751851
// TODO: Just hard-coding reqs for now
@@ -967,6 +1067,8 @@ def beginFile(self, genOpts):
9671067
write('#include "mock_icd.h"', file=self.outFile)
9681068
write('#include <stdlib.h>', file=self.outFile)
9691069
write('#include <vector>', file=self.outFile)
1070+
write('#include <cassert>', file=self.outFile)
1071+
write('#include <algorithm>', file=self.outFile)
9701072

9711073
write('namespace vkmock {', file=self.outFile)
9721074
if self.header:
@@ -976,7 +1078,7 @@ def beginFile(self, genOpts):
9761078
device_exts = []
9771079
instance_exts = []
9781080
# Ignore extensions that ICDs should not implement or are not safe to report
979-
ignore_exts = ['VK_EXT_validation_cache', 'VK_KHR_push_descriptor']
1081+
ignore_exts = ['VK_EXT_validation_cache']
9801082
for ext in self.registry.tree.findall("extensions/extension"):
9811083
if ext.attrib['supported'] != 'disabled': # Only include enabled extensions
9821084
if (ext.attrib['name'] in ignore_exts):

0 commit comments

Comments
 (0)