diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index 7a9e29653e..dd28d3cfb4 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -758,9 +758,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last } GLRProgram *curProgram = nullptr; - int activeSlot = 0; - if (first) - glActiveTexture(GL_TEXTURE0 + activeSlot); + int activeSlot = -1; // State filtering tracking. int attrMask = 0; @@ -1202,8 +1200,13 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last } case GLRRenderCommand::TEXTURE_SUBIMAGE: { - GLRTexture *tex = c.texture_subimage.texture; + GLint slot = c.texture_subimage.slot; + if (slot != activeSlot) { + glActiveTexture(GL_TEXTURE0 + slot); + activeSlot = slot; + } // TODO: Need bind? + GLRTexture *tex = c.texture_subimage.texture; if (!c.texture_subimage.data) Crash(); _assert_(tex->target == GL_TEXTURE_2D); diff --git a/Common/GPU/OpenGL/GLQueueRunner.h b/Common/GPU/OpenGL/GLQueueRunner.h index 13c5cfd701..e82b265ed1 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.h +++ b/Common/GPU/OpenGL/GLQueueRunner.h @@ -148,11 +148,12 @@ struct GLRRenderData { struct { GLRTexture *texture; Draw::DataFormat format; - int level; - int x; - int y; - int width; - int height; + uint8_t slot; + uint8_t level; + uint16_t width; + uint16_t height; + uint16_t x; + uint16_t y; GLRAllocType allocType; uint8_t *data; // owned, delete[]-d } texture_subimage; diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index 9e4fafb50f..6be44a70ee 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -555,7 +555,7 @@ public: initSteps_.push_back(step); } - void TextureSubImage(GLRTexture *texture, int level, int x, int y, int width, int height, Draw::DataFormat format, uint8_t *data, GLRAllocType allocType = GLRAllocType::NEW) { + void TextureSubImage(int slot, GLRTexture *texture, int level, int x, int y, int width, int height, Draw::DataFormat format, uint8_t *data, GLRAllocType allocType = GLRAllocType::NEW) { _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER); GLRRenderData _data{ GLRRenderCommand::TEXTURE_SUBIMAGE }; _data.texture_subimage.texture = texture; @@ -567,6 +567,7 @@ public: _data.texture_subimage.width = width; _data.texture_subimage.height = height; _data.texture_subimage.allocType = allocType; + _data.texture_subimage.slot = slot; curRenderStep_->commands.push_back(_data); } diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 96dc11ea22..2b6dd53a43 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -504,13 +504,13 @@ void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *p } renderManager_->BindTexture(TEX_SLOT_SPLINE_POINTS, data_tex[0]); // Position - renderManager_->TextureSubImage(data_tex[0], 0, 0, 0, size_u, size_v, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)pos, GLRAllocType::NEW); + renderManager_->TextureSubImage(TEX_SLOT_SPLINE_POINTS, data_tex[0], 0, 0, 0, size_u, size_v, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)pos, GLRAllocType::NEW); // Texcoord if (hasTexCoord) - renderManager_->TextureSubImage(data_tex[0], 0, size_u, 0, size_u, size_v, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)tex, GLRAllocType::NEW); + renderManager_->TextureSubImage(TEX_SLOT_SPLINE_POINTS, data_tex[0], 0, size_u, 0, size_u, size_v, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)tex, GLRAllocType::NEW); // Color if (hasColor) - renderManager_->TextureSubImage(data_tex[0], 0, size_u * 2, 0, size_u, size_v, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)col, GLRAllocType::NEW); + renderManager_->TextureSubImage(TEX_SLOT_SPLINE_POINTS, data_tex[0], 0, size_u * 2, 0, size_u, size_v, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)col, GLRAllocType::NEW); // Weight U if (prevSizeWU < weights.size_u) { @@ -521,7 +521,7 @@ void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *p renderManager_->FinalizeTexture(data_tex[1], 0, false); } renderManager_->BindTexture(TEX_SLOT_SPLINE_WEIGHTS_U, data_tex[1]); - renderManager_->TextureSubImage(data_tex[1], 0, 0, 0, weights.size_u * 2, 1, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)weights.u, GLRAllocType::NONE); + renderManager_->TextureSubImage(TEX_SLOT_SPLINE_WEIGHTS_U, data_tex[1], 0, 0, 0, weights.size_u * 2, 1, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)weights.u, GLRAllocType::NONE); // Weight V if (prevSizeWV < weights.size_v) { @@ -532,7 +532,7 @@ void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *p renderManager_->FinalizeTexture(data_tex[2], 0, false); } renderManager_->BindTexture(TEX_SLOT_SPLINE_WEIGHTS_V, data_tex[2]); - renderManager_->TextureSubImage(data_tex[2], 0, 0, 0, weights.size_v * 2, 1, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)weights.v, GLRAllocType::NONE); + renderManager_->TextureSubImage(TEX_SLOT_SPLINE_WEIGHTS_V, data_tex[2], 0, 0, 0, weights.size_v * 2, 1, Draw::DataFormat::R32G32B32A32_FLOAT, (u8 *)weights.v, GLRAllocType::NONE); } void TessellationDataTransferGLES::EndFrame() {