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>);
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,
+37 -11
View File
@@ -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<Meshlet> 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,6 +114,10 @@ void VertexData::createDescriptors()
},
.stride = sizeof(InstanceData)
});
matInst.descriptorSet = instanceDataLayout->allocateDescriptorSet();
matInst.descriptorSet->updateBuffer(0, instanceBuffer);
if (Gfx::useMeshShading)
{
Gfx::PShaderBuffer meshDataBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
.resourceData = {
.size = sizeof(MeshData) * meshes.size(),
@@ -94,12 +125,10 @@ void VertexData::createDescriptors()
},
.stride = sizeof(MeshData)
});
matInst.descriptorSet = instanceDataLayout->allocateDescriptorSet();
matInst.descriptorSet->updateBuffer(0, instanceBuffer);
if (Gfx::useMeshShading)
{
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();
+2
View File
@@ -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;