def expect(self):
        architecture = self.architecture
        device_properties = require(
            self.next_call_of("vkGetPhysicalDeviceProperties"))

        createSwapchain = require(self.next_call_of("vkCreateSwapchainKHR"))
        destroySwapchain = require(self.next_call_of("vkDestroySwapchainKHR"))

        def get_swapchain_create_info_member(offset, size):
            return little_endian_bytes_to_int(
                require(
                    createSwapchain.get_read_data(
                        createSwapchain.hex_pCreateInfo + offset, size)))

        swapchain_create_info = VulkanStruct(
            architecture,
            [
                ("sType", UINT32_T),
                ("pNext", POINTER),
                ("flags", UINT32_T),
                ("surface", HANDLE),
                ("minImageCount", UINT32_T),
                ("imageFormat", UINT32_T),
                ("imageColorSpace", UINT32_T),
                ("extent.width", UINT32_T),
                ("extent.height", UINT32_T),
                ("imageArrayLayers", UINT32_T),
                ("imageUsage", UINT32_T),
                ("imageSharingMode", UINT32_T),
                ("queueFamilyIndexCount", UINT32_T),
                ("queueFamilyIndices", POINTER),
                ("preTransform", UINT32_T),
                ("compositeAlpha", UINT32_T),
                ("presentMode", UINT32_T),
                ("clipped", UINT32_T),
                ("oldSwapchain", HANDLE)  # oldSwapchain
            ],
            get_swapchain_create_info_member)

        require_equal(swapchain_create_info.sType,
                      VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR)

        require_equal(swapchain_create_info.oldSwapchain, 0)
        require_equal(swapchain_create_info.clipped, 0)
        require_equal(swapchain_create_info.imageArrayLayers, 1)
        require_not_equal(0, destroySwapchain.int_swapchain)
        require_equal(True,
                      (swapchain_create_info.queueFamilyIndexCount == 0
                       or swapchain_create_info.queueFamilyIndexCount == 2))

        # Our second vkDestroySwapchain should have been called with
        # VK_NULL_HANDLE.
        if (self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200)
                and self.not_android_version("7.1.1")):
            destroySwapchain = require(
                self.next_call_of("vkDestroySwapchainKHR"))
            require_equal(0, destroySwapchain.int_swapchain)
    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)

        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)
