mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 15:24:34 +00:00
Reverted back to dispatch table creation function in device type
- Added noexcept modifier to proxys - Change name of header to VkBoostrapDispatch.h
This commit is contained in:
parent
2c0fe72ad9
commit
10d88ae840
@ -19,13 +19,13 @@
|
||||
# This file is a part of VkBootstrap
|
||||
# https://github.com/charles-lunarg/vk-bootstrap
|
||||
|
||||
# On run, vk.xml is pulled from the master of Khronos's Vulkan-Headers repo and a VkDispatchTable type
|
||||
# On run, vk.xml is pulled from the master of Khronos's Vulkan-Headers repo and a VkBoostrapDispatch header
|
||||
# is generated and placed in VkBoostrap's source directory
|
||||
# https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/registry/vk.xml
|
||||
|
||||
# This script makes use of xmltodict
|
||||
# https://github.com/martinblech/xmltodict
|
||||
# The module will be auto-installed if not detected
|
||||
# User will be prompted to install if not detected
|
||||
|
||||
# Exclusions
|
||||
exclusions = [
|
||||
@ -44,6 +44,7 @@ from string import Template
|
||||
installed = {pkg.key for pkg in pkg_resources.working_set}
|
||||
xmltodict_missing = {'xmltodict'} - installed
|
||||
|
||||
# Install xmltodict
|
||||
if xmltodict_missing:
|
||||
val = input("xmltodict is required to run this script. Would you like to install? (y/n): ");
|
||||
if(val.lower() == "y"):
|
||||
@ -199,7 +200,7 @@ proxy_section = ''
|
||||
fp_decl_section = ''
|
||||
pfn_load_section = ''
|
||||
|
||||
proxy_template = Template('\t$return_type $proxy_name($args_full) const {\n\t\t$opt_return$fp_name($args_names);\n\t}\n')
|
||||
proxy_template = Template('\t$return_type $proxy_name($args_full) const noexcept {\n\t\t$opt_return$fp_name($args_names);\n\t}\n')
|
||||
fp_decl_template = Template('\t$pfn_name $fp_name = nullptr;\n')
|
||||
pfn_load_template = Template('\t\t$fp_name = ($pfn_name)procAddr(device, "$command_name");\n')
|
||||
|
||||
@ -286,7 +287,7 @@ body += '} // namespace vkb'
|
||||
|
||||
header = license + info + body
|
||||
|
||||
header_file = open("../src/VkDispatchTable.h", "w")
|
||||
header_file = open("../src/VkBootstrapDispatch.h", "w")
|
||||
header_file.write(header)
|
||||
header_file.close();
|
||||
|
||||
|
@ -1374,6 +1374,12 @@ detail::Result<VkQueue> Device::get_dedicated_queue(QueueType type) const {
|
||||
return detail::get_queue(device, index.value());
|
||||
}
|
||||
|
||||
// ---- Dispatch ---- //
|
||||
|
||||
DispatchTable Device::make_table() const {
|
||||
return {device, fp_vkGetDeviceProcAddr};
|
||||
}
|
||||
|
||||
// ---- Device ---- //
|
||||
|
||||
CustomQueueDescription::CustomQueueDescription(uint32_t index, uint32_t count, std::vector<float> priorities)
|
||||
@ -1478,9 +1484,6 @@ detail::Result<Device> DeviceBuilder::build() const {
|
||||
device.queue_families = physical_device.queue_families;
|
||||
device.allocation_callbacks = info.allocation_callbacks;
|
||||
device.fp_vkGetDeviceProcAddr = detail::vulkan_functions().fp_vkGetDeviceProcAddr;
|
||||
if(info.load_dispatch) {
|
||||
device.dispatch = DispatchTable(device.device, device.fp_vkGetDeviceProcAddr);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
DeviceBuilder& DeviceBuilder::custom_queue_setup(std::vector<CustomQueueDescription> queue_descriptions) {
|
||||
@ -1491,10 +1494,6 @@ DeviceBuilder& DeviceBuilder::set_allocation_callbacks(VkAllocationCallbacks* ca
|
||||
info.allocation_callbacks = callbacks;
|
||||
return *this;
|
||||
}
|
||||
DeviceBuilder& DeviceBuilder::populate_dispatch_table() {
|
||||
info.load_dispatch = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---- Swapchain ---- //
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "VkDispatchTable.h"
|
||||
#include "VkBootstrapDispatch.h"
|
||||
|
||||
namespace vkb {
|
||||
|
||||
@ -543,7 +543,6 @@ struct Device {
|
||||
std::vector<VkQueueFamilyProperties> queue_families;
|
||||
VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE;
|
||||
PFN_vkGetDeviceProcAddr fp_vkGetDeviceProcAddr = nullptr;
|
||||
DispatchTable dispatch;
|
||||
|
||||
detail::Result<uint32_t> get_queue_index(QueueType type) const;
|
||||
// Only a compute or transfer queue type is valid. All other queue types do not support a 'dedicated' queue index
|
||||
@ -552,6 +551,9 @@ struct Device {
|
||||
detail::Result<VkQueue> get_queue(QueueType type) const;
|
||||
// Only a compute or transfer queue type is valid. All other queue types do not support a 'dedicated' queue
|
||||
detail::Result<VkQueue> get_dedicated_queue(QueueType type) const;
|
||||
|
||||
// Return a loaded dispatch table
|
||||
DispatchTable make_table() const;
|
||||
};
|
||||
|
||||
// For advanced device queue setup
|
||||
@ -585,8 +587,6 @@ class DeviceBuilder {
|
||||
// Provide custom allocation callbacks.
|
||||
DeviceBuilder& set_allocation_callbacks(VkAllocationCallbacks* callbacks);
|
||||
|
||||
// Populate dispatch table for the device
|
||||
DeviceBuilder& populate_dispatch_table();
|
||||
private:
|
||||
PhysicalDevice physical_device;
|
||||
struct DeviceInfo {
|
||||
@ -594,7 +594,6 @@ class DeviceBuilder {
|
||||
std::vector<VkBaseOutStructure*> pNext_chain;
|
||||
std::vector<CustomQueueDescription> queue_descriptions;
|
||||
VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE;
|
||||
bool load_dispatch = false;
|
||||
} info;
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -200,19 +200,19 @@ TEST_CASE("Loading Dispatch Table", "[VkBootstrap.bootstrap]") {
|
||||
REQUIRE(phys_dev_ret.has_value());
|
||||
|
||||
vkb::DeviceBuilder device_builder(phys_dev_ret.value());
|
||||
auto device_ret = device_builder.populate_dispatch_table().build();
|
||||
auto device_ret = device_builder.build();
|
||||
REQUIRE(device_ret.has_value());
|
||||
auto device = device_ret.value();
|
||||
auto dispatch_table = device_ret.value().make_table();
|
||||
|
||||
// Create a basic Device specific type to test with
|
||||
VkFenceCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
|
||||
VkFence fence = VK_NULL_HANDLE;
|
||||
device.dispatch.createFence(&info, nullptr, &fence);
|
||||
dispatch_table.createFence(&info, nullptr, &fence);
|
||||
REQUIRE(fence != VK_NULL_HANDLE);
|
||||
|
||||
device.dispatch.destroyFence(fence, nullptr);
|
||||
dispatch_table.destroyFence(fence, nullptr);
|
||||
vkb::destroy_device(device_ret.value());
|
||||
}
|
||||
vkb::destroy_instance(instance_ret.value());
|
||||
|
Loading…
Reference in New Issue
Block a user