コード例 #1
0
def _cast_ptr2(x, _type):
    if isinstance(x, ffi.CData):
        if (_type.item == ffi.typeof(x) or
            (_type.item.cname == 'void' and ffi.typeof(x).kind in
             ['struct', 'union'])):
            return ffi.addressof(x), x
        return x, x

    if isinstance(x, _collections.Iterable):
        if _type.item.kind == 'pointer':
            ptrs = [_cast_ptr(i, _type.item) for i in x]
            ret = ffi.new(_type.item.cname+'[]', [i for i, _ in ptrs])
            _weakkey_dict[ret] = tuple(i for _, i in ptrs if i != ffi.NULL)
        else:
            ret = ffi.new(_type.item.cname+'[]', x)

        return ret, ret

    return ffi.cast(_type, x), x
コード例 #2
0
comp_shader_spirv = shader_data
comp_shader_spirv_size = len(comp_shader_spirv)

logging.debug('Create shader')

shaderInfo = VkShaderModuleCreateInfo(sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
                                      codeSize = comp_shader_spirv_size,
                                      pCode = comp_shader_spirv
                                     )

p_shader_module = vkCreateShaderModule(device = logical_device, 
                                     pCreateInfo = shaderInfo,   #cffi turns this to pointer?? 
                                     pAllocator = 0
                                    )

shader_main = ffi.new('char[]',b'main')

# Now bind indices to the two buffers for use in shader stage
binding0 = VkDescriptorSetLayoutBinding(binding = 0,
                                        descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
                                        descriptorCount = 1,
                                        stageFlags = VK_SHADER_STAGE_COMPUTE_BIT
                                        )
binding1 = VkDescriptorSetLayoutBinding(binding = 1,
                                        descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
                                        descriptorCount = 1,
                                        stageFlags = VK_SHADER_STAGE_COMPUTE_BIT
                                        )

descriptorInfo = VkDescriptorSetLayoutCreateInfo(sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
                                                 bindingCount = 2,
コード例 #3
0
def vkMapMemory(device, memory, offset, size, flags):
    ppData = ffi.new('void**')
コード例 #4
0
def VK_VERSION_MAJOR(version):
    return version >> 22


def VK_VERSION_MINOR(version):
    return (version >> 12) & 0x3ff


def VK_VERSION_PATCH(version):
    return version & 0xfff


VK_API_VERSION = VK_MAKE_VERSION(1, 0, 0)
VK_API_VERSION_1_0 = VK_MAKE_VERSION(1, 0, 0)
VK_NULL_HANDLE = 0
_UINT64_MAX = ffi.new('unsigned long long int*', 18446744073709551615)
UINT64_MAX = _UINT64_MAX[0]


{# iterate two times to handle dependacy between constants #}
{% for name, value in model.macros.items() %}
{% if value is not string %}
{{name}} = {{value}}
{% elif value is string and not value.startswith('VK_') %}
{{name}} = {{value}}
{% endif %}
{% endfor %}

{% for name, value in model.macros.items() %}
{% if value is string and value.startswith('VK_') %}
{{name}} = {{value}}