Skip to content

Commit 62f855b

Browse files
committed
fix texture per-element size
1 parent 21df190 commit 62f855b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cocos/renderer/backend/Texture.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ namespace
99
uint8_t ret = 0;
1010
switch (textureFormat)
1111
{
12-
case TextureFormat::RGBA4444:
1312
case TextureFormat::R8G8B8A8:
1413
ret = 4;
1514
break;
1615
case TextureFormat::R8G8B8:
1716
ret = 3;
1817
break;
18+
case TextureFormat::RGBA4444:
19+
ret = 2;
20+
break;
1921
case TextureFormat::A8:
2022
ret = 1;
2123
break;

cocos/renderer/backend/metal/TextureMTL.mm

+5-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ bool convertData(uint8_t* src, unsigned int length, TextureFormat format, uint8_
102102
createTexture(mtlDevice, descriptor);
103103
createSampler(mtlDevice, descriptor);
104104

105-
// Metal doesn't support RGB888, so should convert to RGBA888;
106-
if (TextureFormat::R8G8B8 == _textureFormat)
105+
// Metal doesn't support RGB888/RGBA4444, so should convert to RGBA888;
106+
if (TextureFormat::R8G8B8 == _textureFormat ||
107+
TextureFormat::RGBA4444 == _textureFormat)
108+
{
107109
_bytesPerElement = 4;
110+
}
108111

109112
_bytesPerRow = _bytesPerElement * descriptor.width;
110113
}

0 commit comments

Comments
 (0)