Jelajahi Sumber

Added check for texture flag missuse.

Branimir Karadžić 9 tahun lalu
induk
melakukan
9beac469af
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 5 1
      src/bgfx.cpp

+ 5 - 1
src/bgfx.cpp

@@ -2905,9 +2905,13 @@ namespace bgfx
 		_height = bx::uint16_max(1, _height);
 		_height = bx::uint16_max(1, _height);
 	}
 	}
 
 
-	TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
+	static TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
 	{
 	{
 		BGFX_CHECK_MAIN_THREAD();
 		BGFX_CHECK_MAIN_THREAD();
+
+		BX_CHECK(0 == (_flags & BGFX_TEXTURE_RT_MASK) || 0 == (_flags & BGFX_TEXTURE_READ_BACK)
+			, "Can't create render target with BGFX_TEXTURE_READ_BACK flag."
+			);
 		BX_CHECK(0 != (g_caps.formats[_format] & (BGFX_CAPS_FORMAT_TEXTURE_2D|BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED|BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB) )
 		BX_CHECK(0 != (g_caps.formats[_format] & (BGFX_CAPS_FORMAT_TEXTURE_2D|BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED|BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB) )
 			, "Format %s is not supported for 2D texture. Use bgfx::getCaps to check available texture formats."
 			, "Format %s is not supported for 2D texture. Use bgfx::getCaps to check available texture formats."
 			, getName(_format)
 			, getName(_format)