mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Bug fixes.
This commit is contained in:
parent
38b75c9470
commit
8a8b958d1f
4 changed files with 66 additions and 25 deletions
|
@ -298,7 +298,11 @@ namespace bgfx
|
|||
const float texelWidth = 1.0f/2048.0f;
|
||||
const float texelWidthHalf = texelWidth*0.5f;
|
||||
const float texelHeight = 1.0f/24.0f;
|
||||
#if BGFX_CONFIG_RENDERER_DIRECT3D9
|
||||
const float texelHeightHalf = texelHeight*0.5f;
|
||||
#else
|
||||
const float texelHeightHalf = 0.0f;
|
||||
#endif // BGFX_CONFIG_RENDERER_
|
||||
const float utop = (_mem.m_small ? 0.0f : 8.0f)*texelHeight + texelHeightHalf;
|
||||
const float ubottom = (_mem.m_small ? 8.0f : 24.0f)*texelHeight + texelHeightHalf;
|
||||
const float fontHeight = (_mem.m_small ? 8.0f : 16.0f);
|
||||
|
@ -396,7 +400,6 @@ namespace bgfx
|
|||
indices[4] = 3;
|
||||
indices[5] = 0;
|
||||
m_ib = s_ctx.createIndexBuffer(mem);
|
||||
|
||||
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ namespace bgfx
|
|||
{ DXGI_FORMAT_BC3_UNORM, 1 },
|
||||
{ DXGI_FORMAT_UNKNOWN, 0 },
|
||||
{ DXGI_FORMAT_R8_UNORM, 1 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM, 4 },
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM, 4 },
|
||||
{ DXGI_FORMAT_B8G8R8A8_UNORM, 4 },
|
||||
{ DXGI_FORMAT_B8G8R8A8_UNORM, 4 },
|
||||
{ DXGI_FORMAT_R16G16B16A16_FLOAT, 8 },
|
||||
};
|
||||
|
||||
|
@ -1254,10 +1254,13 @@ namespace bgfx
|
|||
D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D11_SUBRESOURCE_DATA) );
|
||||
|
||||
uint32_t kk = 0;
|
||||
bool convert = TextureFormat::XRGB8 == dds.m_type;
|
||||
|
||||
if (decompress
|
||||
|| TextureFormat::Unknown < dds.m_type)
|
||||
{
|
||||
uint32_t bpp = s_textureFormat[dds.m_type].m_bpp;
|
||||
|
||||
for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
{
|
||||
uint32_t width = dds.m_width;
|
||||
|
@ -1273,10 +1276,23 @@ namespace bgfx
|
|||
Mip mip;
|
||||
if (getRawImageData(dds, side, lod, _mem, mip) )
|
||||
{
|
||||
srd[kk].pSysMem = mip.m_data;
|
||||
srd[kk].SysMemPitch = mip.m_width*mip.m_bpp;
|
||||
srd[kk].SysMemSlicePitch = 0;
|
||||
++kk;
|
||||
if (convert)
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)g_realloc(NULL, mip.m_width*bpp*mip.m_height);
|
||||
mip.decode(temp);
|
||||
|
||||
srd[kk].pSysMem = temp;
|
||||
srd[kk].SysMemPitch = mip.m_width*bpp;
|
||||
srd[kk].SysMemSlicePitch = 0;
|
||||
++kk;
|
||||
}
|
||||
else
|
||||
{
|
||||
srd[kk].pSysMem = mip.m_data;
|
||||
srd[kk].SysMemPitch = mip.m_width*mip.m_bpp;
|
||||
srd[kk].SysMemSlicePitch = 0;
|
||||
++kk;
|
||||
}
|
||||
}
|
||||
|
||||
width >>= 1;
|
||||
|
@ -1322,6 +1338,19 @@ namespace bgfx
|
|||
DX_CHECK(s_renderCtx.m_device->CreateShaderResourceView(texture, &srv, &m_ptr) );
|
||||
|
||||
DX_RELEASE(texture, 0);
|
||||
|
||||
if (convert)
|
||||
{
|
||||
kk = 0;
|
||||
for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
{
|
||||
for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod)
|
||||
{
|
||||
g_free(const_cast<void*>(srd[kk].pSysMem) );
|
||||
++kk;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1471,6 +1500,7 @@ namespace bgfx
|
|||
if (_alloc)
|
||||
{
|
||||
m_data = g_realloc(NULL, size);
|
||||
memset(m_data, 0, size);
|
||||
}
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
|
|
|
@ -1802,6 +1802,7 @@ namespace bgfx
|
|||
{
|
||||
uint32_t size = BX_ALIGN_16(g_constantTypeSize[_type]*_num);
|
||||
void* data = g_realloc(NULL, size);
|
||||
memset(data, 0, size);
|
||||
s_renderCtx.m_uniforms[_handle.idx] = data;
|
||||
s_renderCtx.m_uniformReg.reg(_name, s_renderCtx.m_uniforms[_handle.idx]);
|
||||
}
|
||||
|
|
|
@ -128,13 +128,13 @@ namespace bgfx
|
|||
m_graphicsInterface->SwapBuffers(m_context, naclSwapComplete);
|
||||
|
||||
#if 0
|
||||
# define GL_IMPORT(_optional, _proto, _func) \
|
||||
{ \
|
||||
_func = (_proto)eglGetProcAddress(#_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. eglGetProcAddress(\"%s\")", #_func); \
|
||||
}
|
||||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
# define GL_IMPORT(_optional, _proto, _func) \
|
||||
{ \
|
||||
_func = (_proto)eglGetProcAddress(#_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. eglGetProcAddress(\"%s\")", #_func); \
|
||||
}
|
||||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -731,9 +731,9 @@ namespace bgfx
|
|||
|
||||
static const TextureFormatInfo s_textureFormat[TextureFormat::Count] =
|
||||
{
|
||||
{ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_ZERO, GL_ZERO, 1 },
|
||||
{ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_ZERO, GL_ZERO, 1 },
|
||||
{ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_ZERO, GL_ZERO, 1 },
|
||||
{ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_ZERO, GL_ZERO, 4 },
|
||||
{ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_ZERO, GL_ZERO, 4 },
|
||||
{ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_ZERO, GL_ZERO, 4 },
|
||||
{ GL_ZERO, GL_ZERO, GL_ZERO, 0 },
|
||||
{ GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 1 },
|
||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 4 },
|
||||
|
@ -1156,12 +1156,21 @@ namespace bgfx
|
|||
if (!s_renderCtx.m_dxtSupport
|
||||
|| TextureFormat::Unknown < dds.m_type)
|
||||
{
|
||||
if (GL_RGBA == internalFmt)
|
||||
bool decompress = TextureFormat::Unknown > dds.m_type;
|
||||
|
||||
if (GL_RGBA == internalFmt
|
||||
|| decompress)
|
||||
{
|
||||
internalFmt = s_extension[Extension::EXT_texture_format_BGRA8888].m_supported ? GL_BGRA_EXT : GL_RGBA;
|
||||
fmt = internalFmt;
|
||||
}
|
||||
|
||||
GLenum type = tfi.m_type;
|
||||
if (decompress)
|
||||
{
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
uint8_t* bits = (uint8_t*)g_realloc(NULL, dds.m_width*dds.m_height*tfi.m_bpp);
|
||||
|
||||
for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
|
@ -1209,7 +1218,7 @@ namespace bgfx
|
|||
, depth
|
||||
, 0
|
||||
, fmt
|
||||
, tfi.m_type
|
||||
, type
|
||||
, bits
|
||||
) );
|
||||
}
|
||||
|
@ -1223,7 +1232,7 @@ namespace bgfx
|
|||
, height
|
||||
, 0
|
||||
, fmt
|
||||
, tfi.m_type
|
||||
, type
|
||||
, bits
|
||||
) );
|
||||
}
|
||||
|
@ -1578,7 +1587,6 @@ namespace bgfx
|
|||
// GL_CHECK(glUniform1iv(loc, num, value) );
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
|
||||
CASE_IMPLEMENT_UNIFORM(Uniform1i, 1iv, I, int);
|
||||
CASE_IMPLEMENT_UNIFORM(Uniform1f, 1fv, F, float);
|
||||
|
@ -1888,6 +1896,7 @@ namespace bgfx
|
|||
{
|
||||
uint32_t size = g_constantTypeSize[_type]*_num;
|
||||
void* data = g_realloc(NULL, size);
|
||||
memset(data, 0, size);
|
||||
s_renderCtx.m_uniforms[_handle.idx] = data;
|
||||
s_renderCtx.m_uniformReg.reg(_name, s_renderCtx.m_uniforms[_handle.idx]);
|
||||
}
|
||||
|
@ -2317,9 +2326,9 @@ namespace bgfx
|
|||
|| current.m_flags != sampler.m_flags
|
||||
|| materialChanged)
|
||||
{
|
||||
GL_CHECK(glActiveTexture(GL_TEXTURE0+stage) );
|
||||
if (invalidHandle != sampler.m_idx)
|
||||
{
|
||||
GL_CHECK(glActiveTexture(GL_TEXTURE0+stage) );
|
||||
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
||||
{
|
||||
case BGFX_SAMPLER_TEXTURE:
|
||||
|
@ -2349,8 +2358,6 @@ namespace bgfx
|
|||
current = sampler;
|
||||
flag <<= 1;
|
||||
}
|
||||
|
||||
GL_CHECK(glActiveTexture(GL_TEXTURE0) );
|
||||
}
|
||||
|
||||
if (currentState.m_vertexBuffer.idx != state.m_vertexBuffer.idx || materialChanged)
|
||||
|
@ -2419,7 +2426,7 @@ namespace bgfx
|
|||
numPrimsRendered = numPrimsSubmitted*state.m_numInstances;
|
||||
|
||||
GL_CHECK(s_drawElementsInstanced(primType
|
||||
, s_renderCtx.m_indexBuffers[state.m_indexBuffer.idx].m_size/2
|
||||
, numIndices
|
||||
, GL_UNSIGNED_SHORT
|
||||
, (void*)0
|
||||
, state.m_numInstances
|
||||
|
|
Loading…
Reference in a new issue