From 4e7f4a56b876c4a670254869f030e3ff43a8dc8f Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Tue, 31 Oct 2023 23:44:46 +0100 Subject: [PATCH] more warning fixes --- src/Engine/Graphics/Initializer.h | 68 +++++++++++++++--------------- src/Engine/Graphics/VertexData.cpp | 54 ++++++++++++++++++------ src/Engine/Graphics/VertexData.h | 2 + 3 files changed, 76 insertions(+), 48 deletions(-) diff --git a/src/Engine/Graphics/Initializer.h b/src/Engine/Graphics/Initializer.h index 875fa51..9876f52 100644 --- a/src/Engine/Graphics/Initializer.h +++ b/src/Engine/Graphics/Initializer.h @@ -140,52 +140,52 @@ struct VertexElement static_assert(std::is_aggregate_v); struct RasterizationState { - uint8 depthClampEnable : 1; - uint8 rasterizerDiscardEnable : 1; - uint8 depthBiasEnable : 1; - float depthBoasConstantFactor; - float depthBiasClamp; - float depthBiasSlopeFactor; - float lineWidth; + uint8 depthClampEnable : 1 = 0; + uint8 rasterizerDiscardEnable : 1 = 0; + uint8 depthBiasEnable : 1 = 0; + float depthBiasConstantFactor = 0; + float depthBiasClamp = 0; + float depthBiasSlopeFactor = 0; + float lineWidth = 0; SePolygonMode polygonMode; SeCullModeFlags cullMode; SeFrontFace frontFace; }; struct MultisampleState { - uint32 samples; - float minSampleShading; - uint8 sampleShadingEnable : 1; - uint8 alphaCoverageEnable; - uint8 alphaToOneEnable; + uint32 samples = 1; + float minSampleShading = 1; + uint8 sampleShadingEnable : 1 = 0; + uint8 alphaCoverageEnable = 0; + uint8 alphaToOneEnable = 0; }; struct DepthStencilState { - uint8 depthTestEnable : 1; - uint8 depthWriteEnable : 1; - uint8 depthBoundsTestEnable : 1; - uint8 stencilTestEnable : 1; + uint8 depthTestEnable : 1 = 0; + uint8 depthWriteEnable : 1 = 0; + uint8 depthBoundsTestEnable : 1 = 0; + uint8 stencilTestEnable : 1 = 0; SeCompareOp depthCompareOp; - SeStencilOp front; - SeStencilOp back; + SeStencilOp front = Gfx::SE_STENCIL_OP_END_RANGE; + SeStencilOp back = Gfx::SE_STENCIL_OP_END_RANGE; float minDepthBounds; float maxDepthBounds; }; struct ColorBlendState { uint8 logicOpEnable : 1; - SeLogicOp logicOp; + SeLogicOp logicOp = Gfx::SE_LOGIC_OP_OR; uint32 attachmentCount; struct BlendAttachment { - uint8 blendEnable; - SeBlendFactor srcColorBlendFactor; - SeBlendFactor dstColorBlendFactor; - SeBlendOp colorBlendOp; - SeBlendFactor srcAlphaBlendFactor; - SeBlendFactor dstAlphaBlendFactor; - SeBlendOp alphaBlendOp; - SeColorComponentFlags colorWriteMask; + uint8 blendEnable = 0; + SeBlendFactor srcColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA; + SeBlendFactor dstColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA; + SeBlendOp colorBlendOp = Gfx::SE_BLEND_OP_ADD; + SeBlendFactor srcAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA; + SeBlendFactor dstAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA; + SeBlendOp alphaBlendOp = Gfx::SE_BLEND_OP_ADD; + SeColorComponentFlags colorWriteMask = 0; } blendAttachments[16]; float blendConstants[4]; }; @@ -212,6 +212,9 @@ struct LegacyPipelineCreateInfo ColorBlendState colorBlend; LegacyPipelineCreateInfo() : topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST) + , multisampleState(MultisampleState{ + .samples = 1, + }) , rasterizationState(RasterizationState{ .polygonMode = Gfx::SE_POLYGON_MODE_FILL, .cullMode = Gfx::SE_CULL_MODE_BACK_BIT, @@ -225,9 +228,6 @@ struct LegacyPipelineCreateInfo .minDepthBounds = 0.0f, .maxDepthBounds = 1.0f, }) - , multisampleState(MultisampleState{ - .samples = 1, - }) , colorBlend(ColorBlendState{ .logicOpEnable = false, .attachmentCount = 0, @@ -263,7 +263,10 @@ struct MeshPipelineCreateInfo DepthStencilState depthStencilState; ColorBlendState colorBlend; MeshPipelineCreateInfo() - : rasterizationState(RasterizationState{ + : multisampleState(MultisampleState{ + .samples = 1, + }) + , rasterizationState(RasterizationState{ .polygonMode = Gfx::SE_POLYGON_MODE_FILL, .cullMode = Gfx::SE_CULL_MODE_BACK_BIT, .frontFace = Gfx::SE_FRONT_FACE_COUNTER_CLOCKWISE, @@ -276,9 +279,6 @@ struct MeshPipelineCreateInfo .minDepthBounds = 0.0f, .maxDepthBounds = 1.0f, }) - , multisampleState(MultisampleState{ - .samples = 1, - }) , colorBlend(ColorBlendState{ .logicOpEnable = false, .attachmentCount = 0, diff --git a/src/Engine/Graphics/VertexData.cpp b/src/Engine/Graphics/VertexData.cpp index ce5200e..b415cee 100644 --- a/src/Engine/Graphics/VertexData.cpp +++ b/src/Engine/Graphics/VertexData.cpp @@ -1,4 +1,6 @@ #include "VertexData.h" +#include "Graphics/Enums.h" +#include "Graphics/Initializer.h" #include "Material/Material.h" #include "Graphics/Graphics.h" #include "Graphics/Descriptor.h" @@ -62,6 +64,31 @@ void VertexData::loadMesh(MeshId id, Array loadedMeshlets) }); currentMesh += numMeshlets; } + meshletBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo { + .resourceData = { + .size = sizeof(MeshletDescription) * meshlets.size(), + .data = (uint8*)meshlets.data() + }, + .stride = sizeof(MeshletDescription), + .bDynamic = true, + }); + vertexIndicesBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo { + .resourceData = { + .size = sizeof(uint32) * vertexIndices.size(), + .data = (uint8*)vertexIndices.data(), + }, + .stride = sizeof(uint32), + .bDynamic = true, + }); + primitiveIndicesBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo { + .resourceData = { + .size = sizeof(uint8) * primitiveIndices.size(), + .data = (uint8*)primitiveIndices.data(), + }, + .stride = sizeof(uint8), + .bDynamic = true, + }); + } void VertexData::createDescriptors() @@ -87,19 +114,21 @@ void VertexData::createDescriptors() }, .stride = sizeof(InstanceData) }); - Gfx::PShaderBuffer meshDataBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ - .resourceData = { - .size = sizeof(MeshData) * meshes.size(), - .data = (uint8*)meshes.data(), - }, - .stride = sizeof(MeshData) - }); matInst.descriptorSet = instanceDataLayout->allocateDescriptorSet(); matInst.descriptorSet->updateBuffer(0, instanceBuffer); if (Gfx::useMeshShading) { + Gfx::PShaderBuffer meshDataBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ + .resourceData = { + .size = sizeof(MeshData) * meshes.size(), + .data = (uint8*)meshes.data(), + }, + .stride = sizeof(MeshData) + }); matInst.descriptorSet->updateBuffer(1, meshDataBuffer); matInst.descriptorSet->updateBuffer(2, meshletBuffer); + matInst.descriptorSet->updateBuffer(3, primitiveIndicesBuffer); + matInst.descriptorSet->updateBuffer(4, vertexIndicesBuffer); } matInst.descriptorSet->writeChanges(); matInst.numMeshes = meshes.size(); @@ -139,13 +168,10 @@ void Seele::VertexData::init(Gfx::PGraphics graphics) instanceDataLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); // meshletData instanceDataLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - meshletBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ - .resourceData = { - .size = sizeof(MeshletDescription) * 512, - .data = nullptr, - }, - .bDynamic = true, - }); + // primitiveIndices + instanceDataLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + // vetexIndices + instanceDataLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); } instanceDataLayout->create(); resizeBuffers(); diff --git a/src/Engine/Graphics/VertexData.h b/src/Engine/Graphics/VertexData.h index 4b8a3c3..48a0a34 100644 --- a/src/Engine/Graphics/VertexData.h +++ b/src/Engine/Graphics/VertexData.h @@ -100,6 +100,8 @@ protected: Gfx::PDescriptorLayout instanceDataLayout; // for mesh shading Gfx::PShaderBuffer meshletBuffer; + Gfx::PShaderBuffer vertexIndicesBuffer; + Gfx::PShaderBuffer primitiveIndicesBuffer; // for legacy pipeline Gfx::PIndexBuffer indexBuffer; uint64 idCounter;