Ver Fonte

Fixed texture formats for iOS.

Branimir Karadžić há 11 anos atrás
pai
commit
f1a1212efc
3 ficheiros alterados com 30 adições e 21 exclusões
  1. 3 3
      examples/09-hdr/hdr.cpp
  2. 14 14
      src/bgfx_p.h
  3. 13 4
      src/renderer_gl.cpp

+ 3 - 3
examples/09-hdr/hdr.cpp

@@ -478,7 +478,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 	bgfx::FrameBufferHandle fbh;
 	bgfx::TextureHandle fbtextures[] =
 	{
-		bgfx::createTexture2D(width, height, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_RT),
+		bgfx::createTexture2D(width, height, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_RT|BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP),
 		bgfx::createTexture2D(width, height, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_BUFFER_ONLY),
 	};
 	fbh = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true);
@@ -539,12 +539,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 			bgfx::destroyFrameBuffer(bright);
 			bgfx::destroyFrameBuffer(blur);
 
-			fbtextures[0] = bgfx::createTexture2D(width, height, 1, bgfx::TextureFormat::BGRA8, ( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT) );
+			fbtextures[0] = bgfx::createTexture2D(width, height, 1, bgfx::TextureFormat::BGRA8, ( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT)|BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
 			fbtextures[1] = bgfx::createTexture2D(width, height, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_BUFFER_ONLY|( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT) );
 			fbh = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true);
 
 			bright = bgfx::createFrameBuffer(width/2, height/2, bgfx::TextureFormat::BGRA8);
-			blur = bgfx::createFrameBuffer(width/8, height/8, bgfx::TextureFormat::BGRA8);
+			blur   = bgfx::createFrameBuffer(width/8, height/8, bgfx::TextureFormat::BGRA8);
 		}
 
 		imguiBeginFrame(mouseState.m_mx

+ 14 - 14
src/bgfx_p.h

@@ -621,31 +621,31 @@ namespace bgfx
 			// |                 ^          ^ ^        ^                       ^|
 			// |                 |          | |        |                       ||
 
-			uint64_t tmp0 = m_depth;
-			uint64_t tmp1 = uint64_t(m_program)<<0x18;
-			uint64_t tmp2 = uint64_t(m_trans)<<0x21;
-			uint64_t tmp3 = uint64_t(m_seq)<<0x23;
-			uint64_t tmp4 = uint64_t(m_view)<<0x2e;
-			uint64_t key = tmp0|tmp1|tmp2|tmp3|tmp4;
+			const uint64_t tmp0 = m_depth;
+			const uint64_t tmp1 = uint64_t(m_program)<<0x18;
+			const uint64_t tmp2 = uint64_t(m_trans  )<<0x21;
+			const uint64_t tmp3 = uint64_t(m_seq    )<<0x23;
+			const uint64_t tmp4 = uint64_t(m_view   )<<0x2e;
+			const uint64_t key  = tmp0|tmp1|tmp2|tmp3|tmp4;
 			return key;
 		}
 
 		void decode(uint64_t _key)
 		{
-			m_depth = _key&0xffffffff;
+			m_depth   =  _key       & 0xffffffff;
 			m_program = (_key>>0x18)&(BGFX_CONFIG_MAX_PROGRAMS-1);
-			m_trans = (_key>>0x21)&0x3;
-			m_seq = (_key>>0x23)&0x7ff;
-			m_view = (_key>>0x2e)&(BGFX_CONFIG_MAX_VIEWS-1);
+			m_trans   = (_key>>0x21)& 0x3;
+			m_seq     = (_key>>0x23)& 0x7ff;
+			m_view    = (_key>>0x2e)&(BGFX_CONFIG_MAX_VIEWS-1);
 		}
 
 		void reset()
 		{
-			m_depth = 0;
+			m_depth   = 0;
 			m_program = 0;
-			m_seq = 0;
-			m_view = 0;
-			m_trans = 0;
+			m_seq     = 0;
+			m_view    = 0;
+			m_trans   = 0;
 		}
 
 		int32_t m_depth;

+ 13 - 4
src/renderer_gl.cpp

@@ -1242,11 +1242,20 @@ namespace bgfx
 			s_textureFormat[TextureFormat::PTC22].m_supported |= ptc2Supported;
 			s_textureFormat[TextureFormat::PTC24].m_supported |= ptc2Supported;
 
-			if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES)
-			&&  BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) )
+			if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
 			{
-				setTextureFormat(TextureFormat::R16,    GL_R16UI,    GL_RED_INTEGER,  GL_UNSIGNED_SHORT);
-				setTextureFormat(TextureFormat::RGBA16, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT);
+				setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT);
+
+				if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) )
+				{
+					setTextureFormat(TextureFormat::R16,    GL_R16UI,    GL_RED_INTEGER,  GL_UNSIGNED_SHORT);
+					setTextureFormat(TextureFormat::RGBA16, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT);
+				}
+				else if (BX_ENABLED(BX_PLATFORM_IOS) )
+				{
+					setTextureFormat(TextureFormat::D16,   GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
+					setTextureFormat(TextureFormat::D24S8, GL_DEPTH_STENCIL,   GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8);
+				}
 			}
 
 			if (s_extension[Extension::EXT_texture_format_BGRA8888].m_supported