Trying to fix memory usage, made it worse and nothing works

This commit is contained in:
Dynamitos
2024-08-08 22:14:25 +02:00
parent 3f8ce3a25e
commit ac72377210
13 changed files with 172 additions and 284 deletions
+1 -4
View File
@@ -116,10 +116,7 @@ void BasePass::beginFrame(const Component::Camera& cam) {
textureLayout->reset();
skyboxData.transformMatrix = glm::rotate(skyboxData.transformMatrix, (float)(Gfx::getCurrentFrameDelta()), Vector(0, 1, 0));
skyboxBuffer->rotateBuffer(sizeof(SkyboxData));
skyboxBuffer->updateContents(DataSource{
.size = sizeof(SkyboxData),
.data = (uint8*)&skyboxData,
});
skyboxBuffer->updateContents(0, sizeof(SkyboxData), &skyboxData);
skyboxBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_UNIFORM_READ_BIT,
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
@@ -22,18 +22,10 @@ void LightCullingPass::beginFrame(const Component::Camera& cam) {
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, Gfx::SE_ACCESS_MEMORY_WRITE_BIT,
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
uint32 reset = 0;
ShaderBufferCreateInfo counterReset = {
.sourceData =
{
.size = sizeof(uint32),
.data = (uint8*)&reset,
.owner = Gfx::QueueType::COMPUTE,
},
};
oLightIndexCounter->rotateBuffer(sizeof(uint32));
oLightIndexCounter->updateContents(counterReset);
oLightIndexCounter->updateContents(0, sizeof(uint32), &reset);
tLightIndexCounter->rotateBuffer(sizeof(uint32));
tLightIndexCounter->updateContents(counterReset);
tLightIndexCounter->updateContents(0, sizeof(uint32), &reset);
oLightIndexCounter->pipelineBarrier(Gfx::SE_ACCESS_MEMORY_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
tLightIndexCounter->pipelineBarrier(Gfx::SE_ACCESS_MEMORY_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
@@ -32,12 +32,8 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
.cameraPosition = Vector4(cam.getCameraPosition(), 1),
.screenDimensions = Vector2(static_cast<float>(viewport->getWidth()), static_cast<float>(viewport->getHeight())),
};
DataSource uniformUpdate = {
.size = sizeof(ViewParameter),
.data = (uint8*)&viewParams,
};
viewParamsBuffer->rotateBuffer(sizeof(ViewParameter));
viewParamsBuffer->updateContents(uniformUpdate);
viewParamsBuffer->updateContents(0, sizeof(ViewParameter), &viewParams);
viewParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_UNIFORM_READ_BIT | Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
Gfx::SE_PIPELINE_STAGE_TASK_SHADER_BIT_EXT | Gfx::SE_PIPELINE_STAGE_MESH_SHADER_BIT_EXT |
+1 -5
View File
@@ -53,11 +53,7 @@ void TextPass::beginFrame(const Component::Camera& cam) {
};
}
auto proj = viewport->getProjectionMatrix();
DataSource projectionUpdate = {
.size = sizeof(Matrix4),
.data = (uint8*)&proj,
};
projectionBuffer->updateContents(projectionUpdate);
projectionBuffer->updateContents(0, sizeof(Matrix4), &proj);
generalSet->updateBuffer(1, projectionBuffer);
generalSet->writeChanges();
// co_return;
+1 -4
View File
@@ -20,10 +20,7 @@ void UIPass::beginFrame(const Component::Camera& cam) {
};
elementBuffer = graphics->createVertexBuffer(info);
uint32 numTextures = static_cast<uint32>(usedTextures.size());
numTexturesBuffer->updateContents({
.size = sizeof(uint32),
.data = (uint8*)&numTextures,
});
numTexturesBuffer->updateContents(0, sizeof(uint32), &numTextures);
descriptorSet->updateBuffer(2, numTexturesBuffer);
descriptorSet->updateTextureArray(3, usedTextures);
descriptorSet->writeChanges();