Added texture caps flag for compute image formats.

This commit is contained in:
Branimir Karadžić 2015-04-21 15:44:16 -07:00
parent ccb0f73308
commit f246fd29fa
4 changed files with 53 additions and 7 deletions

View file

@ -325,6 +325,7 @@
#define BGFX_CAPS_FORMAT_TEXTURE_COLOR UINT8_C(0x01)
#define BGFX_CAPS_FORMAT_TEXTURE_EMULATED UINT8_C(0x02)
#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT8_C(0x04)
#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT8_C(0x08)
///
#define BGFX_VIEW_NONE UINT8_C(0x00)

View file

@ -847,18 +847,20 @@ namespace bgfx
}
BX_TRACE("Supported texture formats:");
BX_TRACE("\t +------ x = supported / * = emulated");
BX_TRACE("\t |+----- vertex format");
BX_TRACE("\t || +-- name");
BX_TRACE("\t +------- x = supported / * = emulated");
BX_TRACE("\t |+------ vertex format");
BX_TRACE("\t ||+----- image");
BX_TRACE("\t ||| +-- name");
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%c] %s"
BX_TRACE("\t[%c%c%c] %s"
, flags&BGFX_CAPS_FORMAT_TEXTURE_COLOR ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_EMULATED ? '*' : ' '
, flags&BGFX_CAPS_FORMAT_TEXTURE_VERTEX ? 'v' : ' '
, flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE ? 'i' : ' '
, getName(TextureFormat::Enum(ii) )
);
BX_UNUSED(flags);

View file

@ -926,11 +926,38 @@ BX_PRAGMA_DIAGNOSTIC_POP();
? BGFX_CAPS_FORMAT_TEXTURE_VERTEX
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
support |= 0 != (data.OutFormatSupport & (0
| D3D11_FORMAT_SUPPORT_SHADER_LOAD
) )
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
}
else
{
BX_TRACE("CheckFeatureSupport failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii) ) );
}
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE) )
{
// clear image flag for additional testing
support &= ~BGFX_CAPS_FORMAT_TEXTURE_IMAGE;
D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
data.InFormat = s_textureFormat[ii].m_fmt;
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT2, &data, sizeof(data) );
if (SUCCEEDED(hr) )
{
support |= 0 != (data.OutFormatSupport & (0
| D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD
| D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE
) )
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
}
}
}
g_caps.formats[ii] = support;

View file

@ -1325,9 +1325,26 @@ namespace bgfx { namespace gl
}
}
const bool computeSupport = false
|| !!(BGFX_CONFIG_RENDERER_OPENGLES >= 31)
|| s_extension[Extension::ARB_compute_shader].m_supported
;
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
g_caps.formats[ii] = s_textureFormat[ii].m_supported ? 1 : 0;
uint8_t supported = 0;
supported |= s_textureFormat[ii].m_supported
? BGFX_CAPS_FORMAT_TEXTURE_COLOR
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
supported |= computeSupport
&& GL_ZERO != s_imageFormat[ii]
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
: BGFX_CAPS_FORMAT_TEXTURE_NONE
;
g_caps.formats[ii] = supported;
}
g_caps.supported |= !!(BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES >= 30)
@ -1436,8 +1453,7 @@ namespace bgfx { namespace gl
: 0
;
g_caps.supported |= !!(BGFX_CONFIG_RENDERER_OPENGLES >= 31)
|| s_extension[Extension::ARB_compute_shader].m_supported
g_caps.supported |= computeSupport
? BGFX_CAPS_COMPUTE
: 0
;