Branimir Karadžić 9 years ago
parent
commit
00d0f765fc
3 changed files with 8 additions and 17 deletions
  1. 1 0
      3rdparty/ocornut-imgui/imgui.cpp
  2. 2 0
      3rdparty/stb/stb_image.c
  3. 5 17
      src/image.cpp

+ 1 - 0
3rdparty/ocornut-imgui/imgui.cpp

@@ -602,6 +602,7 @@
 #pragma clang diagnostic ignored "-Wmissing-noreturn"       // warning : function xx could be declared with attribute 'noreturn' warning    // GetDefaultFontData() asserts which some implementation makes it never return.
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"// warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
 #pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
+#pragma clang diagnostic ignored "-Wunused-function"          // warning: 'xxxx' defined but not used
 #endif
 #ifdef __GNUC__
 #pragma GCC diagnostic ignored "-Wunused-function"          // warning: 'xxxx' defined but not used

+ 2 - 0
3rdparty/stb/stb_image.c

@@ -5,6 +5,8 @@
 #		pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #	endif // __clang__
 #elif defined(_MSC_VER)
+#	pragma warning(disable:4244) // warning C4244: '=': conversion from 'int' to 'stbi__uint16', possible loss of data
+#	pragma warning(disable:4245) // warning C4245: 'argument': conversion from 'int' to 'char', signed/unsigned mismatch
 #	pragma warning(disable:4312) // warning C4312: 'type cast': conversion from '' to '' of greater size
 #	pragma warning(disable:4456) // warning C4456: declaration of 'k' hides previous local declaration
 #	pragma warning(disable:4457) // warning C4457: declaration of 'y' hides function parameter

+ 5 - 17
src/image.cpp

@@ -252,24 +252,12 @@ namespace bgfx
 		const uint16_t minBlockX   = blockInfo.minBlockX;
 		const uint16_t minBlockY   = blockInfo.minBlockY;
 
-		_width   = bx::uint16_max(blockWidth  * minBlockX, ( (_width  + blockWidth  - 1) / blockWidth)*blockWidth);
-		_height  = bx::uint16_max(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight);
-		_depth   = bx::uint16_max(1, _depth);
-
-		uint8_t numMips = 0;
+		_width  = bx::uint16_max(blockWidth  * minBlockX, ( (_width  + blockWidth  - 1) / blockWidth)*blockWidth);
+		_height = bx::uint16_max(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight);
+		_depth  = bx::uint16_max(1, _depth);
 
-		for (uint32_t width = _width, height = _height, depth = _depth
-			; blockWidth < width || blockHeight < height || 1 < depth
-			; ++numMips)
-		{
-			width  = bx::uint32_max(blockWidth  * minBlockX, ( (width  + blockWidth  - 1) / blockWidth )*blockWidth);
-			height = bx::uint32_max(blockHeight * minBlockY, ( (height + blockHeight - 1) / blockHeight)*blockHeight);
-			depth  = bx::uint32_max(1, depth);
-
-			width  >>= 1;
-			height >>= 1;
-			depth  >>= 1;
-		}
+		uint32_t max = bx::uint32_max(_width, bx::uint32_max(_height, _depth) );
+		uint8_t numMips = uint8_t(bx::flog2(float(max) ) );
 
 		return numMips;
 	}