2020-03-08 13:38:40 +01:00
|
|
|
#include "GraphicsResources.h"
|
2020-06-02 11:46:18 +02:00
|
|
|
#include "Graphics.h"
|
2021-05-06 17:02:10 +02:00
|
|
|
#include "RenderPass/DepthPrepass.h"
|
|
|
|
|
#include "RenderPass/BasePass.h"
|
2022-11-15 12:19:11 +01:00
|
|
|
#include "Material/MaterialAsset.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-08-06 00:54:43 +02:00
|
|
|
std::string getShaderNameFromRenderPassType(Gfx::RenderPassType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case Gfx::RenderPassType::DepthPrepass:
|
2022-11-15 12:19:11 +01:00
|
|
|
return "DepthPrepass";
|
2020-08-06 00:54:43 +02:00
|
|
|
case Gfx::RenderPassType::BasePass:
|
2022-11-15 12:19:11 +01:00
|
|
|
return "ForwardPlus";
|
2020-08-06 00:54:43 +02:00
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-06 17:02:10 +02:00
|
|
|
void modifyRenderPassMacros(Gfx::RenderPassType type, Map<const char*, const char*>& defines)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case Gfx::RenderPassType::DepthPrepass:
|
|
|
|
|
DepthPrepass::modifyRenderPassMacros(defines);
|
2021-10-15 23:12:29 +02:00
|
|
|
break;
|
2021-05-06 17:02:10 +02:00
|
|
|
case Gfx::RenderPassType::BasePass:
|
|
|
|
|
BasePass::modifyRenderPassMacros(defines);
|
2021-10-15 23:12:29 +02:00
|
|
|
break;
|
2021-05-06 17:02:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-06 00:54:43 +02:00
|
|
|
|
|
|
|
|
ShaderMap::ShaderMap()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShaderMap::~ShaderMap()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ShaderCollection* ShaderMap::findShaders(PermutationId&& id) const
|
|
|
|
|
{
|
|
|
|
|
for(uint32 i = 0; i < shaders.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if(shaders[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
return &(shaders[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
ShaderCollection& ShaderMap::createShaders(
|
|
|
|
|
PGraphics graphics,
|
|
|
|
|
RenderPassType renderPass,
|
2021-10-19 23:04:38 +02:00
|
|
|
PMaterialAsset material,
|
2020-09-19 14:36:50 +02:00
|
|
|
VertexInputType* vertexInput,
|
2021-04-01 16:40:14 +02:00
|
|
|
bool /*bPositionOnly*/)
|
2020-08-06 00:54:43 +02:00
|
|
|
{
|
2022-01-12 14:40:26 +01:00
|
|
|
std::scoped_lock lock(shadersLock);
|
2020-08-06 00:54:43 +02:00
|
|
|
ShaderCollection& collection = shaders.add();
|
2020-09-19 14:36:50 +02:00
|
|
|
//collection.vertexDeclaration = bPositionOnly ? vertexInput->getPositionDeclaration() : vertexInput->getDeclaration();
|
2020-08-06 00:54:43 +02:00
|
|
|
|
|
|
|
|
ShaderCreateInfo createInfo;
|
|
|
|
|
createInfo.entryPoint = "vertexMain";
|
2020-09-19 14:36:50 +02:00
|
|
|
createInfo.typeParameter = {material->getName().c_str()};
|
|
|
|
|
createInfo.defines["NUM_MATERIAL_TEXCOORDS"] = "1";
|
|
|
|
|
createInfo.defines["USE_INSTANCING"] = "0";
|
2021-05-06 17:02:10 +02:00
|
|
|
modifyRenderPassMacros(renderPass, createInfo.defines);
|
|
|
|
|
createInfo.name = getShaderNameFromRenderPassType(renderPass) + " Material " + material->getName();
|
2020-08-06 00:54:43 +02:00
|
|
|
|
2021-10-23 00:22:35 +02:00
|
|
|
std::ifstream codeStream("./shaders/" + getShaderNameFromRenderPassType(renderPass));
|
|
|
|
|
|
2022-11-15 12:19:11 +01:00
|
|
|
createInfo.mainModule = getShaderNameFromRenderPassType(renderPass);
|
|
|
|
|
createInfo.additionalModules.add(vertexInput->getShaderFilename());
|
|
|
|
|
createInfo.additionalModules.add(material->getName());
|
2020-09-19 14:36:50 +02:00
|
|
|
|
2020-08-06 00:54:43 +02:00
|
|
|
collection.vertexShader = graphics->createVertexShader(createInfo);
|
|
|
|
|
|
2020-09-19 14:36:50 +02:00
|
|
|
if(renderPass != RenderPassType::DepthPrepass)
|
|
|
|
|
{
|
|
|
|
|
createInfo.entryPoint = "fragmentMain";
|
|
|
|
|
|
|
|
|
|
collection.fragmentShader = graphics->createFragmentShader(createInfo);
|
|
|
|
|
}
|
2020-10-03 11:00:10 +02:00
|
|
|
ShaderPermutation permutation;
|
2021-04-13 23:09:16 +02:00
|
|
|
std::string materialName = material->getName();
|
2020-10-03 11:00:10 +02:00
|
|
|
std::string vertexInputName = vertexInput->getName();
|
|
|
|
|
permutation.passType = renderPass;
|
|
|
|
|
std::memcpy(permutation.materialName, materialName.c_str(), sizeof(permutation.materialName));
|
|
|
|
|
std::memcpy(permutation.vertexInputName, vertexInputName.c_str(), sizeof(permutation.vertexInputName));
|
|
|
|
|
collection.id = PermutationId(permutation);
|
2020-09-19 14:36:50 +02:00
|
|
|
|
2020-08-06 00:54:43 +02:00
|
|
|
return collection;
|
|
|
|
|
}
|
2022-04-15 11:19:30 +02:00
|
|
|
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount, SeDescriptorBindingFlags bindingFlags)
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
|
|
|
|
if (descriptorBindings.size() <= bindingIndex)
|
|
|
|
|
{
|
|
|
|
|
descriptorBindings.resize(bindingIndex + 1);
|
|
|
|
|
}
|
2022-04-15 11:19:30 +02:00
|
|
|
DescriptorBinding& binding = descriptorBindings[bindingIndex];
|
2020-03-08 13:38:40 +01:00
|
|
|
binding.binding = bindingIndex;
|
|
|
|
|
binding.descriptorType = type;
|
|
|
|
|
binding.descriptorCount = arrayCount;
|
2022-04-15 11:19:30 +02:00
|
|
|
binding.bindingFlags = bindingFlags;
|
2020-03-08 13:38:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-10 23:57:55 +02:00
|
|
|
PDescriptorSet DescriptorLayout::allocateDescriptorSet()
|
2020-03-08 13:38:40 +01:00
|
|
|
{
|
2022-01-12 14:40:26 +01:00
|
|
|
std::scoped_lock lock(allocatorLock);
|
2020-03-08 13:38:40 +01:00
|
|
|
PDescriptorSet result;
|
|
|
|
|
allocator->allocateDescriptorSet(result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-03 11:00:10 +02:00
|
|
|
void DescriptorLayout::reset()
|
|
|
|
|
{
|
2022-01-12 14:40:26 +01:00
|
|
|
std::scoped_lock lock(allocatorLock);
|
2020-10-03 11:00:10 +02:00
|
|
|
allocator->reset();
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2021-10-16 12:59:11 +02:00
|
|
|
descriptorSetLayouts[setIndex] = layout;
|
2020-10-03 11:00:10 +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-09-19 14:36:50 +02:00
|
|
|
QueueOwnedResource::QueueOwnedResource(QueueFamilyMapping mapping, QueueType startQueueType)
|
2021-04-01 16:40:14 +02:00
|
|
|
: currentOwner(startQueueType)
|
|
|
|
|
, mapping(mapping)
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QueueOwnedResource::~QueueOwnedResource()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QueueOwnedResource::transferOwnership(QueueType newOwner)
|
|
|
|
|
{
|
2020-09-19 14:36:50 +02:00
|
|
|
if(mapping.needsTransfer(currentOwner, newOwner))
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
|
|
|
|
executeOwnershipBarrier(newOwner);
|
|
|
|
|
}
|
2021-05-10 23:57:55 +02:00
|
|
|
currentOwner = newOwner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QueueOwnedResource::pipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage, SeAccessFlags dstAccess, SePipelineStageFlags dstStage)
|
|
|
|
|
{
|
|
|
|
|
// maybe add some checks
|
|
|
|
|
executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
|
2020-06-02 11:46:18 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-19 14:36:50 +02:00
|
|
|
Buffer::Buffer(QueueFamilyMapping mapping, QueueType startQueue)
|
|
|
|
|
: QueueOwnedResource(mapping, startQueue)
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Buffer::~Buffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-03 11:00:10 +02:00
|
|
|
UniformBuffer::UniformBuffer(QueueFamilyMapping mapping, const BulkResourceData& resourceData)
|
|
|
|
|
: Buffer(mapping, resourceData.owner)
|
2021-04-25 23:43:40 +02:00
|
|
|
, contents(resourceData.size)
|
2020-04-12 15:47:19 +02:00
|
|
|
{
|
2020-10-03 11:00:10 +02:00
|
|
|
if(resourceData.data != nullptr)
|
|
|
|
|
{
|
2021-04-25 23:43:40 +02:00
|
|
|
std::memcpy(contents.data(), resourceData.data, contents.size());
|
2020-10-03 11:00:10 +02:00
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniformBuffer::~UniformBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-10-03 11:00:10 +02:00
|
|
|
|
2021-04-25 23:43:40 +02:00
|
|
|
bool UniformBuffer::updateContents(const BulkResourceData& resourceData)
|
2020-10-03 11:00:10 +02:00
|
|
|
{
|
2021-04-25 23:43:40 +02:00
|
|
|
assert(contents.size() == resourceData.size);
|
|
|
|
|
if(std::memcmp(contents.data(), resourceData.data, contents.size()) == 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
std::memcpy(contents.data(), resourceData.data, contents.size());
|
|
|
|
|
return true;
|
2020-10-03 11:00:10 +02:00
|
|
|
}
|
|
|
|
|
|
2022-04-15 23:45:44 +02:00
|
|
|
StructuredBuffer::StructuredBuffer(QueueFamilyMapping mapping, uint32 stride, const BulkResourceData& resourceData)
|
2021-06-04 18:27:49 +02:00
|
|
|
: Buffer(mapping, resourceData.owner)
|
|
|
|
|
, contents(resourceData.size)
|
2022-04-15 23:45:44 +02:00
|
|
|
, stride(stride)
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
2022-04-17 09:10:20 +02:00
|
|
|
if(resourceData.data != nullptr)
|
|
|
|
|
{
|
|
|
|
|
std::memcpy(contents.data(), resourceData.data, resourceData.size);
|
|
|
|
|
}
|
2020-06-02 11:46:18 +02:00
|
|
|
}
|
|
|
|
|
StructuredBuffer::~StructuredBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-06-04 18:27:49 +02:00
|
|
|
|
|
|
|
|
bool StructuredBuffer::updateContents(const BulkResourceData& resourceData)
|
|
|
|
|
{
|
2022-04-18 18:08:38 +02:00
|
|
|
assert(contents.size() >= resourceData.size);
|
|
|
|
|
if(std::memcmp(contents.data(), resourceData.data, resourceData.size) == 0)
|
2021-06-04 18:27:49 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-04-18 18:08:38 +02:00
|
|
|
std::memcpy(contents.data(), resourceData.data, resourceData.size);
|
2021-06-04 18:27:49 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-09-19 14:36:50 +02:00
|
|
|
VertexBuffer::VertexBuffer(QueueFamilyMapping mapping, uint32 numVertices, uint32 vertexSize, QueueType startQueueType)
|
|
|
|
|
: Buffer(mapping, startQueueType)
|
|
|
|
|
, numVertices(numVertices)
|
|
|
|
|
, vertexSize(vertexSize)
|
2020-05-05 01:51:13 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexBuffer::~VertexBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-11-15 12:19:11 +01:00
|
|
|
IndexBuffer::IndexBuffer(QueueFamilyMapping mapping, uint64 size, Gfx::SeIndexType indexType, QueueType startQueueType)
|
2020-09-19 14:36:50 +02:00
|
|
|
: Buffer(mapping, startQueueType)
|
2020-06-02 11:46:18 +02:00
|
|
|
, indexType(indexType)
|
2020-05-05 01:51:13 +02:00
|
|
|
{
|
|
|
|
|
switch (indexType)
|
|
|
|
|
{
|
|
|
|
|
case SE_INDEX_TYPE_UINT16:
|
2020-10-23 01:47:56 +02:00
|
|
|
numIndices = size / sizeof(uint16);
|
2020-05-05 01:51:13 +02:00
|
|
|
break;
|
|
|
|
|
case SE_INDEX_TYPE_UINT32:
|
2020-10-23 01:47:56 +02:00
|
|
|
numIndices = size / sizeof(uint32);
|
2020-05-05 01:51:13 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IndexBuffer::~IndexBuffer()
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-06-08 01:44:47 +02:00
|
|
|
VertexStream::VertexStream()
|
|
|
|
|
{}
|
2020-09-19 14:36:50 +02:00
|
|
|
VertexStream::VertexStream(uint32 stride, uint32 offset, uint8 instanced)
|
2021-04-01 16:40:14 +02:00
|
|
|
: stride(stride)
|
|
|
|
|
, offset(offset)
|
|
|
|
|
, instanced(instanced)
|
2020-05-05 01:51:13 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexStream::~VertexStream()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void VertexStream::addVertexElement(VertexElement element)
|
|
|
|
|
{
|
|
|
|
|
vertexDescription.add(element);
|
|
|
|
|
}
|
|
|
|
|
const Array<VertexElement> VertexStream::getVertexDescriptions() const
|
|
|
|
|
{
|
|
|
|
|
return vertexDescription;
|
|
|
|
|
}
|
2022-11-15 12:19:11 +01:00
|
|
|
|
|
|
|
|
VertexDataManager::VertexDataManager(PGraphics graphics)
|
|
|
|
|
: currentSize(8 * 1024 * 1024)
|
|
|
|
|
, inUse(0)
|
|
|
|
|
, graphics(graphics)
|
|
|
|
|
{
|
|
|
|
|
VertexBufferCreateInfo defaultInfo = {
|
|
|
|
|
.resourceData = {
|
|
|
|
|
.size = currentSize,
|
|
|
|
|
.data = nullptr,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
buffer = graphics->createVertexBuffer(defaultInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VertexDataManager::~VertexDataManager()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VertexDataAllocation VertexDataManager::createVertexBuffer(const VertexBufferCreateInfo& vbInfo)
|
|
|
|
|
{
|
|
|
|
|
VertexDataAllocation data = allocateData(vbInfo.resourceData.size);
|
|
|
|
|
|
|
|
|
|
buffer->updateRegion(BulkResourceData{
|
|
|
|
|
.size = data.size,
|
|
|
|
|
.offset = data.offset,
|
|
|
|
|
.data = vbInfo.resourceData.data
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
activeAllocations[data.offset] = data;
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VertexDataManager::freeAllocation(VertexDataAllocation alloc)
|
|
|
|
|
{
|
|
|
|
|
uint64 lowerBound = alloc.offset;
|
|
|
|
|
uint64 upperBound = alloc.offset + alloc.size;
|
|
|
|
|
bool joinedLower = false;
|
|
|
|
|
uint64 lowerOffset = 0;
|
|
|
|
|
|
|
|
|
|
//Join lower bound
|
|
|
|
|
for (auto& [offset, freeAlloc] : freeRanges)
|
|
|
|
|
{
|
|
|
|
|
if (freeAlloc.offset <= lowerBound
|
|
|
|
|
&& freeAlloc.offset + freeAlloc.size >= upperBound)
|
|
|
|
|
{
|
|
|
|
|
// allocation is already in a free region
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (freeAlloc.offset + freeAlloc.size == lowerBound)
|
|
|
|
|
{
|
|
|
|
|
//extend freeAlloc by the allocatedSize
|
|
|
|
|
freeAlloc.size += alloc.size;
|
|
|
|
|
joinedLower = true;
|
|
|
|
|
lowerOffset = freeAlloc.offset;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Join upper bound
|
|
|
|
|
auto foundAlloc = freeRanges.find(upperBound);
|
|
|
|
|
if (foundAlloc != freeRanges.end())
|
|
|
|
|
{
|
|
|
|
|
// There is a free allocation ending where the new free one ends
|
|
|
|
|
if (joinedLower)
|
|
|
|
|
{
|
|
|
|
|
// extend allocHandle by another foundAlloc->allocatedSize bytes
|
|
|
|
|
freeRanges[lowerOffset].size += foundAlloc->value.size;
|
|
|
|
|
freeRanges.erase(upperBound);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// set foundAlloc back by size amount
|
|
|
|
|
freeRanges[upperBound].offset -= alloc.size;
|
|
|
|
|
freeRanges[upperBound].size += alloc.size;
|
|
|
|
|
// place back at correct offset
|
|
|
|
|
freeRanges[freeRanges[upperBound].offset] = freeRanges[upperBound];
|
|
|
|
|
// remove from offset map since key changes
|
|
|
|
|
freeRanges.erase(upperBound);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// No matching upper bound found
|
|
|
|
|
if(!joinedLower)
|
|
|
|
|
{
|
|
|
|
|
// Lower bound also not joined, create new range
|
|
|
|
|
freeRanges[alloc.offset] = alloc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
activeAllocations.erase(alloc.offset);
|
|
|
|
|
inUse -= alloc.size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VertexDataAllocation VertexDataManager::allocateData(uint64 size)
|
|
|
|
|
{
|
|
|
|
|
for (auto& [offset, freeAllocation] : freeRanges)
|
|
|
|
|
{
|
|
|
|
|
assert(offset == freeAllocation.offset);
|
|
|
|
|
if (freeAllocation.size == size)
|
|
|
|
|
{
|
|
|
|
|
activeAllocations[offset] = freeAllocation;
|
|
|
|
|
freeRanges.erase(offset);
|
|
|
|
|
inUse += size;
|
|
|
|
|
return freeAllocation;
|
|
|
|
|
}
|
|
|
|
|
else if (size < freeAllocation.size)
|
|
|
|
|
{
|
|
|
|
|
freeAllocation.size -= size;
|
|
|
|
|
freeAllocation.offset += size;
|
|
|
|
|
VertexDataAllocation subAlloc = VertexDataAllocation(size, offset);
|
|
|
|
|
activeAllocations[offset] = subAlloc;
|
|
|
|
|
freeRanges[freeAllocation.offset] = freeAllocation;
|
|
|
|
|
freeRanges.erase(offset);
|
|
|
|
|
inUse += size;
|
|
|
|
|
return subAlloc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw std::logic_error("TODO: expand buffer");
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 01:51:13 +02:00
|
|
|
VertexDeclaration::VertexDeclaration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
VertexDeclaration::~VertexDeclaration()
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-10-03 11:00:10 +02:00
|
|
|
|
|
|
|
|
static std::mutex vertexDeclarationLock;
|
|
|
|
|
static Map<uint32, PVertexDeclaration> vertexDeclarationCache;
|
|
|
|
|
|
|
|
|
|
PVertexDeclaration VertexDeclaration::createDeclaration(PGraphics graphics, const Array<VertexElement>& elementList)
|
2020-05-05 01:51:13 +02:00
|
|
|
{
|
2022-01-12 14:40:26 +01:00
|
|
|
std::scoped_lock lock(vertexDeclarationLock);
|
2022-11-22 22:11:37 +01:00
|
|
|
uint32 key = CRC::Calculate(&elementList, sizeof(VertexElement) * elementList.size(), CRC::CRC_32());
|
2020-10-03 11:00:10 +02:00
|
|
|
|
|
|
|
|
auto found = vertexDeclarationCache[key];
|
|
|
|
|
if(found == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PVertexDeclaration newDeclaration = graphics->createVertexDeclaration(elementList);
|
|
|
|
|
|
|
|
|
|
vertexDeclarationCache[key] = newDeclaration;
|
|
|
|
|
return newDeclaration;
|
2020-05-05 01:51:13 +02:00
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
|
2020-09-19 14:36:50 +02:00
|
|
|
Texture::Texture(QueueFamilyMapping mapping, Gfx::QueueType startQueueType)
|
|
|
|
|
: QueueOwnedResource(mapping, startQueueType)
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Texture::~Texture()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-19 14:36:50 +02:00
|
|
|
Texture2D::Texture2D(QueueFamilyMapping mapping, Gfx::QueueType startQueueType)
|
|
|
|
|
: Texture(mapping, startQueueType)
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Texture2D::~Texture2D()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderCommand::RenderCommand()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderCommand::~RenderCommand()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-10 23:57:55 +02:00
|
|
|
ComputeCommand::ComputeCommand()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ComputeCommand::~ComputeCommand()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 02:17:49 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout()
|
2021-04-01 16:40:14 +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)
|
2021-04-01 16:40:14 +02:00
|
|
|
: inputAttachments()
|
|
|
|
|
, colorAttachments()
|
|
|
|
|
, depthAttachment(depthAttachment)
|
|
|
|
|
, width(depthAttachment->getTexture()->getSizeX())
|
|
|
|
|
, height(depthAttachment->getTexture()->getSizeY())
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 15:47:19 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment)
|
2021-04-01 16:40:14 +02:00
|
|
|
: inputAttachments()
|
|
|
|
|
, depthAttachment(depthAttachment)
|
|
|
|
|
, width(depthAttachment->getTexture()->getSizeX())
|
|
|
|
|
, height(depthAttachment->getTexture()->getSizeY())
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
colorAttachments.add(colorAttachment);
|
|
|
|
|
}
|
2021-04-01 16:40:14 +02:00
|
|
|
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
|
|
|
|
|
: inputAttachments()
|
|
|
|
|
, colorAttachments(colorAttachments)
|
|
|
|
|
, depthAttachment(depthAttachment)
|
|
|
|
|
, width(depthAttachment->getTexture()->getSizeX())
|
|
|
|
|
, height(depthAttachment->getTexture()->getSizeY())
|
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)
|
2021-04-01 16:40:14 +02:00
|
|
|
: inputAttachments(inputAttachments)
|
|
|
|
|
, colorAttachments(colorAttachments)
|
|
|
|
|
, depthAttachment(depthAttachment)
|
|
|
|
|
, width(depthAttachment->getTexture()->getSizeX())
|
|
|
|
|
, height(depthAttachment->getTexture()->getSizeY())
|
2020-04-01 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
2020-04-12 15:47:19 +02:00
|
|
|
|
|
|
|
|
Window::Window(const WindowCreateInfo &createInfo)
|
2022-04-15 23:45:44 +02:00
|
|
|
: windowState(createInfo)
|
2020-04-12 15:47:19 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Window::~Window()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Viewport::Viewport(PWindow owner, const ViewportCreateInfo &viewportInfo)
|
2022-11-17 16:47:42 +01:00
|
|
|
: sizeX(viewportInfo.dimensions.size.x)
|
|
|
|
|
, sizeY(viewportInfo.dimensions.size.y)
|
|
|
|
|
, offsetX(viewportInfo.dimensions.offset.x)
|
|
|
|
|
, offsetY(viewportInfo.dimensions.offset.y)
|
2021-04-01 16:40:14 +02:00
|
|
|
, owner(owner)
|
2020-04-12 15:47:19 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Viewport::~Viewport()
|
|
|
|
|
{
|
2020-10-03 11:00:10 +02:00
|
|
|
}
|
|
|
|
|
|