2022-09-07 09:02:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2022-10-22 12:15:25 +00:00
|
|
|
#include <vector>
|
2023-03-21 20:10:23 +00:00
|
|
|
#include <type_traits>
|
2022-09-07 09:02:01 +00:00
|
|
|
|
2023-02-19 13:55:08 +00:00
|
|
|
// Enums and structs for the graphics abstraction
|
|
|
|
|
2022-10-22 12:15:25 +00:00
|
|
|
namespace engine::gfx {
|
2022-09-07 09:02:01 +00:00
|
|
|
|
2023-03-13 01:19:32 +00:00
|
|
|
// handles (incomplete types)
|
|
|
|
struct Pipeline;
|
2023-03-21 20:10:23 +00:00
|
|
|
struct UniformBuffer;
|
2023-03-13 01:19:32 +00:00
|
|
|
struct Buffer;
|
|
|
|
struct Texture;
|
|
|
|
struct DrawBuffer;
|
|
|
|
struct DescriptorSetLayout;
|
|
|
|
struct DescriptorSet;
|
2023-03-15 01:49:03 +00:00
|
|
|
struct Image;
|
2023-03-21 23:52:52 +00:00
|
|
|
struct Sampler;
|
2023-03-13 01:19:32 +00:00
|
|
|
|
2023-02-19 13:55:08 +00:00
|
|
|
enum class MSAALevel {
|
|
|
|
MSAA_OFF,
|
|
|
|
MSAA_2X,
|
|
|
|
MSAA_4X,
|
|
|
|
MSAA_8X,
|
|
|
|
MSAA_16X,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GraphicsSettings {
|
|
|
|
|
|
|
|
GraphicsSettings()
|
|
|
|
{
|
|
|
|
// sane defaults
|
2023-03-15 01:49:03 +00:00
|
|
|
enableValidation = true;
|
2023-02-24 16:35:27 +00:00
|
|
|
vsync = true;
|
|
|
|
waitForPresent = true; // not all GPUs/drivers support immediate present with V-sync enabled
|
2023-02-19 13:55:08 +00:00
|
|
|
msaaLevel = MSAALevel::MSAA_OFF;
|
|
|
|
}
|
|
|
|
|
2023-03-15 01:49:03 +00:00
|
|
|
bool enableValidation;
|
2023-02-19 13:55:08 +00:00
|
|
|
bool vsync;
|
2023-03-15 01:49:03 +00:00
|
|
|
// idle CPU after render until the frame has been presented (no affect with V-sync disabled)
|
|
|
|
bool waitForPresent;
|
2023-02-19 13:55:08 +00:00
|
|
|
MSAALevel msaaLevel;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-09-07 09:02:01 +00:00
|
|
|
enum class ShaderType {
|
|
|
|
VERTEX,
|
|
|
|
FRAGMENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class BufferType {
|
|
|
|
VERTEX,
|
|
|
|
INDEX,
|
2022-10-24 13:30:05 +00:00
|
|
|
UNIFORM,
|
2022-09-07 09:02:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class Primitive {
|
|
|
|
POINTS,
|
|
|
|
LINES,
|
|
|
|
LINE_STRIP,
|
|
|
|
TRIANGLES,
|
|
|
|
TRIANGLE_STRIP,
|
|
|
|
};
|
|
|
|
|
2022-10-22 12:15:25 +00:00
|
|
|
enum class VertexAttribFormat {
|
2023-01-20 16:30:35 +00:00
|
|
|
FLOAT2,
|
|
|
|
FLOAT3,
|
|
|
|
FLOAT4
|
2022-09-07 09:02:01 +00:00
|
|
|
};
|
|
|
|
|
2022-11-15 13:59:43 +00:00
|
|
|
enum class TextureFilter {
|
|
|
|
LINEAR,
|
|
|
|
NEAREST,
|
|
|
|
};
|
|
|
|
|
2023-01-26 21:17:07 +00:00
|
|
|
enum class MipmapSetting {
|
|
|
|
OFF,
|
|
|
|
NEAREST,
|
|
|
|
LINEAR,
|
|
|
|
};
|
|
|
|
|
2023-03-21 20:10:23 +00:00
|
|
|
enum class DescriptorType {
|
|
|
|
UNIFORM_BUFFER,
|
|
|
|
COMBINED_IMAGE_SAMPLER,
|
2022-10-22 12:15:25 +00:00
|
|
|
};
|
|
|
|
|
2023-03-21 20:10:23 +00:00
|
|
|
namespace ShaderStageFlags {
|
|
|
|
enum Bits : uint32_t {
|
|
|
|
VERTEX = 1 << 0,
|
|
|
|
FRAGMENT = 1 << 1,
|
|
|
|
};
|
|
|
|
typedef std::underlying_type<Bits>::type Flags;
|
|
|
|
}
|
|
|
|
|
2022-10-22 12:15:25 +00:00
|
|
|
struct VertexAttribDescription {
|
2023-02-18 15:54:31 +00:00
|
|
|
VertexAttribDescription(uint32_t location, VertexAttribFormat format, uint32_t offset) :
|
|
|
|
location(location),
|
|
|
|
format(format),
|
|
|
|
offset(offset) {}
|
2023-03-12 17:11:13 +00:00
|
|
|
uint32_t location; // the index to use in the shader
|
2022-10-22 12:15:25 +00:00
|
|
|
VertexAttribFormat format;
|
|
|
|
uint32_t offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VertexFormat {
|
|
|
|
uint32_t stride;
|
|
|
|
std::vector<VertexAttribDescription> attributeDescriptions;
|
|
|
|
};
|
|
|
|
|
2023-03-13 01:19:32 +00:00
|
|
|
struct PipelineInfo {
|
|
|
|
const char* vertShaderPath;
|
|
|
|
const char* fragShaderPath;
|
2023-03-15 01:49:03 +00:00
|
|
|
VertexFormat vertexFormat;
|
2023-03-13 01:19:32 +00:00
|
|
|
bool alphaBlending;
|
|
|
|
bool backfaceCulling;
|
|
|
|
std::vector<const DescriptorSetLayout*> descriptorSetLayouts;
|
|
|
|
};
|
2022-10-22 12:15:25 +00:00
|
|
|
|
2023-03-21 20:10:23 +00:00
|
|
|
struct DescriptorSetLayoutBinding {
|
|
|
|
DescriptorType descriptorType = DescriptorType::UNIFORM_BUFFER;
|
|
|
|
ShaderStageFlags::Flags stageFlags = 0;
|
|
|
|
};
|
|
|
|
|
2022-09-07 09:02:01 +00:00
|
|
|
}
|