2
0
Эх сурвалжийг харах

Merge branch 'master' of github.com:bkaradzic/bgfx

bkaradzic 12 жил өмнө
parent
commit
12545b0a88

+ 1 - 1
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)

+ 1 - 1
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;
 
 
    /**

+ 1 - 1
3rdparty/glsl-optimizer/src/glsl/ralloc.c

@@ -29,7 +29,7 @@
 #include <stdint.h>
 
 /* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */
-#ifdef ANDROID
+#if defined(__ANDROID__) || defined(ANDROID)
 #include <limits.h>
 #endif
 

+ 1 - 1
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);

+ 1 - 1
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))

+ 2 - 1
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

+ 0 - 6
examples/00-helloworld/helloworld.nmf

@@ -1,6 +0,0 @@
-{
-	"program": {
-		"x86-32": {"url": "nacl-x86/helloworldRelease.nexe"},
-		"x86-64": {"url": "nacl-x64/helloworldRelease.nexe"}
-	}
-}

+ 0 - 15
examples/00-helloworld/index.htm

@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-	<head>
-		<title>BGFX: Hello, World!</title>
-	</head>
-	<body>
-		<embed name="nacl_module"
-			id="helloworld"
-			width=1280
-			height=720
-			src="helloworld.nmf"
-			type="application/x-nacl"
-		/>
-	</body>
-</html>

+ 0 - 10
examples/00-helloworld/nacl-chrome.bat

@@ -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 %*

+ 3 - 3
examples/04-mesh/mesh.cpp

@@ -3,6 +3,9 @@
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
 
+#include <string>
+#include <vector>
+
 #include "common.h"
 
 #include <bgfx.h>
@@ -14,9 +17,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <string>
-#include <vector>
-
 static const char* s_shaderPath = NULL;
 static bool s_flipV = false;
 

+ 5 - 4
examples/09-hdr/hdr.cpp

@@ -3,6 +3,9 @@
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
 
+#include <vector>
+#include <string>
+
 #include "common.h"
 
 #include <bgfx.h>
@@ -12,8 +15,6 @@
 #include "imgui/imgui.h"
 
 #include <string.h>
-#include <vector>
-#include <string>
 
 static const char* s_shaderPath = NULL;
 
@@ -475,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);
@@ -527,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);
 		}

+ 3 - 3
examples/12-lod/lod.cpp

@@ -3,6 +3,9 @@
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
 
+#include <string>
+#include <vector>
+
 #include "common.h"
 
 #include <bgfx.h>
@@ -14,9 +17,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <string>
-#include <vector>
-
 static const char* s_shaderPath = NULL;
 static bool s_flipV = false;
 

+ 3 - 3
examples/13-stencil/stencil.cpp

@@ -3,6 +3,9 @@
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
 
+#include <string>
+#include <vector>
+
 #include "common.h"
 
 #include <bgfx.h>
@@ -12,9 +15,6 @@
 #include "fpumath.h"
 #include "imgui/imgui.h"
 
-#include <string>
-#include <vector>
-
 #define RENDER_VIEWID_RANGE1_PASS_0   1 
 #define RENDER_VIEWID_RANGE1_PASS_1   2 
 #define RENDER_VIEWID_RANGE1_PASS_2   3 

+ 10 - 10
examples/14-shadowvolumes/shadowvolumes.cpp

@@ -3,6 +3,14 @@
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
 
+#include <stdio.h>
+#include <string.h>
+
+#include <string>
+#include <vector>
+#include <unordered_map>
+#include <map>
+
 namespace std { namespace tr1 {} }
 using namespace std::tr1;
 
@@ -18,14 +26,6 @@ using namespace std::tr1;
 #include "fpumath.h"
 #include "imgui/imgui.h"
 
-#include <stdio.h>
-#include <string.h>
-
-#include <string>
-#include <vector>
-#include <unordered_map>
-#include <map>
-
 #define SV_USE_SIMD 1
 #define MAX_INSTANCE_COUNT 25
 #define MAX_LIGHTS_COUNT 5
@@ -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

+ 2 - 0
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     );

+ 1 - 0
examples/common/entry/entry_linux.cpp

@@ -332,6 +332,7 @@ namespace entry
 
 	void setMouseLock(bool _lock)
 	{
+		BX_UNUSED(_lock);
 	}
 
 } // namespace entry

+ 3 - 3
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 <memory.h>
 #include <string>
 #include <unordered_map>
 
+#include "entry_p.h"
+#include "input.h"
+
 struct Mouse
 {
 	Mouse()

+ 1 - 0
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)

+ 10 - 1
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)

+ 10 - 3
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)];

+ 20 - 7
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[] =
@@ -1459,6 +1470,8 @@ namespace bgfx
 		}
 
 		BX_CHECK(false, "You should not be here.");
+		_pitch = 0;
+		_slicePitch = 0;
 		return NULL;
 	}
 
@@ -1725,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
@@ -1749,7 +1762,7 @@ namespace bgfx
 					, m_height
 					, 1
 					, D3DUSAGE_DEPTHSTENCIL
-					, D3DFMT_DF24 //s_depthFormat[depthFormat]
+					, s_depthFormat[depthFormat]
 					, D3DPOOL_DEFAULT
 					, &m_depthTexture
 					, NULL
@@ -1797,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
@@ -2881,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);

+ 53 - 16
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<<msaa);
 
-		uint32_t colorFormat = (_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>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);

+ 22 - 6
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 <GLES3/gl3platform.h>
 #		include <GLES3/gl3.h>
@@ -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"