def expect(self): architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) get_cache_data_with_null_pdata = require( self.nth_call_of("vkGetPipelineCacheData", 3)) write_data_size = VulkanStruct( architecture, DATA_SIZE, get_write_offset_function( get_cache_data_with_null_pdata, get_cache_data_with_null_pdata.hex_pDataSize)) # The pipeline cache data size must be at least as large as its header # size require_true(16 + VK_UUID_SIZE <= write_data_size.dataSize) get_cache_data_with_not_null_pdata = require( self.next_call_of("vkGetPipelineCacheData")) cache_data_header = VulkanStruct( architecture, DATA_HEADER, get_write_offset_function( get_cache_data_with_not_null_pdata, get_cache_data_with_not_null_pdata.hex_pData)) require_equal(16 + VK_UUID_SIZE, cache_data_header.headerSize) require_equal(1, cache_data_header.headerVersion) require_not_equal(0, cache_data_header.venderID) require_not_equal(0, cache_data_header.deviceID) destroy_pipeline_cache = require( self.next_call_of("vkDestroyPipelineCache"))
def expect(self): architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) get_image_memory_requirements = require( self.next_call_of("vkGetImageMemoryRequirements")) memory_requirements = VulkanStruct( architecture, MEMORY_REQUIREMENTS, get_write_offset_function( get_image_memory_requirements, get_image_memory_requirements.hex_pMemoryRequirements)) allocate_memory = require(self.next_call_of("vkAllocateMemory")) require_not_equal(0, allocate_memory.int_device) require_not_equal(0, allocate_memory.hex_pAllocateInfo) require_equal(0, allocate_memory.hex_pAllocator) require_not_equal(0, allocate_memory.hex_pMemory) allocate_memory_info = VulkanStruct( architecture, MEMORY_ALLOCATE_INFO, get_read_offset_function(allocate_memory, allocate_memory.hex_pAllocateInfo)) require_equal(VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, allocate_memory_info.sType) require_equal(0, allocate_memory_info.pNext) require_equal(memory_requirements.size, allocate_memory_info.allocationSize) free_memory = require(self.next_call_of("vkFreeMemory")) require_not_equal(0, free_memory.int_device) require_not_equal(0, free_memory.int_memory) require_equal(0, free_memory.hex_pAllocator)
def expect(self): num_queries = 4 stride = 12 architecture = self.architecture get_query_result = require(self.nth_call_of("vkGetQueryPoolResults", 3)) require_not_equal(0, get_query_result.int_device) require_not_equal(0, get_query_result.int_queryPool) require_equal(0, get_query_result.int_firstQuery) require_equal(num_queries, get_query_result.int_queryCount) require_equal(num_queries * stride, get_query_result.int_dataSize) require_not_equal(0, get_query_result.hex_pData) require_equal(stride, get_query_result.int_stride) require_equal(VK_QUERY_RESULT_PARTIAL_BIT | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT, get_query_result.int_flags) require_equal(VK_SUCCESS, int(get_query_result.return_val)) result_data = VulkanStruct( architecture, [("data", ARRAY, num_queries * stride / 4, UINT32_T)], get_write_offset_function(get_query_result, get_query_result.hex_pData)) expected_data = [0, 1, 0xFFFFFFFF, 0, 1, 0xFFFFFFFF, 0, 1, 0xFFFFFFFF, 0, 1, 0xFFFFFFFF] require_equal(expected_data, result_data.data)
def expect(self): num_queries = 8 get_result_num_queries = 4 result_width = 8 architecture = self.architecture get_query_result = require(self.nth_call_of("vkGetQueryPoolResults", 2)) require_not_equal(0, get_query_result.int_device) require_not_equal(0, get_query_result.int_queryPool) require_equal(num_queries - get_result_num_queries, get_query_result.int_firstQuery) require_equal(get_result_num_queries, get_query_result.int_queryCount) require_equal(result_width * get_result_num_queries, get_query_result.int_dataSize) require_not_equal(0, get_query_result.hex_pData) require_equal(result_width, get_query_result.int_stride) require_equal(VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT, get_query_result.int_flags) require_equal(VK_SUCCESS, int(get_query_result.return_val)) result_data = VulkanStruct( architecture, [("data", ARRAY, get_result_num_queries, UINT64_T)], get_write_offset_function(get_query_result, get_query_result.hex_pData)) require_equal([0 for i in range(get_result_num_queries)], result_data.data)
def GetPhysicalDevices(test, architecture): # first call to enumerate physical devices first_enumerate_physical_devices = require( test.next_call_of("vkEnumeratePhysicalDevices")) require_equal(VK_SUCCESS, int(first_enumerate_physical_devices.return_val)) require_not_equal(0, first_enumerate_physical_devices.int_instance) require_not_equal( 0, first_enumerate_physical_devices.hex_pPhysicalDeviceCount) require_equal(0, first_enumerate_physical_devices.hex_pPhysicalDevices) num_phy_devices = little_endian_bytes_to_int( require( first_enumerate_physical_devices.get_write_data( first_enumerate_physical_devices.hex_pPhysicalDeviceCount, architecture.int_integerSize))) # second call to enumerate physical devices second_enumerate_physical_devices = require( test.next_call_of("vkEnumeratePhysicalDevices")) require_equal(VK_SUCCESS, int(second_enumerate_physical_devices.return_val)) require_not_equal(0, second_enumerate_physical_devices.int_instance) require_not_equal( 0, second_enumerate_physical_devices.hex_pPhysicalDeviceCount) require_not_equal(0, second_enumerate_physical_devices.hex_pPhysicalDevices) require_not_equal(0, num_phy_devices) PHYSICAL_DEVICES = [("physicalDevices", ARRAY, num_phy_devices, POINTER)] returned_physical_devices = VulkanStruct( architecture, PHYSICAL_DEVICES, get_write_offset_function( second_enumerate_physical_devices, second_enumerate_physical_devices.hex_pPhysicalDevices)) return returned_physical_devices.physicalDevices
def expect(self): architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) create_buffer = require(self.next_call_of("vkCreateBuffer")) buffer_create_info = VulkanStruct( architecture, BUFFER_CREATE_INFO, get_read_offset_function(create_buffer, create_buffer.hex_pCreateInfo)) written_buffer = little_endian_bytes_to_int( require( create_buffer.get_write_data(create_buffer.hex_pBuffer, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, written_buffer) require_equal(buffer_create_info.sType, VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO) require_equal(buffer_create_info.pNext, 0) require_equal(buffer_create_info.createFlags, 0) require_equal(buffer_create_info.size, 1024) require_equal(buffer_create_info.usage, VK_BUFFER_USAGE_TRANSFER_SRC_BIT) require_equal(buffer_create_info.sharingMode, VK_SHARING_MODE_EXCLUSIVE) require_equal(buffer_create_info.queueFamilyIndexCount, 0) require_equal(buffer_create_info.pQueueFamilyIndices, 0) get_buffer_memory_requirements = require( self.next_call_of("vkGetBufferMemoryRequirements")) require_not_equal(0, get_buffer_memory_requirements.int_device) require_equal(written_buffer, get_buffer_memory_requirements.int_buffer) require_not_equal( 0, get_buffer_memory_requirements.hex_pMemoryRequirements) memory_requirements = VulkanStruct( architecture, MEMORY_REQUIREMENTS, get_write_offset_function( get_buffer_memory_requirements, get_buffer_memory_requirements.hex_pMemoryRequirements)) require_equal(True, memory_requirements.size >= 1) require_not_equal(0, memory_requirements.alignment) require_not_equal(0, memory_requirements.memoryTypeBits) destroy_buffer = require(self.next_call_of("vkDestroyBuffer")) require_equal(destroy_buffer.int_device, get_buffer_memory_requirements.int_device) require_equal(written_buffer, destroy_buffer.int_buffer) # Our second vkDestroySwapchain should have been called with # VK_NULL_HANDLE if (self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200)): destroy_buffer = require(self.next_call_of("vkDestroyBuffer")) require_not_equal(0, destroy_buffer.int_device) require_equal(0, destroy_buffer.int_buffer)
def expect(self): architecture = self.architecture first_call = require( self.next_call_of("vkGetImageSparseMemoryRequirements")) require_not_equal(0, first_call.int_device) require_not_equal(0, first_call.int_image) require_not_equal(0, first_call.hex_pSparseMemoryRequirementCount) require_equal(0, first_call.hex_pSparseMemoryRequirements) count = little_endian_bytes_to_int( require( first_call.get_write_data( first_call.hex_pSparseMemoryRequirementCount, architecture.int_integerSize))) second_call = require( self.next_call_of("vkGetImageSparseMemoryRequirements")) require_not_equal(0, second_call.int_device) require_not_equal(0, second_call.int_image) require_not_equal(0, second_call.hex_pSparseMemoryRequirementCount) require_not_equal(0, second_call.hex_pSparseMemoryRequirements) offset = 0 for i in range(count): memory_requirements = VulkanStruct( architecture, SPRASE_IMAGE_MEMORY_REQUIREMENTS, get_write_offset_function( second_call, second_call.hex_pSparseMemoryRequirements + offset)) offset += memory_requirements.total_size
def expect(self): """1. Expects a command pool created and destroyed with VK_COMMAND_POOL_CREATE_TRANSIENT_BIT .""" architecture = self.architecture create_command_pool = require( self.nth_call_of("vkCreateCommandPool", 1)) device = create_command_pool.int_device require_not_equal(0, device) require_not_equal(0, create_command_pool.hex_pCreateInfo) require_equal(0, create_command_pool.hex_pAllocator) require_not_equal(0, create_command_pool.hex_pCommandPool) require_equal(VK_SUCCESS, int(create_command_pool.return_val)) create_info = VulkanStruct( architecture, COMMAND_POOL_CREATE_INFO, get_read_offset_function(create_command_pool, create_command_pool.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, create_info.sType) require_equal(0, create_info.pNext) require_equal(VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, create_info.flags) require_equal(0, create_info.queueFamilyIndex) command_pool = VulkanStruct( architecture, COMMAND_POOL, get_write_offset_function(create_command_pool, create_command_pool.hex_pCommandPool)) require_not_equal(0, command_pool.handle) destroy_command_pool = require( self.next_call_of("vkDestroyCommandPool")) require_equal(device, destroy_command_pool.int_device) require_equal(command_pool.handle, destroy_command_pool.int_commandPool)
def expect(self): arch = self.architecture physical_devices = GetPhysicalDevices(self, arch) create_device = require(self.nth_call_of("vkCreateDevice", 1)) require_equal(True, create_device.int_physicalDevice in physical_devices) require_not_equal(0, create_device.hex_pCreateInfo) require_equal(0, create_device.hex_pAllocator) require_not_equal(0, create_device.hex_pDevice) create_info = VulkanStruct( arch, DEVICE_CREATE_INFO, get_read_offset_function(create_device, create_device.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, create_info.sType) # require_equal(0, create_info.pNext) require_equal(0, create_info.flags) require_equal(1, create_info.queueCreateInfoCount) require_not_equal(0, create_info.pQueueCreateInfos) require_equal(0, create_info.enabledLayerCount) require_equal(0, create_info.ppEnabledLayerNames) require_equal(0, create_info.enabledExtensionCount) require_equal(0, create_info.ppEnabledExtensionNames) require_equal(0, create_info.pEnabledFeatures) DEVICE = [("device", POINTER)] device = VulkanStruct( arch, DEVICE, get_write_offset_function(create_device, create_device.hex_pDevice)).device require_not_equal(0, device) queue_create_info = VulkanStruct( arch, DEVICE_QUEUE_CREATE_INFO, get_read_offset_function(create_device, create_info.pQueueCreateInfos)) require_equal(VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, queue_create_info.sType) # require_equal(0, queue_create_info.pNext) require_equal(0, queue_create_info.flags) require_equal(0, queue_create_info.queueFamilyIndex) require_equal(1, queue_create_info.queueCount) require_not_equal(0, queue_create_info.pQueuePriorities) PRIORITY = [("priority", FLOAT)] priority = VulkanStruct( arch, PRIORITY, get_read_offset_function( create_device, queue_create_info.pQueuePriorities)).priority require_equal(1.0, priority) destroy_device = require(self.next_call_of("vkDestroyDevice")) require_equal(device, destroy_device.int_device) require_equal(0, destroy_device.hex_pAllocator)
def expect(self): arch = self.architecture physical_devices = GetPhysicalDevices(self, arch) for pd in physical_devices: for fmt in ALL_VK_FORMATS: get_properties = require(self.next_call_of( "vkGetPhysicalDeviceFormatProperties")) require_equal( True, get_properties.int_physicalDevice in physical_devices) require_equal(fmt, get_properties.int_format) require_not_equal(0, get_properties.hex_pFormatProperties) VulkanStruct(arch, FORMAT_PROPERTIES, get_write_offset_function( get_properties, get_properties.hex_pFormatProperties))
def expect(self): architecture = self.architecture get_granularity = require( self.next_call_of("vkGetRenderAreaGranularity")) require_not_equal(0, get_granularity.int_device) require_not_equal(0, get_granularity.int_renderPass) granularity = VulkanStruct( architecture, EXTENT_2D, get_write_offset_function(get_granularity, get_granularity.hex_pGranularity)) require_not_equal(0, granularity.width) require_not_equal(0, granularity.height)
def expect(self): """3. Expects a query pool to be created with queryCount: 4 and queryType: VK_QUERY_TYPE_PIPELINE_STATISTICS and pipelineStatistics: VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT.""" architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) create_device = self.nth_call_of("vkCreateDevice", 3) if create_device[0] is None: raise GapidUnsupportedException( "physical device feature: pipelineStatistics not supported") create_query_pool = require(self.next_call_of("vkCreateQueryPool")) device = create_query_pool.int_device require_not_equal(0, device) require_not_equal(0, create_query_pool.hex_pCreateInfo) require_equal(0, create_query_pool.hex_pAllocator) require_not_equal(0, create_query_pool.hex_pQueryPool) require_equal(VK_SUCCESS, int(create_query_pool.return_val)) create_info = VulkanStruct( architecture, QUERY_POOL_CREATE_INFO, get_read_offset_function(create_query_pool, create_query_pool.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, create_info.sType) require_equal(0, create_info.pNext) require_equal(0, create_info.flags) require_equal(VK_QUERY_TYPE_PIPELINE_STATISTICS, create_info.queryType) require_equal(4, create_info.queryCount) require_equal( VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT, create_info.pipelineStatistics) view = VulkanStruct( architecture, QUERY_POOL, get_write_offset_function(create_query_pool, create_query_pool.hex_pQueryPool)) require_not_equal(0, view.handle) destroy_query_pool = require(self.next_call_of("vkDestroyQueryPool")) require_equal(device, destroy_query_pool.int_device) require_equal(view.handle, destroy_query_pool.int_queryPool) if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200): destroy_null_query_pool = require( self.next_call_of("vkDestroyQueryPool")) require_equal(device, destroy_query_pool.int_device) require_equal(0, destroy_null_query_pool.int_queryPool)
def expect(self): """Check the arguments and the VkMappedMemoryRange structs used in vkInvalidateMappedMemoryRanges(). The invalidate memory covers the whole dst buffer which starts at offset 0 and has size VK_WHOLE_SIZE. Only the second half of the buffer has the data copied from the previously flushed memory""" MAP_OFFSET = 0 INVALIDATE_OFFSET = MAP_OFFSET INVALIDATE_SIZE = VK_WHOLE_SIZE DATA_SIZE = 256 MEMORY_DATA = [("data", ARRAY, DATA_SIZE, CHAR)] EXPECTED_MEMORY_DATA = [i for i in range(DATA_SIZE)] architecture = self.architecture # The first and second vkMapMemory() result is managed in # VulkanApplication and is not used here, the fourth is the one we need # here. map_memory = require(self.nth_call_of("vkMapMemory", 4)) require_not_equal(0, map_memory.hex_ppData) # The invalidated data offset is equal to the mapped offset, but the # flushed data starts at mapped offset + 256 invalidate_data_ptr = little_endian_bytes_to_int( require( map_memory.get_write_data(map_memory.hex_ppData, architecture.int_integerSize))) + 256 # Check arguments invalidate_mapped_memory_ranges = require( self.nth_call_of("vkInvalidateMappedMemoryRanges", 1)) require_equal(1, invalidate_mapped_memory_ranges.int_memoryRangeCount) require_not_equal(0, invalidate_mapped_memory_ranges.hex_pMemoryRanges) # Check the memory range struct contents mapped_memory_range = VulkanStruct( architecture, MAPPED_MEMORY_RANGE, get_read_offset_function( invalidate_mapped_memory_ranges, invalidate_mapped_memory_ranges.hex_pMemoryRanges)) require_equal(VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, mapped_memory_range.sType) require_equal(0, mapped_memory_range.pNext) require_not_equal(0, mapped_memory_range.memory) require_equal(INVALIDATE_OFFSET, mapped_memory_range.offset) require_equal(INVALIDATE_SIZE, mapped_memory_range.size) # Check data of the invalidated memory memory_data = VulkanStruct( architecture, MEMORY_DATA, get_write_offset_function(invalidate_mapped_memory_ranges, invalidate_data_ptr)) require_equal(EXPECTED_MEMORY_DATA, memory_data.data)
def expect(self): """Check the arguments to vkAllocateCommandBuffers""" architecture = self.architecture for level in [VK_COMMAND_BUFFER_LEVEL_PRIMARY, VK_COMMAND_BUFFER_LEVEL_SECONDARY]: for count in [1, 2, MAX_COUNT]: allocate = require(self.next_call_of( "vkAllocateCommandBuffers")) require_not_equal(0, allocate.int_device) require_not_equal(0, allocate.hex_pAllocateInfo) require_not_equal(0, allocate.hex_pCommandBuffers) require_equal(VK_SUCCESS, int(allocate.return_val)) allocate_info = VulkanStruct( architecture, COMMAND_BUFFER_ALLOCATE_INFO, get_read_offset_function(allocate, allocate.hex_pAllocateInfo)) require_equal(VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, allocate_info.sType) command_pool = allocate_info.commandPool require_not_equal(0, command_pool) require_equal(level, allocate_info.level) require_equal(count, allocate_info.commandBufferCount) allocated_buffers = [] if count > 0: command_buffers = VulkanStruct( architecture, [("handles", ARRAY, count, POINTER)], get_write_offset_function(allocate, allocate.hex_pCommandBuffers)) for i in range(count): require_not_equal(0, command_buffers.handles[i]) allocated_buffers.append(command_buffers.handles[i]) free = require(self.next_call_of("vkFreeCommandBuffers")) require_not_equal(0, free.int_device) require_equal(command_pool, free.int_commandPool) require_equal(count, free.int_commandBufferCount) freed_buffers = [] if count > 0: command_buffers = VulkanStruct( architecture, [("handles", ARRAY, count, POINTER)], get_read_offset_function(free, free.hex_pCommandBuffers)) for i in range(count): require_not_equal(0, command_buffers.handles[i]) freed_buffers.append(command_buffers.handles[i]) require_equal(allocated_buffers, freed_buffers)
def expect(self): """1. Expect vkEnumeratePhysicalDevices() to be called first, then vkGetPhysicalDeviceFeatures() to be called num_phy_devices times and return physical device features.""" arch = self.architecture physical_devices = GetPhysicalDevices(self, arch) for pd in physical_devices: get_features = require(self.next_call_of( "vkGetPhysicalDeviceFeatures")) require_equal(pd, get_features.int_physicalDevice) require_not_equal(0, get_features.hex_pFeatures) VulkanStruct(arch, PHYSICAL_DEVICE_FEATURES, get_write_offset_function(get_features, get_features.hex_pFeatures))
def expect(self): architecture = self.architecture get_image_memory_requirements = require( self.next_call_of("vkGetImageMemoryRequirements")) require_not_equal(0, get_image_memory_requirements.int_device) require_not_equal(0, get_image_memory_requirements.int_image) require_not_equal(0, get_image_memory_requirements.hex_pMemoryRequirements) memory_requirements = VulkanStruct( architecture, MEMORY_REQUIREMENTS, get_write_offset_function( get_image_memory_requirements, get_image_memory_requirements.hex_pMemoryRequirements)) require_equal(True, memory_requirements.size >= 1) require_not_equal(0, memory_requirements.alignment) require_not_equal(0, memory_requirements.memoryTypeBits)
def expect(self): """2. Expects a buffer view created with non-zero offset and non-VK_WHOLE_SIZE range for a storage texel buffer.""" architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) create_buffer_view = require(self.nth_call_of("vkCreateBufferView", 2)) device = create_buffer_view.int_device require_not_equal(0, device) require_not_equal(0, create_buffer_view.hex_pCreateInfo) require_equal(0, create_buffer_view.hex_pAllocator) require_not_equal(0, create_buffer_view.hex_pView) require_equal(VK_SUCCESS, int(create_buffer_view.return_val)) create_info = VulkanStruct( architecture, BUFFER_VIEW_CREATE_INFO, get_read_offset_function(create_buffer_view, create_buffer_view.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, create_info.sType) require_equal(0, create_info.pNext) require_equal(0, create_info.flags) require_not_equal(0, create_info.buffer) require_equal(VK_FORMAT_R8G8B8A8_UNORM, create_info.format) require_equal(MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT * 1, create_info.offset) require_equal(MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT * 3, create_info.range) view = VulkanStruct( architecture, BUFFER_VIEW, get_write_offset_function(create_buffer_view, create_buffer_view.hex_pView)) require_not_equal(0, view.handle) destroy_buffer_view = require(self.next_call_of("vkDestroyBufferView")) require_equal(device, destroy_buffer_view.int_device) require_equal(view.handle, destroy_buffer_view.int_bufferView) if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200): destroy_null_buffer_view = require( self.next_call_of("vkDestroyBufferView")) require_equal(device, destroy_buffer_view.int_device) require_equal(0, destroy_null_buffer_view.int_bufferView)
def expect(self): arch = self.architecture get_layout = require(self.next_call_of("vkGetImageSubresourceLayout")) require_not_equal(0, get_layout.int_image) subresource = VulkanStruct( arch, IMAGE_SUBRESOURCE_ELEMENTS, get_read_offset_function(get_layout, get_layout.hex_pSubresource)) layout = VulkanStruct( arch, SUBRESOURCE_LAYOUT_ELEMENTS, get_write_offset_function(get_layout, get_layout.hex_pLayout)) require_equal(VK_IMAGE_ASPECT_COLOR_BIT, subresource.aspectMask) require_equal(0, subresource.mipLevel) require_equal(0, subresource.arrayLayer) require_not_equal(0, layout.size) require_not_equal(0, layout.rowPitch)
def expect(self): """2. Expects a query pool to be created with queryCount: 7 and queryType: VK_QUERY_TYPE_TIMESTAMP.""" architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) create_query_pool = require(self.nth_call_of("vkCreateQueryPool", 2)) device = create_query_pool.int_device require_not_equal(0, device) require_not_equal(0, create_query_pool.hex_pCreateInfo) require_equal(0, create_query_pool.hex_pAllocator) require_not_equal(0, create_query_pool.hex_pQueryPool) require_equal(VK_SUCCESS, int(create_query_pool.return_val)) create_info = VulkanStruct( architecture, QUERY_POOL_CREATE_INFO, get_read_offset_function(create_query_pool, create_query_pool.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, create_info.sType) require_equal(0, create_info.pNext) require_equal(0, create_info.flags) require_equal(VK_QUERY_TYPE_TIMESTAMP, create_info.queryType) require_equal(7, create_info.queryCount) require_equal(0, create_info.pipelineStatistics) view = VulkanStruct( architecture, QUERY_POOL, get_write_offset_function(create_query_pool, create_query_pool.hex_pQueryPool)) require_not_equal(0, view.handle) destroy_query_pool = require(self.next_call_of("vkDestroyQueryPool")) require_equal(device, destroy_query_pool.int_device) require_equal(view.handle, destroy_query_pool.int_queryPool) if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200): destroy_null_query_pool = require( self.next_call_of("vkDestroyQueryPool")) require_equal(device, destroy_query_pool.int_device) require_equal(0, destroy_null_query_pool.int_queryPool)
def expect(self): """4. Expects a command pool created with empty flag bit, then reseted with VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT, and finally destroyed""" architecture = self.architecture create_command_pool = require( self.nth_call_of("vkCreateCommandPool", 4)) device = create_command_pool.int_device require_not_equal(0, device) require_not_equal(0, create_command_pool.hex_pCreateInfo) require_equal(0, create_command_pool.hex_pAllocator) require_not_equal(0, create_command_pool.hex_pCommandPool) require_equal(VK_SUCCESS, int(create_command_pool.return_val)) create_info = VulkanStruct( architecture, COMMAND_POOL_CREATE_INFO, get_read_offset_function(create_command_pool, create_command_pool.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, create_info.sType) require_equal(0, create_info.pNext) require_equal(0, create_info.flags) require_equal(0, create_info.queueFamilyIndex) command_pool = VulkanStruct( architecture, COMMAND_POOL, get_write_offset_function(create_command_pool, create_command_pool.hex_pCommandPool)) require_not_equal(0, command_pool.handle) reset_pool = require(self.next_call_of("vkResetCommandPool")) require_equal(device, reset_pool.int_device) require_equal(command_pool.handle, reset_pool.int_commandPool) require_equal(VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT, reset_pool.flags) destroy_command_pool = require( self.next_call_of("vkDestroyCommandPool")) require_equal(device, destroy_command_pool.int_device) require_equal(command_pool.handle, destroy_command_pool.int_commandPool)
def CheckAtom(atom, architecture, physical_device, format=VK_FORMAT_R8G8B8A8_UNORM, type=VK_IMAGE_TYPE_2D, tiling=VK_IMAGE_TILING_OPTIMAL, usage=VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, flags=0): require_equal(True, IsExpectedReturnCode(int(int32(atom.return_val)))) require_equal(physical_device, atom.int_physicalDevice) require_equal(format, atom.int_format) require_equal(type, atom.int_type) require_equal(tiling, atom.int_tiling) require_equal(usage, atom.int_usage) require_equal(flags, atom.int_flags) require_not_equal(0, atom.hex_pImageFormatProperties) if int(atom.return_val) == VK_SUCCESS: VulkanStruct( architecture, IMAGE_FORMAT_PROPERTIES, get_write_offset_function(atom, atom.hex_pImageFormatProperties))
def expect(self): """1. Expects a buffer view created with zero offset and VK_WHOLE_SIZE range for a uniform texel buffer.""" architecture = self.architecture device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) create_buffer_view = require(self.nth_call_of("vkCreateBufferView", 1)) device = create_buffer_view.int_device require_not_equal(0, device) require_not_equal(0, create_buffer_view.hex_pCreateInfo) require_equal(0, create_buffer_view.hex_pAllocator) require_not_equal(0, create_buffer_view.hex_pView) require_equal(VK_SUCCESS, int(create_buffer_view.return_val)) create_info = VulkanStruct( architecture, BUFFER_VIEW_CREATE_INFO, get_read_offset_function(create_buffer_view, create_buffer_view.hex_pCreateInfo)) require_equal(VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, create_info.sType) require_equal(0, create_info.pNext) require_equal(0, create_info.flags) require_not_equal(0, create_info.buffer) require_equal(VK_FORMAT_R8G8B8A8_UNORM, create_info.format) require_equal(0, create_info.offset) require_equal(VK_WHOLE_SIZE, create_info.range) view = VulkanStruct( architecture, BUFFER_VIEW, get_write_offset_function(create_buffer_view, create_buffer_view.hex_pView)) require_not_equal(0, view.handle) destroy_buffer_view = require(self.next_call_of("vkDestroyBufferView")) require_equal(device, destroy_buffer_view.int_device) require_equal(view.handle, destroy_buffer_view.int_bufferView)
def expect(self): arch = self.architecture physical_devices = GetPhysicalDevices(self, arch) property_counts = {} # case pQueueFamilyProperties == nullptr for pd in physical_devices: get_properties = require(self.next_call_of( "vkGetPhysicalDeviceQueueFamilyProperties")) require_equal( True, get_properties.int_physicalDevice in physical_devices) require_not_equal(0, get_properties.hex_pQueueFamilyPropertyCount) require_equal(0, get_properties.hex_pQueueFamilyProperties) observation_num_properties = little_endian_bytes_to_int( require(get_properties.get_write_data( get_properties.hex_pQueueFamilyPropertyCount, arch.int_integerSize))) property_counts[pd] = observation_num_properties # case *pQueueFamilyPropertyCount == 0 for pd in physical_devices: get_properties = require(self.next_call_of( "vkGetPhysicalDeviceQueueFamilyProperties")) require_equal( True, get_properties.int_physicalDevice in physical_devices) require_not_equal(0, get_properties.hex_pQueueFamilyPropertyCount) require_not_equal(0, get_properties.hex_pQueueFamilyProperties) observation_num_properties = little_endian_bytes_to_int( require(get_properties.get_write_data( get_properties.hex_pQueueFamilyPropertyCount, arch.int_integerSize))) require_equal(0, observation_num_properties) # case *pQueueFamilyPropertyCount < capacity for pd in physical_devices: if property_counts[pd] <= 1: continue get_properties = require(self.next_call_of( "vkGetPhysicalDeviceQueueFamilyProperties")) require_equal( True, get_properties.int_physicalDevice in physical_devices) require_not_equal(0, get_properties.hex_pQueueFamilyPropertyCount) require_not_equal(0, get_properties.hex_pQueueFamilyProperties) # Check the count observation_num_properties = little_endian_bytes_to_int( require(get_properties.get_write_data( get_properties.hex_pQueueFamilyPropertyCount, arch.int_integerSize))) require_equal(property_counts[pd] - 1, observation_num_properties) # Check the properties offset = 0 for i in range(property_counts[pd] - 1): p = VulkanStruct( arch, QUEUE_FAMILY_PROPERTIES, get_write_offset_function( get_properties, get_properties.hex_pQueueFamilyProperties + offset)) offset += p.total_size # case *pQueueFamilyPropertyCount < capacity for pd in physical_devices: get_properties = require(self.next_call_of( "vkGetPhysicalDeviceQueueFamilyProperties")) require_equal( True, get_properties.int_physicalDevice in physical_devices) require_not_equal(0, get_properties.hex_pQueueFamilyPropertyCount) require_not_equal(0, get_properties.hex_pQueueFamilyProperties) # Check the count observation_num_properties = little_endian_bytes_to_int( require(get_properties.get_write_data( get_properties.hex_pQueueFamilyPropertyCount, arch.int_integerSize))) require_equal(property_counts[pd], observation_num_properties) # Check the properties offset = 0 for i in range(property_counts[pd]): p = VulkanStruct( arch, QUEUE_FAMILY_PROPERTIES, get_write_offset_function( get_properties, get_properties.hex_pQueueFamilyProperties + offset)) offset += p.total_size # case *pQueueFamilyPropertyCount > capacity for pd in physical_devices: get_properties = require(self.next_call_of( "vkGetPhysicalDeviceQueueFamilyProperties")) require_equal( True, get_properties.int_physicalDevice in physical_devices) require_not_equal(0, get_properties.hex_pQueueFamilyPropertyCount) require_not_equal(0, get_properties.hex_pQueueFamilyProperties) # Check the count observation_num_properties = little_endian_bytes_to_int( require(get_properties.get_write_data( get_properties.hex_pQueueFamilyPropertyCount, arch.int_integerSize))) require_equal(property_counts[pd], observation_num_properties) # Check the properties offset = 0 for i in range(property_counts[pd]): p = VulkanStruct( arch, QUEUE_FAMILY_PROPERTIES, get_write_offset_function( get_properties, get_properties.hex_pQueueFamilyProperties + offset)) offset += p.total_size
def expect(self): """Check the arguments and values referred by the pointer arugments of vkEnumerateDeviceExtensionProperties""" architecture = self.architecture # First call returns the number of extension properties get_device_extension_property_count = require(self.next_call_of( "vkEnumerateDeviceExtensionProperties")) require_equal(VK_SUCCESS, int(get_device_extension_property_count.return_val)) # Skip the check of layer name because device layer is a deprecate # concept, and all layer names will be empty strings. require_not_equal( 0, get_device_extension_property_count.hex_pPropertyCount) require_equal(0, get_device_extension_property_count.hex_pProperties) property_count_after_call = little_endian_bytes_to_int(require( get_device_extension_property_count.get_write_data( get_device_extension_property_count.hex_pPropertyCount, architecture.int_integerSize))) property_count = property_count_after_call # If the number of properties is larger than 1, there should be a call # with one less number of properties passed to # vkEnumerateDeviceExtensionProperties() and a VK_INCOMPLETE should be # returned. if property_count > 1: incomplete_reutrn = require(self.next_call_of( "vkEnumerateDeviceExtensionProperties")) require_equal(VK_INCOMPLETE, int(incomplete_reutrn.return_val)) # Skip the check of layer name because device layer is a deprecate # concept, and all layer names will be empty strings. require_not_equal(0, incomplete_reutrn.hex_pPropertyCount) require_not_equal(0, incomplete_reutrn.hex_pProperties) one_less_count = little_endian_bytes_to_int(require( incomplete_reutrn.get_write_data( incomplete_reutrn.hex_pPropertyCount, architecture.int_integerSize))) require_equal(one_less_count, property_count - 1) # If the number of properties is not zero, there must be a call to get # the properties, and each property struct should have a non-zero # specVersion value. if property_count > 0: get_device_extension_properties = require(self.next_call_of( "vkEnumerateDeviceExtensionProperties")) require_equal(VK_SUCCESS, int(get_device_extension_properties.return_val)) # Skip the check of layer name because device layer is a deprecate # concept, and all layer names will be empty strings. require_not_equal( 0, get_device_extension_properties.hex_pPropertyCount) require_not_equal(0, get_device_extension_properties.hex_pProperties) property_count_after_call = little_endian_bytes_to_int(require( get_device_extension_properties.get_write_data( get_device_extension_properties.hex_pPropertyCount, architecture.int_integerSize))) require_equal(property_count, property_count_after_call) EXTENSION_PROPERTIES = [ ("extensionName", ARRAY, VK_MAX_EXTENSION_NAME_SIZE, CHAR), ("specVersion", UINT32_T), ] property_offset = 0 for i in range(property_count_after_call): property = VulkanStruct( architecture, EXTENSION_PROPERTIES, get_write_offset_function( get_device_extension_properties, get_device_extension_properties.hex_pProperties + property_offset)) property_offset += property.total_size require_not_equal(0, property.specVersion)
def expect(self): """Check the arguments and the values referred by the pointer arguments of vkEnumeratePhysicalDevices""" architecture = self.architecture # The first call to vkEnumeratePhysicalDevices, pPhysicalDevices is # NULL, pPhysicalDeviceCount refer to 0 prior to the call and should be # non zero after. get_count = require(self.next_call_of("vkEnumeratePhysicalDevices")) require_not_equal(0, get_count.int_instance) require_not_equal(0, get_count.hex_pPhysicalDeviceCount) require_equal(0, get_count.hex_pPhysicalDevices) # Strictly speaking here the return value should be VK_INCOMPLETE, but # Nvidia drivers return VK_SUCCESS when pPhysicalDevices is NULL # TODO(qining): Uncomment this once drivers handle it correctly # require_equal(VK_INCOMPLETE, int(get_count.return_val)) physical_device_count_after_call = require(get_count.get_write_data( get_count.hex_pPhysicalDeviceCount, architecture.int_integerSize)) physical_device_count = little_endian_bytes_to_int( physical_device_count_after_call) require_not_equal(0, physical_device_count) # The second call should have physical device handles returned in the memory # pointed by pPhysicalDevices get_handles = require(self.next_call_of("vkEnumeratePhysicalDevices")) require_not_equal(0, get_handles.int_instance) require_not_equal(0, get_handles.hex_pPhysicalDeviceCount) require_not_equal(0, get_handles.hex_pPhysicalDevices) require_equal(VK_SUCCESS, int(get_handles.return_val)) # physical device handles are not NON_DISPATCHALBE_HANDLE PHYSICAL_DEVICES = [("handles", ARRAY, physical_device_count, POINTER)] physical_devices = VulkanStruct( architecture, PHYSICAL_DEVICES, get_write_offset_function( get_handles, get_handles.hex_pPhysicalDevices)) for handle in physical_devices.handles: require_not_equal(0, handle) # The windows loader + some drivers do very odd things here. # They change around the calls to EnumeratePhyiscalDevices # in order to handle multiple devices. if self.device.Configuration.OS.Kind == WINDOWS: return # The third call is made with non-NULL pPhysicalDevices, while the physical # device count is one less than the actual count. Command should return # with VK_INCOMPLETE one_less_count = require( self.next_call_of("vkEnumeratePhysicalDevices")) require_not_equal(0, one_less_count.int_instance) require_not_equal(0, one_less_count.hex_pPhysicalDeviceCount) require_not_equal(0, one_less_count.hex_pPhysicalDevices) require_equal(VK_INCOMPLETE, int(one_less_count.return_val)) # The fourth call is made with non-NULL pPhysicalDevices, while the physical # device count is zero. Command should return with VK_INCOMPLETE zero_count = require(self.next_call_of("vkEnumeratePhysicalDevices")) require_not_equal(0, zero_count.int_instance) require_not_equal(0, zero_count.hex_pPhysicalDeviceCount) require_not_equal(0, zero_count.hex_pPhysicalDevices) require_equal(VK_INCOMPLETE, int(zero_count.return_val)) physical_device_count_before_call = require(zero_count.get_read_data( zero_count.hex_pPhysicalDeviceCount, architecture.int_integerSize)) require_equal( 0, little_endian_bytes_to_int(physical_device_count_before_call))