more warning fixes

This commit is contained in:
2023-10-31 23:44:46 +01:00
parent 59b3893391
commit 4e7f4a56b8
3 changed files with 76 additions and 48 deletions
+34 -34
View File
@@ -140,52 +140,52 @@ struct VertexElement
static_assert(std::is_aggregate_v<VertexElement>); static_assert(std::is_aggregate_v<VertexElement>);
struct RasterizationState struct RasterizationState
{ {
uint8 depthClampEnable : 1; uint8 depthClampEnable : 1 = 0;
uint8 rasterizerDiscardEnable : 1; uint8 rasterizerDiscardEnable : 1 = 0;
uint8 depthBiasEnable : 1; uint8 depthBiasEnable : 1 = 0;
float depthBoasConstantFactor; float depthBiasConstantFactor = 0;
float depthBiasClamp; float depthBiasClamp = 0;
float depthBiasSlopeFactor; float depthBiasSlopeFactor = 0;
float lineWidth; float lineWidth = 0;
SePolygonMode polygonMode; SePolygonMode polygonMode;
SeCullModeFlags cullMode; SeCullModeFlags cullMode;
SeFrontFace frontFace; SeFrontFace frontFace;
}; };
struct MultisampleState struct MultisampleState
{ {
uint32 samples; uint32 samples = 1;
float minSampleShading; float minSampleShading = 1;
uint8 sampleShadingEnable : 1; uint8 sampleShadingEnable : 1 = 0;
uint8 alphaCoverageEnable; uint8 alphaCoverageEnable = 0;
uint8 alphaToOneEnable; uint8 alphaToOneEnable = 0;
}; };
struct DepthStencilState struct DepthStencilState
{ {
uint8 depthTestEnable : 1; uint8 depthTestEnable : 1 = 0;
uint8 depthWriteEnable : 1; uint8 depthWriteEnable : 1 = 0;
uint8 depthBoundsTestEnable : 1; uint8 depthBoundsTestEnable : 1 = 0;
uint8 stencilTestEnable : 1; uint8 stencilTestEnable : 1 = 0;
SeCompareOp depthCompareOp; SeCompareOp depthCompareOp;
SeStencilOp front; SeStencilOp front = Gfx::SE_STENCIL_OP_END_RANGE;
SeStencilOp back; SeStencilOp back = Gfx::SE_STENCIL_OP_END_RANGE;
float minDepthBounds; float minDepthBounds;
float maxDepthBounds; float maxDepthBounds;
}; };
struct ColorBlendState struct ColorBlendState
{ {
uint8 logicOpEnable : 1; uint8 logicOpEnable : 1;
SeLogicOp logicOp; SeLogicOp logicOp = Gfx::SE_LOGIC_OP_OR;
uint32 attachmentCount; uint32 attachmentCount;
struct BlendAttachment struct BlendAttachment
{ {
uint8 blendEnable; uint8 blendEnable = 0;
SeBlendFactor srcColorBlendFactor; SeBlendFactor srcColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendFactor dstColorBlendFactor; SeBlendFactor dstColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendOp colorBlendOp; SeBlendOp colorBlendOp = Gfx::SE_BLEND_OP_ADD;
SeBlendFactor srcAlphaBlendFactor; SeBlendFactor srcAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendFactor dstAlphaBlendFactor; SeBlendFactor dstAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
SeBlendOp alphaBlendOp; SeBlendOp alphaBlendOp = Gfx::SE_BLEND_OP_ADD;
SeColorComponentFlags colorWriteMask; SeColorComponentFlags colorWriteMask = 0;
} blendAttachments[16]; } blendAttachments[16];
float blendConstants[4]; float blendConstants[4];
}; };
@@ -212,6 +212,9 @@ struct LegacyPipelineCreateInfo
ColorBlendState colorBlend; ColorBlendState colorBlend;
LegacyPipelineCreateInfo() LegacyPipelineCreateInfo()
: topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST) : topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
, multisampleState(MultisampleState{
.samples = 1,
})
, rasterizationState(RasterizationState{ , rasterizationState(RasterizationState{
.polygonMode = Gfx::SE_POLYGON_MODE_FILL, .polygonMode = Gfx::SE_POLYGON_MODE_FILL,
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT, .cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
@@ -225,9 +228,6 @@ struct LegacyPipelineCreateInfo
.minDepthBounds = 0.0f, .minDepthBounds = 0.0f,
.maxDepthBounds = 1.0f, .maxDepthBounds = 1.0f,
}) })
, multisampleState(MultisampleState{
.samples = 1,
})
, colorBlend(ColorBlendState{ , colorBlend(ColorBlendState{
.logicOpEnable = false, .logicOpEnable = false,
.attachmentCount = 0, .attachmentCount = 0,
@@ -263,7 +263,10 @@ struct MeshPipelineCreateInfo
DepthStencilState depthStencilState; DepthStencilState depthStencilState;
ColorBlendState colorBlend; ColorBlendState colorBlend;
MeshPipelineCreateInfo() MeshPipelineCreateInfo()
: rasterizationState(RasterizationState{ : multisampleState(MultisampleState{
.samples = 1,
})
, rasterizationState(RasterizationState{
.polygonMode = Gfx::SE_POLYGON_MODE_FILL, .polygonMode = Gfx::SE_POLYGON_MODE_FILL,
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT, .cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
.frontFace = Gfx::SE_FRONT_FACE_COUNTER_CLOCKWISE, .frontFace = Gfx::SE_FRONT_FACE_COUNTER_CLOCKWISE,
@@ -276,9 +279,6 @@ struct MeshPipelineCreateInfo
.minDepthBounds = 0.0f, .minDepthBounds = 0.0f,
.maxDepthBounds = 1.0f, .maxDepthBounds = 1.0f,
}) })
, multisampleState(MultisampleState{
.samples = 1,
})
, colorBlend(ColorBlendState{ , colorBlend(ColorBlendState{
.logicOpEnable = false, .logicOpEnable = false,
.attachmentCount = 0, .attachmentCount = 0,
+40 -14
View File
@@ -1,4 +1,6 @@
#include "VertexData.h" #include "VertexData.h"
#include "Graphics/Enums.h"
#include "Graphics/Initializer.h"
#include "Material/Material.h" #include "Material/Material.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include "Graphics/Descriptor.h" #include "Graphics/Descriptor.h"
@@ -62,6 +64,31 @@ void VertexData::loadMesh(MeshId id, Array<Meshlet> loadedMeshlets)
}); });
currentMesh += numMeshlets; 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() void VertexData::createDescriptors()
@@ -87,19 +114,21 @@ void VertexData::createDescriptors()
}, },
.stride = sizeof(InstanceData) .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 = instanceDataLayout->allocateDescriptorSet();
matInst.descriptorSet->updateBuffer(0, instanceBuffer); matInst.descriptorSet->updateBuffer(0, instanceBuffer);
if (Gfx::useMeshShading) 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(1, meshDataBuffer);
matInst.descriptorSet->updateBuffer(2, meshletBuffer); matInst.descriptorSet->updateBuffer(2, meshletBuffer);
matInst.descriptorSet->updateBuffer(3, primitiveIndicesBuffer);
matInst.descriptorSet->updateBuffer(4, vertexIndicesBuffer);
} }
matInst.descriptorSet->writeChanges(); matInst.descriptorSet->writeChanges();
matInst.numMeshes = meshes.size(); matInst.numMeshes = meshes.size();
@@ -139,13 +168,10 @@ void Seele::VertexData::init(Gfx::PGraphics graphics)
instanceDataLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); instanceDataLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
// meshletData // meshletData
instanceDataLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); instanceDataLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
meshletBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ // primitiveIndices
.resourceData = { instanceDataLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
.size = sizeof(MeshletDescription) * 512, // vetexIndices
.data = nullptr, instanceDataLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
},
.bDynamic = true,
});
} }
instanceDataLayout->create(); instanceDataLayout->create();
resizeBuffers(); resizeBuffers();
+2
View File
@@ -100,6 +100,8 @@ protected:
Gfx::PDescriptorLayout instanceDataLayout; Gfx::PDescriptorLayout instanceDataLayout;
// for mesh shading // for mesh shading
Gfx::PShaderBuffer meshletBuffer; Gfx::PShaderBuffer meshletBuffer;
Gfx::PShaderBuffer vertexIndicesBuffer;
Gfx::PShaderBuffer primitiveIndicesBuffer;
// for legacy pipeline // for legacy pipeline
Gfx::PIndexBuffer indexBuffer; Gfx::PIndexBuffer indexBuffer;
uint64 idCounter; uint64 idCounter;