mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Metal: Fixed fallback texture format.
This commit is contained in:
parent
64d3c7884d
commit
55a176618d
2 changed files with 41 additions and 7 deletions
|
@ -58,6 +58,11 @@ namespace bgfx { namespace mtl
|
|||
return [m_obj computeCommandEncoder];
|
||||
}
|
||||
|
||||
id<MTLBlitCommandEncoder> blitCommandEncoder()
|
||||
{
|
||||
return [m_obj blitCommandEncoder];
|
||||
}
|
||||
|
||||
// Scheduling and Executing Commands
|
||||
void enqueue()
|
||||
{
|
||||
|
|
|
@ -429,9 +429,17 @@ namespace bgfx { namespace mtl
|
|||
|
||||
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
|
||||
{
|
||||
uint8_t support = (s_textureFormat[ii].m_fmt != MTLPixelFormatInvalid) ? BGFX_CAPS_FORMAT_TEXTURE_COLOR : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
uint8_t support = 0;
|
||||
|
||||
support |= (s_textureFormat[ii].m_fmtSrgb != MTLPixelFormatInvalid) ? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
support |= MTLPixelFormatInvalid != s_textureFormat[ii].m_fmt
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= MTLPixelFormatInvalid != s_textureFormat[ii].m_fmtSrgb
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
//TODO: additional caps flags
|
||||
// support |= BGFX_CAPS_FORMAT_TEXTURE_VERTEX : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
@ -441,6 +449,20 @@ namespace bgfx { namespace mtl
|
|||
g_caps.formats[ii] = support;
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
{
|
||||
g_caps.formats[TextureFormat::ETC1 ] =
|
||||
g_caps.formats[TextureFormat::ETC2 ] =
|
||||
g_caps.formats[TextureFormat::ETC2A ] =
|
||||
g_caps.formats[TextureFormat::ETC2A1] =
|
||||
g_caps.formats[TextureFormat::PTC12 ] =
|
||||
g_caps.formats[TextureFormat::PTC14 ] =
|
||||
g_caps.formats[TextureFormat::PTC12A] =
|
||||
g_caps.formats[TextureFormat::PTC14A] =
|
||||
g_caps.formats[TextureFormat::PTC22 ] =
|
||||
g_caps.formats[TextureFormat::PTC24 ] = BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
}
|
||||
|
||||
// Init reserved part of view name.
|
||||
for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii)
|
||||
{
|
||||
|
@ -752,9 +774,11 @@ namespace bgfx { namespace mtl
|
|||
rce.setScissorRect(rc);
|
||||
rce.setCullMode(MTLCullModeNone);
|
||||
|
||||
uint64_t state = BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS;
|
||||
uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS
|
||||
;
|
||||
|
||||
setDepthStencilState(state);
|
||||
|
||||
|
@ -1772,12 +1796,17 @@ namespace bgfx { namespace mtl
|
|||
const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod);
|
||||
const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod);
|
||||
|
||||
bool convert = BGFX_CAPS_FORMAT_TEXTURE_NONE == g_caps.formats[m_requestedFormat];
|
||||
|
||||
m_flags = _flags;
|
||||
m_requestedFormat = (uint8_t)imageContainer.m_format;
|
||||
m_textureFormat = (uint8_t)imageContainer.m_format;
|
||||
m_textureFormat = convert
|
||||
? uint8_t(TextureFormat::BGRA8)
|
||||
: m_requestedFormat
|
||||
;
|
||||
|
||||
const TextureFormatInfo& tfi = s_textureFormat[m_requestedFormat];
|
||||
const bool convert = MTLPixelFormatInvalid == tfi.m_fmt;
|
||||
convert = MTLPixelFormatInvalid == tfi.m_fmt;
|
||||
|
||||
uint8_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
|
||||
if (convert)
|
||||
|
|
Loading…
Reference in a new issue