4646static void DestroyDispObjHandle(void* handle) {
4747 delete reinterpret_cast<VK_LOADER_DATA*>(handle);
4848}
49+
50+ struct GENERIC_HEADER {
51+ VkStructureType sType;
52+ void *pNext;
53+ };
4954'''
5055
5156# Manual code at the top of the cpp source file
627632''' ,
628633'vkGetPhysicalDeviceProperties2KHR' : '''
629634 GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
635+ // Handle any extension properties queried down pNext chain
636+ if (pProperties->pNext) {
637+ auto struct_header = reinterpret_cast<GENERIC_HEADER *>(pProperties->pNext);
638+ while (struct_header) {
639+ switch (struct_header->sType) {
640+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR: {
641+ VkPhysicalDeviceIDPropertiesKHR *id_prop = reinterpret_cast<VkPhysicalDeviceIDPropertiesKHR *>(struct_header);
642+ // This is a dummy ID intended to represent "ICDGOOG" for mock ICD
643+ uint8_t icd_id[] = {1, 0xc, 0xd, 6, 0, 0, 6};
644+ std::copy(icd_id, icd_id + 7, id_prop->deviceUUID);
645+ std::copy(icd_id, icd_id + 7, id_prop->driverUUID);
646+ id_prop->deviceLUID[0] = 0;
647+ id_prop->deviceNodeMask = 1;
648+ id_prop->deviceLUIDValid = VK_FALSE; // This causes the above 2 values to be ignored
649+ break;
650+ }
651+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR: {
652+ VkPhysicalDevicePushDescriptorPropertiesKHR *pd_prop = reinterpret_cast<VkPhysicalDevicePushDescriptorPropertiesKHR *>(struct_header);
653+ pd_prop->maxPushDescriptors = 32;
654+ break;
655+ }
656+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHX: {
657+ VkPhysicalDeviceMultiviewPropertiesKHX *mv_prop = reinterpret_cast<VkPhysicalDeviceMultiviewPropertiesKHX *>(struct_header);
658+ mv_prop->maxMultiviewViewCount = 6;
659+ mv_prop->maxMultiviewInstanceIndex = 0x7FFFFFF;
660+ break;
661+ }
662+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT: {
663+ VkPhysicalDeviceDiscardRectanglePropertiesEXT *rect_prop = reinterpret_cast<VkPhysicalDeviceDiscardRectanglePropertiesEXT *>(struct_header);
664+ rect_prop->maxDiscardRectangles = 4;
665+ break;
666+ }
667+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT: {
668+ VkPhysicalDeviceSampleLocationsPropertiesEXT *dsl_prop = reinterpret_cast<VkPhysicalDeviceSampleLocationsPropertiesEXT *>(struct_header);
669+ dsl_prop->sampleLocationSampleCounts = VK_SAMPLE_COUNT_4_BIT;
670+ dsl_prop->maxSampleLocationGridSize.width = 1;
671+ dsl_prop->maxSampleLocationGridSize.height = 1;
672+ dsl_prop->sampleLocationCoordinateRange[0] = 0.0;
673+ dsl_prop->sampleLocationCoordinateRange[1] = 0.9375;
674+ dsl_prop->sampleLocationSubPixelBits = 4;
675+ dsl_prop->variableSampleLocations = VK_FALSE;
676+ break;
677+ }
678+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT: {
679+ VkPhysicalDeviceExternalMemoryHostPropertiesEXT *mh_prop = reinterpret_cast<VkPhysicalDeviceExternalMemoryHostPropertiesEXT *>(struct_header);
680+ mh_prop->minImportedHostPointerAlignment = 65536;
681+ break;
682+ }
683+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX: {
684+ VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX *mpva_prop = reinterpret_cast<VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX *>(struct_header);
685+ mpva_prop->perViewPositionAllComponents = VK_TRUE;
686+ break;
687+ }
688+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR: {
689+ VkPhysicalDevicePointClippingPropertiesKHR *pc_prop = reinterpret_cast<VkPhysicalDevicePointClippingPropertiesKHR *>(struct_header);
690+ pc_prop->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR;
691+ break;
692+ }
693+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT: {
694+ VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *boa_prop = reinterpret_cast<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *>(struct_header);
695+ boa_prop->advancedBlendMaxColorAttachments = 1;
696+ boa_prop->advancedBlendIndependentBlend = VK_FALSE;
697+ boa_prop->advancedBlendNonPremultipliedSrcColor = VK_FALSE;
698+ boa_prop->advancedBlendNonPremultipliedDstColor = VK_FALSE;
699+ boa_prop->advancedBlendCorrelatedOverlap = VK_FALSE;
700+ boa_prop->advancedBlendAllOperations = VK_FALSE;
701+ break;
702+ }
703+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: {
704+ VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *sfm_prop = reinterpret_cast<VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *>(struct_header);
705+ sfm_prop->filterMinmaxSingleComponentFormats = VK_TRUE;
706+ sfm_prop->filterMinmaxImageComponentMapping = VK_TRUE;
707+ break;
708+ }
709+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT: {
710+ VkPhysicalDeviceConservativeRasterizationPropertiesEXT *cr_prop = reinterpret_cast<VkPhysicalDeviceConservativeRasterizationPropertiesEXT *>(struct_header);
711+ cr_prop->primitiveOverestimationSize = 0.0;
712+ cr_prop->maxExtraPrimitiveOverestimationSize = 0.0;
713+ cr_prop->extraPrimitiveOverestimationSizeGranularity = 0.0;
714+ cr_prop->primitiveUnderestimation = VK_FALSE;
715+ cr_prop->conservativePointAndLineRasterization = VK_FALSE;
716+ cr_prop->degenerateTrianglesRasterized = VK_FALSE;
717+ cr_prop->degenerateLinesRasterized = VK_FALSE;
718+ cr_prop->fullyCoveredFragmentShaderInputVariable = VK_FALSE;
719+ cr_prop->conservativeRasterizationPostDepthCoverage = VK_FALSE;
720+ break;
721+ }
722+ default:
723+ assert(0);
724+ // Unknown extension property request needs to be added to mock_icd
725+ break;
726+ }
727+ struct_header = reinterpret_cast<GENERIC_HEADER *>(struct_header->pNext);
728+ }
729+ }
630730''' ,
631731'vkGetBufferMemoryRequirements' : '''
632732 // TODO: Just hard-coding reqs for now
@@ -831,6 +931,7 @@ def beginFile(self, genOpts):
831931 write ('#include "mock_icd.h"' , file = self .outFile )
832932 write ('#include <stdlib.h>' , file = self .outFile )
833933 write ('#include <vector>' , file = self .outFile )
934+ write ('#include <cassert>' , file = self .outFile )
834935
835936 write ('namespace vkmock {' , file = self .outFile )
836937 if self .header :
@@ -840,7 +941,7 @@ def beginFile(self, genOpts):
840941 device_exts = []
841942 instance_exts = []
842943 # Ignore extensions that ICDs should not implement or are not safe to report
843- ignore_exts = ['VK_EXT_validation_cache' , 'VK_KHR_push_descriptor' ]
944+ ignore_exts = ['VK_EXT_validation_cache' ]
844945 for ext in self .registry .tree .findall ("extensions/extension" ):
845946 if '0' != ext [0 ][0 ].attrib ['value' ]: # Only include implemented extensions
846947 if (ext .attrib ['name' ] in ignore_exts ):
0 commit comments