mirror of https://github.com/axmolengine/axmol.git
Make multi-meta-textures support works on Metal.
This commit is contained in:
parent
55f96054b7
commit
67c153f589
|
@ -178,12 +178,12 @@ namespace
|
|||
return mtlDescritpor;
|
||||
}
|
||||
|
||||
id<MTLTexture> getMTLTexture(TextureBackend* texture)
|
||||
id<MTLTexture> getMTLTexture(TextureBackend* texture, int index = 0)
|
||||
{
|
||||
switch (texture->getTextureType())
|
||||
{
|
||||
case TextureType::TEXTURE_2D:
|
||||
return static_cast<TextureMTL*>(texture)->getMTLTexture();
|
||||
return static_cast<TextureMTL*>(texture)->getMTLTexture(index);
|
||||
case TextureType::TEXTURE_CUBE:
|
||||
return static_cast<TextureCubeMTL*>(texture)->getMTLTexture();
|
||||
default:
|
||||
|
@ -422,27 +422,29 @@ void CommandBufferMTL::doSetTextures(bool isVertex) const
|
|||
|
||||
for(const auto& iter : bindTextureInfos)
|
||||
{
|
||||
//FIXME: should support texture array.
|
||||
int i = 0;
|
||||
auto location = iter.first;
|
||||
const auto& textures = iter.second.textures;
|
||||
const auto& slot = iter.second.slot;
|
||||
|
||||
if (isVertex)
|
||||
int i = 0;
|
||||
for (const auto& texture: textures)
|
||||
{
|
||||
[_mtlRenderEncoder setVertexTexture:getMTLTexture(textures[i])
|
||||
atIndex:location];
|
||||
[_mtlRenderEncoder setVertexSamplerState:getMTLSamplerState(textures[i])
|
||||
atIndex:location];
|
||||
int metaIdx = slot[i++];
|
||||
if (isVertex)
|
||||
{
|
||||
[_mtlRenderEncoder setVertexTexture:getMTLTexture(texture, metaIdx)
|
||||
atIndex:location];
|
||||
[_mtlRenderEncoder setVertexSamplerState:getMTLSamplerState(texture)
|
||||
atIndex:location];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_mtlRenderEncoder setFragmentTexture:getMTLTexture(texture, metaIdx)
|
||||
atIndex:location];
|
||||
[_mtlRenderEncoder setFragmentSamplerState:getMTLSamplerState(texture)
|
||||
atIndex:location];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[_mtlRenderEncoder setFragmentTexture:getMTLTexture(textures[i])
|
||||
atIndex:location];
|
||||
[_mtlRenderEncoder setFragmentSamplerState:getMTLSamplerState(textures[i])
|
||||
atIndex:location];
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
* Get MTLTexture object.
|
||||
* @return A MTLTexture object.
|
||||
*/
|
||||
inline id<MTLTexture> getMTLTexture() const { return _mtlTextures[0]; }
|
||||
inline id<MTLTexture> getMTLTexture(int index = 0) const { return _mtlTextures[index]; }
|
||||
|
||||
/**
|
||||
* Get MTLSamplerState object
|
||||
|
|
|
@ -487,8 +487,7 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const
|
|||
int i = 0;
|
||||
for (const auto& texture: textures)
|
||||
{
|
||||
applyTexture(texture, slot[i]);
|
||||
++i;
|
||||
applyTexture(texture, slot[i++]);
|
||||
}
|
||||
|
||||
auto arrayCount = slot.size();
|
||||
|
|
Loading…
Reference in New Issue