removing device builder
This commit is contained in:
@@ -86,38 +86,6 @@ Device::~Device() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::Builder& Device::Builder::withWindow(Window& window) {
|
|
||||||
this->window = &window;
|
|
||||||
this->headlessRequested = false;
|
|
||||||
this->modeSet = true;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Device::Builder& Device::Builder::headless() {
|
|
||||||
this->window = nullptr;
|
|
||||||
this->headlessRequested = true;
|
|
||||||
this->modeSet = true;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Device> Device::Builder::build() const {
|
|
||||||
if (!this->modeSet) {
|
|
||||||
log::fatal(
|
|
||||||
"failed to build device: neither withWindow() nor headless() was "
|
|
||||||
"called");
|
|
||||||
throw std::runtime_error(
|
|
||||||
"failed to build device: no window/headless mode specified");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->headlessRequested) {
|
|
||||||
log::verbose("building headless Device");
|
|
||||||
return std::unique_ptr<Device>(new Device(nullptr));
|
|
||||||
} else {
|
|
||||||
log::verbose("building windowed Device");
|
|
||||||
return std::unique_ptr<Device>(new Device(this->window));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 Device::findMemoryType(u32 typeFilter, vk::MemoryPropertyFlags properties) {
|
u32 Device::findMemoryType(u32 typeFilter, vk::MemoryPropertyFlags properties) {
|
||||||
vk::PhysicalDeviceMemoryProperties memoryProperties =
|
vk::PhysicalDeviceMemoryProperties memoryProperties =
|
||||||
this->physicalDevice.getMemoryProperties();
|
this->physicalDevice.getMemoryProperties();
|
||||||
|
|||||||
+1
-19
@@ -32,13 +32,12 @@ struct SwapchainSupportDetails {
|
|||||||
|
|
||||||
class Device {
|
class Device {
|
||||||
public:
|
public:
|
||||||
class Builder;
|
|
||||||
|
|
||||||
Device(const Device&) = delete;
|
Device(const Device&) = delete;
|
||||||
Device& operator=(const Device&) = delete;
|
Device& operator=(const Device&) = delete;
|
||||||
Device(Device&&) = delete;
|
Device(Device&&) = delete;
|
||||||
Device& operator=(Device&&) = delete;
|
Device& operator=(Device&&) = delete;
|
||||||
|
|
||||||
|
Device(Window* window);
|
||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
const vk::Device* get() const {
|
const vk::Device* get() const {
|
||||||
@@ -87,8 +86,6 @@ class Device {
|
|||||||
vk::PhysicalDeviceProperties properties;
|
vk::PhysicalDeviceProperties properties;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Device(Window* window);
|
|
||||||
|
|
||||||
void setupDebugMessenger();
|
void setupDebugMessenger();
|
||||||
|
|
||||||
bool checkValidationLayerSupport();
|
bool checkValidationLayerSupport();
|
||||||
@@ -130,19 +127,4 @@ class Device {
|
|||||||
const std::vector<const char*> enabledExtensions;
|
const std::vector<const char*> enabledExtensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Device::Builder {
|
|
||||||
public:
|
|
||||||
Builder() = default;
|
|
||||||
|
|
||||||
Builder& withWindow(Window& window);
|
|
||||||
Builder& headless();
|
|
||||||
|
|
||||||
std::unique_ptr<Device> build() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Window* window = nullptr;
|
|
||||||
bool headlessRequested = false;
|
|
||||||
bool modeSet = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace sophia
|
} // namespace sophia
|
||||||
|
|||||||
Reference in New Issue
Block a user