From 336bea58490351a9db4f9e3c845c0270aceca185 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sat, 21 Dec 2013 23:37:35 -0800 Subject: [PATCH 1/9] Fixed memory leak. --- examples/common/font/text_buffer_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/common/font/text_buffer_manager.cpp b/examples/common/font/text_buffer_manager.cpp index 5a085ac6..b8b484b0 100644 --- a/examples/common/font/text_buffer_manager.cpp +++ b/examples/common/font/text_buffer_manager.cpp @@ -219,6 +219,7 @@ TextBuffer::~TextBuffer() { delete [] m_vertexBuffer; delete [] m_indexBuffer; + delete [] m_styleBuffer; } void TextBuffer::appendText(FontHandle _fontHandle, const char* _string, const char* _end) From 835131d69f492daa18918d7f0e6a432b371463e3 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Mon, 23 Dec 2013 20:57:58 -0800 Subject: [PATCH 2/9] Quiet GCC 4.8.1. --- src/renderer_d3d9.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index dd4b120c..7ec420a2 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1459,6 +1459,8 @@ namespace bgfx } BX_CHECK(false, "You should not be here."); + _pitch = 0; + _slicePitch = 0; return NULL; } From 48a48d9bf587e944d458f55dae35688985c2f678 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Mon, 23 Dec 2013 22:36:30 -0800 Subject: [PATCH 3/9] Fixes for MinGW GCC 4.8.1. --- 3rdparty/stb_image/stb_image.c | 3 ++- examples/14-shadowvolumes/shadowvolumes.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/3rdparty/stb_image/stb_image.c b/3rdparty/stb_image/stb_image.c index c40f8e1e..5c2ed571 100644 --- a/3rdparty/stb_image/stb_image.c +++ b/3rdparty/stb_image/stb_image.c @@ -4171,7 +4171,8 @@ static uint8 *stbi_gif_load_next(stbi *s, stbi_gif *g, int *comp, int req_comp) static stbi_uc *stbi_gif_load(stbi *s, int *x, int *y, int *comp, int req_comp) { uint8 *u = 0; - stbi_gif g={0}; + stbi_gif g; + memset(&g, 0, sizeof(g) ); u = stbi_gif_load_next(s, &g, comp, req_comp); if (u == (void *) 1) u = 0; // end of animated gif marker diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index d0f769db..37662b1e 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -3,6 +3,14 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ +#include +#include + +#include +#include +#include +#include + namespace std { namespace tr1 {} } using namespace std::tr1; @@ -18,14 +26,6 @@ using namespace std::tr1; #include "fpumath.h" #include "imgui/imgui.h" -#include -#include - -#include -#include -#include -#include - #define SV_USE_SIMD 1 #define MAX_INSTANCE_COUNT 25 #define MAX_LIGHTS_COUNT 5 From a1294a4d5d7901dbf2bc88cf9e59b8530095ef6c Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Tue, 24 Dec 2013 20:18:49 -0800 Subject: [PATCH 4/9] Fixed MinGW64 compile errors. --- examples/04-mesh/mesh.cpp | 6 +++--- examples/09-hdr/hdr.cpp | 5 +++-- examples/12-lod/lod.cpp | 6 +++--- examples/13-stencil/stencil.cpp | 6 +++--- examples/common/entry/input.cpp | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/04-mesh/mesh.cpp b/examples/04-mesh/mesh.cpp index 97d84416..81353ead 100644 --- a/examples/04-mesh/mesh.cpp +++ b/examples/04-mesh/mesh.cpp @@ -3,6 +3,9 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ +#include +#include + #include "common.h" #include @@ -14,9 +17,6 @@ #include #include -#include -#include - static const char* s_shaderPath = NULL; static bool s_flipV = false; diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index 85bcfa07..b8033242 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -3,6 +3,9 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ +#include +#include + #include "common.h" #include @@ -12,8 +15,6 @@ #include "imgui/imgui.h" #include -#include -#include static const char* s_shaderPath = NULL; diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index 6f97ed0e..1d65728c 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -3,6 +3,9 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ +#include +#include + #include "common.h" #include @@ -14,9 +17,6 @@ #include #include -#include -#include - static const char* s_shaderPath = NULL; static bool s_flipV = false; diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index 4c0000fd..0b1fc66c 100644 --- a/examples/13-stencil/stencil.cpp +++ b/examples/13-stencil/stencil.cpp @@ -3,6 +3,9 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ +#include +#include + #include "common.h" #include @@ -12,9 +15,6 @@ #include "fpumath.h" #include "imgui/imgui.h" -#include -#include - #define RENDER_VIEWID_RANGE1_PASS_0 1 #define RENDER_VIEWID_RANGE1_PASS_1 2 #define RENDER_VIEWID_RANGE1_PASS_2 3 diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index dccbd815..5abc8ea2 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -3,13 +3,13 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ -#include "entry_p.h" -#include "input.h" - #include #include #include +#include "entry_p.h" +#include "input.h" + struct Mouse { Mouse() From 6005ebda2b31e63170e46205b897a56782ad9b47 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Tue, 24 Dec 2013 21:30:28 -0800 Subject: [PATCH 5/9] Added platform name defines. --- examples/common/entry/entry.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 59dbefb4..df8a30ff 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -118,6 +118,8 @@ namespace entry int main(int _argc, char** _argv) { + DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME); + cmdAdd("mouselock", cmdMouseLock); cmdAdd("graphics", cmdGraphics ); cmdAdd("exit", cmdExit ); From d1117f34b5a95812af6c36a3ecdf7b6948806169 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 29 Dec 2013 11:43:44 -0800 Subject: [PATCH 6/9] Added support for different RT depth stencil formats. --- examples/09-hdr/hdr.cpp | 4 +- examples/14-shadowvolumes/shadowvolumes.cpp | 4 +- include/bgfx.h | 11 +++- src/renderer_d3d11.cpp | 13 +++- src/renderer_d3d9.cpp | 25 +++++--- src/renderer_gl.cpp | 69 ++++++++++++++++----- src/renderer_gl.h | 28 +++++++-- 7 files changed, 117 insertions(+), 37 deletions(-) diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index b8033242..21ed32e0 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -476,7 +476,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) Mesh mesh; mesh.load("meshes/bunny.bin"); - bgfx::RenderTargetHandle rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA8|BGFX_RENDER_TARGET_DEPTH); + bgfx::RenderTargetHandle rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA8|BGFX_RENDER_TARGET_DEPTH_D16); bgfx::RenderTargetHandle lum[5]; lum[0] = bgfx::createRenderTarget(128, 128, BGFX_RENDER_TARGET_COLOR_RGBA8); @@ -528,7 +528,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::destroyRenderTarget(bright); bgfx::destroyRenderTarget(blur); - rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA8|BGFX_RENDER_TARGET_DEPTH); + rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA8|BGFX_RENDER_TARGET_DEPTH_D16); bright = bgfx::createRenderTarget(width/2, height/2, BGFX_RENDER_TARGET_COLOR_RGBA8); blur = bgfx::createRenderTarget(width/8, height/8, BGFX_RENDER_TARGET_COLOR_RGBA8); } diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 37662b1e..8f2e2ecf 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -1993,7 +1993,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) mem = loadTexture("fieldstone-rgba.dds"); bgfx::TextureHandle fieldstoneTex = bgfx::createTexture(mem); - s_stencilRt = bgfx::createRenderTarget(viewState.m_width, viewState.m_height, BGFX_RENDER_TARGET_COLOR_RGBA8 | BGFX_RENDER_TARGET_DEPTH); + s_stencilRt = bgfx::createRenderTarget(viewState.m_width, viewState.m_height, BGFX_RENDER_TARGET_COLOR_RGBA8 | BGFX_RENDER_TARGET_DEPTH_D16); u_texColor = bgfx::createUniform("u_texColor", bgfx::UniformType::Uniform1iv); u_texStencil = bgfx::createUniform("u_texStencil", bgfx::UniformType::Uniform1iv); @@ -2172,7 +2172,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::destroyRenderTarget(s_stencilRt); - s_stencilRt = bgfx::createRenderTarget(viewState.m_width, viewState.m_height, BGFX_RENDER_TARGET_COLOR_RGBA8 | BGFX_RENDER_TARGET_DEPTH); + s_stencilRt = bgfx::createRenderTarget(viewState.m_width, viewState.m_height, BGFX_RENDER_TARGET_COLOR_RGBA8 | BGFX_RENDER_TARGET_DEPTH_D16); } //set view and projection matrices diff --git a/include/bgfx.h b/include/bgfx.h index 6ae2d7d1..09f7750a 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -203,9 +203,18 @@ #define BGFX_RENDER_TARGET_COLOR_R32F UINT32_C(0x00000006) #define BGFX_RENDER_TARGET_COLOR_SHIFT 0 #define BGFX_RENDER_TARGET_COLOR_MASK UINT32_C(0x000000ff) -#define BGFX_RENDER_TARGET_DEPTH UINT32_C(0x00000100) + +#define BGFX_RENDER_TARGET_DEPTH_D16 UINT32_C(0x00000100) +#define BGFX_RENDER_TARGET_DEPTH_D24 UINT32_C(0x00000200) +#define BGFX_RENDER_TARGET_DEPTH_D24S8 UINT32_C(0x00000300) +#define BGFX_RENDER_TARGET_DEPTH_D32 UINT32_C(0x00000400) +#define BGFX_RENDER_TARGET_DEPTH_D16F UINT32_C(0x00000500) +#define BGFX_RENDER_TARGET_DEPTH_D24F UINT32_C(0x00000600) +#define BGFX_RENDER_TARGET_DEPTH_D32F UINT32_C(0x00000700) +#define BGFX_RENDER_TARGET_DEPTH_D0S8 UINT32_C(0x00000800) #define BGFX_RENDER_TARGET_DEPTH_SHIFT 8 #define BGFX_RENDER_TARGET_DEPTH_MASK UINT32_C(0x0000ff00) + #define BGFX_RENDER_TARGET_MSAA_X2 UINT32_C(0x00010000) #define BGFX_RENDER_TARGET_MSAA_X4 UINT32_C(0x00020000) #define BGFX_RENDER_TARGET_MSAA_X8 UINT32_C(0x00030000) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 3a49b5e8..d8aa9cd4 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -122,8 +122,15 @@ namespace bgfx static const DXGI_FORMAT s_depthFormat[] = { - DXGI_FORMAT_UNKNOWN, // ignored - DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, // ignored + DXGI_FORMAT_D16_UNORM, // D16 + DXGI_FORMAT_D24_UNORM_S8_UINT, // D24 + DXGI_FORMAT_D24_UNORM_S8_UINT, // D24S8 + DXGI_FORMAT_D24_UNORM_S8_UINT, // D32 + DXGI_FORMAT_D32_FLOAT, // D16F + DXGI_FORMAT_D32_FLOAT, // D24F + DXGI_FORMAT_D32_FLOAT, // D32F + DXGI_FORMAT_D24_UNORM_S8_UINT, // D0S8 }; static const D3D11_TEXTURE_ADDRESS_MODE s_textureAddress[] = @@ -2740,7 +2747,7 @@ namespace bgfx tvm.clear(); uint16_t pos = 0; - tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " "); + tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "); const DXGI_ADAPTER_DESC& desc = s_renderCtx->m_adapterDesc; char description[BX_COUNTOF(desc.Description)]; diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 7ec420a2..c8d663f6 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -162,8 +162,19 @@ namespace bgfx static const D3DFORMAT s_depthFormat[] = { - D3DFMT_UNKNOWN, // ignored - D3DFMT_D24S8, + D3DFMT_UNKNOWN, // ignored + D3DFMT_D16, // D16 + D3DFMT_D24X8, // D24 + D3DFMT_D24S8, // D24S8 + D3DFMT_D32, // D32 + D3DFMT_DF16, // D16F + D3DFMT_DF24, // D24F + D3DFMT_D32F_LOCKABLE, // D32F +#if defined(D3D_DISABLE_9EX) + D3DFMT_UNKNOWN, // D0S8 +#else + D3DFMT_S8_LOCKABLE, // D0S8 +#endif // defined(D3D_DISABLE_9EX) }; static const D3DTEXTUREADDRESS s_textureAddress[] = @@ -1727,8 +1738,8 @@ namespace bgfx if (0 != m_flags) { m_msaa = s_msaa[(m_flags&BGFX_RENDER_TARGET_MSAA_MASK)>>BGFX_RENDER_TARGET_MSAA_SHIFT]; - uint32_t colorFormat = (m_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT; - uint32_t depthFormat = (m_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; + const uint32_t colorFormat = (m_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT; + const uint32_t depthFormat = (m_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; m_depthOnly = (0 == colorFormat && 0 < depthFormat); // CheckDeviceFormat D3DUSAGE_SRGBWRITE @@ -1751,7 +1762,7 @@ namespace bgfx , m_height , 1 , D3DUSAGE_DEPTHSTENCIL - , D3DFMT_DF24 //s_depthFormat[depthFormat] + , s_depthFormat[depthFormat] , D3DPOOL_DEFAULT , &m_depthTexture , NULL @@ -1799,7 +1810,7 @@ namespace bgfx { DX_CHECK(s_renderCtx->m_device->CreateDepthStencilSurface(m_width , m_height - , s_depthFormat[depthFormat] // s_renderCtx->m_fmtDepth + , s_depthFormat[depthFormat] , m_msaa.m_type , m_msaa.m_quality , FALSE @@ -2883,7 +2894,7 @@ namespace bgfx tvm.clear(); uint16_t pos = 0; - tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " "); + tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "); const D3DADAPTER_IDENTIFIER9& identifier = s_renderCtx->m_identifier; tvm.printf(0, pos++, 0x0f, " Device: %s (%s)", identifier.Description, identifier.Driver); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index c5d7f3a3..73f96a1d 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -157,10 +157,23 @@ namespace bgfx { GL_R32F, GL_FLOAT, 32 }, }; - static const GLenum s_depthFormat[] = + struct RenderTargetDepthFormat { - 0, // ignored - 0, + GLenum m_internalFmt; + GLenum m_attachment; + }; + + static const RenderTargetDepthFormat s_depthFormat[] = + { + { 0, 0 }, // ignored + { GL_DEPTH_COMPONENT16, GL_DEPTH_ATTACHMENT }, // D16 + { GL_DEPTH_COMPONENT24, GL_DEPTH_ATTACHMENT }, // D24 + { GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT }, // D24S8 + { GL_DEPTH_COMPONENT32, GL_DEPTH_ATTACHMENT }, // D32 + { GL_DEPTH_COMPONENT32F, GL_DEPTH_ATTACHMENT }, // D16F + { GL_DEPTH_COMPONENT32F, GL_DEPTH_ATTACHMENT }, // D24F + { GL_DEPTH_COMPONENT32F, GL_DEPTH_ATTACHMENT }, // D32F + { GL_STENCIL_INDEX8, GL_STENCIL_ATTACHMENT }, // D0S8 }; static const GLenum s_textureAddress[] = @@ -278,9 +291,12 @@ namespace bgfx NVX_gpu_memory_info, OES_compressed_ETC1_RGB8_texture, OES_depth24, + OES_depth32, OES_depth_texture, OES_fragment_precision_high, OES_get_program_binary, + OES_required_internalformat, + OES_packed_depth_stencil, OES_read_format, OES_rgb8_rgba8, OES_standard_derivatives, @@ -358,9 +374,12 @@ namespace bgfx { "GL_NVX_gpu_memory_info", false, true }, { "GL_OES_compressed_ETC1_RGB8_texture", false, true }, { "GL_OES_depth24", false, true }, + { "GL_OES_depth32", false, true }, { "GL_OES_depth_texture", false, true }, { "GL_OES_fragment_precision_high", false, true }, { "GL_OES_get_program_binary", false, true }, + { "GL_OES_required_internalformat", false, true }, + { "GL_OES_packed_depth_stencil", false, true }, { "GL_OES_read_format", false, true }, { "GL_OES_rgb8_rgba8", false, true }, { "GL_OES_standard_derivatives", false, true }, @@ -1846,7 +1865,7 @@ namespace bgfx || findMatch(code, "fwidth") ); - bool usesFragDepth = findMatch(code, "gl_FragDepth"); + bool usesFragDepth = !!findMatch(code, "gl_FragDepth"); bool usesTexture3D = s_extension[Extension::OES_texture_3D].m_supported && ( findMatch(code, "texture3D") @@ -1983,10 +2002,10 @@ namespace bgfx uint32_t msaa = (_flags&BGFX_RENDER_TARGET_MSAA_MASK)>>BGFX_RENDER_TARGET_MSAA_SHIFT; m_msaa = bx::uint32_min(s_renderCtx->m_maxMsaa, msaa == 0 ? 0 : 1<>BGFX_RENDER_TARGET_COLOR_SHIFT; - uint32_t depthFormat = (_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; - GLenum minFilter = s_textureFilterMin[(_textureFlags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT][0]; - GLenum magFilter = s_textureFilterMag[(_textureFlags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT]; + const uint32_t colorFormat = (_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT; + const uint32_t depthFormat = (_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; + const GLenum minFilter = s_textureFilterMin[(_textureFlags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT][0]; + const GLenum magFilter = s_textureFilterMag[(_textureFlags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT]; if (0 < colorFormat) { @@ -2049,16 +2068,13 @@ namespace bgfx if (0 < colorFormat) { -#if BGFX_CONFIG_RENDERER_OPENGL - GLenum depthComponent = GL_DEPTH_COMPONENT32; -#else - GLenum depthComponent = GL_DEPTH_COMPONENT16; -#endif // BGFX_CONFIG_RENDERER_OPENGL - GL_CHECK(glGenRenderbuffers(1, &m_depthRbo) ); BX_CHECK(0 != m_depthRbo, "Failed to generate renderbuffer id."); GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_depthRbo) ); + const GLenum depthComponent = s_depthFormat[depthFormat].m_internalFmt; + const GLenum attachment = s_depthFormat[depthFormat].m_attachment; + #if BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3 if (0 != m_msaa) { @@ -2071,11 +2087,32 @@ namespace bgfx } GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, 0) ); +#if BGFX_CONFIG_RENDERER_OPENGLES2 + if (GL_STENCIL_ATTACHMENT != attachment) + { + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER + , GL_DEPTH_ATTACHMENT + , GL_RENDERBUFFER + , m_depthRbo + ) ); + } + + if (GL_DEPTH_STENCIL_ATTACHMENT == attachment + || GL_STENCIL_ATTACHMENT == attachment) + { + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER + , GL_STENCIL_ATTACHMENT + , GL_RENDERBUFFER + , m_depthRbo + ) ); + } +#else GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER - , GL_DEPTH_ATTACHMENT + , attachment , GL_RENDERBUFFER , m_depthRbo ) ); +#endif // BGFX_CONFIG_RENDERER_OPENGLES2 } else { @@ -3743,7 +3780,7 @@ namespace bgfx tvm.clear(); uint16_t pos = 0; - tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " "); + tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "); tvm.printf(0, pos++, 0x0f, " Vendor: %s", s_renderCtx->m_vendor); tvm.printf(0, pos++, 0x0f, " Renderer: %s", s_renderCtx->m_renderer); tvm.printf(0, pos++, 0x0f, " Version: %s", s_renderCtx->m_version); diff --git a/src/renderer_gl.h b/src/renderer_gl.h index cc66a56d..a099fe0f 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -96,6 +96,10 @@ typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLu # define GL_TEXTURE_WRAP_R GL_TEXTURE_WRAP_R_OES # define GL_MIN GL_MIN_EXT # define GL_MAX GL_MAX_EXT +# define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES +# define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES +# define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES +# define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES # elif BGFX_CONFIG_RENDERER_OPENGLES3 # include # include @@ -136,6 +140,14 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b # define GL_RGB10_A2_EXT 0x8059 #endif // GL_RGB10_A2_EXT +#ifndef GL_RGBA16 +# define GL_RGBA16 0x805B +#endif // GL_RGBA16 + +#ifndef GL_RGBA16F +# define GL_RGBA16F 0x881A +#endif // GL_RGBA16F + #ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT # define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT @@ -253,13 +265,17 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b # define GL_UNPACK_ROW_LENGTH 0x0CF2 #endif // GL_UNPACK_ROW_LENGTH -#ifndef GL_RGBA16 -# define GL_RGBA16 0x805B -#endif // GL_RGBA16 +#ifndef GL_DEPTH_COMPONENT32 +# define GL_DEPTH_COMPONENT32 0x81A7 +#endif // GL_DEPTH_COMPONENT32 -#ifndef GL_RGBA16F -# define GL_RGBA16F 0x881A -#endif // GL_RGBA16F +#ifndef GL_DEPTH_COMPONENT32F +# define GL_DEPTH_COMPONENT32F 0x8CAC +#endif // GL_DEPTH_COMPONENT32F + +#ifndef GL_DEPTH_STENCIL_ATTACHMENT +# define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#endif // GL_DEPTH_STENCIL_ATTACHMENT #if BX_PLATFORM_NACL # include "glcontext_ppapi.h" From 2e0952bbec147e8831114fe449b5e7d4932bf435 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 29 Dec 2013 15:03:51 -0800 Subject: [PATCH 7/9] Fixed GCC warning. --- examples/common/entry/entry_linux.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/common/entry/entry_linux.cpp b/examples/common/entry/entry_linux.cpp index 1c3c13ce..2eccfe17 100644 --- a/examples/common/entry/entry_linux.cpp +++ b/examples/common/entry/entry_linux.cpp @@ -332,6 +332,7 @@ namespace entry void setMouseLock(bool _lock) { + BX_UNUSED(_lock); } } // namespace entry From 82d6813c5c77b026fceb59c94cd854a0f5fb8107 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Mon, 30 Dec 2013 15:56:55 -0800 Subject: [PATCH 8/9] Fixed GLSL optimizer Android build. --- 3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp | 2 +- 3rdparty/glsl-optimizer/src/glsl/glsl_types.h | 2 +- 3rdparty/glsl-optimizer/src/glsl/ralloc.c | 2 +- 3rdparty/glsl-optimizer/src/glsl/strtod.c | 2 +- 3rdparty/glsl-optimizer/src/mesa/main/imports.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp index b15d2b07..ef4a81e4 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp @@ -586,7 +586,7 @@ glsl_type::field_type(const char *name) const return error_type; } -const glsl_precision +glsl_precision glsl_type::field_precision(const char *name) const { if (this->base_type != GLSL_TYPE_STRUCT) diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.h b/3rdparty/glsl-optimizer/src/glsl/glsl_types.h index 771291d3..95b7a8a6 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_types.h +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.h @@ -454,7 +454,7 @@ struct glsl_type { */ const glsl_type *field_type(const char *name) const; - const glsl_precision field_precision(const char *name) const; + glsl_precision field_precision(const char *name) const; /** diff --git a/3rdparty/glsl-optimizer/src/glsl/ralloc.c b/3rdparty/glsl-optimizer/src/glsl/ralloc.c index 9d014967..4bd88fc9 100644 --- a/3rdparty/glsl-optimizer/src/glsl/ralloc.c +++ b/3rdparty/glsl-optimizer/src/glsl/ralloc.c @@ -29,7 +29,7 @@ #include /* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */ -#ifdef ANDROID +#if defined(__ANDROID__) || defined(ANDROID) #include #endif diff --git a/3rdparty/glsl-optimizer/src/glsl/strtod.c b/3rdparty/glsl-optimizer/src/glsl/strtod.c index 47c1f0ed..822364cb 100644 --- a/3rdparty/glsl-optimizer/src/glsl/strtod.c +++ b/3rdparty/glsl-optimizer/src/glsl/strtod.c @@ -45,7 +45,7 @@ double glsl_strtod(const char *s, char **end) { #if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) + !defined(__HAIKU__) && !defined(__UCLIBC__) && !defined(__ANDROID__) static locale_t loc = NULL; if (!loc) { loc = newlocale(LC_CTYPE_MASK, "C", NULL); diff --git a/3rdparty/glsl-optimizer/src/mesa/main/imports.h b/3rdparty/glsl-optimizer/src/mesa/main/imports.h index fec9f305..7cfb2d58 100644 --- a/3rdparty/glsl-optimizer/src/mesa/main/imports.h +++ b/3rdparty/glsl-optimizer/src/mesa/main/imports.h @@ -114,7 +114,7 @@ typedef union { GLfloat f; GLint i; } fi_type; #define floorf(f) ((float) floor(f)) #define logf(f) ((float) log(f)) -#ifdef ANDROID +#if defined(__ANDROID__) || defined(ANDROID) #define log2f(f) (logf(f) * (float) (1.0 / M_LN2)) #else #define log2f(f) ((float) log2(f)) From 7d61b3eafa0c7c5555bb48dd844921abd9499bcc Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Thu, 2 Jan 2014 09:20:58 -0800 Subject: [PATCH 9/9] Removed unused files. --- examples/00-helloworld/helloworld.nmf | 6 ------ examples/00-helloworld/index.htm | 15 --------------- examples/00-helloworld/nacl-chrome.bat | 10 ---------- 3 files changed, 31 deletions(-) delete mode 100644 examples/00-helloworld/helloworld.nmf delete mode 100644 examples/00-helloworld/index.htm delete mode 100644 examples/00-helloworld/nacl-chrome.bat diff --git a/examples/00-helloworld/helloworld.nmf b/examples/00-helloworld/helloworld.nmf deleted file mode 100644 index 3b83681a..00000000 --- a/examples/00-helloworld/helloworld.nmf +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": { - "x86-32": {"url": "nacl-x86/helloworldRelease.nexe"}, - "x86-64": {"url": "nacl-x64/helloworldRelease.nexe"} - } -} diff --git a/examples/00-helloworld/index.htm b/examples/00-helloworld/index.htm deleted file mode 100644 index c904dc08..00000000 --- a/examples/00-helloworld/index.htm +++ /dev/null @@ -1,15 +0,0 @@ - - - - BGFX: Hello, World! - - - - - diff --git a/examples/00-helloworld/nacl-chrome.bat b/examples/00-helloworld/nacl-chrome.bat deleted file mode 100644 index 62676c30..00000000 --- a/examples/00-helloworld/nacl-chrome.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -setlocal -set NACL_DEBUG=%~dp0..\..\.debug\nacl -set NACL_EXE_STDERR=%NACL_DEBUG%\stderr.txt -set NACL_EXE_STDOUT=%NACL_DEBUG%\stdout.txt -set NACL_DANGEROUS_ENABLE_FILE_ACCESS=1 -mkdir %NACL_DEBUG% > nul -rm -rf %NACL_EXE_STDERR% > nul -rm -rf %NACL_EXE_STDOUT% > nul -start %LOCALAPPDATA%\Google\Chrome\Application\chrome.exe --incognito --no-sandbox --show-fps-counter http://localhost:8080 %*