1
0
forked from mirrors/0ad

Adds instancing support to backend and enables it for minimap.

Tested By: Langbart
Differential Revision: https://code.wildfiregames.com/D4650
This was SVN commit r26901.
This commit is contained in:
vladislavbelov
2022-05-24 07:11:23 +00:00
parent 7cbe8125f7
commit a6f60afdc5
35 changed files with 538 additions and 204 deletions
+12 -6
View File
@@ -323,11 +323,13 @@ void InstancingModelRenderer::PrepareModelDef(
deviceCommandContext->SetVertexAttributeFormat(
Renderer::Backend::VertexAttributeStream::POSITION,
m->imodeldef->m_Position.format,
firstVertexOffset + m->imodeldef->m_Position.offset, stride, 0);
firstVertexOffset + m->imodeldef->m_Position.offset, stride,
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0);
deviceCommandContext->SetVertexAttributeFormat(
Renderer::Backend::VertexAttributeStream::NORMAL,
m->imodeldef->m_Normal.format,
firstVertexOffset + m->imodeldef->m_Normal.offset, stride, 0);
firstVertexOffset + m->imodeldef->m_Normal.offset, stride,
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0);
constexpr size_t MAX_UV = 2;
for (size_t uv = 0; uv < std::min(MAX_UV, def.GetNumUVsPerVertex()); ++uv)
@@ -337,7 +339,8 @@ void InstancingModelRenderer::PrepareModelDef(
static_cast<int>(Renderer::Backend::VertexAttributeStream::UV0) + uv);
deviceCommandContext->SetVertexAttributeFormat(
stream, m->imodeldef->m_UVs[uv].format,
firstVertexOffset + m->imodeldef->m_UVs[uv].offset, stride, 0);
firstVertexOffset + m->imodeldef->m_UVs[uv].offset, stride,
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0);
}
// GPU skinning requires extra attributes to compute positions/normals.
@@ -346,11 +349,13 @@ void InstancingModelRenderer::PrepareModelDef(
deviceCommandContext->SetVertexAttributeFormat(
Renderer::Backend::VertexAttributeStream::UV2,
m->imodeldef->m_BlendJoints.format,
firstVertexOffset + m->imodeldef->m_BlendJoints.offset, stride, 0);
firstVertexOffset + m->imodeldef->m_BlendJoints.offset, stride,
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0);
deviceCommandContext->SetVertexAttributeFormat(
Renderer::Backend::VertexAttributeStream::UV3,
m->imodeldef->m_BlendWeights.format,
firstVertexOffset + m->imodeldef->m_BlendWeights.offset, stride, 0);
firstVertexOffset + m->imodeldef->m_BlendWeights.offset, stride,
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0);
}
if (m->calculateTangents)
@@ -358,7 +363,8 @@ void InstancingModelRenderer::PrepareModelDef(
deviceCommandContext->SetVertexAttributeFormat(
Renderer::Backend::VertexAttributeStream::UV4,
m->imodeldef->m_Tangent.format,
firstVertexOffset + m->imodeldef->m_Tangent.offset, stride, 0);
firstVertexOffset + m->imodeldef->m_Tangent.offset, stride,
Renderer::Backend::VertexAttributeRate::PER_VERTEX, 0);
}
deviceCommandContext->SetVertexBuffer(0, m->imodeldef->m_Array.GetBuffer());