device->rad_info.family == CHIP_RAVEN;
radv_physical_device_init_mem_types(device);
+ radv_fill_device_extension_table(device, &device->supported_extensions);
result = radv_init_wsi(device);
if (result != VK_SUCCESS) {
return VK_SUCCESS;
}
+bool
+radv_instance_extension_supported(const char *name)
+{
+ for (unsigned i = 0; i < RADV_INSTANCE_EXTENSION_COUNT; ++i) {
+ if (strcmp(name, radv_instance_extensions[i].extensionName) == 0)
+ return radv_supported_instance_extensions.extensions[i];
+ }
+ return false;
+}
+
+VkResult radv_EnumerateInstanceExtensionProperties(
+ const char* pLayerName,
+ uint32_t* pPropertyCount,
+ VkExtensionProperties* pProperties)
+{
+ VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
+
+ for (int i = 0; i < RADV_INSTANCE_EXTENSION_COUNT; i++) {
+ if (radv_supported_instance_extensions.extensions[i]) {
+ vk_outarray_append(&out, prop) {
+ *prop = radv_instance_extensions[i];
+ }
+ }
+ }
+
+ return vk_outarray_status(&out);
+}
+
+bool
+radv_physical_device_extension_supported(struct radv_physical_device *device,
+ const char *name)
+{
+ for (unsigned i = 0; i < RADV_DEVICE_EXTENSION_COUNT; ++i) {
+ if (strcmp(name, radv_device_extensions[i].extensionName) == 0)
+ return device->supported_extensions.extensions[i];
+ }
+ return false;
+}
+
+VkResult radv_EnumerateDeviceExtensionProperties(
+ VkPhysicalDevice physicalDevice,
+ const char* pLayerName,
+ uint32_t* pPropertyCount,
+ VkExtensionProperties* pProperties)
+{
+ RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
+ VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
+
+ for (int i = 0; i < RADV_DEVICE_EXTENSION_COUNT; i++) {
+ if (device->supported_extensions.extensions[i]) {
+ vk_outarray_append(&out, prop) {
+ *prop = radv_device_extensions[i];
+ }
+ }
+ }
+
+ return vk_outarray_status(&out);
+}
+
PFN_vkVoidFunction radv_GetInstanceProcAddr(
VkInstance instance,
const char* pName)
ext = ext_name_map[ext_name]
ext.type = ext_elem.attrib['type']
-_TEMPLATE = Template(COPYRIGHT + """
+_TEMPLATE_H = Template(COPYRIGHT + """
+#ifndef RADV_EXTENSIONS_H
+#define RADV_EXTENSIONS_H
+
+enum {
+ RADV_INSTANCE_EXTENSION_COUNT = ${len(instance_extensions)},
+ RADV_DEVICE_EXTENSION_COUNT = ${len(device_extensions)},
+};
+
+struct radv_instance_extension_table {
+ union {
+ bool extensions[RADV_INSTANCE_EXTENSION_COUNT];
+ struct {
+%for ext in instance_extensions:
+ bool ${ext.name[3:]};
+%endfor
+ };
+ };
+};
+
+struct radv_device_extension_table {
+ union {
+ bool extensions[RADV_DEVICE_EXTENSION_COUNT];
+ struct {
+%for ext in device_extensions:
+ bool ${ext.name[3:]};
+%endfor
+ };
+ };
+};
+
+const VkExtensionProperties radv_instance_extensions[RADV_INSTANCE_EXTENSION_COUNT];
+const VkExtensionProperties radv_device_extensions[RADV_DEVICE_EXTENSION_COUNT];
+const struct radv_instance_extension_table radv_supported_instance_extensions;
+
+
+struct radv_physical_device;
+
+void radv_fill_device_extension_table(const struct radv_physical_device *device,
+ struct radv_device_extension_table* table);
+#endif
+""")
+
+_TEMPLATE_C = Template(COPYRIGHT + """
#include "radv_private.h"
#include "vk_util.h"
VK_USE_PLATFORM_XCB_KHR || \\
VK_USE_PLATFORM_XLIB_KHR)
-bool
-radv_instance_extension_supported(const char *name)
-{
+const VkExtensionProperties radv_instance_extensions[RADV_INSTANCE_EXTENSION_COUNT] = {
%for ext in instance_extensions:
- if (strcmp(name, "${ext.name}") == 0)
- return ${ext.enable};
+ {"${ext.name}", ${ext.ext_version}},
%endfor
- return false;
-}
+};
-VkResult radv_EnumerateInstanceExtensionProperties(
- const char* pLayerName,
- uint32_t* pPropertyCount,
- VkExtensionProperties* pProperties)
-{
- VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
+const VkExtensionProperties radv_device_extensions[RADV_DEVICE_EXTENSION_COUNT] = {
+%for ext in device_extensions:
+ {"${ext.name}", ${ext.ext_version}},
+%endfor
+};
+const struct radv_instance_extension_table radv_supported_instance_extensions = {
%for ext in instance_extensions:
- if (${ext.enable}) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "${ext.name}",
- .specVersion = ${ext.ext_version},
- };
- }
- }
+ .${ext.name[3:]} = ${ext.enable},
%endfor
+};
- return vk_outarray_status(&out);
-}
-
-uint32_t
-radv_physical_device_api_version(struct radv_physical_device *dev)
-{
- return ${MAX_API_VERSION.c_vk_version()};
-}
-
-bool
-radv_physical_device_extension_supported(struct radv_physical_device *device,
- const char *name)
+void radv_fill_device_extension_table(const struct radv_physical_device *device,
+ struct radv_device_extension_table* table)
{
%for ext in device_extensions:
- if (strcmp(name, "${ext.name}") == 0)
- return ${ext.enable};
+ table->${ext.name[3:]} = ${ext.enable};
%endfor
- return false;
}
-VkResult radv_EnumerateDeviceExtensionProperties(
- VkPhysicalDevice physicalDevice,
- const char* pLayerName,
- uint32_t* pPropertyCount,
- VkExtensionProperties* pProperties)
+uint32_t
+radv_physical_device_api_version(struct radv_physical_device *dev)
{
- RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
- VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
- (void)device;
-
-%for ext in device_extensions:
- if (${ext.enable}) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "${ext.name}",
- .specVersion = ${ext.ext_version},
- };
- }
- }
-%endfor
-
- return vk_outarray_status(&out);
+ return ${MAX_API_VERSION.c_vk_version()};
}
""")
if __name__ == '__main__':
parser = argparse.ArgumentParser()
- parser.add_argument('--out', help='Output C file.', required=True)
+ parser.add_argument('--out-c', help='Output C file.', required=True)
+ parser.add_argument('--out-h', help='Output H file.', required=True)
parser.add_argument('--xml',
help='Vulkan API XML file.',
required=True,
'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
}
- with open(args.out, 'w') as f:
- f.write(_TEMPLATE.render(**template_env))
+ with open(args.out_c, 'w') as f:
+ f.write(_TEMPLATE_C.render(**template_env))
+ with open(args.out_h, 'w') as f:
+ f.write(_TEMPLATE_H.render(**template_env))