Files
Seele/src/Engine/Graphics/Initializer.h
T

232 lines
7.4 KiB
C++
Raw Normal View History

2020-06-02 11:46:18 +02:00
#pragma once
2023-10-26 18:37:29 +02:00
#include "Enums.h"
2023-02-13 14:56:13 +01:00
#include "Containers/Map.h"
2023-10-26 18:37:29 +02:00
#include "Math/Math.h"
2020-05-05 01:51:13 +02:00
namespace Seele
{
struct GraphicsInitializer
{
const char *applicationName;
const char *engineName;
2021-04-01 16:40:14 +02:00
const char *windowLayoutFile;
2020-05-05 01:51:13 +02:00
/**
* layers defines the enabled Vulkan layers used in the instance,
* if ENABLE_VALIDATION is defined, standard validation is already enabled
* not yet implemented
*/
Array<const char *> layers;
Array<const char *> instanceExtensions;
Array<const char *> deviceExtensions;
2021-04-01 16:40:14 +02:00
void *windowHandle;
2020-05-05 01:51:13 +02:00
GraphicsInitializer()
2021-04-01 16:40:14 +02:00
: applicationName("SeeleEngine")
, engineName("SeeleEngine")
2022-01-12 14:40:26 +01:00
, windowLayoutFile(nullptr)
2022-04-15 23:45:44 +02:00
, layers{"VK_LAYER_KHRONOS_validation"}
2023-11-05 11:47:22 +01:00
, instanceExtensions{}
2021-04-01 16:40:14 +02:00
, deviceExtensions{"VK_KHR_swapchain"}
, windowHandle(nullptr)
2020-05-05 01:51:13 +02:00
{
}
};
struct WindowCreateInfo
{
int32 width;
int32 height;
const char *title;
2020-08-11 21:23:20 +02:00
Gfx::SeSampleCountFlags numSamples;
2023-11-16 22:58:47 +01:00
Gfx::SeFormat preferredFormat = Gfx::SE_FORMAT_MAX_ENUM;
2020-05-05 01:51:13 +02:00
void *windowHandle;
};
struct ViewportCreateInfo
{
2023-01-21 18:43:21 +01:00
URect dimensions;
2022-11-30 10:19:45 +01:00
float fieldOfView = 1.222f; // 70 deg
2020-05-05 01:51:13 +02:00
};
2020-06-02 11:46:18 +02:00
// doesnt own the data, only proxy it
2023-11-01 23:12:30 +01:00
struct DataSource
2020-06-02 11:46:18 +02:00
{
uint64 size = 0;
uint64 offset = 0;
2022-04-15 11:19:30 +02:00
uint8 *data = nullptr;
2021-05-10 23:57:55 +02:00
Gfx::QueueType owner = Gfx::QueueType::GRAPHICS;
2020-06-02 11:46:18 +02:00
};
2020-05-05 01:51:13 +02:00
struct TextureCreateInfo
{
2023-11-15 00:06:00 +01:00
DataSource sourceData = DataSource();
Gfx::SeFormat format = Gfx::SE_FORMAT_R32G32B32A32_SFLOAT;
uint32 width = 1;
uint32 height = 1;
uint32 depth = 1;
uint32 mipLevels = 1;
2023-11-15 17:42:57 +01:00
uint32 layers = 1;
uint32 elements = 1;
2023-11-15 00:06:00 +01:00
uint32 samples = 1;
Gfx::SeImageUsageFlagBits usage = Gfx::SE_IMAGE_USAGE_SAMPLED_BIT;
2020-05-05 01:51:13 +02:00
};
2020-10-03 11:00:10 +02:00
struct SamplerCreateInfo
{
2022-04-15 11:19:30 +02:00
Gfx::SeSamplerCreateFlags flags;
Gfx::SeFilter magFilter;
Gfx::SeFilter minFilter;
Gfx::SeSamplerMipmapMode mipmapMode;
Gfx::SeSamplerAddressMode addressModeU;
Gfx::SeSamplerAddressMode addressModeV;
Gfx::SeSamplerAddressMode addressModeW;
float mipLodBias;
uint32 anisotropyEnable;
float maxAnisotropy;
uint32 compareEnable;
Gfx::SeCompareOp compareOp;
float minLod;
float maxLod;
Gfx::SeBorderColor borderColor;
uint32 unnormalizedCoordinates;
2020-10-03 11:00:10 +02:00
};
2020-05-05 01:51:13 +02:00
struct VertexBufferCreateInfo
{
2023-11-15 00:06:00 +01:00
DataSource sourceData = DataSource();
2020-05-05 01:51:13 +02:00
// bytes per vertex
2023-11-15 00:06:00 +01:00
uint32 vertexSize = 0;
uint32 numVertices = 0;
2020-05-05 01:51:13 +02:00
};
struct IndexBufferCreateInfo
{
2023-11-15 00:06:00 +01:00
DataSource sourceData = DataSource();
Gfx::SeIndexType indexType = Gfx::SeIndexType::SE_INDEX_TYPE_UINT16;
2020-05-05 01:51:13 +02:00
};
struct UniformBufferCreateInfo
{
2023-11-15 00:06:00 +01:00
DataSource sourceData = DataSource();
uint8 dynamic = 0;
};
2023-08-28 21:23:13 +02:00
struct ShaderBufferCreateInfo
2021-05-10 23:57:55 +02:00
{
2023-11-15 00:06:00 +01:00
DataSource sourceData = DataSource();
2023-11-15 17:42:57 +01:00
uint64 numElements = 1;
2023-11-15 00:06:00 +01:00
uint8 dynamic = 0;
2021-05-10 23:57:55 +02:00
};
2020-06-02 11:46:18 +02:00
struct ShaderCreateInfo
{
2023-11-15 00:06:00 +01:00
std::string mainModule;
Array<std::string> additionalModules;
std::string name; // Debug info
std::string entryPoint;
Array<Pair<const char*, const char*>> typeParameter;
Map<const char*, const char*> defines;
2020-06-02 11:46:18 +02:00
};
2020-05-05 01:51:13 +02:00
namespace Gfx
{
struct SePushConstantRange
{
2023-11-15 00:06:00 +01:00
SeShaderStageFlags stageFlags;
uint32 offset;
uint32 size;
2020-05-05 01:51:13 +02:00
};
struct RasterizationState
{
2023-11-15 00:06:00 +01:00
uint32 depthClampEnable = 0;
uint32 rasterizerDiscardEnable = 0;
SePolygonMode polygonMode;
SeCullModeFlags cullMode;
SeFrontFace frontFace;
uint32 depthBiasEnable = 0;
float depthBiasConstantFactor = 0;
float depthBiasClamp = 0;
float depthBiasSlopeFactor = 0;
float lineWidth = 0;
2020-05-05 01:51:13 +02:00
};
struct MultisampleState
{
2023-11-15 00:06:00 +01:00
SeSampleCountFlags samples = 1;
uint32 sampleShadingEnable = 0;
float minSampleShading = 1;
uint8 alphaCoverageEnable = 0;
uint8 alphaToOneEnable = 0;
2020-05-05 01:51:13 +02:00
};
struct DepthStencilState
{
2023-11-15 00:06:00 +01:00
uint32 depthTestEnable = 0;
uint32 depthWriteEnable = 0;
SeCompareOp depthCompareOp = Gfx::SE_COMPARE_OP_LESS;
uint32 depthBoundsTestEnable = 0;
uint32 stencilTestEnable = 0;
2023-10-31 23:44:46 +01:00
SeStencilOp front = Gfx::SE_STENCIL_OP_END_RANGE;
SeStencilOp back = Gfx::SE_STENCIL_OP_END_RANGE;
2023-11-15 00:06:00 +01:00
float minDepthBounds;
float maxDepthBounds;
2020-05-05 01:51:13 +02:00
};
struct ColorBlendState
{
struct BlendAttachment
{
2023-11-15 00:06:00 +01:00
uint32 blendEnable = 0;
SeBlendFactor srcColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendFactor dstColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendOp colorBlendOp = Gfx::SE_BLEND_OP_ADD;
SeBlendFactor srcAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendFactor dstAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendOp alphaBlendOp = Gfx::SE_BLEND_OP_ADD;
SeColorComponentFlags colorWriteMask = 0;
};
uint32 logicOpEnable;
SeLogicOp logicOp = Gfx::SE_LOGIC_OP_OR;
uint32 attachmentCount;
StaticArray<BlendAttachment, 16> blendAttachments;
StaticArray<float, 4> blendConstants;
2020-05-05 01:51:13 +02:00
};
2023-11-15 00:06:00 +01:00
2023-11-05 10:36:01 +01:00
DECLARE_REF(VertexShader)
DECLARE_REF(TaskShader)
DECLARE_REF(MeshShader)
DECLARE_REF(FragmentShader)
DECLARE_REF(ComputeShader)
2023-10-26 18:37:29 +02:00
DECLARE_REF(RenderPass)
2023-11-01 13:38:49 +01:00
DECLARE_REF(PipelineLayout)
2023-10-26 18:37:29 +02:00
struct LegacyPipelineCreateInfo
2020-05-05 01:51:13 +02:00
{
2023-10-26 18:37:29 +02:00
SePrimitiveTopology topology;
2023-11-15 00:06:00 +01:00
PVertexShader vertexShader;
PFragmentShader fragmentShader;
PRenderPass renderPass;
OPipelineLayout pipelineLayout;
MultisampleState multisampleState;
RasterizationState rasterizationState;
DepthStencilState depthStencilState;
ColorBlendState colorBlend;
2023-11-01 13:38:49 +01:00
LegacyPipelineCreateInfo();
2023-11-09 22:15:51 +01:00
LegacyPipelineCreateInfo(LegacyPipelineCreateInfo&& rhs) = default;
LegacyPipelineCreateInfo& operator=(LegacyPipelineCreateInfo&& rhs) = default;
2023-11-01 13:38:49 +01:00
~LegacyPipelineCreateInfo();
2023-10-26 18:37:29 +02:00
};
struct MeshPipelineCreateInfo
{
2023-11-15 00:06:00 +01:00
PTaskShader taskShader;
PMeshShader meshShader;
PFragmentShader fragmentShader;
PRenderPass renderPass;
OPipelineLayout pipelineLayout;
MultisampleState multisampleState;
RasterizationState rasterizationState;
DepthStencilState depthStencilState;
ColorBlendState colorBlend;
2023-11-05 10:36:01 +01:00
MeshPipelineCreateInfo();
2023-11-09 22:15:51 +01:00
MeshPipelineCreateInfo(MeshPipelineCreateInfo&& rhs) = default;
MeshPipelineCreateInfo& operator=(MeshPipelineCreateInfo&& rhs) = default;
2023-11-05 10:36:01 +01:00
~MeshPipelineCreateInfo();
2020-05-05 01:51:13 +02:00
};
2021-05-06 17:02:10 +02:00
struct ComputePipelineCreateInfo
{
2023-11-15 00:06:00 +01:00
Gfx::PComputeShader computeShader;
Gfx::OPipelineLayout pipelineLayout;
2023-11-09 22:15:51 +01:00
ComputePipelineCreateInfo();
ComputePipelineCreateInfo(ComputePipelineCreateInfo&& rhs) = default;
ComputePipelineCreateInfo& operator=(ComputePipelineCreateInfo&& rhs) = default;
~ComputePipelineCreateInfo();
2021-05-06 17:02:10 +02:00
};
2023-10-26 18:37:29 +02:00
} // namespace Gfx
2020-05-05 01:51:13 +02:00
} // namespace Seele