Always use GESPMBuffer for GEVulkanDrawCall::m_materials key

This commit is contained in:
Benau 2022-09-12 13:14:05 +08:00
parent 23470bbde2
commit bf8a411f01
2 changed files with 9 additions and 35 deletions

View File

@ -225,12 +225,7 @@ void GEVulkanDrawCall::generate()
const irr::video::ITexture** list = &textures[0];
const int material_id = m_texture_descriptor->getTextureID(list);
if (!GEVulkanFeatures::supportsBindMeshTexturesAtOnce())
{
if (use_base_vertex)
m_materials[p.first->getVBOOffset()] = material_id;
else
m_materials[(size_t)p.first] = material_id;
}
m_materials[p.first] = material_id;
const bool skinning = p.first->hasSkinning();
for (auto& q : p.second)
@ -271,24 +266,11 @@ void GEVulkanDrawCall::generate()
}
if (!GEVulkanFeatures::supportsBindMeshTexturesAtOnce())
{
if (use_base_vertex)
{
std::stable_sort(m_cmds.begin(), m_cmds.end(),
[this](const DrawCallData& a, const DrawCallData& b)
{
return m_materials[a.m_cmd.vertexOffset] <
m_materials[b.m_cmd.vertexOffset];
});
}
else
{
std::stable_sort(m_cmds.begin(), m_cmds.end(),
[this](const DrawCallData& a, const DrawCallData& b)
{
return m_materials[(size_t)a.m_mb] <
m_materials[(size_t)b.m_mb];
});
}
std::stable_sort(m_cmds.begin(), m_cmds.end(),
[this](const DrawCallData& a, const DrawCallData& b)
{
return m_materials[a.m_mb] < m_materials[b.m_mb];
});
}
std::stable_sort(m_cmds.begin(), m_cmds.end(),
@ -1036,11 +1018,7 @@ void GEVulkanDrawCall::render(GEVulkanDriver* vk, GEVulkanCameraSceneNode* cam,
}
else
{
int cur_mid = 0;
if (use_base_vertex)
cur_mid = m_materials[m_cmds[0].m_cmd.vertexOffset];
else
cur_mid = m_materials[(size_t)m_cmds[0].m_mb];
int cur_mid = m_materials[m_cmds[0].m_mb];
bindPipeline(cmd, cur_pipeline);
if (!GEVulkanFeatures::supportsBindMeshTexturesAtOnce())
{
@ -1077,11 +1055,7 @@ void GEVulkanDrawCall::render(GEVulkanDriver* vk, GEVulkanCameraSceneNode* cam,
}
}
int mid = 0;
if (use_base_vertex)
mid = m_materials[cur_cmd.vertexOffset];
else
mid = m_materials[(size_t)m_cmds[i].m_mb];
int mid = m_materials[m_cmds[i].m_mb];
if (!GEVulkanFeatures::supportsBindMeshTexturesAtOnce() &&
cur_mid != mid)
{

View File

@ -104,7 +104,7 @@ private:
std::unordered_map<std::string, std::pair<VkPipeline, PipelineSettings> >
m_graphics_pipelines;
std::unordered_map<size_t, int> m_materials;
std::unordered_map<GESPMBuffer*, int> m_materials;
GEVulkanTextureDescriptor* m_texture_descriptor;