Example #3
0
    def expect(self):
        """Check the arguments and the VkMappedMemoryRange structs used in
        vkFlushMappedMemoryRanges(). The flushed memory starts at offset 768 and
        has size 256"""
        MAP_OFFSET = 512
        FLUSH_OFFSET = MAP_OFFSET + 256
        FLUSH_SIZE = 256
        MEMORY_DATA = [("data", ARRAY, FLUSH_SIZE, CHAR)]
        EXPECTED_MEMORY_DATA = [i for i in range(FLUSH_SIZE)]

        architecture = self.architecture
        # The first and second vkMapMemory() result is managed in
        # VulkanApplication and is not used here, the third is the one we need
        # here.
        map_memory = require(self.nth_call_of("vkMapMemory", 3))
        require_not_equal(0, map_memory.hex_ppData)
        # The flushed data starts at mapped offset + 256
        flushed_data_ptr = little_endian_bytes_to_int(require(
            map_memory.get_write_data(map_memory.hex_ppData,
                                      architecture.int_sizeSize))) + 256

        # Check arguments
        flush_mapped_memory_ranges = require(self.nth_call_of(
            "vkFlushMappedMemoryRanges", 1))
        require_equal(1, flush_mapped_memory_ranges.int_memoryRangeCount)
        require_not_equal(0, flush_mapped_memory_ranges.hex_pMemoryRanges)

        # Check the memory range struct content
        mapped_memory_range = VulkanStruct(
            architecture, MAPPED_MEMORY_RANGE, get_read_offset_function(
                flush_mapped_memory_ranges,
                flush_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(FLUSH_OFFSET, mapped_memory_range.offset)
        require_equal(FLUSH_SIZE, mapped_memory_range.size)

        # check the flushed memory data
        memory_data = VulkanStruct(
            architecture, MEMORY_DATA, get_read_offset_function(
                flush_mapped_memory_ranges, flushed_data_ptr))
        require_equal(EXPECTED_MEMORY_DATA, memory_data.data)
Example #4
0
    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 get_image_view_create_info(create_image_view, architecture):
    """Returns a VulkanStruct which is built to represent the image view create
    info struct used in the given create image view command."""

    def get_data(offset, size):
        return little_endian_bytes_to_int(require(
            create_image_view.get_read_data(create_image_view.hex_pCreateInfo +
                                            offset, size)))

    return VulkanStruct(architecture, IMAGE_VIEW_CREATE_INFO_ELEMENTS, get_data)
def get_pool_size(create_descriptor_pool, architecture, create_info, index):
    """Returns a VulkanStruct representing the VkDescriptorPoolSize struct."""
    pool_size_offset = (create_info.pPoolSizes +
                        # (4 + 4) is the size of a VkDescriptorPoolSize struct.
                        index * (4 + 4))
    return VulkanStruct(
        architecture, DESCRIPTOR_POOL_SIZE_ELEMENTS,
        lambda offset, size: little_endian_bytes_to_int(require(
            create_descriptor_pool.get_read_data(
                pool_size_offset + offset, size))))
Example #7
0
    def expect(self):
        """2. Expects a command pool created with
        VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, then reseted with flag
        of value 0, and finally destroyed"""

        architecture = self.architecture
        create_command_pool = require(
            self.nth_call_of("vkCreateCommandPool", 2))
        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_RESET_COMMAND_BUFFER_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)

        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(0, 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 get_descriptor_set_layout_create_info(create_descriptor_set_layout,
                                          architecture):
    """Returns a VulkanStruct representing the VkDescriptorSetLayoutCreateInfo
    struct used in the given |create_descriptor_set_layout| command."""
    return VulkanStruct(
        architecture, DESCRIPTOR_SET_LAYOUT_CREATE_INFO_ELEMENTS,
        lambda offset, size: little_endian_bytes_to_int(
            require(
                create_descriptor_set_layout.get_read_data(
                    create_descriptor_set_layout.hex_pCreateInfo + offset, size
                ))))
    def expect(self):
        architecture = self.architecture

        create_render_pass = require(self.nth_call_of("vkCreateRenderPass", 1))
        destroy_render_pass = require(self.next_call_of("vkDestroyRenderPass"))

        render_pass_create_info = VulkanStruct(
            architecture, RENDER_PASS_CREATE_INFO,
            get_read_offset_function(create_render_pass,
                                     create_render_pass.hex_pCreateInfo))

        subpass_info = VulkanStruct(
            architecture, SUBPASS_DESCRIPTION,
            get_read_offset_function(create_render_pass,
                                     render_pass_create_info.pSubpasses))

        require_equal(VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
                      render_pass_create_info.sType)
        require_equal(0, render_pass_create_info.pNext)
        require_equal(0, render_pass_create_info.flags)
        require_equal(0, render_pass_create_info.attachmentCount)
        require_equal(0, render_pass_create_info.pAttachments)
        require_equal(1, render_pass_create_info.subpassCount)
        require_not_equal(0, render_pass_create_info.pSubpasses)
        require_equal(0, render_pass_create_info.dependencyCount)
        require_equal(0, render_pass_create_info.pDependencies)

        require_equal(0, subpass_info.flags)
        require_equal(VK_PIPELINE_BIND_POINT_GRAPHICS,
                      subpass_info.pipelineBindPoint)
        require_equal(0, subpass_info.inputAttachmentCount)
        require_equal(0, subpass_info.pInputAttachments)
        require_equal(0, subpass_info.colorAttachmentCount)
        require_equal(0, subpass_info.pColorAttachments)
        require_equal(0, subpass_info.pResolveAttachments)
        require_equal(0, subpass_info.pDepthStencilAttachment)
        require_equal(0, subpass_info.preserveAttachmentCount)
        require_equal(0, subpass_info.pPreserveAttachments)

        require_not_equal(0, destroy_render_pass.int_renderPass)
        require_not_equal(0, destroy_render_pass.int_device)
Example #10
0
    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_equal(0, layout.offset)
        require_equal(4 * 32 * 32, layout.size)
        require_equal(4 * 32, layout.rowPitch)
        require_equal(4 * 32 * 32, layout.arrayPitch)
        require_equal(4 * 32 * 32, layout.depthPitch)
Example #11
0
def get_buffer_info(update_atom, architecture, base, count):
    """Returns |count| VulkanStructs representing the VkDescriptorBufferInfo
    structs used in the VkWriteDescriptorSet parameter of the given
    |update_atom| atom."""
    infos = [
        VulkanStruct(
            architecture, DESCRIPTOR_BUFFER_INFO_ELEMENTS,
            lambda offset, size: little_endian_bytes_to_int(
                require(update_atom.get_read_data(base + offset, size))))
    ]
    buffer_info_size = infos[-1].total_size

    for i in range(1, count):
        infos.append(
            VulkanStruct(
                architecture, DESCRIPTOR_BUFFER_INFO_ELEMENTS,
                lambda offset, size: little_endian_bytes_to_int(
                    require(
                        update_atom.get_read_data(
                            base + i * buffer_info_size + offset, size)))))
    return infos
 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))
