mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Split texture format test.
This commit is contained in:
parent
76ad2441b0
commit
70ad9aac0e
6 changed files with 132 additions and 22 deletions
|
@ -376,11 +376,17 @@
|
|||
#define BGFX_CAPS_FORMAT_TEXTURE_2D UINT16_C(0x0001) //!< Texture format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB UINT16_C(0x0002) //!< Texture as sRGB format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED UINT16_C(0x0004) //!< Texture format is emulated.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT16_C(0x0008) //!< Texture format can be used from vertex shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT16_C(0x0010) //!< Texture format can be used as image from compute shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER UINT16_C(0x0020) //!< Texture format can be used as frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA UINT16_C(0x0040) //!< Texture format can be used as MSAA frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_MSAA UINT16_C(0x0080) //!< Texture can be sampled as MSAA.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_3D UINT16_C(0x0008) //!< Texture format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB UINT16_C(0x0010) //!< Texture as sRGB format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED UINT16_C(0x0020) //!< Texture format is emulated.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_CUBE UINT16_C(0x0040) //!< Texture format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB UINT16_C(0x0080) //!< Texture as sRGB format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED UINT16_C(0x0100) //!< Texture format is emulated.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT16_C(0x0200) //!< Texture format can be used from vertex shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT16_C(0x0400) //!< Texture format can be used as image from compute shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER UINT16_C(0x0800) //!< Texture format can be used as frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA UINT16_C(0x1000) //!< Texture format can be used as MSAA frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_MSAA UINT16_C(0x2000) //!< Texture can be sampled as MSAA.
|
||||
|
||||
///
|
||||
#define BGFX_VIEW_NONE UINT8_C(0x00) //!<
|
||||
|
|
40
src/bgfx.cpp
40
src/bgfx.cpp
|
@ -998,23 +998,31 @@ namespace bgfx
|
|||
}
|
||||
|
||||
BX_TRACE("Supported texture formats:");
|
||||
BX_TRACE("\t +----------- x = supported / * = emulated");
|
||||
BX_TRACE("\t |+---------- sRGB format");
|
||||
BX_TRACE("\t ||+--------- vertex format");
|
||||
BX_TRACE("\t |||+-------- image");
|
||||
BX_TRACE("\t ||||+------- framebuffer");
|
||||
BX_TRACE("\t |||||+------ MSAA framebuffer");
|
||||
BX_TRACE("\t ||||||+----- MSAA texture");
|
||||
BX_TRACE("\t ||||||| +-- name");
|
||||
BX_TRACE("\t +--------------- 2D: x = supported / * = emulated");
|
||||
BX_TRACE("\t |+-------------- 2D: sRGB format");
|
||||
BX_TRACE("\t ||+------------- 3D: x = supported / * = emulated");
|
||||
BX_TRACE("\t |||+------------ 3D: sRGB format");
|
||||
BX_TRACE("\t ||||+----------- Cube: x = supported / * = emulated");
|
||||
BX_TRACE("\t |||||+---------- Cube: sRGB format");
|
||||
BX_TRACE("\t ||||||+--------- vertex format");
|
||||
BX_TRACE("\t |||||||+-------- image");
|
||||
BX_TRACE("\t ||||||||+------- framebuffer");
|
||||
BX_TRACE("\t |||||||||+------ MSAA framebuffer");
|
||||
BX_TRACE("\t ||||||||||+----- MSAA texture");
|
||||
BX_TRACE("\t ||||||||||| +-- name");
|
||||
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
|
||||
{
|
||||
if (TextureFormat::Unknown != ii
|
||||
&& TextureFormat::UnknownDepth != ii)
|
||||
{
|
||||
uint16_t flags = g_caps.formats[ii];
|
||||
BX_TRACE("\t[%c%c%c%c%c%c%c] %s"
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED ? '*' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ? 'l' : ' '
|
||||
BX_TRACE("\t[%c%c%c%c%c%c%c%c%c%c%c] %s"
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED ? '*' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ? 'l' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_3D ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED ? '*' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB ? 'l' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_CUBE ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED ? '*' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB ? 'l' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_VERTEX ? 'v' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE ? 'i' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER ? 'f' : ' '
|
||||
|
@ -1139,6 +1147,16 @@ namespace bgfx
|
|||
{
|
||||
g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED;
|
||||
}
|
||||
|
||||
if (0 == (g_caps.formats[s_emulatedFormats[ii] ] & BGFX_CAPS_FORMAT_TEXTURE_3D) )
|
||||
{
|
||||
g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED;
|
||||
}
|
||||
|
||||
if (0 == (g_caps.formats[s_emulatedFormats[ii] ] & BGFX_CAPS_FORMAT_TEXTURE_CUBE) )
|
||||
{
|
||||
g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED;
|
||||
}
|
||||
}
|
||||
|
||||
g_caps.rendererType = m_renderCtx->getRendererType();
|
||||
|
|
|
@ -1281,6 +1281,20 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_BUFFER
|
||||
| D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER
|
||||
|
@ -1359,12 +1373,24 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
{
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE2D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -907,13 +907,25 @@ namespace bgfx { namespace d3d12
|
|||
{
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURE2D
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURE3D
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_BUFFER
|
||||
| D3D12_FORMAT_SUPPORT1_IA_VERTEX_BUFFER
|
||||
|
@ -992,12 +1004,24 @@ namespace bgfx { namespace d3d12
|
|||
{
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURE2D
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURE3D
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.Support1 & (0
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -599,6 +599,38 @@ namespace bgfx { namespace d3d9
|
|||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
, adapterFormat
|
||||
, 0
|
||||
, D3DRTYPE_VOLUMETEXTURE
|
||||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_3D : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
, adapterFormat
|
||||
, D3DUSAGE_QUERY_SRGBREAD
|
||||
, D3DRTYPE_VOLUMETEXTURE
|
||||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
, adapterFormat
|
||||
, 0
|
||||
, D3DRTYPE_CUBETEXTURE
|
||||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
, adapterFormat
|
||||
, D3DUSAGE_QUERY_SRGBREAD
|
||||
, D3DRTYPE_CUBETEXTURE
|
||||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
, adapterFormat
|
||||
|
|
|
@ -1595,11 +1595,15 @@ namespace bgfx { namespace gl
|
|||
uint8_t supported = 0;
|
||||
supported |= s_textureFormat[ii].m_supported
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_3D
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_CUBE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
supported |= isTextureFormatValid(TextureFormat::Enum(ii), true)
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue