|
|
@@ -12,10 +12,10 @@
|
|
|
|
|
|
namespace anki {
|
|
|
|
|
|
-void allocateAndPopulateDebugBox(RebarStagingGpuMemoryPool& stagingGpuAllocator, RebarGpuMemoryToken& vertsToken,
|
|
|
- RebarGpuMemoryToken& indicesToken, U32& indexCount)
|
|
|
+void allocateAndPopulateDebugBox(RebarGpuMemoryToken& vertsToken, RebarGpuMemoryToken& indicesToken, U32& indexCount)
|
|
|
{
|
|
|
- Vec3* verts = static_cast<Vec3*>(stagingGpuAllocator.allocateFrame(sizeof(Vec3) * 8, vertsToken));
|
|
|
+ Vec3* verts =
|
|
|
+ static_cast<Vec3*>(RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Vec3) * 8, vertsToken));
|
|
|
|
|
|
constexpr F32 kSize = 1.0f;
|
|
|
verts[0] = Vec3(kSize, kSize, kSize); // front top right
|
|
|
@@ -28,7 +28,8 @@ void allocateAndPopulateDebugBox(RebarStagingGpuMemoryPool& stagingGpuAllocator,
|
|
|
verts[7] = Vec3(kSize, -kSize, -kSize); // back bottom right
|
|
|
|
|
|
constexpr U kIndexCount = 12 * 2;
|
|
|
- U16* indices = static_cast<U16*>(stagingGpuAllocator.allocateFrame(sizeof(U16) * kIndexCount, indicesToken));
|
|
|
+ U16* indices = static_cast<U16*>(
|
|
|
+ RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(U16) * kIndexCount, indicesToken));
|
|
|
|
|
|
U c = 0;
|
|
|
indices[c++] = 0;
|
|
|
@@ -136,12 +137,12 @@ Error DebugDrawer2::init(ResourceManager* rsrcManager, GrManager* gr)
|
|
|
}
|
|
|
|
|
|
void DebugDrawer2::drawCubes(ConstWeakArray<Mat4> mvps, const Vec4& color, F32 lineSize, Bool ditherFailedDepth,
|
|
|
- F32 cubeSideSize, RebarStagingGpuMemoryPool& stagingGpuAllocator,
|
|
|
- CommandBufferPtr& cmdb) const
|
|
|
+ F32 cubeSideSize, CommandBufferPtr& cmdb) const
|
|
|
{
|
|
|
// Set the uniforms
|
|
|
RebarGpuMemoryToken unisToken;
|
|
|
- Mat4* pmvps = static_cast<Mat4*>(stagingGpuAllocator.allocateFrame(sizeof(Mat4) * mvps.getSize(), unisToken));
|
|
|
+ Mat4* pmvps = static_cast<Mat4*>(
|
|
|
+ RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Mat4) * mvps.getSize(), unisToken));
|
|
|
|
|
|
if(cubeSideSize == 2.0f)
|
|
|
{
|
|
|
@@ -166,7 +167,8 @@ void DebugDrawer2::drawCubes(ConstWeakArray<Mat4> mvps, const Vec4& color, F32 l
|
|
|
cmdb->bindVertexBuffer(0, m_cubePositionsBuffer, 0, sizeof(Vec3));
|
|
|
cmdb->bindIndexBuffer(m_cubeIndicesBuffer, 0, IndexType::kU16);
|
|
|
|
|
|
- cmdb->bindStorageBuffer(0, 0, stagingGpuAllocator.getBuffer(), unisToken.m_offset, unisToken.m_range);
|
|
|
+ cmdb->bindStorageBuffer(0, 0, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), unisToken.m_offset,
|
|
|
+ unisToken.m_range);
|
|
|
|
|
|
cmdb->setLineWidth(lineSize);
|
|
|
constexpr U kIndexCount = 12 * 2;
|
|
|
@@ -174,21 +176,21 @@ void DebugDrawer2::drawCubes(ConstWeakArray<Mat4> mvps, const Vec4& color, F32 l
|
|
|
}
|
|
|
|
|
|
void DebugDrawer2::drawLines(ConstWeakArray<Mat4> mvps, const Vec4& color, F32 lineSize, Bool ditherFailedDepth,
|
|
|
- ConstWeakArray<Vec3> linePositions, RebarStagingGpuMemoryPool& stagingGpuAllocator,
|
|
|
- CommandBufferPtr& cmdb) const
|
|
|
+ ConstWeakArray<Vec3> linePositions, CommandBufferPtr& cmdb) const
|
|
|
{
|
|
|
ANKI_ASSERT(mvps.getSize() > 0);
|
|
|
ANKI_ASSERT(linePositions.getSize() > 0 && (linePositions.getSize() % 2) == 0);
|
|
|
|
|
|
// Verts
|
|
|
RebarGpuMemoryToken vertsToken;
|
|
|
- Vec3* verts =
|
|
|
- static_cast<Vec3*>(stagingGpuAllocator.allocateFrame(sizeof(Vec3) * linePositions.getSize(), vertsToken));
|
|
|
+ Vec3* verts = static_cast<Vec3*>(
|
|
|
+ RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Vec3) * linePositions.getSize(), vertsToken));
|
|
|
memcpy(verts, linePositions.getBegin(), linePositions.getSizeInBytes());
|
|
|
|
|
|
// Set the uniforms
|
|
|
RebarGpuMemoryToken unisToken;
|
|
|
- Mat4* pmvps = static_cast<Mat4*>(stagingGpuAllocator.allocateFrame(sizeof(Mat4) * mvps.getSize(), unisToken));
|
|
|
+ Mat4* pmvps = static_cast<Mat4*>(
|
|
|
+ RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Mat4) * mvps.getSize(), unisToken));
|
|
|
memcpy(pmvps, &mvps[0], mvps.getSizeInBytes());
|
|
|
|
|
|
// Setup state
|
|
|
@@ -202,9 +204,10 @@ void DebugDrawer2::drawLines(ConstWeakArray<Mat4> mvps, const Vec4& color, F32 l
|
|
|
cmdb->setPushConstants(&color, sizeof(color));
|
|
|
|
|
|
cmdb->setVertexAttribute(0, 0, Format::kR32G32B32_Sfloat, 0);
|
|
|
- cmdb->bindVertexBuffer(0, stagingGpuAllocator.getBuffer(), vertsToken.m_offset, sizeof(Vec3));
|
|
|
+ cmdb->bindVertexBuffer(0, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), vertsToken.m_offset, sizeof(Vec3));
|
|
|
|
|
|
- cmdb->bindStorageBuffer(0, 0, stagingGpuAllocator.getBuffer(), unisToken.m_offset, unisToken.m_range);
|
|
|
+ cmdb->bindStorageBuffer(0, 0, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), unisToken.m_offset,
|
|
|
+ unisToken.m_range);
|
|
|
|
|
|
cmdb->setLineWidth(lineSize);
|
|
|
cmdb->drawArrays(PrimitiveTopology::kLines, linePositions.getSize(), mvps.getSize());
|
|
|
@@ -212,11 +215,11 @@ void DebugDrawer2::drawLines(ConstWeakArray<Mat4> mvps, const Vec4& color, F32 l
|
|
|
|
|
|
void DebugDrawer2::drawBillboardTextures(const Mat4& projMat, const Mat3x4& viewMat, ConstWeakArray<Vec3> positions,
|
|
|
const Vec4& color, Bool ditherFailedDepth, TextureViewPtr tex,
|
|
|
- SamplerPtr sampler, Vec2 billboardSize,
|
|
|
- RebarStagingGpuMemoryPool& stagingGpuAllocator, CommandBufferPtr& cmdb) const
|
|
|
+ SamplerPtr sampler, Vec2 billboardSize, CommandBufferPtr& cmdb) const
|
|
|
{
|
|
|
RebarGpuMemoryToken positionsToken;
|
|
|
- Vec3* verts = static_cast<Vec3*>(stagingGpuAllocator.allocateFrame(sizeof(Vec3) * 4, positionsToken));
|
|
|
+ Vec3* verts =
|
|
|
+ static_cast<Vec3*>(RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Vec3) * 4, positionsToken));
|
|
|
|
|
|
verts[0] = Vec3(-0.5f, -0.5f, 0.0f);
|
|
|
verts[1] = Vec3(+0.5f, -0.5f, 0.0f);
|
|
|
@@ -224,7 +227,7 @@ void DebugDrawer2::drawBillboardTextures(const Mat4& projMat, const Mat3x4& view
|
|
|
verts[3] = Vec3(+0.5f, +0.5f, 0.0f);
|
|
|
|
|
|
RebarGpuMemoryToken uvsToken;
|
|
|
- Vec2* uvs = static_cast<Vec2*>(stagingGpuAllocator.allocateFrame(sizeof(Vec2) * 4, uvsToken));
|
|
|
+ Vec2* uvs = static_cast<Vec2*>(RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Vec2) * 4, uvsToken));
|
|
|
|
|
|
uvs[0] = Vec2(0.0f, 0.0f);
|
|
|
uvs[1] = Vec2(1.0f, 0.0f);
|
|
|
@@ -233,7 +236,8 @@ void DebugDrawer2::drawBillboardTextures(const Mat4& projMat, const Mat3x4& view
|
|
|
|
|
|
// Set the uniforms
|
|
|
RebarGpuMemoryToken unisToken;
|
|
|
- Mat4* pmvps = static_cast<Mat4*>(stagingGpuAllocator.allocateFrame(sizeof(Mat4) * positions.getSize(), unisToken));
|
|
|
+ Mat4* pmvps = static_cast<Mat4*>(
|
|
|
+ RebarStagingGpuMemoryPool::getSingleton().allocateFrame(sizeof(Mat4) * positions.getSize(), unisToken));
|
|
|
|
|
|
const Mat4 camTrf = Mat4(viewMat, Vec4(0.0f, 0.0f, 0.0f, 1.0f)).getInverse();
|
|
|
const Vec3 zAxis = camTrf.getZAxis().xyz().getNormalized();
|
|
|
@@ -268,10 +272,12 @@ void DebugDrawer2::drawBillboardTextures(const Mat4& projMat, const Mat3x4& view
|
|
|
|
|
|
cmdb->setVertexAttribute(0, 0, Format::kR32G32B32_Sfloat, 0);
|
|
|
cmdb->setVertexAttribute(1, 1, Format::kR32G32_Sfloat, 0);
|
|
|
- cmdb->bindVertexBuffer(0, stagingGpuAllocator.getBuffer(), positionsToken.m_offset, sizeof(Vec3));
|
|
|
- cmdb->bindVertexBuffer(1, stagingGpuAllocator.getBuffer(), uvsToken.m_offset, sizeof(Vec2));
|
|
|
+ cmdb->bindVertexBuffer(0, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), positionsToken.m_offset,
|
|
|
+ sizeof(Vec3));
|
|
|
+ cmdb->bindVertexBuffer(1, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), uvsToken.m_offset, sizeof(Vec2));
|
|
|
|
|
|
- cmdb->bindStorageBuffer(0, 0, stagingGpuAllocator.getBuffer(), unisToken.m_offset, unisToken.m_range);
|
|
|
+ cmdb->bindStorageBuffer(0, 0, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), unisToken.m_offset,
|
|
|
+ unisToken.m_range);
|
|
|
cmdb->bindSampler(0, 3, sampler);
|
|
|
cmdb->bindTexture(0, 4, tex);
|
|
|
|
|
|
@@ -303,7 +309,7 @@ void PhysicsDebugDrawer::flush()
|
|
|
if(m_vertCount > 0)
|
|
|
{
|
|
|
m_dbg->drawLines(ConstWeakArray<Mat4>(&m_mvp, 1), m_currentColor, 2.0f, false,
|
|
|
- ConstWeakArray<Vec3>(&m_vertCache[0], m_vertCount), *m_stagingGpuAllocator, m_cmdb);
|
|
|
+ ConstWeakArray<Vec3>(&m_vertCache[0], m_vertCount), m_cmdb);
|
|
|
|
|
|
m_vertCount = 0;
|
|
|
}
|