it at least does something

This commit is contained in:
Dynamitos
2025-02-28 16:56:51 +09:00
parent f73cc61693
commit 67b4a533f2
40 changed files with 440 additions and 413 deletions
+20 -27
View File
@@ -13,6 +13,7 @@
#include "Graphics/Shader.h"
#include "Graphics/StaticMeshVertexData.h"
#include "Material/MaterialInstance.h"
#include "Math/Matrix.h"
#include "Math/Vector.h"
#include "RenderGraph.h"
#include "Window/Window.h"
@@ -34,14 +35,12 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics)
basePassLayout->addDescriptorLayout(Material::getDescriptorLayout());
lightCullingLayout = graphics->createDescriptorLayout("pLightCullingData");
// oLightIndexList
lightCullingLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = LIGHTINDEX_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
// oLightGrid
lightCullingLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = LIGHTGRID_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE,
});
lightCullingLayout->create();
@@ -122,17 +121,15 @@ void BasePass::beginFrame(const Component::Camera& cam) {
skyboxDataLayout->reset();
textureLayout->reset();
skyboxData.transformMatrix = glm::rotate(skyboxData.transformMatrix, (float)(Gfx::getCurrentFrameDelta()), Vector(0, 1, 0));
skyboxBuffer->rotateBuffer(sizeof(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();
skyboxDataSet->updateBuffer(0, 0, skyboxBuffer);
skyboxDataSet->updateConstants("transformMatrix", 0, &skyboxData.transformMatrix);
skyboxDataSet->updateConstants("fogBlend", 0, &skyboxData.fogColor);
skyboxDataSet->writeChanges();
textureSet = textureLayout->allocateDescriptorSet();
textureSet->updateTexture(0, 0, skybox.day);
textureSet->updateTexture(1, 0, skybox.night);
textureSet->updateSampler(2, 0, skyboxSampler);
textureSet->updateTexture(SKYBOXDAY_NAME, 0, skybox.day);
textureSet->updateTexture(SKYBOXNIGHT_NAME, 0, skybox.night);
textureSet->updateSampler(SKYBOXSAMPLER_NAME, 0, skyboxSampler);
textureSet->writeChanges();
}
}
@@ -252,7 +249,6 @@ void BasePass::render() {
//commands.add(terrainRenderer->render(viewParamsSet));
*/
// Skybox
graphics->waitDeviceIdle();
graphics->beginRenderPass(renderPass);
{
Gfx::ORenderCommand skyboxCommand = graphics->createRenderCommand("SkyboxRender");
@@ -556,22 +552,27 @@ void BasePass::createRenderPass() {
{
skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData");
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
.uniformLength = sizeof(SkyboxData)
.name = "transformMatrix",
.uniformLength = sizeof(Matrix4)
});
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = "fogBlend",
.uniformLength = sizeof(Vector4)
});
skyboxDataLayout->create();
textureLayout = graphics->createDescriptorLayout("pSkyboxTextures");
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = SKYBOXDAY_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = SKYBOXNIGHT_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2,
.name = SKYBOXSAMPLER_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
textureLayout->create();
@@ -582,14 +583,6 @@ void BasePass::createRenderPass() {
skyboxData.fogColor = skybox.fogColor;
skyboxData.blendFactor = skybox.blendFactor;
skyboxBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
.sourceData =
{
.size = sizeof(SkyboxData),
.data = (uint8*)&skyboxData,
},
});
pipelineLayout = graphics->createPipelineLayout("SkyboxLayout");
pipelineLayout->addDescriptorLayout(viewParamsLayout);
pipelineLayout->addDescriptorLayout(skyboxDataLayout);
+5 -1
View File
@@ -28,6 +28,8 @@ class BasePass : public RenderPass {
Gfx::PShaderBuffer tLightIndexList;
Gfx::PTexture2D oLightGrid;
Gfx::PTexture2D tLightGrid;
constexpr static std::string LIGHTINDEX_NAME = "lightIndexList";
constexpr static std::string LIGHTGRID_NAME = "lightGrid";
Gfx::PDescriptorSet opaqueCulling;
Gfx::PDescriptorSet transparentCulling;
@@ -76,8 +78,10 @@ class BasePass : public RenderPass {
Vector fogColor;
float blendFactor;
} skyboxData;
Gfx::OUniformBuffer skyboxBuffer;
Component::Skybox skybox;
constexpr static std::string SKYBOXDAY_NAME = "day";
constexpr static std::string SKYBOXNIGHT_NAME = "night";
constexpr static std::string SKYBOXSAMPLER_NAME = "sampler";
PScene scene;
};
DEFINE_REF(BasePass)
@@ -1,18 +1,18 @@
#include "DepthCullingPass.h"
#include "Graphics/Shader.h"
#include <algorithm>
using namespace Seele;
DepthCullingPass::DepthCullingPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics), scene(scene) {
depthAttachmentLayout = graphics->createDescriptorLayout("pDepthAttachment");
depthAttachmentLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = DEPTHTEXTURE_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.shaderStages = Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_MESH_BIT_EXT | Gfx::SE_SHADER_STAGE_COMPUTE_BIT,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
depthAttachmentLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = DEPTHMIP_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.shaderStages = Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_COMPUTE_BIT,
});
@@ -75,8 +75,8 @@ void DepthCullingPass::render() {
depthMipBuffer->rotateBuffer(depthMipBuffer->getNumElements() * sizeof(uint32));
Gfx::PDescriptorSet set = depthAttachmentLayout->allocateDescriptorSet();
set->updateTexture(0, 0, depthAttachment.getTexture());
set->updateBuffer(1, 0, depthMipBuffer);
set->updateTexture(DEPTHTEXTURE_NAME, 0, depthAttachment.getTexture());
set->updateBuffer(DEPTHMIP_NAME, 0, depthMipBuffer);
set->writeChanges();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "MipBegin");
@@ -29,7 +29,9 @@ class DepthCullingPass : public RenderPass {
Array<uint32> mipOffsets;
Array<UVector2> mipDims;
constexpr static std::string DEPTHTEXTURE_NAME = "depthTexture";
Gfx::OShaderBuffer depthMipBuffer;
constexpr static std::string DEPTHMIP_NAME = "depthMip";
Gfx::RenderTargetAttachment depthAttachment;
Gfx::RenderTargetAttachment visibilityAttachment;
Gfx::ODescriptorLayout depthAttachmentLayout;
@@ -3,6 +3,7 @@
#include "Component/Camera.h"
#include "Graphics/Command.h"
#include "Graphics/Graphics.h"
#include "Math/Vector.h"
#include "RenderGraph.h"
#include "Scene/Scene.h"
#include "Graphics/Metal/Descriptor.h"
@@ -82,50 +83,39 @@ void LightCullingPass::publishOutputs() {
setupFrustums();
uint32_t viewportWidth = viewport->getWidth();
uint32_t viewportHeight = viewport->getHeight();
glm::uvec3 numThreadGroups = glm::ceil(glm::vec3(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1));
dispatchParams.numThreadGroups = numThreadGroups;
dispatchParams.numThreads = numThreadGroups * glm::uvec3(BLOCK_SIZE, BLOCK_SIZE, 1);
dispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
.sourceData =
{
.size = sizeof(DispatchParams),
.data = (uint8*)&dispatchParams,
.owner = Gfx::QueueType::COMPUTE,
},
.name = "DispatchParams",
});
dispatchParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
UVector4 numThreadGroups = glm::ceil(glm::vec4(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1, 0));
UVector4 numThreads = numThreadGroups * glm::uvec4(BLOCK_SIZE, BLOCK_SIZE, 1, 0);
dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
dispatchParamsSet->updateBuffer(0, 0, dispatchParamsBuffer);
dispatchParamsSet->updateBuffer(1, 0, frustumBuffer);
dispatchParamsSet->updateConstants("numThreadGroups", 0, &numThreadGroups);
dispatchParamsSet->updateConstants("numThreads", 0, &numThreads);
dispatchParamsSet->writeChanges();
cullingDescriptorLayout = graphics->createDescriptorLayout("pCullingParams");
// DepthTexture
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = DEPTHATTACHMENT_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
// o_lightIndexCounter
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
.name = OLIGHTINDEXCOUNTER_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,});
// t_lightIndexCounter
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
.name = TLIGHTINDEXCOUNTER_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,});
// o_lightIndexList
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
.name = OLIGHTINDEXLIST_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,});
// t_lightIndexList
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
.name = TLIGHTINDEXLIST_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,});
// o_lightGrid
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 5, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
.name = OLIGHTGRID_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,});
// t_lightGrid
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 6, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
.name = TLIGHTGRID_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,});
cullingDescriptorLayout->create();
@@ -195,8 +185,8 @@ void LightCullingPass::publishOutputs() {
structInfo = {
.sourceData =
{
.size = (uint32)sizeof(uint32) * dispatchParams.numThreadGroups.x * dispatchParams.numThreadGroups.y *
dispatchParams.numThreadGroups.z * 8192,
.size = (uint32)sizeof(uint32) * numThreadGroups.x * numThreadGroups.y *
numThreadGroups.z * 8192,
.data = nullptr,
.owner = Gfx::QueueType::COMPUTE,
},
@@ -210,8 +200,8 @@ void LightCullingPass::publishOutputs() {
TextureCreateInfo textureInfo = {
.format = Gfx::SE_FORMAT_R32G32_UINT,
.width = dispatchParams.numThreadGroups.x,
.height = dispatchParams.numThreadGroups.y,
.width = numThreadGroups.x,
.height = numThreadGroups.y,
.usage = Gfx::SE_IMAGE_USAGE_STORAGE_BIT,
};
oLightGrid = graphics->createTexture2D(textureInfo);
@@ -237,25 +227,24 @@ void LightCullingPass::setupFrustums() {
uint32_t viewportWidth = viewport->getWidth();
uint32_t viewportHeight = viewport->getHeight();
glm::uvec3 numThreads = glm::ceil(glm::vec3(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1));
glm::uvec3 numThreadGroups = glm::ceil(glm::vec3(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1));
glm::uvec4 numThreads = glm::ceil(glm::vec4(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1, 0));
glm::uvec4 numThreadGroups = glm::ceil(glm::vec4(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1, 0));
RenderPass::beginFrame(Component::Camera());
viewParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
dispatchParams.numThreads = numThreads;
dispatchParams.numThreadGroups = numThreadGroups;
dispatchParamsLayout = graphics->createDescriptorLayout("pDispatchParams");
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
.uniformLength = sizeof(DispatchParams),
.name = "numThreadGroups",
.uniformLength = sizeof(UVector4),
});
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = "numThreads",
.uniformLength = sizeof(UVector4),
});
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = FRUSTUMBUFFER_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.access = Gfx::SE_DESCRIPTOR_ACCESS_WRITE_ONLY_BIT,
.access = Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,
});
dispatchParamsLayout->create();
frustumLayout = graphics->createPipelineLayout("FrustumLayout");
@@ -278,17 +267,6 @@ void LightCullingPass::setupFrustums() {
pipelineInfo.pipelineLayout = frustumLayout;
frustumPipeline = graphics->createComputePipeline(pipelineInfo);
Gfx::OUniformBuffer frustumDispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
.sourceData =
{
.size = sizeof(DispatchParams),
.data = (uint8*)&dispatchParams,
.owner = Gfx::QueueType::COMPUTE,
},
.name = "FrustumDispatch",
});
frustumDispatchParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
frustumBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
.sourceData =
{
@@ -302,10 +280,10 @@ void LightCullingPass::setupFrustums() {
frustumBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_WRITE_BIT,
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
graphics->waitDeviceIdle();
Gfx::PDescriptorSet dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
dispatchParamsSet->updateBuffer(0, 0, frustumDispatchParamsBuffer);
dispatchParamsSet->updateBuffer(1, 0, frustumBuffer);
dispatchParamsSet->updateConstants("numThreadGroups", 0, &numThreadGroups);
dispatchParamsSet->updateConstants("numThreads", 0, &numThreads);
dispatchParamsSet->updateBuffer(FRUSTUMBUFFER_NAME, 0, frustumBuffer);
dispatchParamsSet->writeChanges();
Gfx::OComputeCommand command = graphics->createComputeCommand("FrustumCommand");
@@ -25,15 +25,9 @@ class LightCullingPass : public RenderPass {
void setupFrustums();
static constexpr uint32 BLOCK_SIZE = 32;
static constexpr uint32 INDEX_LIGHT_ENV = 1;
struct DispatchParams {
glm::uvec3 numThreadGroups;
uint32_t pad0;
glm::uvec3 numThreads;
uint32_t pad1;
} dispatchParams;
Gfx::OShaderBuffer frustumBuffer;
Gfx::OUniformBuffer dispatchParamsBuffer;
constexpr static std::string FRUSTUMBUFFER_NAME = "frustums";
Gfx::ODescriptorLayout dispatchParamsLayout;
Gfx::PDescriptorSet dispatchParamsSet;
Gfx::OComputeShader frustumShader;
@@ -42,12 +36,19 @@ class LightCullingPass : public RenderPass {
PLightEnvironment lightEnv;
Gfx::PTexture2D depthAttachment;
constexpr static std::string DEPTHATTACHMENT_NAME = "depth";
Gfx::OShaderBuffer oLightIndexCounter;
constexpr static std::string OLIGHTINDEXCOUNTER_NAME = "oLightIndexCounter";
Gfx::OShaderBuffer tLightIndexCounter;
constexpr static std::string TLIGHTINDEXCOUNTER_NAME = "tLightIndexCounter";
Gfx::OShaderBuffer oLightIndexList;
constexpr static std::string OLIGHTINDEXLIST_NAME = "oLightIndexList";
Gfx::OShaderBuffer tLightIndexList;
constexpr static std::string TLIGHTINDEXLIST_NAME = "tLightIndexList";
Gfx::OTexture2D oLightGrid;
constexpr static std::string OLIGHTGRID_NAME = "oLightGrid";
Gfx::OTexture2D tLightGrid;
constexpr static std::string TLIGHTGRID_NAME = "tLightGrid";
Gfx::PDescriptorSet cullingDescriptorSet;
Gfx::ODescriptorLayout cullingDescriptorLayout;
Gfx::OPipelineLayout cullingLayout;
@@ -16,7 +16,7 @@ struct SampleParams {
RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics), scene(scene) {
paramsLayout = graphics->createDescriptorLayout("pRayTracingParams");
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
/*paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
});
@@ -39,7 +39,7 @@ RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPa
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 5,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
});*/
paramsLayout->create();
pipelineLayout = graphics->createPipelineLayout("RayTracing");
pipelineLayout->addDescriptorLayout(viewParamsLayout);
@@ -137,12 +137,12 @@ void RayTracingPass::render() {
.bottomLevelStructures = accelerationStructures,
});
Gfx::PDescriptorSet desc = paramsLayout->allocateDescriptorSet();
desc->updateAccelerationStructure(0, 0, tlas);
/*desc->updateAccelerationStructure(0, 0, tlas);
desc->updateTexture(1, 0, radianceAccumulator);
desc->updateTexture(2, 0, texture);
desc->updateBuffer(3, 0, StaticMeshVertexData::getInstance()->getIndexBuffer());
desc->updateTexture(4, 0, skyBox);
desc->updateSampler(5, 0, skyBoxSampler);
desc->updateSampler(5, 0, skyBoxSampler);*/
desc->writeChanges();
Gfx::ORenderCommand command = graphics->createRenderCommand("RayTracing");
+28 -22
View File
@@ -4,20 +4,20 @@ using namespace Seele;
RenderPass::RenderPass(Gfx::PGraphics graphics) : graphics(graphics) {
viewParamsLayout = graphics->createDescriptorLayout("pViewParams");
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
.uniformLength = sizeof(ViewParameter),
});
UniformBufferCreateInfo uniformInitializer = {
.sourceData =
{
.size = sizeof(ViewParameter),
.data = (uint8*)&viewParams,
},
.name = "viewParamsBuffer",
};
viewParamsBuffer = graphics->createUniformBuffer(uniformInitializer);
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "viewMatrix", .uniformLength = sizeof(Matrix4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "inverseViewMatrix", .uniformLength = sizeof(Matrix4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "projectionMatrix", .uniformLength = sizeof(Matrix4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "inverseProjection", .uniformLength = sizeof(Matrix4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "viewProjectionMatrix", .uniformLength = sizeof(Matrix4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "inverseViewProjectionMatrix", .uniformLength = sizeof(Matrix4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "cameraPosition_WS", .uniformLength = sizeof(Vector4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "cameraForward_WS", .uniformLength = sizeof(Vector4)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "screenDimensions", .uniformLength = sizeof(Vector2)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "invScreenDimensions", .uniformLength = sizeof(Vector2)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "frameIndex", .uniformLength = sizeof(uint32)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "time", .uniformLength = sizeof(float)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "pad0", .uniformLength = sizeof(float)});
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "pad1", .uniformLength = sizeof(float)});
viewParamsLayout->create();
}
@@ -62,16 +62,22 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
//extract_planes_from_view_projection_matrix(viewParams.viewProjectionMatrix, viewParams.viewFrustum);
viewParamsBuffer->rotateBuffer(sizeof(ViewParameter));
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 |
Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT |
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
viewParamsLayout->reset();
viewParamsSet = viewParamsLayout->allocateDescriptorSet();
viewParamsSet->updateBuffer(0, 0, viewParamsBuffer);
viewParamsSet->updateConstants("viewMatrix", 0, &viewParams.viewMatrix);
viewParamsSet->updateConstants("inverseViewMatrix", 0, &viewParams.inverseViewMatrix);
viewParamsSet->updateConstants("projectionMatrix", 0, &viewParams.projectionMatrix);
viewParamsSet->updateConstants("inverseProjection", 0, &viewParams.inverseProjection);
viewParamsSet->updateConstants("viewProjectionMatrix", 0, &viewParams.viewProjectionMatrix);
viewParamsSet->updateConstants("inverseViewProjectionMatrix", 0, &viewParams.inverseViewProjectionMatrix);
viewParamsSet->updateConstants("cameraPosition_WS", 0, &viewParams.cameraPosition_WS);
viewParamsSet->updateConstants("cameraForward_WS", 0, &viewParams.cameraForward_WS);
viewParamsSet->updateConstants("screenDimensions", 0, &viewParams.screenDimensions);
viewParamsSet->updateConstants("invScreenDimensions", 0, &viewParams.invScreenDimensions);
viewParamsSet->updateConstants("frameIndex", 0, &viewParams.frameIndex);
viewParamsSet->updateConstants("time", 0, &viewParams.time);
viewParamsSet->updateConstants("pad0", 0, &viewParams.pad0);
viewParamsSet->updateConstants("pad1", 0, &viewParams.pad1);
viewParamsSet->writeChanges();
}
@@ -67,7 +67,6 @@ class RenderPass {
} viewParams;
PRenderGraphResources resources;
Gfx::ODescriptorLayout viewParamsLayout;
Gfx::OUniformBuffer viewParamsBuffer;
Gfx::PDescriptorSet viewParamsSet;
Gfx::ORenderPass renderPass;
Gfx::PGraphics graphics;
@@ -273,10 +273,10 @@ void TerrainRenderer::beginFrame(Gfx::PDescriptorSet viewParamsSet, const Compon
Gfx::ORenderCommand TerrainRenderer::render(Gfx::PDescriptorSet viewParamsSet) {
Gfx::PDescriptorSet set = meshUpdater.layout->allocateDescriptorSet();
set->updateBuffer(CURRENT_VERTEX_BUFFER, 0, plainMesh.currentVertexBuffer);
/*set->updateBuffer(CURRENT_VERTEX_BUFFER, 0, plainMesh.currentVertexBuffer);
set->updateBuffer(INDEXED_BISECTOR_BUFFER, 0, plainMesh.indexedBisectorBuffer);
set->updateSampler(SAMPLER_LOCATION, 0, sampler);
set->updateTexture(DISPLACEMENT_MAP, 0, displacementAsset);
set->updateTexture(DISPLACEMENT_MAP, 0, displacementAsset);*/
set->writeChanges();
Gfx::ORenderCommand command = graphics->createRenderCommand("TerrainRender");
command->setViewport(viewport);
@@ -322,11 +322,11 @@ void TerrainRenderer::setViewport(Gfx::PViewport _viewport, Gfx::PRenderPass ren
void TerrainRenderer::applyDeformation(Gfx::PDescriptorSet viewParamsSet) {
graphics->beginDebugRegion("ApplyDeformation");
Gfx::PDescriptorSet set = meshUpdater.layout->allocateDescriptorSet();
set->updateBuffer(GEOMETRY_CB, 0, geometryBuffer);
/*set->updateBuffer(GEOMETRY_CB, 0, geometryBuffer);
set->updateBuffer(INDIRECT_DRAW_BUFFER, 0, plainMesh.indirectDrawBuffer);
set->updateBuffer(INDEXED_BISECTOR_BUFFER, 0, plainMesh.indexedBisectorBuffer);
set->updateBuffer(LEB_POSITION_BUFFER, 0, plainMesh.lebVertexBuffer);
set->updateBuffer(CURRENT_VERTEX_BUFFER, 0, plainMesh.currentVertexBuffer);
set->updateBuffer(CURRENT_VERTEX_BUFFER, 0, plainMesh.currentVertexBuffer);*/
set->writeChanges();
Gfx::OComputeCommand command = graphics->createComputeCommand("Deform");
command->bindPipeline(deform);
+14 -12
View File
@@ -13,17 +13,18 @@ UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphic
elementBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "RenderStyleElements"});
textDescriptorLayout = graphics->createDescriptorLayout("pText");
textDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = GLYPHINSTANCE_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
textDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = GLYPHSAMPLER_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
textDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2,
.name = TEXTURES_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.descriptorCount = 1024,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
textPipelineLayout = graphics->createPipelineLayout("TextPipeline");
textPipelineLayout->addDescriptorLayout(viewParamsLayout);
@@ -31,17 +32,18 @@ UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphic
uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = GLYPHINSTANCE_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = GLYPHSAMPLER_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2,
.name = TEXTURES_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.descriptorCount = 1024,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
uiPipelineLayout = graphics->createPipelineLayout("UIPipeline");
uiPipelineLayout->addDescriptorLayout(viewParamsLayout);
@@ -81,10 +83,10 @@ void UIPass::beginFrame(const Component::Camera& cam) {
textDescriptorLayout->reset();
textDescriptorSet = textDescriptorLayout->allocateDescriptorSet();
textDescriptorSet->updateBuffer(0, 0, glyphInstanceBuffer);
textDescriptorSet->updateSampler(1, 0, glyphSampler);
textDescriptorSet->updateBuffer(GLYPHINSTANCE_NAME, 0, glyphInstanceBuffer);
textDescriptorSet->updateSampler(GLYPHSAMPLER_NAME, 0, glyphSampler);
for (uint32 i = 0; i < usedTextures.size(); ++i) {
textDescriptorSet->updateTexture(2, i, usedTextures[i]);
textDescriptorSet->updateTexture(TEXTURES_NAME, i, usedTextures[i]);
}
textDescriptorSet->writeChanges();
@@ -94,10 +96,10 @@ void UIPass::beginFrame(const Component::Camera& cam) {
Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
uiDescriptorLayout->reset();
uiDescriptorSet = uiDescriptorLayout->allocateDescriptorSet();
uiDescriptorSet->updateBuffer(0, 0, elementBuffer);
uiDescriptorSet->updateSampler(1, 0, glyphSampler);
uiDescriptorSet->updateBuffer(ELEMENT_NAME, 0, elementBuffer);
uiDescriptorSet->updateSampler(GLYPHSAMPLER_NAME, 0, glyphSampler);
for (uint32 i = 0; i < usedTextures.size(); ++i) {
uiDescriptorSet->updateTexture(2, i, usedTextures[i]);
uiDescriptorSet->updateTexture(TEXTURES_NAME, i, usedTextures[i]);
}
uiDescriptorSet->writeChanges();
}
+4
View File
@@ -72,9 +72,13 @@ class UIPass : public RenderPass {
Array<GlyphInstanceData> glyphs;
Array<RenderElementStyle> elements;
Gfx::OShaderBuffer glyphInstanceBuffer;
constexpr static std::string GLYPHINSTANCE_NAME = "glyphData";
Gfx::OShaderBuffer elementBuffer;
constexpr static std::string ELEMENT_NAME = "elements";
Gfx::OSampler glyphSampler;
constexpr static std::string GLYPHSAMPLER_NAME = "glyphSampler";
Array<Gfx::PTexture2D> usedTextures;
constexpr static std::string TEXTURES_NAME = "textures";
};
DEFINE_REF(UIPass);
} // namespace Seele
@@ -21,8 +21,8 @@ void VisibilityPass::render() {
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
visibilityDescriptor->reset();
visibilitySet = visibilityDescriptor->allocateDescriptorSet();
visibilitySet->updateTexture(0, 0, visibilityAttachment.getTexture());
visibilitySet->updateBuffer(1, 0, cullingBuffer);
visibilitySet->updateTexture(VISIBILITY_NAME, 0, visibilityAttachment.getTexture());
visibilitySet->updateBuffer(CULLINGBUFFER_NAME, 0, cullingBuffer);
visibilitySet->writeChanges();
query->beginQuery();
@@ -49,13 +49,14 @@ void VisibilityPass::publishOutputs() {
threadGroupSize = glm::ceil(glm::vec3(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1));
visibilityDescriptor = graphics->createDescriptorLayout("pVisibilityParams");
visibilityDescriptor->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.name = VISIBILITY_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.access = Gfx::SE_DESCRIPTOR_ACCESS_SAMPLE_BIT,
});
visibilityDescriptor->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = CULLINGBUFFER_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT,
.access = Gfx::SE_DESCRIPTOR_ACCESS_READ_BIT | Gfx::SE_DESCRIPTOR_ACCESS_WRITE_BIT,
});
visibilityDescriptor->create();
@@ -1,5 +1,6 @@
#pragma once
#include "Graphics/Query.h"
#include "Math/Vector.h"
#include "RenderPass.h"
namespace Seele {
@@ -26,9 +27,11 @@ class VisibilityPass : public RenderPass {
Gfx::OPipelineStatisticsQuery query;
Gfx::PTimestampQuery timestamps;
constexpr static std::string VISIBILITY_NAME = "visibilityTexture";
// Holds culling information for every meshlet for each instance
Gfx::OShaderBuffer cullingBuffer;
glm::uvec3 threadGroupSize;
constexpr static std::string CULLINGBUFFER_NAME = "cullingBuffer";
UVector threadGroupSize;
};
DEFINE_REF(VisibilityPass)
} // namespace Seele
@@ -121,7 +121,7 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri
});
computeLayout = graphics->createDescriptorLayout("pParams");
computeLayout->addDescriptorBinding(Gfx::DescriptorBinding{
/*computeLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
.uniformLength = sizeof(MaterialParams),
@@ -153,7 +153,7 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri
computeLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 7,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
});*/
computeLayout->create();
pipelineLayout = graphics->createPipelineLayout("WaterComputeLayout");
@@ -210,7 +210,7 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri
});
materialLayout = graphics->createDescriptorLayout("pWaterMaterial");
materialLayout->addDescriptorBinding(Gfx::DescriptorBinding{
/*materialLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
});
@@ -233,7 +233,7 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri
materialLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 5,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
});*/
materialLayout->create();
waterLayout = graphics->createPipelineLayout("WaterLayout");
waterLayout->addDescriptorLayout(viewParamsLayout);
@@ -530,14 +530,14 @@ void WaterRenderer::updateFFTDescriptor() {
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
computeSet = computeLayout->allocateDescriptorSet();
computeSet->updateBuffer(0, 0, paramsBuffer);
/*computeSet->updateBuffer(0, 0, paramsBuffer);
computeSet->updateTexture(1, 0, spectrumTextures);
computeSet->updateTexture(2, 0, initialSpectrumTextures);
computeSet->updateTexture(3, 0, displacementTextures);
computeSet->updateTexture(4, 0, slopeTextures);
computeSet->updateTexture(5, 0, boyancyData);
computeSet->updateBuffer(6, 0, spectrumBuffer);
computeSet->updateSampler(7, 0, linearRepeatSampler);
computeSet->updateSampler(7, 0, linearRepeatSampler);*/
computeSet->writeChanges();
}
@@ -547,11 +547,11 @@ void WaterRenderer::updateMaterialDescriptor() {
Gfx::SE_ACCESS_UNIFORM_READ_BIT,
Gfx::SE_PIPELINE_STAGE_MESH_SHADER_BIT_EXT | Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
materialSet = materialLayout->allocateDescriptorSet();
materialSet->updateBuffer(0, 0, materialUniforms);
/*materialSet->updateBuffer(0, 0, materialUniforms);
materialSet->updateTexture(1, 0, displacementTextures);
materialSet->updateTexture(2, 0, slopeTextures);
materialSet->updateTexture(3, 0, skyBox);
materialSet->updateSampler(4, 0, linearRepeatSampler);
materialSet->updateBuffer(5, 0, waterTiles);
materialSet->updateBuffer(5, 0, waterTiles);*/
materialSet->writeChanges();
}