50 lines
2.8 KiB
C++
50 lines
2.8 KiB
C++
// =============================================
|
|
// Aster: helpers.h
|
|
// Copyright (c) 2020-2024 Anish Bhobe
|
|
// =============================================
|
|
|
|
#pragma once
|
|
|
|
#include "global.h"
|
|
|
|
#include "queue_allocation.h"
|
|
|
|
#include "EASTL/span.h"
|
|
#include <EASTL/vector.h>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
struct PhysicalDevice;
|
|
class PhysicalDevices;
|
|
|
|
PhysicalDevice FindSuitableDevice(const PhysicalDevices &physicalDevices);
|
|
QueueAllocation FindAppropriateQueueAllocation(const PhysicalDevice *physicalDevice);
|
|
eastl::vector<u32> ReadFile(cstr fileName);
|
|
eastl::vector<u8> ReadFileBytes(cstr fileName, bool errorOnFail = true);
|
|
bool WriteFileBytes(cstr fileName, eastl::span<u8> data);
|
|
|
|
template <usize TSize>
|
|
using StackString = eastl::fixed_string<char, TSize, false>;
|
|
|
|
#define AbortIfFailed(RESULT) \
|
|
do \
|
|
{ \
|
|
vk::Result _checkResultValue_; \
|
|
ERROR_IF(Failed(_checkResultValue_ = Cast<vk::Result>(RESULT)), "Cause: {}", _checkResultValue_) \
|
|
THEN_ABORT(_checkResultValue_); \
|
|
} while (false)
|
|
|
|
#define AbortIfFailedMV(RESULT, MSG, EXTRA) \
|
|
do \
|
|
{ \
|
|
vk::Result _checkResultValue_; \
|
|
ERROR_IF(Failed(_checkResultValue_ = Cast<vk::Result>(RESULT)), MSG " Cause: {}", EXTRA, _checkResultValue_) \
|
|
THEN_ABORT(_checkResultValue_); \
|
|
} while (false)
|
|
|
|
#define AbortIfFailedM(RESULT, MSG) \
|
|
do \
|
|
{ \
|
|
auto _checkResultValue_ = Cast<vk::Result>(RESULT); \
|
|
ERROR_IF(Failed(_checkResultValue_), MSG " Cause: {}", _checkResultValue_) THEN_ABORT(_checkResultValue_); \
|
|
} while (false)
|