Moved a few things to shader buffers, added some bugs that I have to fix

This commit is contained in:
2023-05-30 08:35:18 -07:00
parent 8da23b123a
commit b6cbd982eb
14 changed files with 141 additions and 83 deletions

View File

@ -226,9 +226,8 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
// Now we've sorted everything! Let's actually start rendering.
Shader *boundShader = nullptr;
std::map<textureslot_t, Texture*> boundTextures;
std::map<shaderbufferlocation_t, shaderbufferslot_t> locationSlotMap;
std::map<IShaderParameterBuffer<shaderbufferlocation_t>*, shaderbufferslot_t> bufferSlotMap;
shaderbufferslot_t globalSlot = 0;
std::map<shaderbufferlocation_t, shaderbufferslot_t> boundBuffers;
shaderbufferslot_t slot;
// TODO: This will be editable!
renderTarget->bind();
@ -262,25 +261,14 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
}
// Bind the buffers to their slots
slot = 0;
auto itBufferSlot = item.parameterBuffers.begin();
while(itBufferSlot != item.parameterBuffers.end()) {
// First check if buffer is already bound
auto location = itBufferSlot->first;
auto buff = itBufferSlot->second;
// auto existingBind = bufferSlotMap.find(buff);
shaderbufferslot_t slot;
// if(existingBind == bufferSlotMap.end()) {
// Not bound, let's find a slot we can use!
// slot = -1;
slot = globalSlot++;
// } else {
// // Already bound
// slot = existingBind->second;
// }
boundBuffers[itBufferSlot->first] = slot;
buff->bind(slot);
locationSlotMap[itBufferSlot->first] = slot;
slot++;
++itBufferSlot;
}
@ -317,7 +305,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
auto itBuffer = item.parameterBuffers.begin();
while(itBuffer != item.parameterBuffers.end()) {
item.shader->setParameterBuffer(itBuffer->first, locationSlotMap[itBuffer->first]);
item.shader->setParameterBuffer(itBuffer->first, boundBuffers[itBuffer->first]);
++itBuffer;
}