From effc75bd7828fa695fa4fbc55ad9df71136b8873 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sat, 15 Feb 2020 10:48:44 +0800 Subject: [PATCH] Refine sources --- cocos/renderer/backend/metal/CommandBufferMTL.mm | 10 +++++----- cocos/renderer/backend/opengl/CommandBufferGL.cpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/renderer/backend/metal/CommandBufferMTL.mm b/cocos/renderer/backend/metal/CommandBufferMTL.mm index 775edcbecc..6af6afea2d 100644 --- a/cocos/renderer/backend/metal/CommandBufferMTL.mm +++ b/cocos/renderer/backend/metal/CommandBufferMTL.mm @@ -185,7 +185,7 @@ namespace case TextureType::TEXTURE_2D: return static_cast(texture)->getMTLTexture(index); case TextureType::TEXTURE_CUBE: - return static_cast(texture)->getMTLTexture(); + return static_cast(texture)->getMTLTexture(index); default: assert(false); return nil; @@ -427,23 +427,23 @@ void CommandBufferMTL::doSetTextures(bool isVertex) const const auto& slot = iter.second.slot; int i = 0; - for (const auto& texture: textures) + for (const auto& texture : textures) { - int metaIdx = slot[i++]; if (isVertex) { - [_mtlRenderEncoder setVertexTexture:getMTLTexture(texture, metaIdx) + [_mtlRenderEncoder setVertexTexture:getMTLTexture(texture, slot[i]) atIndex:location]; [_mtlRenderEncoder setVertexSamplerState:getMTLSamplerState(texture) atIndex:location]; } else { - [_mtlRenderEncoder setFragmentTexture:getMTLTexture(texture, metaIdx) + [_mtlRenderEncoder setFragmentTexture:getMTLTexture(texture, slot[i]) atIndex:location]; [_mtlRenderEncoder setFragmentSamplerState:getMTLSamplerState(texture) atIndex:location]; } + ++i; } } } diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index 02d94578f0..fbfecf5296 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -54,15 +54,15 @@ namespace } } - void applyTexture(TextureBackend* texture, int slot) + void applyTexture(TextureBackend* texture, int index) { switch (texture->getTextureType()) { case TextureType::TEXTURE_2D: - static_cast(texture)->apply(slot); + static_cast(texture)->apply(index); break; case TextureType::TEXTURE_CUBE: - static_cast(texture)->apply(slot); + static_cast(texture)->apply(index); break; default: assert(false);