Refine sources

This commit is contained in:
halx99 2020-02-15 10:48:44 +08:00
parent 8aee15f7c0
commit effc75bd78
2 changed files with 8 additions and 8 deletions

View File

@ -185,7 +185,7 @@ namespace
case TextureType::TEXTURE_2D: case TextureType::TEXTURE_2D:
return static_cast<TextureMTL*>(texture)->getMTLTexture(index); return static_cast<TextureMTL*>(texture)->getMTLTexture(index);
case TextureType::TEXTURE_CUBE: case TextureType::TEXTURE_CUBE:
return static_cast<TextureCubeMTL*>(texture)->getMTLTexture(); return static_cast<TextureCubeMTL*>(texture)->getMTLTexture(index);
default: default:
assert(false); assert(false);
return nil; return nil;
@ -429,21 +429,21 @@ void CommandBufferMTL::doSetTextures(bool isVertex) const
int i = 0; int i = 0;
for (const auto& texture : textures) for (const auto& texture : textures)
{ {
int metaIdx = slot[i++];
if (isVertex) if (isVertex)
{ {
[_mtlRenderEncoder setVertexTexture:getMTLTexture(texture, metaIdx) [_mtlRenderEncoder setVertexTexture:getMTLTexture(texture, slot[i])
atIndex:location]; atIndex:location];
[_mtlRenderEncoder setVertexSamplerState:getMTLSamplerState(texture) [_mtlRenderEncoder setVertexSamplerState:getMTLSamplerState(texture)
atIndex:location]; atIndex:location];
} }
else else
{ {
[_mtlRenderEncoder setFragmentTexture:getMTLTexture(texture, metaIdx) [_mtlRenderEncoder setFragmentTexture:getMTLTexture(texture, slot[i])
atIndex:location]; atIndex:location];
[_mtlRenderEncoder setFragmentSamplerState:getMTLSamplerState(texture) [_mtlRenderEncoder setFragmentSamplerState:getMTLSamplerState(texture)
atIndex:location]; atIndex:location];
} }
++i;
} }
} }
} }

View File

@ -54,15 +54,15 @@ namespace
} }
} }
void applyTexture(TextureBackend* texture, int slot) void applyTexture(TextureBackend* texture, int index)
{ {
switch (texture->getTextureType()) switch (texture->getTextureType())
{ {
case TextureType::TEXTURE_2D: case TextureType::TEXTURE_2D:
static_cast<Texture2DGL*>(texture)->apply(slot); static_cast<Texture2DGL*>(texture)->apply(index);
break; break;
case TextureType::TEXTURE_CUBE: case TextureType::TEXTURE_CUBE:
static_cast<TextureCubeGL*>(texture)->apply(slot); static_cast<TextureCubeGL*>(texture)->apply(index);
break; break;
default: default:
assert(false); assert(false);