mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Fixed issue with decompressing DDS.
This commit is contained in:
parent
fb37505a8a
commit
48c8200ed3
3 changed files with 23 additions and 10 deletions
|
@ -423,10 +423,12 @@ bool parseDds(Dds& _dds, const Memory* _mem)
|
|||
{
|
||||
case DDPF_RGB:
|
||||
blockSize *= 3;
|
||||
bpp = 3;
|
||||
break;
|
||||
|
||||
case DDPF_RGB|DDPF_ALPHAPIXELS:
|
||||
blockSize *= 4;
|
||||
bpp = 4;
|
||||
break;
|
||||
|
||||
case DDPF_LUMINANCE:
|
||||
|
|
|
@ -182,6 +182,8 @@ namespace bgfx
|
|||
|
||||
BGFX_FATAL(m_device, bgfx::Fatal::D3D9_UnableToCreateDevice, "Unable to create Direct3D9 device.");
|
||||
|
||||
DX_CHECK(m_device->GetDeviceCaps(&m_caps) );
|
||||
|
||||
m_fmtNULL = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_NULL) );
|
||||
m_fmtDF16 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF16) );
|
||||
m_fmtDF24 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF24) );
|
||||
|
@ -466,6 +468,8 @@ namespace bgfx
|
|||
}
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
D3DCAPS9 m_caps;
|
||||
|
||||
D3DPERF_SetMarkerFunc m_D3DPERF_SetMarker;
|
||||
D3DPERF_BeginEventFunc m_D3DPERF_BeginEvent;
|
||||
D3DPERF_EndEventFunc m_D3DPERF_EndEvent;
|
||||
|
@ -846,9 +850,9 @@ namespace bgfx
|
|||
D3DFORMAT fmt = typefmt[dds.m_type];
|
||||
|
||||
bool decompress = false;
|
||||
uint8_t bpp = dds.m_bpp;
|
||||
|
||||
if (decompress
|
||||
|| (0 == dds.m_type) )
|
||||
if (0 == dds.m_type)
|
||||
{
|
||||
switch (dds.m_bpp)
|
||||
{
|
||||
|
@ -865,6 +869,11 @@ namespace bgfx
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (decompress)
|
||||
{
|
||||
fmt = D3DFMT_A8R8G8B8;
|
||||
bpp = 4;
|
||||
}
|
||||
|
||||
DX_CHECK(s_renderCtx.m_device->CreateTexture(dds.m_width
|
||||
, dds.m_height
|
||||
|
@ -897,7 +906,7 @@ namespace bgfx
|
|||
if (width != mip.m_width
|
||||
|| height != mip.m_height)
|
||||
{
|
||||
uint32_t srcpitch = mip.m_width*mip.m_bpp;
|
||||
uint32_t srcpitch = mip.m_width*bpp;
|
||||
|
||||
uint8_t* temp = (uint8_t*)g_realloc(NULL, srcpitch*mip.m_height);
|
||||
mip.decode(temp);
|
||||
|
|
|
@ -631,11 +631,16 @@ namespace bgfx
|
|||
{
|
||||
fmt = s_extension[Extension::GL_EXT_texture_format_BGRA8888].m_supported ? GL_BGRA_EXT : GL_RGBA;
|
||||
|
||||
if (dds.m_bpp == 1)
|
||||
uint8_t bpp = 4;
|
||||
if (dds.m_type == 0
|
||||
&& dds.m_bpp == 1)
|
||||
{
|
||||
fmt = GL_LUMINANCE;
|
||||
bpp = 1;
|
||||
}
|
||||
|
||||
uint8_t* bits = (uint8_t*)g_realloc(NULL, dds.m_width*dds.m_height*bpp);
|
||||
|
||||
for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod)
|
||||
{
|
||||
width = uint32_max(1, width);
|
||||
|
@ -644,9 +649,6 @@ namespace bgfx
|
|||
Mip mip;
|
||||
if (getRawImageData(dds, lod, _mem, mip) )
|
||||
{
|
||||
uint32_t srcpitch = mip.m_width*mip.m_bpp;
|
||||
uint8_t* bits = (uint8_t*)g_realloc(NULL, srcpitch*mip.m_height);
|
||||
|
||||
mip.decode(bits);
|
||||
|
||||
if (GL_RGBA == fmt)
|
||||
|
@ -676,13 +678,13 @@ namespace bgfx
|
|||
, GL_UNSIGNED_BYTE
|
||||
, bits
|
||||
) );
|
||||
|
||||
g_free(bits);
|
||||
}
|
||||
|
||||
width >>= 1;
|
||||
height >>= 1;
|
||||
}
|
||||
|
||||
g_free(bits);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1139,7 +1141,7 @@ namespace bgfx
|
|||
pos += len+1;
|
||||
}
|
||||
|
||||
s_renderCtx.m_dxtSupport = false //true
|
||||
s_renderCtx.m_dxtSupport = true
|
||||
&& s_extension[Extension::GL_EXT_texture_compression_dxt1].m_supported
|
||||
&& s_extension[Extension::GL_CHROMIUM_texture_compression_dxt3].m_supported
|
||||
&& s_extension[Extension::GL_CHROMIUM_texture_compression_dxt5].m_supported
|
||||
|
|
Loading…
Reference in a new issue