Pipeline key now includes the VertexBufferLayout
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled

This commit is contained in:
2026-06-14 15:27:20 -07:00
parent fd2c213aec
commit 38cdbb6ce5
3 changed files with 11 additions and 26 deletions

View File

@@ -67,13 +67,15 @@ KRPipelineManager::~KRPipelineManager()
KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInfo& info) KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInfo& info)
{ {
std::pair<std::string, std::vector<int> > key; const char* szShaderName = info.shader_name->c_str();
key.first = *info.shader_name; std::vector<std::byte> key;
key.second.push_back(surface.m_deviceHandle); key.insert(key.begin(), (std::byte*)szShaderName, (std::byte*)szShaderName + strlen(szShaderName) + 1); // purposefully include the zero terminator
key.second.push_back(surface.m_swapChain->m_imageFormat); key.insert(key.begin(), (std::byte*)&surface.m_deviceHandle, (std::byte*)&surface.m_deviceHandle + sizeof(surface.m_deviceHandle));
key.second.push_back(surface.m_swapChain->m_extent.width); key.insert(key.begin(), (std::byte*)&surface.m_swapChain->m_imageFormat, (std::byte*)&surface.m_swapChain->m_imageFormat + sizeof(surface.m_swapChain->m_imageFormat));
key.second.push_back(surface.m_swapChain->m_extent.height); key.insert(key.begin(), (std::byte*)&surface.m_swapChain->m_extent.width, (std::byte*)&surface.m_swapChain->m_extent.width + sizeof(surface.m_swapChain->m_extent.width));
// key.second.push_back(info.layout); // FINDME!! KIPG!! HACK!!! Need to add a unique key generated from info.layout key.insert(key.begin(), (std::byte*)&surface.m_swapChain->m_extent.height, (std::byte*)&surface.m_swapChain->m_extent.height + sizeof(surface.m_swapChain->m_extent.height));
key.insert(key.begin(), (std::byte*)info.layout, (std::byte*)info.layout + sizeof(*info.layout));
// TODO - Add renderPass unique identifier to key // TODO - Add renderPass unique identifier to key
PipelineMap::iterator itr = m_pipelines.find(key); PipelineMap::iterator itr = m_pipelines.find(key);
if (itr != m_pipelines.end()) { if (itr != m_pipelines.end()) {
@@ -308,15 +310,3 @@ size_t KRPipelineManager::getPipelineHandlesUsed()
{ {
return m_pipelines.size(); return m_pipelines.size();
} }
KRPipeline* KRPipelineManager::get(const char* name)
{
std::pair<std::string, std::vector<int> > key;
key.first = name;
auto itr = m_pipelines.find(key);
if (itr == m_pipelines.end()) {
return nullptr;
}
return (*itr).second;
}

View File

@@ -54,7 +54,6 @@ public:
KRPipelineManager(KRContext& context); KRPipelineManager(KRContext& context);
virtual ~KRPipelineManager(); virtual ~KRPipelineManager();
KRPipeline* get(const char* szKey);
KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info); KRPipeline* getPipeline(KRSurface& surface, const PipelineInfo& info);
@@ -63,6 +62,6 @@ public:
KRPipeline* m_active_pipeline; KRPipeline* m_active_pipeline;
private: private:
typedef std::map<std::pair<std::string, std::vector<int> >, KRPipeline*> PipelineMap; typedef std::map<std::vector<std::byte>, KRPipeline* > PipelineMap;
PipelineMap m_pipelines; PipelineMap m_pipelines;
}; };

View File

@@ -481,11 +481,7 @@ void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, const K
if (iVertex + cVertexes >= MAX_VBO_SIZE) { if (iVertex + cVertexes >= MAX_VBO_SIZE) {
assert(iVertex + (MAX_VBO_SIZE - iVertex) <= cBufferVertexes); assert(iVertex + (MAX_VBO_SIZE - iVertex) <= cBufferVertexes);
if (getIndexCount(0) == 0) {
vkCmdDraw(commandBuffer, (MAX_VBO_SIZE - iVertex), 1, iVertex, 0); vkCmdDraw(commandBuffer, (MAX_VBO_SIZE - iVertex), 1, iVertex, 0);
} else {
vkCmdDrawIndexed(commandBuffer, (MAX_VBO_SIZE - iVertex), 1, iVertex, 0, 0);
}
m_pContext->getMeshManager()->log_draw_call(renderPass->getType(), object_name, material_name, (MAX_VBO_SIZE - iVertex)); m_pContext->getMeshManager()->log_draw_call(renderPass->getType(), object_name, material_name, (MAX_VBO_SIZE - iVertex));
cVertexes -= (MAX_VBO_SIZE - iVertex); cVertexes -= (MAX_VBO_SIZE - iVertex);