Extending position only support

This commit is contained in:
Dynamitos
2024-06-19 10:33:19 +02:00
parent e501a69b36
commit 1e91f88355
17 changed files with 75 additions and 112 deletions
+1 -7
View File
@@ -8,7 +8,6 @@ struct PrimitiveAttributes
#ifdef VISIBILITY #ifdef VISIBILITY
uint32_t prim : SV_PrimitiveID; uint32_t prim : SV_PrimitiveID;
#endif #endif
bool cull: SV_CullPrimitive;
}; };
[numthreads(MESH_GROUP_SIZE, 1, 1)] [numthreads(MESH_GROUP_SIZE, 1, 1)]
@@ -38,9 +37,8 @@ void meshMain(
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1]; uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2]; uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
indices[p] = uint3(local_idx0, local_idx1, local_idx2); indices[p] = uint3(local_idx0, local_idx1, local_idx2);
prim[p].cull = !cull.triangleCulled(p);
#ifdef VISIBILITY #ifdef VISIBILITY
prim[p].prim = encodePrimitive(p, meshletId); prim[p].prim = encodePrimitive(meshletId);
#endif #endif
} }
} }
@@ -49,11 +47,7 @@ void meshMain(
uint v = min(i, m.vertexCount - 1); uint v = min(i, m.vertexCount - 1);
{ {
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v]; uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
#ifdef POS_ONLY
VertexAttributes attr = pVertexData.getPosition(m.indicesOffset + vertexIndex);
#else
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex); VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
#endif
vertices[v] = attr.getParameter(inst.transformMatrix); vertices[v] = attr.getParameter(inst.transformMatrix);
} }
} }
+1 -1
View File
@@ -52,7 +52,7 @@ void taskMain(
MeshletDescription meshlet = pScene.meshletInfos[m]; MeshletDescription meshlet = pScene.meshletInfos[m];
MeshletCullingInfo culling = pScene.cullingInfos[cull]; MeshletCullingInfo culling = pScene.cullingInfos[cull];
// if any triangle was visible last frame, it was drawn by the cached pass already // if any triangle was visible last frame, it was drawn by the cached pass already
if(!culling.anyVisible()) if(!culling.wasVisible())
{ {
// if the meshlet is outside of the frustum, we skip it since we cant do depth culling anyways // if the meshlet is outside of the frustum, we skip it since we cant do depth culling anyways
if(meshlet.bounding.insideFrustum(viewFrustum)) if(meshlet.bounding.insideFrustum(viewFrustum))
+1 -5
View File
@@ -40,7 +40,7 @@ void meshMain(
indices[p] = uint3(local_idx0, local_idx1, local_idx2); indices[p] = uint3(local_idx0, local_idx1, local_idx2);
prim[p].cull = false;//cull.triangleCulled(p); prim[p].cull = false;//cull.triangleCulled(p);
#ifdef VISIBILITY #ifdef VISIBILITY
prim[p].prim = encodePrimitive(p, meshletId); prim[p].prim = encodePrimitive(meshletId);
#endif #endif
} }
} }
@@ -49,11 +49,7 @@ void meshMain(
uint v = min(i, m.vertexCount - 1); uint v = min(i, m.vertexCount - 1);
{ {
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v]; uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
#ifdef POS_ONLY
VertexAttributes attr = pVertexData.getPosition(m.indicesOffset + vertexIndex);
#else
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex); VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
#endif
vertices[v] = attr.getParameter(inst.transformMatrix); vertices[v] = attr.getParameter(inst.transformMatrix);
} }
} }
+2 -1
View File
@@ -27,7 +27,8 @@ void taskMain(
MeshletDescription meshlet = pScene.meshletInfos[m]; MeshletDescription meshlet = pScene.meshletInfos[m];
MeshletCullingInfo culling = pScene.cullingInfos[cull]; MeshletCullingInfo culling = pScene.cullingInfos[cull];
#ifdef DEPTH_CULLING #ifdef DEPTH_CULLING
if(culling.anyVisible()) // if depth culling is disabled, we draw the whole scene as if cached
if(culling.wasVisible())
#endif #endif
{ {
uint index; uint index;
+3 -6
View File
@@ -4,7 +4,7 @@ import Scene;
struct VisibilityCullingData struct VisibilityCullingData
{ {
Texture2D<uint> visibilityTexture; Texture2D<uint> visibilityTexture;
globallycoherent RWStructuredBuffer<MeshletCullingInfo> cullingInfos; RWStructuredBuffer<MeshletCullingInfo> cullingInfos;
}; };
ParameterBlock<VisibilityCullingData> pVisibilityParams; ParameterBlock<VisibilityCullingData> pVisibilityParams;
@@ -15,9 +15,6 @@ void computeMain(
){ ){
int3 texCoords = int3(dispatchThreadID.xy, 0); int3 texCoords = int3(dispatchThreadID.xy, 0);
uint encoded = pVisibilityParams.visibilityTexture.Load(texCoords).r; uint encoded = pVisibilityParams.visibilityTexture.Load(texCoords).r;
uint2 decoded = decodePrimitive(encoded); uint meshletId = decodePrimitive(encoded);
uint arrIdx = decoded.x / 32; pVisibilityParams.cullingInfos[meshletId].visible = 1;
uint bit = decoded.x % 32;
uint32_t orig;
InterlockedOr(pVisibilityParams.cullingInfos[decoded.y].visible[arrIdx], (1 << bit), orig);
} }
+6
View File
@@ -20,6 +20,7 @@ struct LightingParameter
struct FragmentParameter struct FragmentParameter
{ {
float4 position_CS : SV_Position; float4 position_CS : SV_Position;
#ifndef POS_ONLY
float3 cameraPos_WS: POSITION0; float3 cameraPos_WS: POSITION0;
float3 normal_WS : NORMAL0; float3 normal_WS : NORMAL0;
float3 tangent_WS : TANGENT0; float3 tangent_WS : TANGENT0;
@@ -47,6 +48,7 @@ struct FragmentParameter
result.normal_WS = normal_WS; result.normal_WS = normal_WS;
return result; return result;
} }
#endif
}; };
// data passed to visibility render // data passed to visibility render
@@ -60,11 +62,13 @@ struct VisibilityParameter
struct VertexAttributes struct VertexAttributes
{ {
float3 position_MS; float3 position_MS;
#ifndef POS_ONLY
float3 normal_MS; float3 normal_MS;
float3 tangent_MS; float3 tangent_MS;
float3 biTangent_MS; float3 biTangent_MS;
float3 vertexColor; float3 vertexColor;
float2 texCoords[MAX_TEXCOORDS]; float2 texCoords[MAX_TEXCOORDS];
#endif
FragmentParameter getParameter(float4x4 transformMatrix) FragmentParameter getParameter(float4x4 transformMatrix)
{ {
float4 modelPos = float4(position_MS, 1); float4 modelPos = float4(position_MS, 1);
@@ -73,6 +77,7 @@ struct VertexAttributes
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos); float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
FragmentParameter result; FragmentParameter result;
result.position_CS = clipPos; result.position_CS = clipPos;
#ifndef POS_ONLY
float3x3 normalMatrix = float3x3(transformMatrix); float3x3 normalMatrix = float3x3(transformMatrix);
float3 T = mul(normalMatrix, tangent_MS); float3 T = mul(normalMatrix, tangent_MS);
float3 N = mul(normalMatrix, normal_MS); float3 N = mul(normalMatrix, normal_MS);
@@ -87,6 +92,7 @@ struct VertexAttributes
{ {
result.texCoords[i] = texCoords[i]; result.texCoords[i] = texCoords[i];
} }
#endif
return result; return result;
} }
}; };
+7 -26
View File
@@ -34,26 +34,10 @@ struct InstanceData
struct MeshletCullingInfo struct MeshletCullingInfo
{ {
uint32_t visible[MAX_PRIMITIVES / 32]; uint32_t visible;
// lookup if a specific triangle is visible bool wasVisible()
bool triangleVisible(uint32_t primIndex)
{ {
uint32_t arrIdx = primIndex / 32; return bool(visible);
uint32_t cullIdx = primIndex % 32;
return (visible[arrIdx] & (1 << cullIdx)) != 0;
}
bool triangleCulled(uint32_t primIndex)
{
return !triangleVisible(primIndex);
}
bool anyVisible()
{
uint result = 0;
for(uint i = 0; i < MAX_PRIMITIVES / 32; ++i)
{
result |= visible[i];
}
return result != 0;
} }
}; };
@@ -80,17 +64,14 @@ struct Scene
layout(set=2) layout(set=2)
ParameterBlock<Scene> pScene; ParameterBlock<Scene> pScene;
uint32_t encodePrimitive(uint32_t primitiveId, uint32_t meshletId) uint32_t encodePrimitive(uint32_t meshletId)
{ {
return primitiveId + (meshletId * uint(MAX_PRIMITIVES)); return meshletId;
} }
uint2 decodePrimitive(uint32_t encoded) uint decodePrimitive(uint32_t encoded)
{ {
uint prim = uint(encoded % MAX_PRIMITIVES); return encoded;
encoded = encoded / MAX_PRIMITIVES;
uint meshletId = uint(encoded);
return uint2(prim, meshletId);
} }
struct MeshPayload struct MeshPayload
+2 -6
View File
@@ -8,6 +8,7 @@ struct StaticMeshVertexData : IVertexData
{ {
VertexAttributes attributes; VertexAttributes attributes;
attributes.position_MS = positions[index].xyz; attributes.position_MS = positions[index].xyz;
#ifndef POS_ONLY
attributes.normal_MS = normals[index].xyz; attributes.normal_MS = normals[index].xyz;
attributes.tangent_MS = tangents[index].xyz; attributes.tangent_MS = tangents[index].xyz;
attributes.biTangent_MS = biTangents[index].xyz; attributes.biTangent_MS = biTangents[index].xyz;
@@ -16,12 +17,7 @@ struct StaticMeshVertexData : IVertexData
attributes.texCoords[i] = texCoords[i][index]; attributes.texCoords[i] = texCoords[i][index];
} }
attributes.vertexColor = color[index].xyz; attributes.vertexColor = color[index].xyz;
return attributes; #endif
}
VertexAttributes getPosition(uint index)
{
VertexAttributes attributes;
attributes.position_MS = positions[index].xyz;
return attributes; return attributes;
} }
StructuredBuffer<float4> positions; StructuredBuffer<float4> positions;
-1
View File
@@ -9,7 +9,6 @@ struct VertexInput
interface IVertexData interface IVertexData
{ {
VertexAttributes getAttributes(uint index); VertexAttributes getAttributes(uint index);
VertexAttributes getPosition(uint index);
}; };
layout(set=1) layout(set=1)
+1 -1
View File
@@ -76,7 +76,7 @@ class ShaderBuffer : public Buffer {
public: public:
ShaderBuffer(QueueFamilyMapping mapping, const ShaderBufferCreateInfo& createInfo); ShaderBuffer(QueueFamilyMapping mapping, const ShaderBufferCreateInfo& createInfo);
virtual ~ShaderBuffer(); virtual ~ShaderBuffer();
virtual void rotateBuffer(uint64 size, bool preserveContents = false, uint32 fillValue = 0) = 0; virtual void rotateBuffer(uint64 size, bool preserveContents = false) = 0;
virtual void updateContents(const ShaderBufferCreateInfo& sourceData) = 0; virtual void updateContents(const ShaderBufferCreateInfo& sourceData) = 0;
constexpr uint32 getNumElements() const { return numElements; } constexpr uint32 getNumElements() const { return numElements; }
+1
View File
@@ -97,6 +97,7 @@ struct UniformBufferCreateInfo {
struct ShaderBufferCreateInfo { struct ShaderBufferCreateInfo {
DataSource sourceData = DataSource(); DataSource sourceData = DataSource();
uint64 numElements = 1; uint64 numElements = 1;
uint32 clearValue = 0;
uint8 dynamic = 0; uint8 dynamic = 0;
uint8 vertexBuffer = 0; uint8 vertexBuffer = 0;
std::string name = "Unnamed"; std::string name = "Unnamed";
@@ -94,6 +94,7 @@ void BasePass::render() {
Gfx::ShaderPermutation permutation = graphics->getShaderCompiler()->getTemplate("BasePass"); Gfx::ShaderPermutation permutation = graphics->getShaderCompiler()->getTemplate("BasePass");
permutation.setDepthCulling(true); // always use the culling info permutation.setDepthCulling(true); // always use the culling info
permutation.setPositionOnly(false);
for (VertexData* vertexData : VertexData::getList()) { for (VertexData* vertexData : VertexData::getList()) {
vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer); vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer);
vertexData->getInstanceDataSet()->writeChanges(); vertexData->getInstanceDataSet()->writeChanges();
@@ -11,7 +11,7 @@ VisibilityPass::~VisibilityPass() {}
void VisibilityPass::beginFrame(const Component::Camera& cam) { void VisibilityPass::beginFrame(const Component::Camera& cam) {
RenderPass::beginFrame(cam); RenderPass::beginFrame(cam);
cullingBuffer->rotateBuffer(VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo), true, 0xffffffff); cullingBuffer->rotateBuffer(VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo), true);
} }
void VisibilityPass::render() { void VisibilityPass::render() {
@@ -77,7 +77,11 @@ void VisibilityPass::publishOutputs() {
pipelineInfo.pipelineLayout = std::move(visibilityLayout); pipelineInfo.pipelineLayout = std::move(visibilityLayout);
visibilityPipeline = graphics->createComputePipeline(std::move(pipelineInfo)); visibilityPipeline = graphics->createComputePipeline(std::move(pipelineInfo));
cullingBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.dynamic = true, .name = "CullingBuffer"}); cullingBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
.clearValue = 0xffffffff,
.dynamic = true,
.name = "CullingBuffer",
});
resources->registerBufferOutput("CULLINGBUFFER", cullingBuffer); resources->registerBufferOutput("CULLINGBUFFER", cullingBuffer);
query = graphics->createPipelineStatisticsQuery(); query = graphics->createPipelineStatisticsQuery();
+2 -5
View File
@@ -1,11 +1,10 @@
#include "Shader.h" #include "Shader.h"
#include "Graphics/Graphics.h"
#include "Graphics/Initializer.h" #include "Graphics/Initializer.h"
#include "Material/Material.h" #include "Material/Material.h"
#include "ThreadPool.h" #include "ThreadPool.h"
#include "Graphics/Graphics.h"
#include <fmt/core.h> #include <fmt/core.h>
using namespace Seele; using namespace Seele;
using namespace Seele::Gfx; using namespace Seele::Gfx;
@@ -55,11 +54,10 @@ void ShaderCompiler::compile() {
for (const auto& [vdName, vd] : vertexData) { for (const auto& [vdName, vd] : vertexData) {
if (pass.useMaterial) { if (pass.useMaterial) {
for (const auto& [matName, mat] : materials) { for (const auto& [matName, mat] : materials) {
for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2; y++) { for (int y = 0; y < 2; y++) {
work.add([=]() { work.add([=]() {
ShaderPermutation permutation = getTemplate(name); ShaderPermutation permutation = getTemplate(name);
permutation.setPositionOnly(x); permutation.setPositionOnly(false);
permutation.setDepthCulling(y); permutation.setDepthCulling(y);
permutation.setVertexData(vd->getTypeName()); permutation.setVertexData(vd->getTypeName());
OPipelineLayout layout = graphics->createPipelineLayout(pass.baseLayout->getName(), pass.baseLayout); OPipelineLayout layout = graphics->createPipelineLayout(pass.baseLayout->getName(), pass.baseLayout);
@@ -70,7 +68,6 @@ void ShaderCompiler::compile() {
}); });
} }
} }
}
} else { } else {
for (int x = 0; x < 2; x++) { for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2; y++) { for (int y = 0; y < 2; y++) {
+1 -1
View File
@@ -28,7 +28,7 @@ class VertexData {
}; };
struct MeshletCullingInfo { struct MeshletCullingInfo {
uint64_t cull[256 / 64]; uint32_t cull;
}; };
struct BatchedDrawCall { struct BatchedDrawCall {
PMaterialInstance materialInstance; PMaterialInstance materialInstance;
+33 -43
View File
@@ -166,11 +166,15 @@ void BufferAllocation::readContents(uint64 regionOffset, uint64 regionSize, void
graphics->getDestructionManager()->queueResourceForDestruction(std::move(staging)); graphics->getDestructionManager()->queueResourceForDestruction(std::move(staging));
} }
Buffer::Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType queueType, bool dynamic, std::string name) Buffer::Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType queueType, bool dynamic, std::string name,
uint32 clearValue)
: graphics(graphics), currentBuffer(0), initialOwner(queueType), : graphics(graphics), currentBuffer(0), initialOwner(queueType),
usage(usage | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT), usage(usage | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT),
dynamic(dynamic), name(name) { dynamic(dynamic), name(name), clearValue(clearValue) {
createBuffer(size); if (size > 0) {
buffers.add(nullptr);
createBuffer(size, 0);
}
} }
Buffer::~Buffer() { Buffer::~Buffer() {
@@ -187,7 +191,7 @@ void Buffer::readContents(uint64 regionOffset, uint64 regionSize, void* buffer)
getAlloc()->readContents(regionOffset, regionSize, buffer); getAlloc()->readContents(regionOffset, regionSize, buffer);
} }
void Buffer::rotateBuffer(uint64 size, bool preserveContents, uint32 fillValue) { void Buffer::rotateBuffer(uint64 size, bool preserveContents) {
assert(dynamic); assert(dynamic);
if (buffers.size() > 0) { if (buffers.size() > 0) {
size = std::max(getSize(), size); size = std::max(getSize(), size);
@@ -198,6 +202,24 @@ void Buffer::rotateBuffer(uint64 size, bool preserveContents, uint32 fillValue)
} }
if (buffers[i]->size < size) { if (buffers[i]->size < size) {
graphics->getDestructionManager()->queueResourceForDestruction(std::move(buffers[i])); graphics->getDestructionManager()->queueResourceForDestruction(std::move(buffers[i]));
createBuffer(size, i);
}
if (preserveContents) {
copyBuffer(currentBuffer, i);
}
currentBuffer = i;
return;
}
buffers.add(nullptr);
createBuffer(size, buffers.size() - 1);
if (preserveContents) {
copyBuffer(currentBuffer, buffers.size() - 1);
}
currentBuffer = buffers.size() - 1;
}
void Buffer::createBuffer(uint64 size, uint32 destIndex) {
if (size > 0) {
uint32 family = graphics->getFamilyMapping().getQueueTypeFamilyIndex(initialOwner); uint32 family = graphics->getFamilyMapping().getQueueTypeFamilyIndex(initialOwner);
VkBufferCreateInfo info = { VkBufferCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
@@ -212,43 +234,11 @@ void Buffer::rotateBuffer(uint64 size, bool preserveContents, uint32 fillValue)
VmaAllocationCreateInfo allocInfo = { VmaAllocationCreateInfo allocInfo = {
.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, .usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
}; };
buffers[i] = new BufferAllocation(graphics, name, info, allocInfo, initialOwner); buffers[destIndex] = new BufferAllocation(graphics, name, info, allocInfo, initialOwner);
} PCommand command = graphics->getQueueCommands(initialOwner)->getCommands();
if (preserveContents) { vkCmdFillBuffer(command->getHandle(), buffers[destIndex]->buffer, 0, VK_WHOLE_SIZE, clearValue);
copyBuffer(currentBuffer, i); pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
if (buffers[i]->size > buffers[currentBuffer]->size) { VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
PCommand command = graphics->getQueueCommands(getAlloc()->owner)->getCommands();
vkCmdFillBuffer(command->getHandle(), buffers[i]->buffer, buffers[currentBuffer]->size,
buffers[i]->size - buffers[currentBuffer]->size, fillValue);
}
}
currentBuffer = i;
return;
}
createBuffer(size);
if (preserveContents) {
copyBuffer(currentBuffer, buffers.size() - 1);
}
currentBuffer = buffers.size() - 1;
}
void Buffer::createBuffer(uint64 size) {
if (size > 0) {
uint32 family = graphics->getFamilyMapping().getQueueTypeFamilyIndex(initialOwner);
VkBufferCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.size = size,
.usage = usage,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 1,
.pQueueFamilyIndices = &family,
};
VmaAllocationCreateInfo allocInfo = {
.usage = VMA_MEMORY_USAGE_AUTO,
};
buffers.add(new BufferAllocation(graphics, name, info, allocInfo, initialOwner));
} }
} }
@@ -349,9 +339,9 @@ void ShaderBuffer::updateContents(const ShaderBufferCreateInfo& createInfo) {
} }
} }
void ShaderBuffer::rotateBuffer(uint64 size, bool preserveContents, uint32 fillValue) { void ShaderBuffer::rotateBuffer(uint64 size, bool preserveContents) {
assert(dynamic); assert(dynamic);
Vulkan::Buffer::rotateBuffer(size, preserveContents, fillValue); Vulkan::Buffer::rotateBuffer(size, preserveContents);
} }
void ShaderBuffer::clear() { void ShaderBuffer::clear() {
+9 -9
View File
@@ -10,10 +10,10 @@ DECLARE_REF(Command)
DECLARE_REF(Fence) DECLARE_REF(Fence)
class BufferAllocation : public CommandBoundResource { class BufferAllocation : public CommandBoundResource {
public: public:
BufferAllocation(PGraphics graphics, const std::string& name, VkBufferCreateInfo bufferInfo, VmaAllocationCreateInfo allocInfo, Gfx::QueueType owner, uint64 alignment = 0); BufferAllocation(PGraphics graphics, const std::string& name, VkBufferCreateInfo bufferInfo, VmaAllocationCreateInfo allocInfo,
Gfx::QueueType owner, uint64 alignment = 0);
virtual ~BufferAllocation(); virtual ~BufferAllocation();
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkPipelineStageFlags dstStage);
void transferOwnership(Gfx::QueueType newOwner); void transferOwnership(Gfx::QueueType newOwner);
void updateContents(uint64 regionOffset, uint64 regionSize, void* ptr); void updateContents(uint64 regionOffset, uint64 regionSize, void* ptr);
void readContents(uint64 regionOffset, uint64 regionSize, void* ptr); void readContents(uint64 regionOffset, uint64 regionSize, void* ptr);
@@ -28,7 +28,7 @@ class BufferAllocation : public CommandBoundResource {
DEFINE_REF(BufferAllocation); DEFINE_REF(BufferAllocation);
class Buffer { class Buffer {
public: public:
Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType initialOwner, bool dynamic, std::string name); Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType initialOwner, bool dynamic, std::string name, uint32 clearValue = 0);
virtual ~Buffer(); virtual ~Buffer();
VkBuffer getHandle() const { return buffers[currentBuffer]->buffer; } VkBuffer getHandle() const { return buffers[currentBuffer]->buffer; }
VkDeviceAddress getDeviceAddress() const { return buffers[currentBuffer]->deviceAddress; } VkDeviceAddress getDeviceAddress() const { return buffers[currentBuffer]->deviceAddress; }
@@ -45,13 +45,13 @@ class Buffer {
VkBufferUsageFlags usage; VkBufferUsageFlags usage;
bool dynamic; bool dynamic;
std::string name; std::string name;
void rotateBuffer(uint64 size, bool preserveContents = false, uint32 fillValue = 0); uint32 clearValue;
void createBuffer(uint64 size); void rotateBuffer(uint64 size, bool preserveContents = false);
void createBuffer(uint64 size, uint32 destIndex);
void copyBuffer(uint64 src, uint64 dest); void copyBuffer(uint64 src, uint64 dest);
void transferOwnership(Gfx::QueueType newOwner); void transferOwnership(Gfx::QueueType newOwner);
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkPipelineStageFlags dstStage);
}; };
DEFINE_REF(Buffer) DEFINE_REF(Buffer)
@@ -107,7 +107,7 @@ class ShaderBuffer : public Gfx::ShaderBuffer, public Buffer {
ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo& sourceData); ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo& sourceData);
virtual ~ShaderBuffer(); virtual ~ShaderBuffer();
virtual void updateContents(const ShaderBufferCreateInfo& createInfo) override; virtual void updateContents(const ShaderBufferCreateInfo& createInfo) override;
virtual void rotateBuffer(uint64 size, bool preserveContents = false, uint32 fillValue = 0) override; virtual void rotateBuffer(uint64 size, bool preserveContents = false) override;
virtual void clear() override; virtual void clear() override;