From 998335b8af6f180f6ea2cdadab724772e57af290 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sat, 29 Aug 2020 17:39:17 +0800 Subject: [PATCH] More clearly comment for multi-textures support --- cocos/renderer/backend/metal/CommandBufferMTL.mm | 8 ++++++-- cocos/renderer/backend/opengl/CommandBufferGL.cpp | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cocos/renderer/backend/metal/CommandBufferMTL.mm b/cocos/renderer/backend/metal/CommandBufferMTL.mm index 1dc16e3905..460df5b1cd 100644 --- a/cocos/renderer/backend/metal/CommandBufferMTL.mm +++ b/cocos/renderer/backend/metal/CommandBufferMTL.mm @@ -422,10 +422,14 @@ void CommandBufferMTL::doSetTextures(bool isVertex) const for(const auto& iter : bindTextureInfos) { + /* About mutli textures support + * a. sampler2DArray, not implemented in Metal Renderer + * b. texture slot, one BackendTexture, multi GPU texture handlers, used by etc1 + * c. Bind multi BackendTexture to 1 Shader Program, see the ShaderTest + * d. iter.second.slots not used for Metal Renderer + */ auto location = iter.first; auto& textures = iter.second.textures; - // auto& slots = iter.second.slots; - // TODO: 1 location, mutli-slots like OpenGL? auto& indexs = iter.second.indexs; int i = 0; diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index 6fba6e5bd1..907ba069a3 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -478,6 +478,11 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const const auto& textureInfo = _programState->getVertexTextureInfos(); for(const auto& iter : textureInfo) { + /* About mutli textures support + * a. sampler2DArray, sampler2D[2], bind BackendTexture one by one, not use GL_TEXTURE_2D_ARRAY, not used at all engine interanl + * b. texture slot, one BackendTexture, multi GPU texture handlers, used by etc1 + * c. Bind multi BackendTexture to 1 Shader Program, see the ShaderTest + */ auto& textures = iter.second.textures; auto& slots = iter.second.slots; auto& indexs = iter.second.indexs; @@ -493,10 +498,10 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const } auto arrayCount = slots.size(); - if (arrayCount > 1) - glUniform1iv(location, (uint32_t)arrayCount, (GLint*)slots.data()); - else + if (arrayCount == 1) // If not use sampler2DArray, always 1 glUniform1i(location, slots[0]); + else + glUniform1iv(location, (uint32_t)arrayCount, (GLint*)slots.data()); } } }