its running i think

This commit is contained in:
Dynamitos
2023-11-09 22:15:51 +01:00
parent 19c3e559b1
commit effb0c6214
34 changed files with 299 additions and 249 deletions
+13 -6
View File
@@ -121,10 +121,10 @@ void BasePass::render()
pipelineInfo.taskShader = collection->taskShader;
pipelineInfo.meshShader = collection->meshShader;
pipelineInfo.fragmentShader = collection->fragmentShader;
pipelineInfo.pipelineLayout = layout;
pipelineInfo.pipelineLayout = std::move(layout);
pipelineInfo.renderPass = renderPass;
pipelineInfo.depthStencilState.depthCompareOp = Gfx::SE_COMPARE_OP_LESS_OR_EQUAL;
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInfo);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
command->bindPipeline(pipeline);
}
else
@@ -133,10 +133,10 @@ void BasePass::render()
pipelineInfo.vertexDeclaration = collection->vertexDeclaration;
pipelineInfo.vertexShader = collection->vertexShader;
pipelineInfo.fragmentShader = collection->fragmentShader;
pipelineInfo.pipelineLayout = layout;
pipelineInfo.pipelineLayout = std::move(layout);
pipelineInfo.renderPass = renderPass;
pipelineInfo.depthStencilState.depthCompareOp = Gfx::SE_COMPARE_OP_LESS_OR_EQUAL;
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInfo);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
command->bindPipeline(pipeline);
}
@@ -156,8 +156,15 @@ void BasePass::render()
for(const auto& mesh : instance.meshes)
{
uint32 vertexOffset = vertexData->getMeshOffset(mesh.id);
command->bindIndexBuffer(mesh.indexBuffer);
command->drawIndexed(mesh.indexBuffer->getNumIndices(), 1, 0, vertexOffset, instanceOffset);
if (mesh.indexBuffer != nullptr)
{
command->bindIndexBuffer(mesh.indexBuffer);
command->drawIndexed(mesh.indexBuffer->getNumIndices(), 1, 0, vertexOffset, instanceOffset);
}
else
{
command->draw(vertexData->getMeshVertexCount(mesh.id), 1, vertexOffset, instanceOffset);
}
}
}
}
+19 -17
View File
@@ -13,7 +13,7 @@ using namespace Seele;
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
: RenderPass(graphics, scene)
, descriptorSets(4)
, descriptorSets(3)
{
UniformBufferCreateInfo uniformInitializer;
@@ -39,18 +39,14 @@ void DepthPrepass::render()
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
Gfx::ShaderPermutation permutation;
permutation.hasFragment = false;
if(graphics->supportMeshShading())
{
permutation.useMeshShading = true;
permutation.hasTaskShader = true;
std::strncpy(permutation.taskFile, "MeshletBasePass", sizeof("MeshletBasePass"));
std::strncpy(permutation.vertexMeshFile, "MeshletBasePass", sizeof("MeshletBasePass"));
permutation.setTaskFile("MeshletBasePass");
permutation.setMeshFile("MeshletBasePass");
}
else
{
permutation.useMeshShading = false;
std::strncpy(permutation.vertexMeshFile, "LegacyBasePass", sizeof("LegacyBasePass"));
permutation.setVertexFile("LegacyBasePass");
}
graphics->beginRenderPass(renderPass);
for (VertexData* vertexData : VertexData::getList())
@@ -65,12 +61,11 @@ void DepthPrepass::render()
// Material => per material
// VertexData => per meshtype
// SceneData => per material instance
std::strncpy(permutation.materialName, materialData.material->getName().c_str(), sizeof(permutation.materialName));
Gfx::PermutationId id(permutation);
Gfx::PRenderCommand command = graphics->createRenderCommand("DepthRender");
Gfx::OPipelineLayout layout = graphics->createPipelineLayout(depthPrepassLayout);
layout->addDescriptorLayout(INDEX_MATERIAL, materialData.material->getDescriptorLayout());
//layout->addDescriptorLayout(INDEX_MATERIAL, materialData.material->getDescriptorLayout());
layout->addDescriptorLayout(INDEX_VERTEX_DATA, vertexData->getVertexDataLayout());
layout->addDescriptorLayout(INDEX_SCENE_DATA, vertexData->getInstanceDataLayout());
layout->create();
@@ -83,10 +78,10 @@ void DepthPrepass::render()
pipelineInfo.taskShader = collection->taskShader;
pipelineInfo.meshShader = collection->meshShader;
pipelineInfo.fragmentShader = collection->fragmentShader;
pipelineInfo.pipelineLayout = layout;
pipelineInfo.pipelineLayout = std::move(layout);
pipelineInfo.renderPass = renderPass;
pipelineInfo.depthStencilState.depthCompareOp = Gfx::SE_COMPARE_OP_LESS_OR_EQUAL;
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInfo);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
command->bindPipeline(pipeline);
}
else
@@ -95,17 +90,17 @@ void DepthPrepass::render()
pipelineInfo.vertexDeclaration = collection->vertexDeclaration;
pipelineInfo.vertexShader = collection->vertexShader;
pipelineInfo.fragmentShader = collection->fragmentShader;
pipelineInfo.pipelineLayout = layout;
pipelineInfo.pipelineLayout = std::move(layout);
pipelineInfo.renderPass = renderPass;
pipelineInfo.depthStencilState.depthCompareOp = Gfx::SE_COMPARE_OP_LESS_OR_EQUAL;
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInfo);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
command->bindPipeline(pipeline);
}
descriptorSets[INDEX_VERTEX_DATA] = vertexData->getVertexDataSet();
for (const auto& [_, instance] : materialData.instances)
{
descriptorSets[INDEX_MATERIAL] = instance.materialInstance->getDescriptorSet();
//descriptorSets[INDEX_MATERIAL] = instance.materialInstance->getDescriptorSet();
descriptorSets[INDEX_SCENE_DATA] = instance.descriptorSet;
command->bindDescriptor(descriptorSets);
if(graphics->supportMeshShading())
@@ -118,8 +113,15 @@ void DepthPrepass::render()
for(const auto& mesh : instance.meshes)
{
uint32 vertexOffset = vertexData->getMeshOffset(mesh.id);
command->bindIndexBuffer(mesh.indexBuffer);
command->drawIndexed(mesh.indexBuffer->getNumIndices(), 1, 0, vertexOffset, instanceOffset);
if (mesh.indexBuffer != nullptr)
{
command->bindIndexBuffer(mesh.indexBuffer);
command->drawIndexed(mesh.indexBuffer->getNumIndices(), 1, 0, vertexOffset, instanceOffset);
}
else
{
command->draw(vertexData->getMeshVertexCount(mesh.id), 1, vertexOffset, instanceOffset);
}
}
}
}
@@ -25,12 +25,10 @@ private:
Gfx::OPipelineLayout depthPrepassLayout;
// Set 0: viewParameter
// Set 1: materials, generated
constexpr static uint32 INDEX_MATERIAL = 1;
// Set 2: vertices, from VertexData
constexpr static uint32 INDEX_VERTEX_DATA = 2;
// Set 3: mesh data, either index buffer or meshlet data
constexpr static uint32 INDEX_SCENE_DATA = 3;
// Set 1: vertices, from VertexData
constexpr static uint32 INDEX_VERTEX_DATA = 1;
// Set 2: mesh data, either index buffer or meshlet data
constexpr static uint32 INDEX_SCENE_DATA = 2;
Gfx::ODescriptorLayout sceneDataLayout;
};
DEFINE_REF(DepthPrepass)
@@ -117,7 +117,7 @@ void LightCullingPass::publishOutputs()
lightEnv = scene->getLightEnvironment();
cullingLayout = graphics->createPipelineLayout();
Gfx::OPipelineLayout cullingLayout = graphics->createPipelineLayout();
cullingLayout->addDescriptorLayout(0, viewParamsLayout);
cullingLayout->addDescriptorLayout(1, lightEnv->getDescriptorLayout());
cullingLayout->addDescriptorLayout(2, cullingDescriptorLayout);
@@ -132,8 +132,8 @@ void LightCullingPass::publishOutputs()
Gfx::ComputePipelineCreateInfo pipelineInfo;
pipelineInfo.computeShader = cullingShader;
pipelineInfo.pipelineLayout = cullingLayout;
cullingPipeline = graphics->createComputePipeline(pipelineInfo);
pipelineInfo.pipelineLayout = std::move(cullingLayout);
cullingPipeline = graphics->createComputePipeline(std::move(pipelineInfo));
uint32 counterReset = 0;
ShaderBufferCreateInfo structInfo =
@@ -203,7 +203,7 @@ void LightCullingPass::setupFrustums()
frustumDescriptorLayout = graphics->createDescriptorLayout("FrustumLayout");
frustumDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
frustumDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
frustumLayout = graphics->createPipelineLayout();
Gfx::OPipelineLayout frustumLayout = graphics->createPipelineLayout();
frustumLayout->addDescriptorLayout(0, viewParamsLayout);
frustumLayout->addDescriptorLayout(1, frustumDescriptorLayout);
frustumLayout->create();
@@ -216,8 +216,8 @@ void LightCullingPass::setupFrustums()
Gfx::ComputePipelineCreateInfo pipelineInfo;
pipelineInfo.computeShader = frustumShader;
pipelineInfo.pipelineLayout = frustumLayout;
frustumPipeline = graphics->createComputePipeline(pipelineInfo);
pipelineInfo.pipelineLayout = std::move(frustumLayout);
frustumPipeline = graphics->createComputePipeline(std::move(pipelineInfo));
Gfx::OUniformBuffer frustumDispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
.sourceData = {
@@ -48,8 +48,7 @@ private:
Gfx::ODescriptorLayout frustumDescriptorLayout;
Gfx::PDescriptorSet frustumDescriptorSet;
Gfx::OComputeShader frustumShader;
Gfx::OPipelineLayout frustumLayout;
Gfx::OComputePipeline frustumPipeline;
Gfx::PComputePipeline frustumPipeline;
PLightEnvironment lightEnv;
Gfx::PTexture2D depthAttachment;
@@ -63,8 +62,7 @@ private:
Gfx::PDescriptorSet cullingDescriptorSet;
Gfx::ODescriptorLayout cullingDescriptorLayout;
Gfx::OComputeShader cullingShader;
Gfx::OPipelineLayout cullingLayout;
Gfx::OComputePipeline cullingPipeline;
Gfx::PComputePipeline cullingPipeline;
};
DEFINE_REF(LightCullingPass)
} // namespace Seele
@@ -96,13 +96,16 @@ void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
uniformUpdate.size = sizeof(ViewParameter);
uniformUpdate.data = (uint8*)&viewParams;
viewParamsBuffer->updateContents(uniformUpdate);
descriptorLayout->reset();
descriptorSet = descriptorLayout->allocateDescriptorSet();
descriptorSet->updateBuffer(0, viewParamsBuffer);
descriptorSet->updateTexture(1, skybox.day);
descriptorSet->updateTexture(2, skybox.night);
descriptorSet->updateSampler(3, skyboxSampler);
descriptorSet->writeChanges();
skyboxDataLayout->reset();
textureLayout->reset();
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
skyboxDataSet->updateBuffer(0, viewParamsBuffer);
skyboxDataSet->writeChanges();
textureSet = textureLayout->allocateDescriptorSet();
textureSet->updateTexture(0, skybox.day);
textureSet->updateTexture(1, skybox.night);
textureSet->updateSampler(2, skyboxSampler);
textureSet->writeChanges();
}
void SkyboxRenderPass::render()
@@ -111,10 +114,8 @@ void SkyboxRenderPass::render()
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender");
renderCommand->setViewport(viewport);
renderCommand->bindPipeline(pipeline);
renderCommand->bindDescriptor(descriptorSet);
renderCommand->bindDescriptor({skyboxDataSet, textureSet});
renderCommand->bindVertexBuffer({ cubeBuffer });
renderCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(Vector), &skybox.fogColor);
renderCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, sizeof(Vector), sizeof(float), &skybox.blendFactor);
renderCommand->draw(36, 1, 0, 0);
graphics->executeCommands(Array{ renderCommand });
graphics->endRenderPass();
@@ -136,22 +137,14 @@ void SkyboxRenderPass::publishOutputs()
};
viewParamsBuffer = graphics->createUniformBuffer(viewCreateInfo);
descriptorLayout = graphics->createDescriptorLayout("SkyboxDescLayout");
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
descriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
descriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
descriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
descriptorLayout->create();
pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->addPushConstants(Gfx::SePushConstantRange{
.stageFlags = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT,
.offset = 0,
.size = sizeof(Vector4),
});
pipelineLayout->create();
skyboxDataLayout = graphics->createDescriptorLayout("SkyboxDescLayout");
skyboxDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
skyboxDataLayout->create();
textureLayout = graphics->createDescriptorLayout();
textureLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
textureLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
textureLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
textureLayout->create();
skyboxSampler = graphics->createSamplerState({});
}
@@ -185,6 +178,11 @@ void SkyboxRenderPass::createRenderPass()
}
});
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, skyboxDataLayout);
pipelineLayout->addDescriptorLayout(0, textureLayout);
pipelineLayout->create();
Gfx::LegacyPipelineCreateInfo gfxInfo;
gfxInfo.vertexDeclaration = declaration;
gfxInfo.vertexShader = vertexShader;
@@ -192,7 +190,7 @@ void SkyboxRenderPass::createRenderPass()
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_FILL;
gfxInfo.rasterizationState.lineWidth = 5.f;
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
gfxInfo.pipelineLayout = pipelineLayout;
gfxInfo.pipelineLayout = std::move(pipelineLayout);
gfxInfo.renderPass = renderPass;
pipeline = graphics->createGraphicsPipeline(gfxInfo);
pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
}
@@ -23,13 +23,14 @@ public:
private:
Gfx::OVertexBuffer cubeBuffer;
Gfx::OUniformBuffer viewParamsBuffer;
Gfx::ODescriptorLayout descriptorLayout;
Gfx::PDescriptorSet descriptorSet;
Gfx::OPipelineLayout pipelineLayout;
Gfx::ODescriptorLayout skyboxDataLayout;
Gfx::PDescriptorSet skyboxDataSet;
Gfx::ODescriptorLayout textureLayout;
Gfx::PDescriptorSet textureSet;
Gfx::OVertexDeclaration declaration;
Gfx::OVertexShader vertexShader;
Gfx::OFragmentShader fragmentShader;
Gfx::OGraphicsPipeline pipeline;
Gfx::PGraphicsPipeline pipeline;
Gfx::OSamplerState skyboxSampler;
Component::Skybox skybox;
};
+5 -4
View File
@@ -85,7 +85,7 @@ void TextPass::render()
command->bindDescriptor({generalSet, resource.textureArraySet});
command->bindVertexBuffer({resource.vertexBuffer});
command->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(TextData), &resource.textData);
command->pushConstants(layoutRef, Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(TextData), &resource.textData);
command->draw(4, static_cast<uint32>(resource.vertexBuffer->getNumVertices()), 0, 0);
}
commands.add(command);
@@ -176,7 +176,8 @@ void TextPass::createRenderPass()
generalSet->updateSampler(1, glyphSampler);
generalSet->writeChanges();
pipelineLayout = graphics->createPipelineLayout();
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
layoutRef = pipelineLayout;
pipelineLayout->addDescriptorLayout(0, generalLayout);
pipelineLayout->addDescriptorLayout(1, textureArrayLayout);
pipelineLayout->addPushConstants({
@@ -193,7 +194,7 @@ void TextPass::createRenderPass()
pipelineInfo.vertexShader = vertexShader;
pipelineInfo.fragmentShader = fragmentShader;
pipelineInfo.renderPass = renderPass;
pipelineInfo.pipelineLayout = pipelineLayout;
pipelineInfo.pipelineLayout = std::move(pipelineLayout);
pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE;
pipelineInfo.colorBlend.attachmentCount = 1;
pipelineInfo.colorBlend.blendAttachments[0].blendEnable = true;
@@ -206,7 +207,7 @@ void TextPass::createRenderPass()
pipelineInfo.colorBlend.blendAttachments[0].alphaBlendOp = Gfx::SE_BLEND_OP_ADD;
pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
pipeline = graphics->createGraphicsPipeline(pipelineInfo);
pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
}
TextPass::FontData& TextPass::getFontData(PFontAsset font)
{
+2 -2
View File
@@ -78,8 +78,8 @@ private:
Gfx::OVertexDeclaration declaration;
Gfx::OVertexShader vertexShader;
Gfx::OFragmentShader fragmentShader;
Gfx::OPipelineLayout pipelineLayout;
Gfx::OGraphicsPipeline pipeline;
Gfx::PPipelineLayout layoutRef;
Gfx::PGraphicsPipeline pipeline;
Array<TextRender> texts;
};
DEFINE_REF(TextPass);
+3 -3
View File
@@ -173,7 +173,7 @@ void UIPass::createRenderPass()
descriptorSet->updateSampler(1, backgroundSampler);
descriptorSet->writeChanges();
pipelineLayout = graphics->createPipelineLayout();
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->create();
@@ -185,9 +185,9 @@ void UIPass::createRenderPass()
pipelineInfo.vertexShader = vertexShader;
pipelineInfo.fragmentShader = fragmentShader;
pipelineInfo.renderPass = renderPass;
pipelineInfo.pipelineLayout = pipelineLayout;
pipelineInfo.pipelineLayout = std::move(pipelineLayout);
pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE;
pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
pipeline = graphics->createGraphicsPipeline(pipelineInfo);
pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
}
+1 -2
View File
@@ -34,8 +34,7 @@ private:
Gfx::OVertexDeclaration declaration;
Gfx::OVertexShader vertexShader;
Gfx::OFragmentShader fragmentShader;
Gfx::OPipelineLayout pipelineLayout;
Gfx::OGraphicsPipeline pipeline;
Gfx::PGraphicsPipeline pipeline;
Array<UI::RenderElementStyle> renderElements;
Array<Gfx::PTexture> usedTextures;