Compare commits
2 Commits
659d6010e3
...
e40b660cb2
| Author | SHA1 | Date | |
|---|---|---|---|
| e40b660cb2 | |||
| db488a5981 |
@@ -22,4 +22,5 @@ target_link_libraries(${ENGINE_NAME} PUBLIC
|
||||
glfw
|
||||
glm
|
||||
imgui
|
||||
entt
|
||||
)
|
||||
|
||||
@@ -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) {
|
||||
vk::PhysicalDeviceMemoryProperties memoryProperties =
|
||||
this->physicalDevice.getMemoryProperties();
|
||||
|
||||
+1
-19
@@ -32,13 +32,12 @@ struct SwapchainSupportDetails {
|
||||
|
||||
class Device {
|
||||
public:
|
||||
class Builder;
|
||||
|
||||
Device(const Device&) = delete;
|
||||
Device& operator=(const Device&) = delete;
|
||||
Device(Device&&) = delete;
|
||||
Device& operator=(Device&&) = delete;
|
||||
|
||||
Device(Window* window);
|
||||
~Device();
|
||||
|
||||
const vk::Device* get() const {
|
||||
@@ -87,8 +86,6 @@ class Device {
|
||||
vk::PhysicalDeviceProperties properties;
|
||||
|
||||
private:
|
||||
Device(Window* window);
|
||||
|
||||
void setupDebugMessenger();
|
||||
|
||||
bool checkValidationLayerSupport();
|
||||
@@ -130,19 +127,4 @@ class Device {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user