Reformatted
This commit is contained in:
parent
49b436f490
commit
93041b4519
14 changed files with 133 additions and 127 deletions
|
|
@ -34,7 +34,8 @@ Manager::~Manager()
|
|||
SPDLOG_DEBUG("Kompute Manager Destructor started");
|
||||
|
||||
if (this->mDevice == nullptr) {
|
||||
spdlog::error("Kompute Manager destructor reached with null Device pointer");
|
||||
spdlog::error(
|
||||
"Kompute Manager destructor reached with null Device pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +46,8 @@ Manager::~Manager()
|
|||
}
|
||||
|
||||
if (this->mInstance == nullptr) {
|
||||
spdlog::error("Kompute Manager destructor reached with null Instance pointer");
|
||||
spdlog::error(
|
||||
"Kompute Manager destructor reached with null Instance pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +65,9 @@ Manager::~Manager()
|
|||
}
|
||||
}
|
||||
|
||||
void Manager::createInstance() {
|
||||
void
|
||||
Manager::createInstance()
|
||||
{
|
||||
|
||||
SPDLOG_DEBUG("Kompute Manager creating instance");
|
||||
|
||||
|
|
@ -91,16 +95,14 @@ void Manager::createInstance() {
|
|||
// We'll identify the layers that are supported
|
||||
std::vector<const char*> validLayerNames;
|
||||
std::vector<const char*> desiredLayerNames = {
|
||||
"VK_LAYER_LUNARG_assistant_layer",
|
||||
"VK_LAYER_LUNARG_standard_validation"
|
||||
"VK_LAYER_LUNARG_assistant_layer", "VK_LAYER_LUNARG_standard_validation"
|
||||
};
|
||||
// Identify the valid layer names based on the desiredLayerNames
|
||||
{
|
||||
std::set<std::string> uniqueLayerNames;
|
||||
std::vector<vk::LayerProperties> availableLayerProperties =
|
||||
vk::enumerateInstanceLayerProperties();
|
||||
for (vk::LayerProperties layerProperties :
|
||||
availableLayerProperties) {
|
||||
for (vk::LayerProperties layerProperties : availableLayerProperties) {
|
||||
std::string layerName(layerProperties.layerName);
|
||||
uniqueLayerNames.insert(layerName);
|
||||
}
|
||||
|
|
@ -114,13 +116,13 @@ void Manager::createInstance() {
|
|||
if (validLayerNames.size() > 0) {
|
||||
computeInstanceCreateInfo.enabledLayerCount =
|
||||
(uint32_t)validLayerNames.size();
|
||||
computeInstanceCreateInfo.ppEnabledLayerNames =
|
||||
validLayerNames.data();
|
||||
computeInstanceCreateInfo.ppEnabledLayerNames = validLayerNames.data();
|
||||
}
|
||||
#endif
|
||||
|
||||
this->mInstance = std::make_shared<vk::Instance>();
|
||||
vk::createInstance(&computeInstanceCreateInfo, nullptr, this->mInstance.get());
|
||||
vk::createInstance(
|
||||
&computeInstanceCreateInfo, nullptr, this->mInstance.get());
|
||||
SPDLOG_DEBUG("Kompute Manager Instance Created");
|
||||
|
||||
#if DEBUG
|
||||
|
|
@ -134,8 +136,7 @@ void Manager::createInstance() {
|
|||
(PFN_vkDebugReportCallbackEXT)debugMessageCallback;
|
||||
debugCreateInfo.flags = debugFlags;
|
||||
|
||||
this->mDebugDispatcher.init(*this->mInstance,
|
||||
&vkGetInstanceProcAddr);
|
||||
this->mDebugDispatcher.init(*this->mInstance, &vkGetInstanceProcAddr);
|
||||
this->mDebugReportCallback =
|
||||
this->mInstance->createDebugReportCallbackEXT(
|
||||
debugCreateInfo, nullptr, this->mDebugDispatcher);
|
||||
|
|
@ -143,7 +144,9 @@ void Manager::createInstance() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Manager::createDevice() {
|
||||
void
|
||||
Manager::createDevice()
|
||||
{
|
||||
|
||||
SPDLOG_DEBUG("Kompute Manager creating Device");
|
||||
|
||||
|
|
@ -151,7 +154,8 @@ void Manager::createDevice() {
|
|||
throw std::runtime_error("Kompute Manager instance is null");
|
||||
}
|
||||
if (this->mPhysicalDeviceIndex < 0) {
|
||||
throw std::runtime_error("Kompute Manager physical device index not provided");
|
||||
throw std::runtime_error(
|
||||
"Kompute Manager physical device index not provided");
|
||||
}
|
||||
|
||||
this->mFreeDevice = true;
|
||||
|
|
@ -159,12 +163,15 @@ void Manager::createDevice() {
|
|||
std::vector<vk::PhysicalDevice> physicalDevices =
|
||||
this->mInstance->enumeratePhysicalDevices();
|
||||
|
||||
vk::PhysicalDevice physicalDevice = physicalDevices[this->mPhysicalDeviceIndex];
|
||||
vk::PhysicalDevice physicalDevice =
|
||||
physicalDevices[this->mPhysicalDeviceIndex];
|
||||
|
||||
vk::PhysicalDeviceProperties physicalDeviceProperties =
|
||||
physicalDevice.getProperties();
|
||||
|
||||
spdlog::info("Using physical device index {} found {}", this->mPhysicalDeviceIndex, physicalDeviceProperties.deviceName);
|
||||
spdlog::info("Using physical device index {} found {}",
|
||||
this->mPhysicalDeviceIndex,
|
||||
physicalDeviceProperties.deviceName);
|
||||
|
||||
// Find compute queue
|
||||
std::vector<vk::QueueFamilyProperties> allQueueFamilyProperties =
|
||||
|
|
@ -175,8 +182,7 @@ void Manager::createDevice() {
|
|||
vk::QueueFamilyProperties queueFamilyProperties =
|
||||
allQueueFamilyProperties[i];
|
||||
|
||||
if (queueFamilyProperties.queueFlags &
|
||||
vk::QueueFlagBits::eCompute) {
|
||||
if (queueFamilyProperties.queueFlags & vk::QueueFlagBits::eCompute) {
|
||||
this->mComputeQueueFamilyIndex = i;
|
||||
break;
|
||||
}
|
||||
|
|
@ -194,17 +200,18 @@ void Manager::createDevice() {
|
|||
defaultQueueCount,
|
||||
&defaultQueuePriority);
|
||||
|
||||
vk::DeviceCreateInfo deviceCreateInfo(
|
||||
vk::DeviceCreateFlags(),
|
||||
1, // Number of deviceQueueCreateInfo
|
||||
&deviceQueueCreateInfo);
|
||||
vk::DeviceCreateInfo deviceCreateInfo(vk::DeviceCreateFlags(),
|
||||
1, // Number of deviceQueueCreateInfo
|
||||
&deviceQueueCreateInfo);
|
||||
|
||||
this->mDevice = std::make_shared<vk::Device>();
|
||||
physicalDevice.createDevice(&deviceCreateInfo, nullptr, this->mDevice.get());
|
||||
physicalDevice.createDevice(
|
||||
&deviceCreateInfo, nullptr, this->mDevice.get());
|
||||
SPDLOG_DEBUG("Kompute Manager device created");
|
||||
|
||||
this->mComputeQueue = std::make_shared<vk::Queue>();
|
||||
this->mDevice->getQueue(this->mComputeQueueFamilyIndex, 0, this->mComputeQueue.get());
|
||||
this->mDevice->getQueue(
|
||||
this->mComputeQueueFamilyIndex, 0, this->mComputeQueue.get());
|
||||
SPDLOG_DEBUG("Kompute Manager compute queue obtained");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue