Add Linux support
- Add linux build system using MakeGen - Fix a swapchain validation error, likelydue to my linux system using a different vulkan version - Make DescriptorPool take in amount of descriptors it needs, instead of allocating a mass amount for every pool, causing loads of RAM/VRAM usage
This commit is contained in:
@@ -15,12 +15,12 @@ namespace Copium
|
||||
{}
|
||||
|
||||
BoundingBox::BoundingBox(glm::vec2 lb, glm::vec2 rt)
|
||||
: lb{lb}, rt{rt}
|
||||
: l{lb.x}, b{lb.y}, r{rt.x}, t{rt.y}
|
||||
{}
|
||||
|
||||
glm::vec2 BoundingBox::GetSize() const
|
||||
glm::vec2 BoundingBox::GetSize() const
|
||||
{
|
||||
return glm::abs(rt - lb);
|
||||
return glm::abs(AsRt() - AsLb());
|
||||
}
|
||||
|
||||
bool BoundingBox::operator==(const BoundingBox& boundingBox) const
|
||||
@@ -32,4 +32,14 @@ namespace Copium
|
||||
{
|
||||
return !(*this == boundingBox);
|
||||
}
|
||||
|
||||
glm::vec2 BoundingBox::AsLb() const
|
||||
{
|
||||
return glm::vec2{l, b};
|
||||
}
|
||||
|
||||
glm::vec2 BoundingBox::AsRt() const
|
||||
{
|
||||
return glm::vec2{r, t};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@ namespace Copium
|
||||
{
|
||||
struct BoundingBox
|
||||
{
|
||||
union
|
||||
{
|
||||
struct { float l; float b; float r; float t; };
|
||||
struct { glm::vec2 lb; glm::vec2 rt; };
|
||||
struct { glm::vec4 lbrt; };
|
||||
};
|
||||
float l;
|
||||
float b;
|
||||
float r;
|
||||
float t;
|
||||
BoundingBox();
|
||||
BoundingBox(float all);
|
||||
BoundingBox(float l, float b, float r, float t);
|
||||
@@ -21,5 +19,8 @@ namespace Copium
|
||||
|
||||
bool operator==(const BoundingBox& boundingBox) const;
|
||||
bool operator!=(const BoundingBox& boundingBox) const;
|
||||
|
||||
glm::vec2 AsLb() const;
|
||||
glm::vec2 AsRt() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
|
||||
#define CP_TERM_RED "\x1B[31m"
|
||||
#define CP_TERM_GREEN "\x1B[32m"
|
||||
@@ -12,42 +13,42 @@
|
||||
#define CP_TERM_GRAY "\x1B[90m"
|
||||
#define CP_TERM_CLEAR "\033[0m"
|
||||
|
||||
#define CP_DEBUG(format, ...) std::cout << CP_TERM_GRAY << "[DBG] " << __func__ << " : " << Copium::String::Format(format, __VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_INFO(format, ...) std::cout << "[INF] " << __func__ << " : " << Copium::String::Format(format, __VA_ARGS__) << std::endl
|
||||
#define CP_WARN(format, ...) std::cout << CP_TERM_YELLOW << "[WRN] " << __func__ << " : " << Copium::String::Format(format, __VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_ERR(format, ...) std::cout << CP_TERM_RED << "[ERR] " << __func__ << " : " << Copium::String::Format(format, __VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_DEBUG(...) std::cout << CP_TERM_GRAY << "[DBG] " << __func__ << " : " << Copium::String::Format(__VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_INFO(...) std::cout << "[INF] " << __func__ << " : " << Copium::String::Format(__VA_ARGS__) << std::endl
|
||||
#define CP_WARN(...) std::cout << CP_TERM_YELLOW << "[WRN] " << __func__ << " : " << Copium::String::Format(__VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_ERR(...) std::cout << CP_TERM_RED << "[ERR] " << __func__ << " : " << Copium::String::Format(__VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
|
||||
// Continue traces, will not print the [XXX] tag before the log
|
||||
#define CP_DEBUG_CONT(format, ...) std::cout << CP_TERM_GRAY << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(format, __VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_INFO_CONT(format, ...) std::cout << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(format, __VA_ARGS__) << std::endl
|
||||
#define CP_WARN_CONT(format, ...) std::cout << CP_TERM_YELLOW << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(format, __VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_ERR_CONT(format, ...) std::cout << CP_TERM_RED << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(format, __VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_DEBUG_CONT(...) std::cout << CP_TERM_GRAY << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(__VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_INFO_CONT(...) std::cout << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(__VA_ARGS__) << std::endl
|
||||
#define CP_WARN_CONT(...) std::cout << CP_TERM_YELLOW << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(__VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
#define CP_ERR_CONT(...) std::cout << CP_TERM_RED << " " << std::setfill(' ') << std::setw(sizeof(__func__)) << " " << Copium::String::Format(__VA_ARGS__) << CP_TERM_CLEAR << std::endl
|
||||
|
||||
#define CP_ABORT(format, ...) \
|
||||
#define CP_ABORT(...) \
|
||||
do \
|
||||
{ \
|
||||
CP_ERR("Aborted at %s:%d", __FILE__, __LINE__); \
|
||||
CP_ERR_CONT(format, __VA_ARGS__); \
|
||||
throw Copium::RuntimeException(Copium::String::Format(format, __VA_ARGS__)); \
|
||||
CP_ERR_CONT(__VA_ARGS__); \
|
||||
throw Copium::RuntimeException(Copium::String::Format(__VA_ARGS__)); \
|
||||
} while(false)
|
||||
#define CP_ASSERT(Function, format, ...) \
|
||||
#define CP_ASSERT(Function, ...) \
|
||||
do \
|
||||
{ \
|
||||
if(!(Function)) \
|
||||
{ \
|
||||
CP_ERR("Assertion failed at %s:%d", __FILE__, __LINE__); \
|
||||
CP_ERR_CONT("%s : %s", #Function, Copium::String::Format(format, __VA_ARGS__).c_str()); \
|
||||
throw Copium::RuntimeException(Copium::String::Format(format, __VA_ARGS__)); \
|
||||
CP_ERR_CONT("%s : %s", #Function, Copium::String::Format(__VA_ARGS__).c_str()); \
|
||||
throw Copium::RuntimeException(Copium::String::Format(__VA_ARGS__)); \
|
||||
} \
|
||||
} while(false)
|
||||
#define CP_VK_ASSERT(Function, format, ...) \
|
||||
#define CP_VK_ASSERT(Function, ...) \
|
||||
do \
|
||||
{ \
|
||||
if(Function != VK_SUCCESS) \
|
||||
{ \
|
||||
CP_ERR("Assertion failed at %s:%d", __FILE__, __LINE__); \
|
||||
CP_ERR_CONT("%s : %s", #Function, Copium::String::Format(format, __VA_ARGS__).c_str()); \
|
||||
throw Copium::VulkanException(Copium::String::Format(format, __VA_ARGS__)); \
|
||||
CP_ERR_CONT("%s : %s", #Function, Copium::String::Format(__VA_ARGS__).c_str()); \
|
||||
throw Copium::VulkanException(Copium::String::Format(__VA_ARGS__)); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
@@ -68,6 +69,11 @@ namespace Copium
|
||||
{
|
||||
CP_STATIC_CLASS(String);
|
||||
public:
|
||||
static std::string Format(const std::string& format)
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
template<typename ... Args>
|
||||
static std::string Format(const std::string& format, Args... args)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -15,7 +14,7 @@ namespace NameSpace { \
|
||||
}; \
|
||||
static const std::string& ToString(EnumName enumName) \
|
||||
{ \
|
||||
static std::vector<std::string> enumNames = Copium::EnumPrinter::GetEnumNames(CP_TO_STRING(EnumList)); \
|
||||
static std::vector<std::string> enumNames = Copium::EnumPrinter::GetEnumNames(CP_TO_STRING(#EnumList)); \
|
||||
return enumNames[(int)enumName]; \
|
||||
} \
|
||||
\
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include "copium/util/FileSystem.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
std::vector<char> FileSystem::ReadFile(const std::string& filename)
|
||||
@@ -78,4 +83,4 @@ namespace Copium
|
||||
CP_ASSERT(stat(filename.c_str(), &result) == 0, "Cannot stat file %s", filename.c_str());
|
||||
return (int64_t)result.st_mtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
#include "copium/util/Common.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
@@ -21,4 +19,4 @@ namespace Copium
|
||||
static bool FileExists(const std::string& filename);
|
||||
static int64_t DateModified(const std::string& filename);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
RuntimeException::RuntimeException(const std::string& str)
|
||||
RuntimeException::RuntimeException(const std::string& str)
|
||||
: errorMessage{str}
|
||||
{}
|
||||
|
||||
const std::string& RuntimeException::GetErrorMessage() const
|
||||
const std::string& RuntimeException::GetErrorMessage() const
|
||||
{
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
@@ -13,4 +13,4 @@ namespace Copium
|
||||
|
||||
const std::string& GetErrorMessage() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
|
||||
class StringUtil
|
||||
{
|
||||
CP_STATIC_CLASS(StringUtil);
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace Copium
|
||||
|
||||
double Timer::Elapsed()
|
||||
{
|
||||
return std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - startTime).count();
|
||||
return std::chrono::duration<double>(std::chrono::steady_clock::now() - startTime).count();
|
||||
}
|
||||
|
||||
double Timer::ElapsedRestart()
|
||||
{
|
||||
std::chrono::time_point<std::chrono::steady_clock> newTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::time_point<std::chrono::steady_clock> newTime = std::chrono::steady_clock::now();
|
||||
|
||||
double elapsedTime = std::chrono::duration<double>(newTime - startTime).count();
|
||||
startTime = newTime;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "copium/util/RuntimeException.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user