Graceful exit
This commit is contained in:
@@ -51,7 +51,7 @@ void taskMain(
|
|||||||
{
|
{
|
||||||
uint m = mesh.meshletOffset + i;
|
uint m = mesh.meshletOffset + i;
|
||||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||||
if(meshlet.boundingBox.insideFrustum(localToClip, viewFrustum))
|
//if(meshlet.boundingBox.insideFrustum(localToClip, viewFrustum))
|
||||||
{
|
{
|
||||||
uint index;
|
uint index;
|
||||||
InterlockedAdd(head, 1, index);
|
InterlockedAdd(head, 1, index);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ struct AABB
|
|||||||
float3 min;
|
float3 min;
|
||||||
float pad0;
|
float pad0;
|
||||||
float3 max;
|
float3 max;
|
||||||
float3 pad1;
|
float pad1;
|
||||||
bool insideFrustum(float4x4 transform, Frustum frustum)
|
bool insideFrustum(float4x4 transform, Frustum frustum)
|
||||||
{
|
{
|
||||||
float3 corners[8];
|
float3 corners[8];
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import AABB;
|
|||||||
|
|
||||||
struct MeshletDescription
|
struct MeshletDescription
|
||||||
{
|
{
|
||||||
AABB boundingBox;
|
|
||||||
uint32_t vertexCount;
|
uint32_t vertexCount;
|
||||||
uint32_t primitiveCount;
|
uint32_t primitiveCount;
|
||||||
uint32_t vertexOffset;
|
uint32_t vertexOffset;
|
||||||
@@ -11,12 +10,11 @@ struct MeshletDescription
|
|||||||
|
|
||||||
struct MeshData
|
struct MeshData
|
||||||
{
|
{
|
||||||
AABB boundingBox;
|
uint32_t meshletOffset = 0;
|
||||||
uint numMeshlets;
|
uint16_t numMeshlets = 0;
|
||||||
uint meshletOffset;
|
uint16_t indicesOffset = 0;
|
||||||
uint firstIndex;
|
uint32_t firstIndex = 0;
|
||||||
uint numIndices;
|
uint32_t numIndices = 0;
|
||||||
uint indicesOffset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint MAX_VERTICES = 64;
|
static const uint MAX_VERTICES = 64;
|
||||||
|
|||||||
+8
-167
@@ -1,178 +1,19 @@
|
|||||||
#version 450
|
#version 450
|
||||||
|
#extension GL_EXT_mesh_shader : require
|
||||||
layout(row_major) uniform;
|
layout(row_major) uniform;
|
||||||
layout(row_major) buffer;
|
layout(row_major) buffer;
|
||||||
|
|
||||||
#line 5 0
|
#line 27 0
|
||||||
struct InstanceData_0
|
layout(local_size_x = 3, local_size_y = 1, local_size_z = 1) in;
|
||||||
{
|
layout(max_vertices = 12) out;
|
||||||
mat4x4 transformMatrix_0;
|
layout(max_primitives = 4) out;
|
||||||
};
|
layout(triangles) out;
|
||||||
|
|
||||||
|
|
||||||
#line 22
|
|
||||||
layout(std430, binding = 0) readonly buffer StructuredBuffer_InstanceData_t_0 {
|
|
||||||
InstanceData_0 _data[];
|
|
||||||
} pScene_instances_0;
|
|
||||||
|
|
||||||
#line 5 1
|
|
||||||
layout(std430, binding = 0, set = 2) readonly buffer StructuredBuffer_float3_t_0 {
|
|
||||||
vec3 _data[];
|
|
||||||
} pVertexData_positions_0;
|
|
||||||
|
|
||||||
#line 5
|
|
||||||
layout(std430, binding = 1, set = 2) readonly buffer StructuredBuffer_float2_t_0 {
|
|
||||||
vec2 _data[];
|
|
||||||
} pVertexData_texCoords_0;
|
|
||||||
|
|
||||||
#line 5
|
|
||||||
layout(std430, binding = 2, set = 2) readonly buffer StructuredBuffer_float3_t_1 {
|
|
||||||
vec3 _data[];
|
|
||||||
} pVertexData_normals_0;
|
|
||||||
|
|
||||||
#line 5
|
|
||||||
layout(std430, binding = 3, set = 2) readonly buffer StructuredBuffer_float3_t_2 {
|
|
||||||
vec3 _data[];
|
|
||||||
} pVertexData_tangents_0;
|
|
||||||
|
|
||||||
#line 5
|
|
||||||
layout(std430, binding = 4, set = 2) readonly buffer StructuredBuffer_float3_t_3 {
|
|
||||||
vec3 _data[];
|
|
||||||
} pVertexData_biTangents_0;
|
|
||||||
|
|
||||||
#line 5 2
|
|
||||||
struct ViewParameter_0
|
|
||||||
{
|
|
||||||
mat4x4 viewMatrix_0;
|
|
||||||
mat4x4 projectionMatrix_0;
|
|
||||||
vec4 cameraPos_WS_0;
|
|
||||||
vec2 screenDimensions_0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#line 12
|
|
||||||
layout(binding = 0, set = 1)
|
|
||||||
layout(std140) uniform _S1
|
|
||||||
{
|
|
||||||
mat4x4 viewMatrix_0;
|
|
||||||
mat4x4 projectionMatrix_0;
|
|
||||||
vec4 cameraPos_WS_0;
|
|
||||||
vec2 screenDimensions_0;
|
|
||||||
}pViewParams_0;
|
|
||||||
|
|
||||||
#line 4206 3
|
|
||||||
layout(location = 0)
|
|
||||||
out vec3 _S2;
|
|
||||||
|
|
||||||
|
|
||||||
#line 4206
|
|
||||||
layout(location = 1)
|
|
||||||
out vec3 _S3;
|
|
||||||
|
|
||||||
|
|
||||||
#line 4206
|
|
||||||
layout(location = 2)
|
|
||||||
out vec2 _S4;
|
|
||||||
|
|
||||||
|
|
||||||
#line 4206
|
|
||||||
layout(location = 3)
|
|
||||||
out vec3 _S5;
|
|
||||||
|
|
||||||
|
|
||||||
#line 4206
|
|
||||||
layout(location = 4)
|
|
||||||
out vec3 _S6;
|
|
||||||
|
|
||||||
|
|
||||||
#line 4206
|
|
||||||
layout(location = 5)
|
|
||||||
out vec3 _S7;
|
|
||||||
|
|
||||||
|
|
||||||
#line 4206
|
|
||||||
layout(location = 6)
|
|
||||||
out vec3 _S8;
|
|
||||||
|
|
||||||
|
|
||||||
#line 1 4
|
|
||||||
struct MaterialParameter_0
|
|
||||||
{
|
|
||||||
vec3 position_TS_0;
|
|
||||||
vec3 worldPosition_0;
|
|
||||||
vec2 texCoords_0;
|
|
||||||
vec3 normal_0;
|
|
||||||
vec3 tangent_0;
|
|
||||||
vec3 biTangent_0;
|
|
||||||
vec3 viewDir_TS_0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertexAttributes_0
|
|
||||||
{
|
|
||||||
MaterialParameter_0 parameter_0;
|
|
||||||
vec4 clipPosition_0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#line 9 1
|
|
||||||
VertexAttributes_0 StaticMeshVertexData_getAttributes_0(uint _S9, mat4x4 _S10)
|
|
||||||
{
|
|
||||||
|
|
||||||
vec4 worldPos_0 = (((vec4(pVertexData_positions_0._data[_S9], 1.0)) * (_S10)));
|
|
||||||
|
|
||||||
vec4 clipPos_0 = ((((((worldPos_0) * (pViewParams_0.viewMatrix_0)))) * (pViewParams_0.projectionMatrix_0)));
|
|
||||||
|
|
||||||
#line 10
|
|
||||||
MaterialParameter_0 params_0;
|
|
||||||
|
|
||||||
#line 15
|
|
||||||
params_0.worldPosition_0 = worldPos_0.xyz;
|
|
||||||
params_0.texCoords_0 = pVertexData_texCoords_0._data[_S9];
|
|
||||||
params_0.normal_0 = pVertexData_normals_0._data[_S9];
|
|
||||||
params_0.tangent_0 = pVertexData_tangents_0._data[_S9];
|
|
||||||
params_0.biTangent_0 = pVertexData_biTangents_0._data[_S9];
|
|
||||||
|
|
||||||
#line 9
|
|
||||||
VertexAttributes_0 attributes_0;
|
|
||||||
|
|
||||||
#line 20
|
|
||||||
attributes_0.parameter_0 = params_0;
|
|
||||||
attributes_0.clipPosition_0 = clipPos_0;
|
|
||||||
return attributes_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#line 18 0
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
||||||
#line 18
|
SetMeshOutputsEXT(12U, 4U);
|
||||||
VertexAttributes_0 _S11 = StaticMeshVertexData_getAttributes_0(uint(gl_VertexIndex), pScene_instances_0._data[uint(gl_InstanceIndex)].transformMatrix_0);
|
|
||||||
|
|
||||||
#line 18
|
#line 46
|
||||||
_S2 = _S11.parameter_0.position_TS_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
_S3 = _S11.parameter_0.worldPosition_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
_S4 = _S11.parameter_0.texCoords_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
_S5 = _S11.parameter_0.normal_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
_S6 = _S11.parameter_0.tangent_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
_S7 = _S11.parameter_0.biTangent_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
_S8 = _S11.parameter_0.viewDir_TS_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
gl_Position = _S11.clipPosition_0;
|
|
||||||
|
|
||||||
#line 18
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+41
-60
@@ -1,63 +1,44 @@
|
|||||||
|
const static float2 positions[3] = {
|
||||||
|
float2(0.0, -0.5),
|
||||||
|
float2(0.5, 0.5),
|
||||||
|
float2(-0.5, 0.5)
|
||||||
|
};
|
||||||
|
|
||||||
struct MeshPayload
|
const static float3 colors[3] = {
|
||||||
{
|
float3(1.0, 1.0, 0.0),
|
||||||
int exponent;
|
float3(0.0, 1.0, 1.0),
|
||||||
};
|
float3(1.0, 0.0, 1.0)
|
||||||
|
};
|
||||||
groupshared MeshPayload payload;
|
struct Vertex
|
||||||
|
|
||||||
[numthreads(1, 1, 1)]
|
|
||||||
[outputtopology("triangle")]
|
|
||||||
void taskMain(
|
|
||||||
uint3 threadID: SV_GroupIndex,
|
|
||||||
uint3 groupID: SV_GroupID
|
|
||||||
){
|
|
||||||
DispatchMesh(1,1,1,payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const static float2 positions[3] = {
|
|
||||||
float2(0.0, -0.5),
|
|
||||||
float2(0.5, 0.5),
|
|
||||||
float2(-0.5, 0.5)
|
|
||||||
};
|
|
||||||
|
|
||||||
const static float3 colors[3] = {
|
|
||||||
float3(1.0, 1.0, 0.0),
|
|
||||||
float3(0.0, 1.0, 1.0),
|
|
||||||
float3(1.0, 0.0, 1.0)
|
|
||||||
};
|
|
||||||
struct Vertex
|
|
||||||
{
|
|
||||||
float4 pos : SV_Position;
|
|
||||||
float3 color : Color;
|
|
||||||
int index : Index;
|
|
||||||
int value : Value;
|
|
||||||
};
|
|
||||||
|
|
||||||
const static uint MAX_VERTS = 12;
|
|
||||||
const static uint MAX_PRIMS = 4;
|
|
||||||
|
|
||||||
[outputtopology("triangle")]
|
|
||||||
[shader("mesh")]
|
|
||||||
[numthreads(12, 1, 1)]
|
|
||||||
void meshMain(
|
|
||||||
in uint tig : SV_GroupIndex,
|
|
||||||
in payload MeshPayload meshPayload,
|
|
||||||
out Vertices<Vertex, MAX_VERTS> verts,
|
|
||||||
out Indices<uint3, MAX_PRIMS> triangles)
|
|
||||||
{
|
|
||||||
const uint numVertices = 12;
|
|
||||||
const uint numPrimitives = 4;
|
|
||||||
SetMeshOutputCounts(numVertices, numPrimitives);
|
|
||||||
|
|
||||||
if(tig < numVertices)
|
|
||||||
{
|
{
|
||||||
const int tri = tig / 3;
|
float4 pos : SV_Position;
|
||||||
verts[tig] = {float4(positions[tig % 3], 0, 1), colors[tig % 3], tri, int(pow(tri, meshPayload.exponent))};
|
float3 color : Color;
|
||||||
}
|
int index : Index;
|
||||||
|
};
|
||||||
|
|
||||||
if(tig < numPrimitives)
|
const static uint MAX_VERTS = 12;
|
||||||
triangles[tig] = tig * 3 + uint3(0,1,2);
|
const static uint MAX_PRIMS = 4;
|
||||||
}
|
|
||||||
|
[outputtopology("triangle")]
|
||||||
|
[shader("mesh")]
|
||||||
|
[numthreads(3, 1, 1)]
|
||||||
|
void meshMain(
|
||||||
|
in uint tig : SV_GroupIndex,
|
||||||
|
out Vertices<Vertex, MAX_VERTS> verts,
|
||||||
|
out Indices<uint3, MAX_PRIMS> triangles)
|
||||||
|
{
|
||||||
|
const uint numVertices = 12;
|
||||||
|
const uint numPrimitives = 4;
|
||||||
|
SetMeshOutputCounts(numVertices, numPrimitives);
|
||||||
|
|
||||||
|
for(uint i = tig; i < numVertices; ++i)
|
||||||
|
{
|
||||||
|
const int tri = i / 3;
|
||||||
|
verts[i] = {float4(positions[i % 3], 0, 1), colors[i % 3], tri};
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint i = tig; i < numPrimitives; ++i)
|
||||||
|
{
|
||||||
|
triangles[i] = i * 3 + uint3(0,1,2);
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-2
@@ -17,6 +17,9 @@
|
|||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Editor;
|
using namespace Seele::Editor;
|
||||||
|
|
||||||
|
// make it global so it gets deleted last and automatically
|
||||||
|
static Gfx::OGraphics graphics;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -31,7 +34,7 @@ int main()
|
|||||||
std::string gameName = "TrackClear";
|
std::string gameName = "TrackClear";
|
||||||
std::filesystem::path cmakePath = outputPath / "cmake";
|
std::filesystem::path cmakePath = outputPath / "cmake";
|
||||||
|
|
||||||
Gfx::OGraphics graphics = new Vulkan::Graphics();
|
graphics = new Vulkan::Graphics();
|
||||||
|
|
||||||
GraphicsInitializer initializer;
|
GraphicsInitializer initializer;
|
||||||
graphics->init(initializer);
|
graphics->init(initializer);
|
||||||
@@ -246,7 +249,7 @@ int main()
|
|||||||
{
|
{
|
||||||
windowManager->render();
|
windowManager->render();
|
||||||
}
|
}
|
||||||
vd->~StaticMeshVertexData();
|
vd->destroy();
|
||||||
//export game
|
//export game
|
||||||
if (false)
|
if (false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using namespace Seele;
|
|||||||
|
|
||||||
extern List<VertexData*> vertexDataList;
|
extern List<VertexData*> vertexDataList;
|
||||||
|
|
||||||
|
|
||||||
StaticMeshVertexData::StaticMeshVertexData()
|
StaticMeshVertexData::StaticMeshVertexData()
|
||||||
{
|
{
|
||||||
vertexDataList.add(this);
|
vertexDataList.add(this);
|
||||||
@@ -128,6 +127,18 @@ void StaticMeshVertexData::init(Gfx::PGraphics graphics)
|
|||||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StaticMeshVertexData::destroy()
|
||||||
|
{
|
||||||
|
VertexData::destroy();
|
||||||
|
positions = nullptr;
|
||||||
|
texCoords = nullptr;
|
||||||
|
normals = nullptr;
|
||||||
|
tangents = nullptr;
|
||||||
|
biTangents = nullptr;
|
||||||
|
colors = nullptr;
|
||||||
|
descriptorLayout = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void StaticMeshVertexData::bindBuffers(Gfx::PRenderCommand)
|
void StaticMeshVertexData::bindBuffers(Gfx::PRenderCommand)
|
||||||
{
|
{
|
||||||
// TODO: for legacy vertex buffer binding
|
// TODO: for legacy vertex buffer binding
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public:
|
|||||||
virtual void serializeMesh(MeshId id, uint64 numVertices, ArchiveBuffer& buffer) override;
|
virtual void serializeMesh(MeshId id, uint64 numVertices, ArchiveBuffer& buffer) override;
|
||||||
virtual void deserializeMesh(MeshId id, ArchiveBuffer& buffer) override;
|
virtual void deserializeMesh(MeshId id, ArchiveBuffer& buffer) override;
|
||||||
virtual void init(Gfx::PGraphics graphics) override;
|
virtual void init(Gfx::PGraphics graphics) override;
|
||||||
|
virtual void destroy() override;
|
||||||
virtual void bindBuffers(Gfx::PRenderCommand command) override;
|
virtual void bindBuffers(Gfx::PRenderCommand command) override;
|
||||||
virtual Gfx::PDescriptorLayout getVertexDataLayout() override;
|
virtual Gfx::PDescriptorLayout getVertexDataLayout() override;
|
||||||
virtual Gfx::PDescriptorSet getVertexDataSet() override;
|
virtual Gfx::PDescriptorSet getVertexDataSet() override;
|
||||||
|
|||||||
@@ -97,11 +97,11 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
{
|
{
|
||||||
uint32 numMeshlets = std::min<uint32>(512, loadedMeshlets.size() - currentMesh);
|
uint32 numMeshlets = std::min<uint32>(512, loadedMeshlets.size() - currentMesh);
|
||||||
uint32 meshletOffset = meshlets.size();
|
uint32 meshletOffset = meshlets.size();
|
||||||
AABB meshAABB;
|
//AABB meshAABB;
|
||||||
for (uint32 i = 0; i < numMeshlets; ++i)
|
for (uint32 i = 0; i < numMeshlets; ++i)
|
||||||
{
|
{
|
||||||
Meshlet& m = loadedMeshlets[currentMesh + i];
|
Meshlet& m = loadedMeshlets[currentMesh + i];
|
||||||
meshAABB = meshAABB.combine(m.boundingBox);
|
//meshAABB = meshAABB.combine(m.boundingBox);
|
||||||
uint32 vertexOffset = vertexIndices.size();
|
uint32 vertexOffset = vertexIndices.size();
|
||||||
vertexIndices.resize(vertexOffset + m.numVertices);
|
vertexIndices.resize(vertexOffset + m.numVertices);
|
||||||
std::memcpy(vertexIndices.data() + vertexOffset, m.uniqueVertices, m.numVertices * sizeof(uint32));
|
std::memcpy(vertexIndices.data() + vertexOffset, m.uniqueVertices, m.numVertices * sizeof(uint32));
|
||||||
@@ -109,7 +109,6 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
||||||
std::memcpy(primitiveIndices.data() + primitiveOffset, m.primitiveLayout, m.numPrimitives * 3 * sizeof(uint8));
|
std::memcpy(primitiveIndices.data() + primitiveOffset, m.primitiveLayout, m.numPrimitives * 3 * sizeof(uint8));
|
||||||
meshlets.add(MeshletDescription{
|
meshlets.add(MeshletDescription{
|
||||||
.boundingBox = m.boundingBox,
|
|
||||||
.vertexCount = m.numVertices,
|
.vertexCount = m.numVertices,
|
||||||
.primitiveCount = m.numPrimitives,
|
.primitiveCount = m.numPrimitives,
|
||||||
.vertexOffset = vertexOffset,
|
.vertexOffset = vertexOffset,
|
||||||
@@ -117,10 +116,9 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
meshData[id].add(MeshData{
|
meshData[id].add(MeshData{
|
||||||
.boundingBox = meshAABB,
|
|
||||||
.numMeshlets = numMeshlets,
|
|
||||||
.meshletOffset = meshletOffset,
|
.meshletOffset = meshletOffset,
|
||||||
.indicesOffset = static_cast<uint32>(meshOffsets[id]),
|
.numMeshlets = (uint16)numMeshlets,
|
||||||
|
.indicesOffset = (uint16)meshOffsets[id],
|
||||||
});
|
});
|
||||||
currentMesh += numMeshlets;
|
currentMesh += numMeshlets;
|
||||||
}
|
}
|
||||||
@@ -225,6 +223,17 @@ void Seele::VertexData::init(Gfx::PGraphics _graphics)
|
|||||||
graphics->getShaderCompiler()->registerVertexData(this);
|
graphics->getShaderCompiler()->registerVertexData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VertexData::destroy()
|
||||||
|
{
|
||||||
|
instanceDataLayout = nullptr;
|
||||||
|
meshletBuffer = nullptr;
|
||||||
|
vertexIndicesBuffer = nullptr;
|
||||||
|
primitiveIndicesBuffer = nullptr;
|
||||||
|
indexBuffer = nullptr;
|
||||||
|
meshData.clear();
|
||||||
|
materialData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
VertexData::VertexData()
|
VertexData::VertexData()
|
||||||
: idCounter(0)
|
: idCounter(0)
|
||||||
, head(0)
|
, head(0)
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ public:
|
|||||||
};
|
};
|
||||||
struct MeshData
|
struct MeshData
|
||||||
{
|
{
|
||||||
AABB boundingBox;
|
|
||||||
uint32 numMeshlets = 0;
|
|
||||||
uint32 meshletOffset = 0;
|
uint32 meshletOffset = 0;
|
||||||
|
uint16 numMeshlets = 0;
|
||||||
|
uint16 indicesOffset = 0;
|
||||||
uint32 firstIndex = 0;
|
uint32 firstIndex = 0;
|
||||||
uint32 numIndices = 0;
|
uint32 numIndices = 0;
|
||||||
uint32 indicesOffset = 0;
|
|
||||||
};
|
};
|
||||||
|
static_assert(sizeof(MeshData) == 16);
|
||||||
struct MeshInstanceData
|
struct MeshInstanceData
|
||||||
{
|
{
|
||||||
InstanceData instance;
|
InstanceData instance;
|
||||||
@@ -86,13 +86,13 @@ public:
|
|||||||
static List<VertexData*> getList();
|
static List<VertexData*> getList();
|
||||||
static VertexData* findByTypeName(std::string name);
|
static VertexData* findByTypeName(std::string name);
|
||||||
virtual void init(Gfx::PGraphics graphics);
|
virtual void init(Gfx::PGraphics graphics);
|
||||||
|
virtual void destroy();
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeBuffers() = 0;
|
virtual void resizeBuffers() = 0;
|
||||||
virtual void updateBuffers() = 0;
|
virtual void updateBuffers() = 0;
|
||||||
VertexData();
|
VertexData();
|
||||||
struct MeshletDescription
|
struct MeshletDescription
|
||||||
{
|
{
|
||||||
AABB boundingBox;
|
|
||||||
uint32_t vertexCount;
|
uint32_t vertexCount;
|
||||||
uint32_t primitiveCount;
|
uint32_t primitiveCount;
|
||||||
uint32_t vertexOffset;
|
uint32_t vertexOffset;
|
||||||
|
|||||||
@@ -267,7 +267,6 @@ void Buffer::unmap()
|
|||||||
.size = pending.size,
|
.size = pending.size,
|
||||||
};
|
};
|
||||||
vkCmdCopyBuffer(cmdHandle, stagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
vkCmdCopyBuffer(cmdHandle, stagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
||||||
graphics->getQueueCommands(owner)->submitCommands();
|
|
||||||
}
|
}
|
||||||
//requestOwnershipTransfer(pending.prevQueue);
|
//requestOwnershipTransfer(pending.prevQueue);
|
||||||
pendingBuffers.erase(this);
|
pendingBuffers.erase(this);
|
||||||
@@ -328,7 +327,6 @@ void UniformBuffer::unmap()
|
|||||||
std::memset(®ion, 0, sizeof(VkBufferCopy));
|
std::memset(®ion, 0, sizeof(VkBufferCopy));
|
||||||
region.size = Vulkan::Buffer::size;
|
region.size = Vulkan::Buffer::size;
|
||||||
vkCmdCopyBuffer(cmdHandle, dedicatedStagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
vkCmdCopyBuffer(cmdHandle, dedicatedStagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
||||||
graphics->getQueueCommands(currentOwner)->submitCommands();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -416,7 +414,6 @@ void ShaderBuffer::unmap()
|
|||||||
.size = Vulkan::Buffer::size,
|
.size = Vulkan::Buffer::size,
|
||||||
};
|
};
|
||||||
vkCmdCopyBuffer(cmdHandle, dedicatedStagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
vkCmdCopyBuffer(cmdHandle, dedicatedStagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
||||||
graphics->getQueueCommands(currentOwner)->submitCommands();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -407,7 +407,9 @@ void Graphics::pickPhysicalDevice()
|
|||||||
VkPhysicalDevice bestDevice = VK_NULL_HANDLE;
|
VkPhysicalDevice bestDevice = VK_NULL_HANDLE;
|
||||||
uint32 deviceRating = 0;
|
uint32 deviceRating = 0;
|
||||||
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||||
features.pNext = &features12;
|
features.pNext = &features11;
|
||||||
|
features11.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
|
||||||
|
features11.pNext = &features12;
|
||||||
features12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
features12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||||
features12.pNext = nullptr;
|
features12.pNext = nullptr;
|
||||||
for (auto dev : physicalDevices)
|
for (auto dev : physicalDevices)
|
||||||
@@ -446,7 +448,7 @@ void Graphics::pickPhysicalDevice()
|
|||||||
{
|
{
|
||||||
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0)
|
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0)
|
||||||
{
|
{
|
||||||
meshShadingEnabled = true;
|
//meshShadingEnabled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,7 +567,7 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
}
|
}
|
||||||
VkDeviceCreateInfo deviceInfo = {
|
VkDeviceCreateInfo deviceInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||||
.pNext = &features12,
|
.pNext = &features11,
|
||||||
.queueCreateInfoCount = (uint32)queueInfos.size(),
|
.queueCreateInfoCount = (uint32)queueInfos.size(),
|
||||||
.pQueueCreateInfos = queueInfos.data(),
|
.pQueueCreateInfos = queueInfos.data(),
|
||||||
.enabledExtensionCount = (uint32)initializer.deviceExtensions.size(),
|
.enabledExtensionCount = (uint32)initializer.deviceExtensions.size(),
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ protected:
|
|||||||
thread_local static OCommandPool dedicatedTransferCommands;
|
thread_local static OCommandPool dedicatedTransferCommands;
|
||||||
VkPhysicalDeviceProperties props;
|
VkPhysicalDeviceProperties props;
|
||||||
VkPhysicalDeviceFeatures2 features;
|
VkPhysicalDeviceFeatures2 features;
|
||||||
|
VkPhysicalDeviceVulkan11Features features11;
|
||||||
VkPhysicalDeviceVulkan12Features features12;
|
VkPhysicalDeviceVulkan12Features features12;
|
||||||
VkDebugReportCallbackEXT callback;
|
VkDebugReportCallbackEXT callback;
|
||||||
Map<uint32, OFramebuffer> allocatedFramebuffers;
|
Map<uint32, OFramebuffer> allocatedFramebuffers;
|
||||||
|
|||||||
Reference in New Issue
Block a user