Example #13
0
def get_write_descriptor_set(update_atom, architecture, count):
    """Returns |count| VulkanStructs representing the VkWriteDescriptorSet
    structs used in the given |update_atom| atom."""
    writes = [
        VulkanStruct(
            architecture, WRITE_DESCRIPTOR_SET_ELEMENTS,
            lambda offset, size: little_endian_bytes_to_int(
                require(
                    update_atom.get_read_data(
                        update_atom.hex_pDescriptorWrites + offset, size))))
    ]
    struct_size = writes[-1].total_size
    for i in range(1, count):
        writes.append(
            VulkanStruct(
                architecture, WRITE_DESCRIPTOR_SET_ELEMENTS,
                lambda offset, size: little_endian_bytes_to_int(
                    require(
                        update_atom.get_read_data(
                            (update_atom.hex_pDescriptorWrites + i *
                             struct_size + offset), size)))))
    return writes
    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)
Example #15
0
    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)

        if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200):
            free_memory = require(self.next_call_of("vkFreeMemory"))
            require_not_equal(0, free_memory.int_device)
            require_equal(0, free_memory.int_memory)
    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", 1))
        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"))
        # Check the header
        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"))

        if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200):
            destroy_pipeline_cache = require(
                self.next_call_of("vkDestroyPipelineCache"))
            require_not_equal(0, destroy_pipeline_cache.int_device)
            require_equal(0, destroy_pipeline_cache.int_pipelineCache)
Example #17
0
    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
        set_scissor = require(self.next_call_of("vkCmdSetScissor"))

        require_not_equal(0, set_scissor.int_commandBuffer)
        require_equal(0, set_scissor.int_firstScissor)
        require_equal(1, set_scissor.int_scissorCount)
        require_not_equal(0, set_scissor.hex_pScissors)

        scissor = VulkanStruct(
            architecture, RECT2D,
            get_read_offset_function(set_scissor, set_scissor.hex_pScissors))
        require_equal(0, scissor.offset_x)
        require_equal(0, scissor.offset_x)
        require_not_equal(0, scissor.extent_width)
        require_not_equal(0, scissor.extent_width)
def GetCreatedEvent(architecture, create_event):
    require_equal(VK_SUCCESS, int(create_event.return_val))
    require_not_equal(0, create_event.int_device)
    require_not_equal(0, create_event.hex_pCreateInfo)
    require_not_equal(0, create_event.hex_pEvent)

    create_info = VulkanStruct(architecture, EVENT_CREATE_INFO,
                               get_read_offset_function(
                                   create_event, create_event.hex_pCreateInfo))
    require_equal(VK_STRUCTURE_TYPE_EVENT_CREATE_INFO, create_info.sType)
    require_equal(0, create_info.pNext)
    require_equal(0, create_info.flags)

    event = little_endian_bytes_to_int(require(create_event.get_write_data(
        create_event.hex_pEvent, NON_DISPATCHABLE_HANDLE_SIZE)))
    return event
