2020-06-02 11:46:18 +02:00
|
|
|
#pragma once
|
2020-05-05 01:51:13 +02:00
|
|
|
#include "GraphicsEnums.h"
|
|
|
|
|
|
|
|
|
|
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-03-26 16:15:50 +01:00
|
|
|
, layers{}
|
2021-04-01 16:40:14 +02:00
|
|
|
, instanceExtensions{}
|
|
|
|
|
, deviceExtensions{"VK_KHR_swapchain"}
|
|
|
|
|
, windowHandle(nullptr)
|
2020-05-05 01:51:13 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
struct WindowCreateInfo
|
|
|
|
|
{
|
|
|
|
|
int32 width;
|
|
|
|
|
int32 height;
|
|
|
|
|
const char *title;
|
|
|
|
|
bool bFullscreen;
|
2020-08-11 21:23:20 +02:00
|
|
|
Gfx::SeSampleCountFlags numSamples;
|
2020-05-05 01:51:13 +02:00
|
|
|
Gfx::SeFormat pixelFormat;
|
|
|
|
|
void *windowHandle;
|
|
|
|
|
};
|
|
|
|
|
struct ViewportCreateInfo
|
|
|
|
|
{
|
|
|
|
|
uint32 sizeX;
|
|
|
|
|
uint32 sizeY;
|
|
|
|
|
uint32 offsetX;
|
|
|
|
|
uint32 offsetY;
|
|
|
|
|
};
|
2020-06-02 11:46:18 +02:00
|
|
|
// doesnt own the data, only proxy it
|
|
|
|
|
struct BulkResourceData
|
|
|
|
|
{
|
|
|
|
|
uint32 size;
|
|
|
|
|
uint8 *data;
|
2021-05-10 23:57:55 +02:00
|
|
|
Gfx::QueueType owner = Gfx::QueueType::GRAPHICS;
|
2020-06-02 11:46:18 +02:00
|
|
|
BulkResourceData()
|
|
|
|
|
: size(0), data(nullptr), owner(Gfx::QueueType::GRAPHICS)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-05-05 01:51:13 +02:00
|
|
|
struct TextureCreateInfo
|
|
|
|
|
{
|
2020-06-02 11:46:18 +02:00
|
|
|
BulkResourceData resourceData;
|
2020-05-05 01:51:13 +02:00
|
|
|
uint32 width;
|
|
|
|
|
uint32 height;
|
|
|
|
|
uint32 depth;
|
|
|
|
|
bool bArray;
|
|
|
|
|
uint32 arrayLayers;
|
|
|
|
|
uint32 mipLevels;
|
|
|
|
|
uint32 samples;
|
|
|
|
|
Gfx::SeFormat format;
|
|
|
|
|
Gfx::SeImageUsageFlagBits usage;
|
|
|
|
|
TextureCreateInfo()
|
2020-06-02 11:46:18 +02:00
|
|
|
: resourceData(), width(1), height(1), depth(1), bArray(false), arrayLayers(1)
|
|
|
|
|
, mipLevels(1), samples(1), format(Gfx::SE_FORMAT_R32G32B32A32_SFLOAT)
|
|
|
|
|
, 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
|
|
|
|
|
{
|
|
|
|
|
};
|
2020-05-05 01:51:13 +02:00
|
|
|
struct VertexBufferCreateInfo
|
|
|
|
|
{
|
|
|
|
|
BulkResourceData resourceData;
|
|
|
|
|
// bytes per vertex
|
|
|
|
|
uint32 vertexSize;
|
|
|
|
|
uint32 numVertices;
|
|
|
|
|
VertexBufferCreateInfo()
|
|
|
|
|
: resourceData(), vertexSize(0), numVertices(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
struct IndexBufferCreateInfo
|
|
|
|
|
{
|
|
|
|
|
BulkResourceData resourceData;
|
|
|
|
|
Gfx::SeIndexType indexType;
|
|
|
|
|
IndexBufferCreateInfo()
|
|
|
|
|
: resourceData(), indexType(Gfx::SeIndexType::SE_INDEX_TYPE_UINT16)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-11-03 01:18:30 +01:00
|
|
|
struct UniformBufferCreateInfo
|
|
|
|
|
{
|
|
|
|
|
BulkResourceData resourceData;
|
|
|
|
|
uint8 bDynamic : 1;
|
|
|
|
|
UniformBufferCreateInfo()
|
|
|
|
|
: resourceData(), bDynamic(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-05-10 23:57:55 +02:00
|
|
|
struct StructuredBufferCreateInfo
|
|
|
|
|
{
|
|
|
|
|
BulkResourceData resourceData;
|
|
|
|
|
uint8 bDynamic: 1;
|
|
|
|
|
StructuredBufferCreateInfo()
|
|
|
|
|
: resourceData(), bDynamic(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-06-02 11:46:18 +02:00
|
|
|
struct ShaderCreateInfo
|
|
|
|
|
{
|
2020-08-06 00:54:43 +02:00
|
|
|
//It's possible to input multiple source files for materials or vertexFactories
|
|
|
|
|
Array<std::string> shaderCode;
|
2021-05-06 17:02:10 +02:00
|
|
|
std::string name; // Debug info
|
2020-06-02 11:46:18 +02:00
|
|
|
std::string entryPoint;
|
|
|
|
|
Array<const char*> typeParameter;
|
2020-09-19 14:36:50 +02:00
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
SeShaderStageFlags stageFlags;
|
|
|
|
|
uint32_t offset;
|
|
|
|
|
uint32_t size;
|
|
|
|
|
};
|
|
|
|
|
struct VertexElement
|
|
|
|
|
{
|
2020-06-02 11:46:18 +02:00
|
|
|
VertexElement(){}
|
2020-10-03 11:00:10 +02:00
|
|
|
//VertexElement(uint8 attributeIndex, SeFormat vertexFormat, uint8 offset)
|
|
|
|
|
// : attributeIndex(attributeIndex), vertexFormat(vertexFormat), offset(offset)
|
|
|
|
|
//{}
|
|
|
|
|
VertexElement(uint8 streamIndex, uint8 offset, SeFormat vertexFormat, uint8 attributeIndex, uint8 stride)
|
|
|
|
|
: streamIndex(streamIndex), offset(offset), vertexFormat(vertexFormat), attributeIndex(attributeIndex), stride(stride)
|
2020-06-02 11:46:18 +02:00
|
|
|
{}
|
2020-10-03 11:00:10 +02:00
|
|
|
uint8 streamIndex;
|
|
|
|
|
uint8 offset;
|
2020-05-05 01:51:13 +02:00
|
|
|
SeFormat vertexFormat;
|
2020-10-03 11:00:10 +02:00
|
|
|
uint8 attributeIndex;
|
|
|
|
|
uint8 stride;
|
|
|
|
|
uint8 bInstanced = 0;
|
2020-05-05 01:51:13 +02:00
|
|
|
};
|
|
|
|
|
struct RasterizationState
|
|
|
|
|
{
|
|
|
|
|
uint8 depthClampEnable : 1;
|
|
|
|
|
uint8 rasterizerDiscardEnable : 1;
|
|
|
|
|
uint8 depthBiasEnable : 1;
|
|
|
|
|
float depthBoasConstantFactor;
|
|
|
|
|
float depthBiasClamp;
|
|
|
|
|
float depthBiasSlopeFactor;
|
|
|
|
|
float lineWidth;
|
|
|
|
|
SePolygonMode polygonMode;
|
|
|
|
|
SeCullModeFlags cullMode;
|
|
|
|
|
SeFrontFace frontFace;
|
|
|
|
|
};
|
|
|
|
|
struct MultisampleState
|
|
|
|
|
{
|
|
|
|
|
uint32 samples;
|
|
|
|
|
float minSampleShading;
|
|
|
|
|
uint8 sampleShadingEnable : 1;
|
|
|
|
|
uint8 alphaCoverageEnable;
|
|
|
|
|
uint8 alphaToOneEnable;
|
|
|
|
|
};
|
|
|
|
|
struct DepthStencilState
|
|
|
|
|
{
|
|
|
|
|
uint8 depthTestEnable : 1;
|
|
|
|
|
uint8 depthWriteEnable : 1;
|
|
|
|
|
uint8 depthBoundsTestEnable : 1;
|
|
|
|
|
uint8 stencilTestEnable : 1;
|
|
|
|
|
SeCompareOp depthCompareOp;
|
|
|
|
|
SeStencilOp front;
|
|
|
|
|
SeStencilOp back;
|
|
|
|
|
float minDepthBounds;
|
|
|
|
|
float maxDepthBounds;
|
|
|
|
|
};
|
|
|
|
|
struct ColorBlendState
|
|
|
|
|
{
|
|
|
|
|
uint8 logicOpEnable : 1;
|
|
|
|
|
SeLogicOp logicOp;
|
|
|
|
|
uint32 attachmentCount;
|
|
|
|
|
struct BlendAttachment
|
|
|
|
|
{
|
|
|
|
|
uint8 blendEnable;
|
|
|
|
|
SeBlendFactor srcColorBlendFactor;
|
|
|
|
|
SeBlendFactor dstColorBlendFactor;
|
|
|
|
|
SeBlendOp colorBlendOp;
|
|
|
|
|
SeBlendFactor srcAlphaBlendFactor;
|
|
|
|
|
SeBlendFactor dstAlphaBlendFactor;
|
|
|
|
|
SeBlendOp alphaBlendOp;
|
|
|
|
|
SeColorComponentFlags colorWriteMask;
|
|
|
|
|
} blendAttachments[16];
|
|
|
|
|
float blendConstants[4];
|
|
|
|
|
};
|
|
|
|
|
} // namespace Gfx
|
2021-04-01 16:40:14 +02:00
|
|
|
DECLARE_NAME_REF(Gfx, VertexDeclaration)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, VertexShader)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, ControlShader)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, EvaluationShader)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, GeometryShader)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, FragmentShader)
|
2021-05-10 23:57:55 +02:00
|
|
|
DECLARE_NAME_REF(Gfx, ComputeShader)
|
2021-04-01 16:40:14 +02:00
|
|
|
DECLARE_NAME_REF(Gfx, PipelineLayout)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, RenderPass)
|
2020-05-05 01:51:13 +02:00
|
|
|
struct GraphicsPipelineCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Gfx::PVertexDeclaration vertexDeclaration;
|
|
|
|
|
Gfx::PVertexShader vertexShader;
|
|
|
|
|
Gfx::PControlShader controlShader;
|
|
|
|
|
Gfx::PEvaluationShader evalShader;
|
|
|
|
|
Gfx::PGeometryShader geometryShader;
|
|
|
|
|
Gfx::PFragmentShader fragmentShader;
|
|
|
|
|
Gfx::PRenderPass renderPass;
|
2020-10-03 11:00:10 +02:00
|
|
|
Gfx::PPipelineLayout pipelineLayout;
|
2020-05-05 01:51:13 +02:00
|
|
|
Gfx::SePrimitiveTopology topology;
|
|
|
|
|
Gfx::RasterizationState rasterizationState;
|
|
|
|
|
Gfx::DepthStencilState depthStencilState;
|
|
|
|
|
Gfx::MultisampleState multisampleState;
|
|
|
|
|
Gfx::ColorBlendState colorBlend;
|
|
|
|
|
GraphicsPipelineCreateInfo()
|
|
|
|
|
{
|
2021-04-01 16:40:14 +02:00
|
|
|
std::memset((void*)this, 0, sizeof(*this));
|
2020-06-02 11:46:18 +02:00
|
|
|
topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
|
|
|
|
rasterizationState.cullMode = Gfx::SE_CULL_MODE_BACK_BIT;
|
|
|
|
|
rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_FILL;
|
|
|
|
|
rasterizationState.frontFace = Gfx::SE_FRONT_FACE_COUNTER_CLOCKWISE;
|
2021-05-06 17:02:10 +02:00
|
|
|
depthStencilState.depthCompareOp = Gfx::SE_COMPARE_OP_LESS_OR_EQUAL;
|
2020-06-02 11:46:18 +02:00
|
|
|
depthStencilState.minDepthBounds = 0.0f;
|
|
|
|
|
depthStencilState.maxDepthBounds = 1.0f;
|
|
|
|
|
depthStencilState.stencilTestEnable = false;
|
|
|
|
|
depthStencilState.depthWriteEnable = true;
|
|
|
|
|
depthStencilState.depthTestEnable = true;
|
|
|
|
|
multisampleState.samples = 1;
|
|
|
|
|
colorBlend.attachmentCount = 0;
|
|
|
|
|
colorBlend.logicOpEnable = false;
|
|
|
|
|
colorBlend.blendConstants[0] = 1.0f;
|
|
|
|
|
colorBlend.blendConstants[1] = 1.0f;
|
|
|
|
|
colorBlend.blendConstants[2] = 1.0f;
|
|
|
|
|
colorBlend.blendConstants[3] = 1.0f;
|
2020-05-05 01:51:13 +02:00
|
|
|
}
|
|
|
|
|
};
|
2021-05-06 17:02:10 +02:00
|
|
|
struct ComputePipelineCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Gfx::PComputeShader computeShader;
|
|
|
|
|
Gfx::PPipelineLayout pipelineLayout;
|
|
|
|
|
ComputePipelineCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
std::memset((void*)this, 0, sizeof(*this));
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-05-05 01:51:13 +02:00
|
|
|
} // namespace Seele
|