Added caps info for all texture formats.

This commit is contained in:
Branimir Karadžić 2014-07-27 20:44:02 -07:00
parent 2b2c7857e8
commit 6c8eeec36e
7 changed files with 81 additions and 123 deletions

View file

@ -258,6 +258,14 @@ typedef struct bgfx_caps
uint16_t maxDrawCalls; /* < Maximum draw calls. */
uint8_t maxFBAttachments; /* < Maximum frame buffer attachments. */
/**
* Supported texture formats.
* 0 - not supported
* 1 - supported
* 2 - emulated
*/
uint8_t formats[BGFX_TEXTURE_FORMAT_COUNT];
} bgfx_caps_t;
/**

View file

@ -100,7 +100,7 @@ namespace bgfx
struct TextureFormat
{
// Availability depends on BGFX_CAPS_TEXTURE_FORMAT_*.
// Availability depends on Caps (see: formats).
enum Enum
{
BC1, // DXT1
@ -257,6 +257,12 @@ namespace bgfx
uint16_t maxTextureSize; ///< Maximum texture size.
uint16_t maxDrawCalls; ///< Maximum draw calls.
uint8_t maxFBAttachments; ///< Maximum frame buffer attachments.
/// Supported texture formats.
/// 0 - not supported
/// 1 - supported
/// 2 - emulated
uint8_t formats[TextureFormat::Count];
};
struct TransientIndexBuffer

View file

@ -265,48 +265,14 @@
#define BGFX_RESET_CAPTURE UINT32_C(0x00000100)
///
#define BGFX_CAPS_TEXTURE_FORMAT_BC1 UINT64_C(0x0000000000000001)
#define BGFX_CAPS_TEXTURE_FORMAT_BC2 UINT64_C(0x0000000000000002)
#define BGFX_CAPS_TEXTURE_FORMAT_BC3 UINT64_C(0x0000000000000004)
#define BGFX_CAPS_TEXTURE_FORMAT_BC4 UINT64_C(0x0000000000000008)
#define BGFX_CAPS_TEXTURE_FORMAT_BC5 UINT64_C(0x0000000000000010)
#define BGFX_CAPS_TEXTURE_FORMAT_ETC1 UINT64_C(0x0000000000000020)
#define BGFX_CAPS_TEXTURE_FORMAT_ETC2 UINT64_C(0x0000000000000040)
#define BGFX_CAPS_TEXTURE_FORMAT_ETC2A UINT64_C(0x0000000000000080)
#define BGFX_CAPS_TEXTURE_FORMAT_ETC2A1 UINT64_C(0x0000000000000100)
#define BGFX_CAPS_TEXTURE_FORMAT_PTC12 UINT64_C(0x0000000000000200)
#define BGFX_CAPS_TEXTURE_FORMAT_PTC14 UINT64_C(0x0000000000000400)
#define BGFX_CAPS_TEXTURE_FORMAT_PTC14A UINT64_C(0x0000000000000800)
#define BGFX_CAPS_TEXTURE_FORMAT_PTC12A UINT64_C(0x0000000000001000)
#define BGFX_CAPS_TEXTURE_FORMAT_PTC22 UINT64_C(0x0000000000002000)
#define BGFX_CAPS_TEXTURE_FORMAT_PTC24 UINT64_C(0x0000000000004000)
#define BGFX_CAPS_TEXTURE_FORMAT_D16 UINT64_C(0x0000000000008000)
#define BGFX_CAPS_TEXTURE_FORMAT_D24 UINT64_C(0x0000000000010000)
#define BGFX_CAPS_TEXTURE_FORMAT_D24S8 UINT64_C(0x0000000000020000)
#define BGFX_CAPS_TEXTURE_FORMAT_D32 UINT64_C(0x0000000000040000)
#define BGFX_CAPS_TEXTURE_FORMAT_D16F UINT64_C(0x0000000000080000)
#define BGFX_CAPS_TEXTURE_FORMAT_D24F UINT64_C(0x0000000000100000)
#define BGFX_CAPS_TEXTURE_FORMAT_D32F UINT64_C(0x0000000000200000)
#define BGFX_CAPS_TEXTURE_FORMAT_D0S8 UINT64_C(0x0000000000400000)
#define BGFX_CAPS_TEXTURE_COMPARE_LEQUAL UINT64_C(0x0000000001000000)
#define BGFX_CAPS_TEXTURE_COMPARE_ALL UINT64_C(0x0000000003000000)
#define BGFX_CAPS_TEXTURE_3D UINT64_C(0x0000000004000000)
#define BGFX_CAPS_VERTEX_ATTRIB_HALF UINT64_C(0x0000000008000000)
#define BGFX_CAPS_INSTANCING UINT64_C(0x0000000010000000)
#define BGFX_CAPS_RENDERER_MULTITHREADED UINT64_C(0x0000000020000000)
#define BGFX_CAPS_FRAGMENT_DEPTH UINT64_C(0x0000000040000000)
#define BGFX_CAPS_BLEND_INDEPENDENT UINT64_C(0x0000000080000000)
#define BGFX_CAPS_COMPUTE UINT64_C(0x0000000100000000)
#define BGFX_CAPS_TEXTURE_DEPTH_MASK (0 \
| BGFX_CAPS_TEXTURE_FORMAT_D16 \
| BGFX_CAPS_TEXTURE_FORMAT_D24 \
| BGFX_CAPS_TEXTURE_FORMAT_D24S8 \
| BGFX_CAPS_TEXTURE_FORMAT_D32 \
| BGFX_CAPS_TEXTURE_FORMAT_D16F \
| BGFX_CAPS_TEXTURE_FORMAT_D24F \
| BGFX_CAPS_TEXTURE_FORMAT_D32F \
| BGFX_CAPS_TEXTURE_FORMAT_D0S8 \
)
#define BGFX_CAPS_TEXTURE_COMPARE_LEQUAL UINT64_C(0x0000000000000001)
#define BGFX_CAPS_TEXTURE_COMPARE_ALL UINT64_C(0x0000000000000003)
#define BGFX_CAPS_TEXTURE_3D UINT64_C(0x0000000000000004)
#define BGFX_CAPS_VERTEX_ATTRIB_HALF UINT64_C(0x0000000000000008)
#define BGFX_CAPS_INSTANCING UINT64_C(0x0000000000000010)
#define BGFX_CAPS_RENDERER_MULTITHREADED UINT64_C(0x0000000000000020)
#define BGFX_CAPS_FRAGMENT_DEPTH UINT64_C(0x0000000000000040)
#define BGFX_CAPS_BLEND_INDEPENDENT UINT64_C(0x0000000000000080)
#define BGFX_CAPS_COMPUTE UINT64_C(0x0000000000000100)
#endif // BGFX_DEFINES_H_HEADER_GUARD

View file

@ -839,31 +839,6 @@ namespace bgfx
static const CapsFlags s_capsFlags[] =
{
#define CAPS_FLAGS(_x) { _x, #_x }
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC1),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC2),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC3),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC4),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC5),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC1),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC2),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC2A),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC2A1),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC12),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC14),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC14A),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC12A),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC22),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC24),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D16),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D24),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D24S8),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D32),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D16F),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D24F),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D32F),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D0S8),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_COMPARE_LEQUAL),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_COMPARE_ALL),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_3D),
@ -896,9 +871,36 @@ namespace bgfx
}
}
BX_TRACE("Supported texture formats:");
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
if (TextureFormat::Unknown != ii
&& TextureFormat::UnknownDepth != ii)
{
uint8_t flags = g_caps.formats[ii];
BX_TRACE("\t[%c] %s"
, flags&1 ? 'x' : flags&2 ? '*' : ' '
, getName(TextureFormat::Enum(ii) )
);
}
}
BX_TRACE("Max FB attachments: %d", g_caps.maxFBAttachments);
}
static TextureFormat::Enum s_emulatedFormats[] =
{
TextureFormat::BC1,
TextureFormat::BC2,
TextureFormat::BC3,
TextureFormat::BC4,
TextureFormat::BC5,
TextureFormat::ETC1,
TextureFormat::ETC2,
TextureFormat::ETC2A,
TextureFormat::ETC2A1,
};
void Context::init(RendererType::Enum _type)
{
BX_CHECK(!m_rendererInitialized, "Already initialized?");
@ -952,19 +954,14 @@ namespace bgfx
// g_caps is initialized and available after this point.
frame();
const uint64_t emulatedCaps = 0
| BGFX_CAPS_TEXTURE_FORMAT_BC1
| BGFX_CAPS_TEXTURE_FORMAT_BC2
| BGFX_CAPS_TEXTURE_FORMAT_BC3
| BGFX_CAPS_TEXTURE_FORMAT_BC4
| BGFX_CAPS_TEXTURE_FORMAT_BC5
| BGFX_CAPS_TEXTURE_FORMAT_ETC1
| BGFX_CAPS_TEXTURE_FORMAT_ETC2
| BGFX_CAPS_TEXTURE_FORMAT_ETC2A
| BGFX_CAPS_TEXTURE_FORMAT_ETC2A1
;
for (uint32_t ii = 0; ii < BX_COUNTOF(s_emulatedFormats); ++ii)
{
if (0 == g_caps.formats[s_emulatedFormats[ii] ])
{
g_caps.formats[s_emulatedFormats[ii] ] = 2;
}
}
g_caps.emulated |= emulatedCaps ^ (g_caps.supported & emulatedCaps);
g_caps.rendererType = m_renderCtx->getRendererType();
initAttribTypeSizeTable(g_caps.rendererType);
@ -2704,6 +2701,7 @@ BX_STATIC_ASSERT(sizeof(bgfx::TransientIndexBuffer) == sizeof(bgfx_transient_in
BX_STATIC_ASSERT(sizeof(bgfx::TransientVertexBuffer) == sizeof(bgfx_transient_vertex_buffer_t) );
BX_STATIC_ASSERT(sizeof(bgfx::InstanceDataBuffer) == sizeof(bgfx_instance_data_buffer_t) );
BX_STATIC_ASSERT(sizeof(bgfx::TextureInfo) == sizeof(bgfx_texture_info_t) );
BX_STATIC_ASSERT(sizeof(bgfx::Caps) == sizeof(bgfx_caps_t) );
BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer)
{

View file

@ -547,11 +547,6 @@ namespace bgfx
}
g_caps.supported |= ( 0
| BGFX_CAPS_TEXTURE_FORMAT_BC1
| BGFX_CAPS_TEXTURE_FORMAT_BC2
| BGFX_CAPS_TEXTURE_FORMAT_BC3
| BGFX_CAPS_TEXTURE_FORMAT_BC4
| BGFX_CAPS_TEXTURE_FORMAT_BC5
| BGFX_CAPS_TEXTURE_3D
| BGFX_CAPS_TEXTURE_COMPARE_ALL
| BGFX_CAPS_INSTANCING
@ -563,6 +558,11 @@ namespace bgfx
g_caps.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
g_caps.maxFBAttachments = bx::uint32_min(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
g_caps.formats[ii] = DXGI_FORMAT_UNKNOWN == s_textureFormat[ii].m_fmt ? 0 : 1;
}
updateMsaa();
postReset();
}

View file

@ -426,9 +426,6 @@ namespace bgfx
BX_TRACE("Num simultaneous render targets: %d", m_caps.NumSimultaneousRTs);
g_caps.supported |= ( 0
| BGFX_CAPS_TEXTURE_FORMAT_BC1
| BGFX_CAPS_TEXTURE_FORMAT_BC2
| BGFX_CAPS_TEXTURE_FORMAT_BC3
| BGFX_CAPS_TEXTURE_3D
| BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
| BGFX_CAPS_VERTEX_ATTRIB_HALF
@ -471,13 +468,18 @@ namespace bgfx
s_textureFormat[TextureFormat::BC4].m_fmt = s_extendedFormats[ExtendedFormat::Ati1].m_supported ? D3DFMT_ATI1 : D3DFMT_UNKNOWN;
s_textureFormat[TextureFormat::BC5].m_fmt = s_extendedFormats[ExtendedFormat::Ati2].m_supported ? D3DFMT_ATI2 : D3DFMT_UNKNOWN;
g_caps.supported |= 0
| (D3DFMT_UNKNOWN != s_textureFormat[TextureFormat::BC4].m_fmt ? BGFX_CAPS_TEXTURE_FORMAT_BC4 : 0)
| (D3DFMT_UNKNOWN != s_textureFormat[TextureFormat::BC5].m_fmt ? BGFX_CAPS_TEXTURE_FORMAT_BC5 : 0)
| (s_extendedFormats[ExtendedFormat::Df16].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D16F : 0)
| (s_extendedFormats[ExtendedFormat::Df24].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D24F : 0)
;
g_caps.supported |= m_instancing ? BGFX_CAPS_INSTANCING : 0;
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
g_caps.formats[ii] = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
, m_deviceType
, adapterFormat
, 0
, D3DRTYPE_TEXTURE
, s_textureFormat[ii].m_fmt
) ) ? 1 : 0;
}
#endif // BGFX_CONFIG_RENDERER_USE_EXTENSIONS
uint32_t index = 1;

View file

@ -331,6 +331,7 @@ namespace bgfx
EXT_blend_color,
EXT_blend_minmax,
EXT_blend_subtract,
EXT_compressed_ETC1_RGB8_sub_texture,
EXT_debug_label,
EXT_debug_marker,
EXT_frag_depth,
@ -472,6 +473,7 @@ namespace bgfx
{ "EXT_blend_color", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
{ "EXT_blend_minmax", BGFX_CONFIG_RENDERER_OPENGL >= 14, true },
{ "EXT_blend_subtract", BGFX_CONFIG_RENDERER_OPENGL >= 14, true },
{ "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension.
{ "EXT_debug_label", false, true },
{ "EXT_debug_marker", false, true },
{ "EXT_frag_depth", false, true }, // GLES2 extension.
@ -1099,34 +1101,10 @@ namespace bgfx
}
}
uint64_t supportedTextureFormats = 0
| (s_textureFormat[TextureFormat::BC1 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC1 : 0)
| (s_textureFormat[TextureFormat::BC2 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC2 : 0)
| (s_textureFormat[TextureFormat::BC3 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC3 : 0)
| (s_textureFormat[TextureFormat::BC4 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC4 : 0)
| (s_textureFormat[TextureFormat::BC5 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC5 : 0)
| (s_textureFormat[TextureFormat::ETC1 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC1 : 0)
| (s_textureFormat[TextureFormat::ETC2 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2 : 0)
| (s_textureFormat[TextureFormat::ETC2A ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2A : 0)
| (s_textureFormat[TextureFormat::ETC2A1].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2A1 : 0)
| (s_textureFormat[TextureFormat::PTC12 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC12 : 0)
| (s_textureFormat[TextureFormat::PTC14 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC14 : 0)
| (s_textureFormat[TextureFormat::PTC14A].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC14A : 0)
| (s_textureFormat[TextureFormat::PTC12A].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC12A : 0)
| (s_textureFormat[TextureFormat::PTC22 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC22 : 0)
| (s_textureFormat[TextureFormat::PTC24 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC24 : 0)
| 0
| (s_textureFormat[TextureFormat::D16 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D16 : 0)
| (s_textureFormat[TextureFormat::D24 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D24 : 0)
| (s_textureFormat[TextureFormat::D24S8 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D24S8 : 0)
| (s_textureFormat[TextureFormat::D32 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D32 : 0)
| (s_textureFormat[TextureFormat::D16F ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D16F : 0)
| (s_textureFormat[TextureFormat::D24F ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D24F : 0)
| (s_textureFormat[TextureFormat::D32F ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D32F : 0)
| (s_textureFormat[TextureFormat::D0S8 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_D0S8 : 0)
;
g_caps.supported |= supportedTextureFormats;
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
g_caps.formats[ii] = s_textureFormat[ii].m_supported ? 1 : 0;
}
g_caps.supported |= !!(BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES >= 30) || s_extension[Extension::OES_texture_3D].m_supported
? BGFX_CAPS_TEXTURE_3D