Fixing some semaphore things

This commit is contained in:
Dynamitos
2025-03-07 21:48:27 +01:00
parent 4d7c5db2c3
commit 913b8391f8
25 changed files with 236 additions and 139 deletions
+5 -5
View File
@@ -28,8 +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";
constexpr static const char* LIGHTINDEX_NAME = "lightIndexList";
constexpr static const char* LIGHTGRID_NAME = "lightGrid";
Gfx::PDescriptorSet opaqueCulling;
Gfx::PDescriptorSet transparentCulling;
@@ -79,9 +79,9 @@ class BasePass : public RenderPass {
float blendFactor;
} skyboxData;
Component::Skybox skybox;
constexpr static std::string SKYBOXDAY_NAME = "day";
constexpr static std::string SKYBOXNIGHT_NAME = "night";
constexpr static std::string SKYBOXSAMPLER_NAME = "sampler";
const char* SKYBOXDAY_NAME = "day";
const char* SKYBOXNIGHT_NAME = "night";
const char* SKYBOXSAMPLER_NAME = "sampler";
PScene scene;
};
DEFINE_REF(BasePass)
@@ -29,9 +29,9 @@ class DepthCullingPass : public RenderPass {
Array<uint32> mipOffsets;
Array<UVector2> mipDims;
constexpr static std::string DEPTHTEXTURE_NAME = "depthTexture";
constexpr static const char* DEPTHTEXTURE_NAME = "depthTexture";
Gfx::OShaderBuffer depthMipBuffer;
constexpr static std::string DEPTHMIP_NAME = "depthMip";
constexpr static const char* DEPTHMIP_NAME = "depthMip";
Gfx::RenderTargetAttachment depthAttachment;
Gfx::RenderTargetAttachment visibilityAttachment;
Gfx::ODescriptorLayout depthAttachmentLayout;
@@ -6,8 +6,6 @@
#include "Math/Vector.h"
#include "RenderGraph.h"
#include "Scene/Scene.h"
#include "Graphics/Metal/Descriptor.h"
#include "Graphics/Metal/Shader.h"
using namespace Seele;
@@ -27,7 +27,7 @@ class LightCullingPass : public RenderPass {
static constexpr uint32 INDEX_LIGHT_ENV = 1;
Gfx::OShaderBuffer frustumBuffer;
constexpr static std::string FRUSTUMBUFFER_NAME = "frustums";
const char* FRUSTUMBUFFER_NAME = "frustums";
Gfx::ODescriptorLayout dispatchParamsLayout;
Gfx::PDescriptorSet dispatchParamsSet;
Gfx::OComputeShader frustumShader;
@@ -36,19 +36,19 @@ class LightCullingPass : public RenderPass {
PLightEnvironment lightEnv;
Gfx::PTexture2D depthAttachment;
constexpr static std::string DEPTHATTACHMENT_NAME = "depth";
constexpr static const char* DEPTHATTACHMENT_NAME = "depth";
Gfx::OShaderBuffer oLightIndexCounter;
constexpr static std::string OLIGHTINDEXCOUNTER_NAME = "oLightIndexCounter";
constexpr static const char* OLIGHTINDEXCOUNTER_NAME = "oLightIndexCounter";
Gfx::OShaderBuffer tLightIndexCounter;
constexpr static std::string TLIGHTINDEXCOUNTER_NAME = "tLightIndexCounter";
constexpr static const char* TLIGHTINDEXCOUNTER_NAME = "tLightIndexCounter";
Gfx::OShaderBuffer oLightIndexList;
constexpr static std::string OLIGHTINDEXLIST_NAME = "oLightIndexList";
constexpr static const char* OLIGHTINDEXLIST_NAME = "oLightIndexList";
Gfx::OShaderBuffer tLightIndexList;
constexpr static std::string TLIGHTINDEXLIST_NAME = "tLightIndexList";
constexpr static const char* TLIGHTINDEXLIST_NAME = "tLightIndexList";
Gfx::OTexture2D oLightGrid;
constexpr static std::string OLIGHTGRID_NAME = "oLightGrid";
constexpr static const char* OLIGHTGRID_NAME = "oLightGrid";
Gfx::OTexture2D tLightGrid;
constexpr static std::string TLIGHTGRID_NAME = "tLightGrid";
constexpr static const char* TLIGHTGRID_NAME = "tLightGrid";
Gfx::PDescriptorSet cullingDescriptorSet;
Gfx::ODescriptorLayout cullingDescriptorLayout;
Gfx::OPipelineLayout cullingLayout;
@@ -16,30 +16,30 @@ struct SampleParams {
RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics), scene(scene) {
paramsLayout = graphics->createDescriptorLayout("pRayTracingParams");
/*paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = TLAS_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
});
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.name = ACCUMULATOR_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE,
});
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2,
.name = TEXTURE_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE,
});
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 3,
.name = INDEXBUFFER_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 4,
.name = SKYBOX_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
});
paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 5,
.name = SKYSAMPLER_NAME,
.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->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->updateAccelerationStructure(TLAS_NAME, 0, tlas);
desc->updateTexture(ACCUMULATOR_NAME, 0, radianceAccumulator);
desc->updateTexture(TEXTURE_NAME, 0, texture);
desc->updateBuffer(INDEXBUFFER_NAME, 0, StaticMeshVertexData::getInstance()->getIndexBuffer());
desc->updateTexture(SKYBOX_NAME, 0, skyBox);
desc->updateSampler(SKYSAMPLER_NAME, 0, skyBoxSampler);
desc->writeChanges();
Gfx::ORenderCommand command = graphics->createRenderCommand("RayTracing");
@@ -17,15 +17,21 @@ class RayTracingPass : public RenderPass {
private:
Gfx::ODescriptorLayout paramsLayout;
Gfx::OPipelineLayout pipelineLayout;
constexpr static const char* TLAS_NAME = "scene";
Gfx::OTopLevelAS tlas;
constexpr static const char* ACCUMULATOR_NAME = "accumulator";
Gfx::OTexture2D radianceAccumulator;
constexpr static const char* TEXTURE_NAME = "image";
Gfx::OTexture2D texture;
constexpr static const char* SKYBOX_NAME = "skybox";
Gfx::PTextureCube skyBox;
constexpr static const char* SKYSAMPLER_NAME = "sampler";
Gfx::OSampler skyBoxSampler;
constexpr static const char* INDEXBUFFER_NAME = "indexBuffer";
Gfx::ORayGenShader rayGen;
Gfx::OAnyHitShader anyhit;
Gfx::OMissShader miss;
Gfx::PRayTracingPipeline pipeline;
Gfx::OTopLevelAS tlas;
PScene scene;
};
} // namespace Seele
+2 -4
View File
@@ -32,7 +32,7 @@ UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphic
uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = GLYPHINSTANCE_NAME,
.name = ELEMENT_NAME,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
@@ -57,6 +57,7 @@ void UIPass::beginFrame(const Component::Camera& cam) {
RenderPass::beginFrame(cam);
glyphs.clear();
usedTextures.clear();
elements.clear();
for (auto& render : renderElements) {
float x = render.position.x;
float y = render.position.y;
@@ -112,9 +113,6 @@ void UIPass::render() {
command->bindPipeline(uiPipeline);
command->bindDescriptor({viewParamsSet, uiDescriptorSet});
command->draw(4, elements.size(), 0, 0);
command->bindPipeline(textPipeline);
command->bindDescriptor({viewParamsSet, textDescriptorSet});
command->draw(4, glyphs.size(), 0, 0);
commands.add(std::move(command));
graphics->executeCommands(std::move(commands));
graphics->endRenderPass();
+4 -4
View File
@@ -72,13 +72,13 @@ class UIPass : public RenderPass {
Array<GlyphInstanceData> glyphs;
Array<RenderElementStyle> elements;
Gfx::OShaderBuffer glyphInstanceBuffer;
constexpr static std::string GLYPHINSTANCE_NAME = "glyphData";
constexpr static const char* GLYPHINSTANCE_NAME = "glyphData";
Gfx::OShaderBuffer elementBuffer;
constexpr static std::string ELEMENT_NAME = "elements";
constexpr static const char* ELEMENT_NAME = "elements";
Gfx::OSampler glyphSampler;
constexpr static std::string GLYPHSAMPLER_NAME = "glyphSampler";
constexpr static const char* GLYPHSAMPLER_NAME = "glyphSampler";
Array<Gfx::PTexture2D> usedTextures;
constexpr static std::string TEXTURES_NAME = "textures";
constexpr static const char* TEXTURES_NAME = "textures";
};
DEFINE_REF(UIPass);
} // namespace Seele
@@ -27,10 +27,10 @@ class VisibilityPass : public RenderPass {
Gfx::OPipelineStatisticsQuery query;
Gfx::PTimestampQuery timestamps;
constexpr static std::string VISIBILITY_NAME = "visibilityTexture";
constexpr static const char* VISIBILITY_NAME = "visibilityTexture";
// Holds culling information for every meshlet for each instance
Gfx::OShaderBuffer cullingBuffer;
constexpr static std::string CULLINGBUFFER_NAME = "cullingBuffer";
constexpr static const char* CULLINGBUFFER_NAME = "cullingBuffer";
UVector threadGroupSize;
};
DEFINE_REF(VisibilityPass)