Example #20
0
    def expect(self):
        architecture = self.architecture
        cmd_copy_buffer = require(self.next_call_of("vkCmdCopyBuffer"))

        require_not_equal(0, cmd_copy_buffer.int_commandBuffer)
        require_not_equal(0, cmd_copy_buffer.int_srcBuffer)
        require_not_equal(0, cmd_copy_buffer.int_dstBuffer)
        require_equal(1, cmd_copy_buffer.int_regionCount)
        require_not_equal(0, cmd_copy_buffer.hex_pRegions)

        copy = VulkanStruct(
            architecture, BUFFER_COPY,
            get_read_offset_function(cmd_copy_buffer,
                                     cmd_copy_buffer.hex_pRegions))
        require_equal(0, copy.srcOffset)
        require_equal(0, copy.dstOffset)
        require_equal(1024, copy.size)
Example #21
0
    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)
Example #22
0
    def expect(self):
        architecture = self.architecture
        device_properties = require(
            self.next_call_of("vkGetPhysicalDeviceProperties"))

        create_framebuffer = require(self.next_call_of("vkCreateFramebuffer"))
        require_not_equal(0, create_framebuffer.int_device)
        require_equal(0, create_framebuffer.hex_pAllocator)

        framebuffer_create_info = VulkanStruct(
            architecture, FRAMEBUFFER_CREATE_INFO,
            get_read_offset_function(create_framebuffer,
                                     create_framebuffer.hex_pCreateInfo))
        require_equal(VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
                      framebuffer_create_info.sType)
        require_equal(0, framebuffer_create_info.pNext)
        require_equal(0, framebuffer_create_info.flags)
        require_not_equal(0, framebuffer_create_info.renderPass)
        require_equal(1, framebuffer_create_info.attachmentCount)
        require_not_equal(0, framebuffer_create_info.pAttachments)
        require_not_equal(0, framebuffer_create_info.width)
        require_not_equal(0, framebuffer_create_info.height)
        require_equal(1, framebuffer_create_info.layers)

        _ = require(
            create_framebuffer.get_read_data(
                framebuffer_create_info.pAttachments,
                NON_DISPATCHABLE_HANDLE_SIZE))
        _ = require(
            create_framebuffer.get_write_data(
                create_framebuffer.hex_pFramebuffer,
                NON_DISPATCHABLE_HANDLE_SIZE))

        destroy_framebuffer = require(
            self.next_call_of("vkDestroyFramebuffer"))
        require_not_equal(0, destroy_framebuffer.int_framebuffer)
        require_not_equal(0, destroy_framebuffer.int_device)
        require_equal(0, destroy_framebuffer.hex_pAllocator)

        if self.not_device(device_properties, 0x5BCE4000, NVIDIA_K2200):
            destroy_framebuffer = require(
                self.next_call_of("vkDestroyFramebuffer"))
            require_equal(0, destroy_framebuffer.int_framebuffer)
            require_not_equal(0, destroy_framebuffer.int_device)
            require_equal(0, destroy_framebuffer.hex_pAllocator)
def get_binding(create_descriptor_set_layout, architecture, create_info,
                index):
    """Returns a VulkanStruct representing the |index|'th (starting from 0)
    VkDescriptorSetLayoutBinding struct baked in |create_info| for the
    |create_descriptor_set_layout| atom."""
    binding_offset = create_info.pBindings + index * (
        # Ok, this is a little bit tricky. We have 4 32-bit integers and a
        # pointer in VkDescriptorSetLayoutBinding struct. On 32-bit
        # architecture, pointer size is 4, so alignement should be fine.
        # On 64-bit architecture, pointer size is 8, the struct totally
        # occupies (4 * 4 + 8) bytes, so alignment should also be fine.
        4 * 4 + int(architecture.int_pointerSize))
    return VulkanStruct(
        architecture, BINDING_ELEMENTS,
        lambda offset, size: little_endian_bytes_to_int(
            require(
                create_descriptor_set_layout.get_read_data(
                    binding_offset + offset, size))))
    def expect(self):
        architecture = self.architecture
        set_viewport = require(self.next_call_of("vkCmdSetViewport"))

        require_not_equal(0, set_viewport.int_commandBuffer)
        require_equal(0, set_viewport.int_firstViewport)
        require_equal(1, set_viewport.int_viewportCount)
        require_not_equal(0, set_viewport.hex_pViewports)

        viewport = VulkanStruct(
            architecture, VIEWPORT,
            get_read_offset_function(set_viewport, set_viewport.hex_pViewports))
        require_equal(0.0, viewport.x)
        require_equal(0.0, viewport.y)
        require_not_equal(0.0, viewport.width)
        require_not_equal(0.0, viewport.height)
        require_equal(0.0, viewport.minDepth)
        require_equal(1.0, viewport.maxDepth)
