somewhat fixed threadpool

This commit is contained in:
2021-11-13 19:28:18 +01:00
parent 01049019fd
commit ad09492e3e
20 changed files with 71 additions and 90 deletions
+11 -16
View File
@@ -12,7 +12,7 @@ BasePassMeshProcessor::BasePassMeshProcessor(Gfx::PViewport viewport, Gfx::PGrap
: MeshProcessor(graphics)
, target(viewport)
, translucentBasePass(translucentBasePass)
, cachedPrimitiveIndex(0)
//, cachedPrimitiveIndex(0)
{
}
@@ -29,28 +29,26 @@ void BasePassMeshProcessor::addMeshBatch(
Array<Gfx::PDescriptorSet>& descriptorSets,
int32 /*staticMeshId*/)
{
const PMaterialAsset material = batch.material;
PMaterialAsset material = batch.material;
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput;
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::BasePass, vertexInput->getType());
assert(collection != nullptr);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
pipelineLayout->addDescriptorLayout(BasePass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
descriptorSets[BasePass::INDEX_MATERIAL] = materialSet;
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet();
descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer);
descriptorSet->writeChanges();
cachedPrimitiveSets.add(descriptorSet);
}
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
pipelineLayout->addDescriptorLayout(BasePass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
descriptorSets[BasePass::INDEX_MATERIAL] = material->getDescriptor();
descriptorSets[BasePass::INDEX_SCENE_DATA] = cachedPrimitiveSets[cachedPrimitiveIndex++];
descriptorSets[BasePass::INDEX_SCENE_DATA] = descriptorSet;
buildMeshDrawCommand(batch,
// primitiveComponent,
renderPass,
@@ -75,8 +73,6 @@ Array<Gfx::PRenderCommand> BasePassMeshProcessor::getRenderCommands()
void BasePassMeshProcessor::clearCommands()
{
renderCommands.clear();
cachedPrimitiveSets.clear();
cachedPrimitiveIndex = 0;
}
BasePass::BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
@@ -148,8 +144,7 @@ void BasePass::beginFrame()
void BasePass::render()
{
oLightIndexList->pipelineBarrier(
oLightIndexList->pipelineBarrier(
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
oLightGrid->pipelineBarrier(
+2 -2
View File
@@ -23,10 +23,10 @@ public:
void clearCommands();
private:
Array<Gfx::PRenderCommand> renderCommands;
Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
//Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
Gfx::PViewport target;
uint8 translucentBasePass;
uint32 cachedPrimitiveIndex;
//uint32 cachedPrimitiveIndex;
};
DEFINE_REF(BasePassMeshProcessor)
DECLARE_REF(CameraActor)
+13 -15
View File
@@ -11,7 +11,6 @@ using namespace Seele;
DepthPrepassMeshProcessor::DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics)
: MeshProcessor(graphics)
, target(viewport)
, cachedPrimitiveIndex(0)
{
}
@@ -28,28 +27,26 @@ void DepthPrepassMeshProcessor::addMeshBatch(
Array<Gfx::PDescriptorSet>& descriptorSets,
int32 /*staticMeshId*/)
{
const PMaterialAsset material = batch.material;
PMaterialAsset material = batch.material;
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput;
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::DepthPrepass, vertexInput->getType());
assert(collection != nullptr);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
pipelineLayout->addDescriptorLayout(DepthPrepass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
descriptorSets[DepthPrepass::INDEX_MATERIAL] = materialSet;
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
{
Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet();
descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer);
descriptorSet->writeChanges();
cachedPrimitiveSets.add(descriptorSet);
}
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
pipelineLayout->addDescriptorLayout(DepthPrepass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
descriptorSets[DepthPrepass::INDEX_MATERIAL] = material->getDescriptor();
descriptorSets[DepthPrepass::INDEX_SCENE_DATA] = cachedPrimitiveSets[cachedPrimitiveIndex++];
descriptorSets[DepthPrepass::INDEX_SCENE_DATA] = descriptorSet;
buildMeshDrawCommand(batch,
// primitiveComponent,
renderPass,
@@ -74,8 +71,8 @@ Array<Gfx::PRenderCommand> DepthPrepassMeshProcessor::getRenderCommands()
void DepthPrepassMeshProcessor::clearCommands()
{
renderCommands.clear();
cachedPrimitiveSets.clear();
cachedPrimitiveIndex = 0;
//cachedPrimitiveSets.clear();
//cachedPrimitiveIndex = 0;
}
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
@@ -129,6 +126,7 @@ void DepthPrepass::beginFrame()
void DepthPrepass::render()
{
depthAttachment->getTexture()->pipelineBarrier(
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
@@ -23,9 +23,9 @@ public:
void clearCommands();
private:
Array<Gfx::PRenderCommand> renderCommands;
Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
//Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
Gfx::PViewport target;
uint32 cachedPrimitiveIndex;
//uint32 cachedPrimitiveIndex;
};
DEFINE_REF(DepthPrepassMeshProcessor)
DECLARE_REF(CameraActor)
@@ -87,6 +87,7 @@ void CmdBuffer::executeCommands(const Array<Gfx::PRenderCommand>& commands)
executingRenders.add(command);
for(auto descriptor : command->boundDescriptors)
{
descriptor->free();
boundDescriptors.add(descriptor);
}
cmdBuffers[i] = command->getHandle();
@@ -104,6 +105,7 @@ void CmdBuffer::executeCommands(const Array<Gfx::PComputeCommand>& commands)
executingComputes.add(command);
for(auto descriptor : command->boundDescriptors)
{
descriptor->free();
boundDescriptors.add(descriptor);
}
cmdBuffers[i] = command->getHandle();
@@ -117,12 +117,12 @@ DescriptorSet::~DescriptorSet()
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer)
{
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
//UniformBuffer* cachedBuffer = reinterpret_cast<UniformBuffer*>(cachedData[binding]);
/*if(vulkanBuffer->isDataEquals(cachedBuffer))
UniformBuffer* cachedBuffer = reinterpret_cast<UniformBuffer*>(cachedData[binding]);
if(vulkanBuffer->isDataEquals(cachedBuffer))
{
std::cout << "uniform data equal, skip" << std::endl;
return;
}*/
}
bufferInfos.add(init::DescriptorBufferInfo(vulkanBuffer->getHandle(), 0, vulkanBuffer->getSize()));
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, binding, &bufferInfos.back());