2020-03-08 13:38:40 +01:00
|
|
|
#include "GraphicsResources.h"
|
2020-05-05 01:51:13 +02:00
|
|
|
#include "Material/MaterialInstance.h"
|
2020-03-08 13:38:40 +01:00
|
|
|
|
2020-04-12 15:47:19 +02:00
|
|
|
using namespace Seele;
|
2020-03-20 01:27:40 +01:00
|
|
|
using namespace Seele::Gfx;
|
2020-03-08 13:38:40 +01:00
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount)
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
|
|
|
|
if (descriptorBindings.size() <= bindingIndex)
|
|
|
|
|
{
|
|
|
|
|
descriptorBindings.resize(bindingIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
DescriptorBinding binding;
|
|
|
|
|
binding.binding = bindingIndex;
|
|
|
|
|
binding.descriptorType = type;
|
|
|
|
|
binding.descriptorCount = arrayCount;
|
|
|
|
|
descriptorBindings[bindingIndex] = binding;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
PDescriptorSet DescriptorLayout::allocatedDescriptorSet()
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
|
|
|
|
PDescriptorSet result;
|
|
|
|
|
allocator->allocateDescriptorSet(result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 01:27:40 +01:00
|
|
|
void PipelineLayout::addDescriptorLayout(uint32 setIndex, PDescriptorLayout layout)
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
|
|
|
|
if (descriptorSetLayouts.size() <= setIndex)
|
|
|
|
|
{
|
|
|
|
|
descriptorSetLayouts.resize(setIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
if (descriptorSetLayouts[setIndex] != nullptr)
|
|
|
|
|
{
|
2020-04-12 15:47:19 +02:00
|
|
|
auto &thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings;
|
|
|
|
|
auto &otherBindings = layout->descriptorBindings;
|
2020-03-08 13:38:40 +01:00
|
|
|
thisBindings.resize(otherBindings.size());
|
|
|
|
|
for (size_t i = 0; i < otherBindings.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (otherBindings[i].descriptorType != SE_DESCRIPTOR_TYPE_MAX_ENUM)
|
|
|
|
|
{
|
|
|
|
|
assert(thisBindings[i].descriptorType != SE_DESCRIPTOR_TYPE_MAX_ENUM ? thisBindings[i].descriptorType == otherBindings[i].descriptorType : true);
|
|
|
|
|
thisBindings[i] = otherBindings[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
descriptorSetLayouts[setIndex] = layout;
|
2020-05-05 01:51:13 +02:00
|
|
|
layout->setIndex = setIndex;
|
2020-03-08 13:38:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 15:47:19 +02:00
|
|
|
void PipelineLayout::addPushConstants(const SePushConstantRange &pushConstant)
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
|
|
|
|
pushConstants.add(pushConstant);
|
|
|
|
|
}
|
2020-04-01 02:17:49 +02:00
|
|
|
|
2020-04-12 15:47:19 +02:00
|
|
|
UniformBuffer::UniformBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniformBuffer::~UniformBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-05-05 01:51:13 +02:00
|
|
|
VertexBuffer::VertexBuffer(uint32 numVertices, uint32 vertexSize)
|
|
|
|
|
: numVertices(numVertices), vertexSize(vertexSize)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexBuffer::~VertexBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
IndexBuffer::IndexBuffer(uint32 size, Gfx::SeIndexType indexType)
|
|
|
|
|
: indexType(indexType)
|
|
|
|
|
{
|
|
|
|
|
switch (indexType)
|
|
|
|
|
{
|
|
|
|
|
case SE_INDEX_TYPE_UINT16:
|
|
|
|
|
numIndices = size / 16;
|
|
|
|
|
break;
|
|
|
|
|
case SE_INDEX_TYPE_UINT32:
|
|
|
|
|
numIndices = size / 32;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IndexBuffer::~IndexBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexStream::VertexStream(PVertexBuffer buffer, uint8 instanced)
|
|
|
|
|
: buffer(buffer)
|
|
|
|
|
, instanced(instanced)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexStream::~VertexStream()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void VertexStream::addVertexElement(VertexElement element)
|
|
|
|
|
{
|
|
|
|
|
vertexDescription.add(element);
|
|
|
|
|
}
|
|
|
|
|
const Array<VertexElement> VertexStream::getVertexDescriptions() const
|
|
|
|
|
{
|
|
|
|
|
return vertexDescription;
|
|
|
|
|
}
|
|
|
|
|
Gfx::PVertexBuffer VertexStream::getVertexBuffer()
|
|
|
|
|
{
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VertexDeclaration::VertexDeclaration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexDeclaration::~VertexDeclaration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
uint32 VertexDeclaration::addVertexStream(const VertexStream &element)
|
|
|
|
|
{
|
|
|
|
|
uint32 currIndex = vertexStreams.size();
|
|
|
|
|
vertexStreams.add(element);
|
|
|
|
|
return currIndex;
|
|
|
|
|
}
|
|
|
|
|
const Array<VertexStream> &VertexDeclaration::getVertexStreams() const
|
|
|
|
|
{
|
|
|
|
|
return vertexStreams;
|
|
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
|
2020-04-01 02:17:49 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout()
|
2020-04-12 15:47:19 +02:00
|
|
|
: inputAttachments(), colorAttachments(), depthAttachment()
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 15:47:19 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment depthAttachment)
|
|
|
|
|
: inputAttachments(), colorAttachments(), depthAttachment(depthAttachment)
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 15:47:19 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment)
|
|
|
|
|
: inputAttachments(), depthAttachment(depthAttachment)
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
colorAttachments.add(colorAttachment);
|
|
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachmet)
|
|
|
|
|
: inputAttachments(), colorAttachments(colorAttachments), depthAttachment(depthAttachment)
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
|
|
|
|
|
: inputAttachments(inputAttachments), colorAttachments(colorAttachments), depthAttachment(depthAttachment)
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
|
|
|
|
|
Window::Window(const WindowCreateInfo &createInfo)
|
|
|
|
|
: sizeX(createInfo.width), sizeY(createInfo.height), bFullscreen(createInfo.bFullscreen), title(createInfo.title), pixelFormat(createInfo.pixelFormat)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Window::~Window()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Viewport::Viewport(PWindow owner, const ViewportCreateInfo &viewportInfo)
|
|
|
|
|
: sizeX(viewportInfo.sizeX), sizeY(viewportInfo.sizeY), offsetX(viewportInfo.offsetX), offsetY(viewportInfo.offsetY), owner(owner)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Viewport::~Viewport()
|
|
|
|
|
{
|
|
|
|
|
}
|