Example #25
0
    def expect(self):
        """Check the arguments to vkCmdCopyImage"""
        architecture = self.architecture
        create_device = self.nth_call_of("vkCreateDevice", 2)
        if create_device[0] is None:
            raise GapidUnsupportedException(
                "physical device feature: textureCompressionBC not supported")

        copy_image = require(self.next_call_of("vkCmdCopyImage"))

        require_not_equal(0, copy_image.int_commandBuffer)
        require_not_equal(0, copy_image.int_srcImage)
        require_equal(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
                      copy_image.int_srcImageLayout)
        require_not_equal(0, copy_image.int_dstImage)
        require_equal(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
                      copy_image.int_dstImageLayout)
        require_equal(1, copy_image.int_regionCount)

        image_copy = VulkanStruct(
            architecture, IMAGE_COPY,
            get_read_offset_function(copy_image, copy_image.hex_pRegions))

        require_equal(VK_IMAGE_ASPECT_COLOR_BIT,
                      image_copy.srcSubresource_aspectMask)
        require_equal(0, image_copy.srcSubresource_mipLevel)
        require_equal(0, image_copy.srcSubresource_baseArrayLayer)
        require_equal(1, image_copy.srcSubresource_layerCount)
        require_equal(8, image_copy.srcOffset_x)
        require_equal(12, image_copy.srcOffset_y)
        require_equal(0, image_copy.srcOffset_z)
        require_equal(VK_IMAGE_ASPECT_COLOR_BIT,
                      image_copy.dstSubresource_aspectMask)
        require_equal(0, image_copy.dstSubresource_mipLevel)
        require_equal(0, image_copy.dstSubresource_baseArrayLayer)
        require_equal(1, image_copy.dstSubresource_layerCount)
        require_equal(16, image_copy.dstOffset_x)
        require_equal(16, image_copy.dstOffset_y)
        require_equal(0, image_copy.dstOffset_z)
        require_equal(16, image_copy.extent_x)
        require_equal(12, image_copy.extent_y)
        require_equal(1, image_copy.extent_z)
    def expect(self):
        architecture = self.architecture
        create_pipeline = require(self.nth_call_of("vkCreatePipelineLayout",
                                                   2))

        require_not_equal(0, create_pipeline.int_device)
        require_not_equal(0, create_pipeline.hex_pCreateInfo)
        require_equal(0, create_pipeline.hex_pAllocator)
        require_not_equal(0, create_pipeline.hex_pPipelineLayout)

        created_pipeline = little_endian_bytes_to_int(
            require(
                create_pipeline.get_write_data(
                    create_pipeline.hex_pPipelineLayout,
                    NON_DISPATCHABLE_HANDLE_SIZE)))

        pipeline_layout_create_info = VulkanStruct(
            architecture, PIPELINE_LAYOUT_CREATE_INFO,
            get_read_offset_function(create_pipeline,
                                     create_pipeline.hex_pCreateInfo))

        require_equal(VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
                      pipeline_layout_create_info.sType)
        require_equal(0, pipeline_layout_create_info.pNext)
        require_equal(0, pipeline_layout_create_info.flags)
        require_equal(1, pipeline_layout_create_info.setLayoutCount)
        require_not_equal(0, pipeline_layout_create_info.pSetLayouts)
        require_equal(0, pipeline_layout_create_info.pushConstantRangeCount)
        require_equal(0, pipeline_layout_create_info.pPushConstantRanges)

        set_layout = little_endian_bytes_to_int(
            require(
                create_pipeline.get_read_data(
                    pipeline_layout_create_info.pSetLayouts,
                    NON_DISPATCHABLE_HANDLE_SIZE)))
        require_not_equal(VK_NULL_HANDLE, set_layout)

        destroy_pipeline = require(
            self.next_call_of("vkDestroyPipelineLayout"))
        require_equal(created_pipeline, destroy_pipeline.int_pipelineLayout)
        require_equal(create_pipeline.int_device, destroy_pipeline.int_device)
        require_equal(0, destroy_pipeline.hex_pAllocator)
    def expect(self):
        """Check the arguments and data to vkCmdPushConstants"""
        architecture = self.architecture
        push_constants = require(self.nth_call_of("vkCmdPushConstants", 1))

        require_not_equal(0, push_constants.int_commandBuffer)
        require_not_equal(0, push_constants.int_layout)
        require_equal(VK_SHADER_STAGE_VERTEX_BIT,
                      push_constants.int_stageFlags)
        require_equal(0, push_constants.int_offset)
        require_equal(100, push_constants.int_size)
        require_not_equal(0, push_constants.hex_pValues)

        CHAR_ARRAY_100 = [("values", ARRAY, 100, CHAR)]
        data = VulkanStruct(
            architecture, CHAR_ARRAY_100,
            get_read_offset_function(push_constants,
                                     push_constants.hex_pValues))
        expected_data = [0xab for i in range(100)]
        require_equal(expected_data, data.values)
    def expect(self):
        """Check the arguments to vkCmdBlitImage"""
        architecture = self.architecture
        blit_image = require(self.nth_call_of("vkCmdBlitImage", 1))

        require_not_equal(0, blit_image.int_commandBuffer)
        require_not_equal(0, blit_image.int_srcImage)
        require_equal(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
                      blit_image.int_srcImageLayout)
        require_not_equal(0, blit_image.int_dstImage)
        require_equal(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
                      blit_image.int_dstImageLayout)
        require_equal(1, blit_image.int_regionCount)
        require_equal(VK_FILTER_LINEAR, blit_image.int_filter)

        image_blit = VulkanStruct(architecture, IMAGE_BLIT,
                                  get_read_offset_function(
                                      blit_image, blit_image.hex_pRegions))

        require_equal(VK_IMAGE_ASPECT_COLOR_BIT,
                      image_blit.srcSubresource_aspectMask)
        require_equal(0, image_blit.srcSubresource_mipLevel)
        require_equal(0, image_blit.srcSubresource_baseArrayLayer)
        require_equal(1, image_blit.srcSubresource_layerCount)
        require_equal(0, image_blit.srcOffset_0_x)
        require_equal(0, image_blit.srcOffset_0_y)
        require_equal(0, image_blit.srcOffset_0_z)
        require_equal(32, image_blit.srcOffset_1_x)
        require_equal(32, image_blit.srcOffset_1_y)
        require_equal(1, image_blit.srcOffset_1_z)
        require_equal(VK_IMAGE_ASPECT_COLOR_BIT,
                      image_blit.dstSubresource_aspectMask)
        require_equal(0, image_blit.dstSubresource_mipLevel)
        require_equal(0, image_blit.dstSubresource_baseArrayLayer)
        require_equal(1, image_blit.dstSubresource_layerCount)
        require_equal(0, image_blit.dstOffset_0_x)
        require_equal(0, image_blit.dstOffset_0_y)
        require_equal(0, image_blit.dstOffset_0_z)
        require_equal(32, image_blit.dstOffset_1_x)
        require_equal(32, image_blit.dstOffset_1_y)
        require_equal(1, image_blit.dstOffset_1_z)
Example #29
0
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):
        num_queries = 4
        result_width = 4

        architecture = self.architecture
        get_query_result = require(self.nth_call_of("vkGetQueryPoolResults", 1))

        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 * result_width, 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(0, get_query_result.int_flags)
        require_equal(VK_SUCCESS, int(get_query_result.return_val))

        result_data = VulkanStruct(
            architecture, [("data", ARRAY, num_queries, UINT32_T)],
            get_write_offset_function(get_query_result,
                                      get_query_result.hex_pData))
        require_equal([0 for i in range(num_queries)], result_data.data)