def expect(self): """Check the arguments to vkCmdExecuteCommands""" execute_commands = require(self.nth_call_of("vkCmdExecuteCommands", 1)) require_not_equal(0, execute_commands.int_commandBuffer) require_equal(2, execute_commands.int_commandBufferCount) require_not_equal(0, execute_commands.hex_pCommandBuffers)
def expect(self): """Expect that the applicationInfoPointer is not null for the second vkCreateInstance, and that it contains some of the expected data.""" architecture = self.architecture create_instance = require(self.nth_call_of("vkCreateInstance", 1)) require_not_equal(create_instance.hex_pCreateInfo, 0) create_info_memory = require( create_instance.get_read_data(create_instance.hex_pCreateInfo, architecture.int_integerSize)) require_equal(little_endian_bytes_to_int(create_info_memory), VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) applicationInfoPointer = require( create_instance.get_read_data( create_instance.hex_pCreateInfo + architecture.int_pointerSize * 3, architecture.int_pointerSize)) require_not_equal(little_endian_bytes_to_int(applicationInfoPointer), 0) # The 2nd pointer(3rd element) in VkApplicationInfo should be the string # Application application_info_application_name_ptr = require( create_instance.get_read_data( little_endian_bytes_to_int(applicationInfoPointer) + 2 * architecture.int_pointerSize, architecture.int_pointerSize)) application_name = require( create_instance.get_read_string( little_endian_bytes_to_int( application_info_application_name_ptr))) require_equal(application_name, "Application")
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): 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 check_destroy_sampler(test, device, sampler): """Checks that the next vkDestroySampler command call atom has the passed-in |device| and |sampler| handle value. """ destroy_sampler = require(test.next_call_of("vkDestroySampler")) require_equal(device, destroy_sampler.int_device) require_equal(sampler, destroy_sampler.int_sampler)
def expect(self): """The first call to vkCmdSetLineWidth should have line width value: 1.0 """ set_line_width = require(self.nth_call_of("vkCmdSetLineWidth", 1)) require_not_equal(0, set_line_width.int_commandBuffer) require_equal(1.0, set_line_width.float_lineWidth)
def expect(self): set_blend_constants = require( self.next_call_of("vkCmdSetBlendConstants")) require_not_equal(0, set_blend_constants.int_commandBuffer) require_equal([1.25, 2.5, 5.0, 10.0], set_blend_constants.float_blendConstants)
def check_destroy_image_view(test, device, image_view, device_properties): """Checks the |index|'th vkDestroyImageView command call atom, including the device handler value and the image view handler value. """ destroy_image_view = require(test.next_call_of("vkDestroyImageView")) require_equal(device, destroy_image_view.int_device) require_equal(image_view, destroy_image_view.int_imageView)
def expect(self): """1. One descriptor set.""" arch = self.architecture # Get the VkDescriptorPool handle returned from the driver. # This will also locate us to the proper position in the stream # so we can call next_call_of() for querying the other atoms. pool = get_descriptor_pool(self, 1) # Get the VkDescriptorSetLayout handle returned from the driver. set_layout = get_descriptor_set_layout(self) alloc_descriptor_set, device, p_sets = \ check_alloc_descriptor_set(self, arch) info = get_descriptor_set_alloc_info(alloc_descriptor_set, arch) require_equal(info.sType, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO) require_equal(0, info.pNext) require_equal(pool, info.descriptorPool) require_equal(1, info.descriptorSetCount) # Read the VkDescriptorSetLayout conveyed in the alloc info. layout = little_endian_bytes_to_int( require(alloc_descriptor_set.get_read_data( info.pSetLayouts, NON_DISPATCHABLE_HANDLE_SIZE))) require_equal(set_layout, layout) # Get the real VkDescriptorSet returned form the driver. actual_set = little_endian_bytes_to_int( require(alloc_descriptor_set.get_write_data( alloc_descriptor_set.hex_pDescriptorSets, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, actual_set) check_free_descriptor_set(self, device, pool, [actual_set])
def expect(self): """2. Expects vkCmdResetQueryPool() is called with firstQuery: 1, queryCount: 5.""" reset_query_pool = require(self.nth_call_of("vkCmdResetQueryPool", 2)) require_not_equal(0, reset_query_pool.int_commandBuffer) require_not_equal(0, reset_query_pool.int_queryPool) require_equal(1, reset_query_pool.int_firstQuery) require_equal(5, reset_query_pool.int_queryCount)
def check_destroy_descriptor_pool(test, device, descriptor_pool): """Checks that the next vkDestroyDescriptorPool command call atom has the passed-in |device| and |descriptor_pool| handle value. """ destroy_descriptor_pool = require( test.next_call_of("vkDestroyDescriptorPool")) require_equal(device, destroy_descriptor_pool.int_device) require_equal(descriptor_pool, destroy_descriptor_pool.int_descriptorPool)
def expect(self): architecture = self.architecture bind_pipeline = require(self.next_call_of("vkCmdBindPipeline")) require_not_equal(0, bind_pipeline.int_commandBuffer) require_equal(VK_PIPELINE_BIND_POINT_GRAPHICS, bind_pipeline.int_pipelineBindPoint) require_not_equal(0, bind_pipeline.int_pipeline)
def GetCreatedImage(create_image): require_equal(VK_SUCCESS, int(create_image.return_val)) require_not_equal(0, create_image.int_device) require_not_equal(0, create_image.hex_pCreateInfo) require_not_equal(0, create_image.hex_pImage) img = little_endian_bytes_to_int(require(create_image.get_write_data( create_image.hex_pImage, NON_DISPATCHABLE_HANDLE_SIZE))) return img
def expect(self): draw = require(self.next_call_of("vkCmdDrawIndexed")) require_not_equal(0, draw.int_commandBuffer) require_equal(3, draw.int_indexCount) require_equal(1, draw.int_instanceCount) require_equal(0, draw.int_firstIndex) require_equal(0, draw.int_vertexOffset) require_equal(0, draw.int_firstInstance)
def expect(self): """3. Destroys a null descriptor pool handle.""" device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200): destroy_descriptor_pool = require( self.nth_call_of("vkDestroyDescriptorPool", 3)) require_equal(0, destroy_descriptor_pool.int_descriptorPool)
def GetCreatedBuffer(create_buffer): require_equal(VK_SUCCESS, int(create_buffer.return_val)) require_not_equal(0, create_buffer.int_device) require_not_equal(0, create_buffer.hex_pCreateInfo) require_not_equal(0, create_buffer.hex_pBuffer) buf = little_endian_bytes_to_int(require(create_buffer.get_write_data( create_buffer.hex_pBuffer, NON_DISPATCHABLE_HANDLE_SIZE))) return buf
def check_destroy_descriptor_set_layout(test, device, descriptor_set_layout): """Checks that the next vkDestroyDescriptorSetLayout command call atom has the passed-in |device| and |descriptor_set_layout| handle value. """ destroy_descriptor_set_layout = require( test.next_call_of("vkDestroyDescriptorSetLayout")) require_equal(device, destroy_descriptor_set_layout.int_device) require_equal(descriptor_set_layout, destroy_descriptor_set_layout.int_descriptorSetLayout)
def expect(self): device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) if (self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200)): destroy_pipeline = require( self.nth_call_of("vkDestroyPipelineLayout", 4)) require_equal(0, destroy_pipeline.int_pipelineLayout) require_not_equal(0, destroy_pipeline.int_device) require_equal(0, destroy_pipeline.hex_pAllocator)
def get_descriptor_set_layout(test): """Returns the handle of the next descriptor set layout created from vkCreateDescriptorSetLayout.""" create = require(test.next_call_of("vkCreateDescriptorSetLayout")) require_equal(VK_SUCCESS, int(create.return_val)) layout = little_endian_bytes_to_int( require(create.get_write_data( create.hex_pSetLayout, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, layout) return layout
def get_descriptor_pool(test, index): """Returns the handle of the |index|th (starting from 1) descriptor pool created from vkCreateDescriptorPool.""" create = require(test.nth_call_of("vkCreateDescriptorPool", index)) require_equal(VK_SUCCESS, int(create.return_val)) pool = little_endian_bytes_to_int( require(create.get_write_data( create.hex_pDescriptorPool, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, pool) return pool
def expect(self): """Check the arguments to vkCmdUpdateBuffer""" update_buffer = require( self.nth_call_of("vkCmdUpdateBuffer", 1)) require_not_equal(0, update_buffer.int_commandBuffer) require_not_equal(0, update_buffer.int_dstBuffer) require_equal(0, update_buffer.int_dstOffset) require_equal(65536, update_buffer.int_dataSize) require_not_equal(0, update_buffer.hex_pData)
def expect(self): """4. Destroys a null descriptor set layout handle.""" device_properties = require( self.next_call_of("vkGetPhysicalDeviceProperties")) if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200): destroy_descriptor_set_layout = require( self.nth_call_of("vkDestroyDescriptorSetLayout", 4)) require_equal( 0, destroy_descriptor_set_layout.int_descriptorSetLayout)
def get_buffer(test): """Returns the next buffer handle created by vkCreateBuffer.""" create = require(test.next_call_of("vkCreateBuffer")) require_equal(VK_SUCCESS, int(create.return_val)) buf = little_endian_bytes_to_int( require( create.get_write_data(create.hex_pBuffer, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, buf) return buf
def expect(self): architecture = self.architecture cmd_bind_vertex_buffers = require( self.nth_call_of("vkCmdBindIndexBuffer", 2)) require_not_equal(0, cmd_bind_vertex_buffers.int_commandBuffer) require_not_equal(0, cmd_bind_vertex_buffers.int_buffer) require_equal(128 * 2, cmd_bind_vertex_buffers.int_offset) require_equal(VK_INDEX_TYPE_UINT16, cmd_bind_vertex_buffers.int_indexType)
def expect(self): """Expect that the pInheritanceInfo is not null for the second vkBeginCommandBuffer, and that it contains some of the expected data.""" architecture = self.architecture begin_command_buffer = require( self.nth_call_of("vkBeginCommandBuffer", 2)) command_buffer_value = begin_command_buffer.int_commandBuffer require_not_equal(command_buffer_value, 0) # The command buffer begin info struct should start with correct sType # value. begin_info_stype_memory = require( begin_command_buffer.get_read_data( begin_command_buffer.hex_pBeginInfo, architecture.int_integerSize)) require_equal(little_endian_bytes_to_int(begin_info_stype_memory), VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO) # The inheritance info pointer should not be a nullptr. inheritance_info_pointer_memory = require( begin_command_buffer.get_read_data( begin_command_buffer.hex_pBeginInfo + architecture.int_pointerSize * 3, architecture.int_pointerSize)) inheritance_info_addr = little_endian_bytes_to_int( inheritance_info_pointer_memory) require_not_equal(inheritance_info_addr, 0) # The inheritance info struct should start with correct sType value. inheritance_info_stype_memory = require( begin_command_buffer.get_read_data(inheritance_info_addr, architecture.int_integerSize)) require_equal( little_endian_bytes_to_int(inheritance_info_stype_memory), VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO) # The last field of inheritance info struct: pipelineStatistics should # have value 0. # TODO(qining): Add tests for other fields. inheritance_info_pipeline_statistics_memory = require( begin_command_buffer.get_read_data( inheritance_info_addr + architecture.int_pointerSize * 2 + NON_DISPATCHABLE_HANDLE_SIZE * 3 + architecture.int_integerSize * 2, architecture.int_integerSize)) require_equal( little_endian_bytes_to_int( inheritance_info_pipeline_statistics_memory), 0) # vkEndCommandBuffer() returns correctly end_command_buffer = require(self.next_call_of("vkEndCommandBuffer")) require_equal(end_command_buffer.int_commandBuffer, command_buffer_value) require_equal(VK_SUCCESS, int(end_command_buffer.return_val))
def get_descriptor_set(test, index): """Returns the descriptor set handle created by the |index|th (starting from 1) vkAllocateDescriptorSet.""" allocate = require(test.nth_call_of("vkAllocateDescriptorSets", index)) require_equal(VK_SUCCESS, int(allocate.return_val)) d_set = little_endian_bytes_to_int( require( allocate.get_write_data(allocate.hex_pDescriptorSets, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, d_set) return d_set
def expect(self): """The second call to vkCmdSetLineWidth should have line width value: 2.0 """ create_device = self.nth_call_of("vkCreateDevice", 3) if create_device[0] is None: raise GapidUnsupportedException( "physical device feature: wideLine not supported") set_line_width = require(self.nth_call_of("vkCmdSetLineWidth", 1)) require_not_equal(0, set_line_width.int_commandBuffer) require_equal(2.0, set_line_width.float_lineWidth)
def get_sampler(test): """Returns the next VkSampler created in |test|.""" create = require(test.next_call_of("vkCreateSampler")) require_equal(VK_SUCCESS, int(create.return_val)) require_not_equal(0, create.int_device) require_not_equal(0, create.hex_pSampler) sampler = little_endian_bytes_to_int( require( create.get_write_data(create.hex_pSampler, NON_DISPATCHABLE_HANDLE_SIZE))) require_not_equal(0, sampler) return sampler
def expect(self): """3. Expect vkEnumeratePhysicalDevices() to be called first, then vkGetPhysicalDeviceProperties() to be called num_phy_devices times and return physical device properties.""" arch = self.architecture physical_devices = GetPhysicalDevices(self, arch) for pd in physical_devices: get_device_properties = require(self.next_call_of( "vkGetPhysicalDeviceProperties")) require_equal(pd, get_device_properties.int_physicalDevice) require_not_equal(0, get_device_properties.hex_pProperties)