Skip to content

Commit

Permalink
Update stb_image version 2.12 -> 2.28
Browse files Browse the repository at this point in the history
stb_image v2.12 has a memory corruption bug, updated to v2.28 to fix.

The only real API change is stb_image_resize.h is now stb_image_resize2.h, and stbir_resize_uint8_srgb() doesnt take alpha channels or flags as params.
  • Loading branch information
jathoma98 authored and baldurk committed Nov 11, 2023
1 parent 73c604d commit bcb7dfd
Show file tree
Hide file tree
Showing 11 changed files with 15,172 additions and 3,718 deletions.
2,861 changes: 2,045 additions & 816 deletions renderdoc/3rdparty/stb/stb_image.h

Large diffs are not rendered by default.

2,578 changes: 0 additions & 2,578 deletions renderdoc/3rdparty/stb/stb_image_resize.h

This file was deleted.

10,303 changes: 10,303 additions & 0 deletions renderdoc/3rdparty/stb/stb_image_resize2.h

Large diffs are not rendered by default.

930 changes: 803 additions & 127 deletions renderdoc/3rdparty/stb/stb_image_write.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion renderdoc/3rdparty/stb/stb_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#pragma warning(disable:4189) // local variable is initialized but not referenced
#pragma warning(disable:4244) // <narrowing conversion>, possible loss of data
#pragma warning(disable:4702) // unreachable code
#pragma warning(disable:4204) // nonstandard extension used: non-constant aggregate initializer

#include "stb_image.h"
#include "stb_image_write.h"
#include "stb_image_resize.h"
#include "stb_image_resize2.h"
#include "stb_truetype.h"
2,188 changes: 1,999 additions & 189 deletions renderdoc/3rdparty/stb/stb_truetype.h

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion renderdoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ set(sources
3rdparty/zstd/zstdmt_compress.h
3rdparty/stb/stb_image.h
3rdparty/stb/stb_image_write.h
3rdparty/stb/stb_image_resize.h
3rdparty/stb/stb_image_resize2.h
3rdparty/stb/stb_impl.c
3rdparty/stb/stb_truetype.h
3rdparty/tinyexr/tinyexr.cpp
Expand Down Expand Up @@ -417,6 +417,12 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR APPLE)

set_property(SOURCE strings/utf8printf.cpp
APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-unknown-warning -Wno-format-truncation")

# stb_image requires these flags to enable ARM SIMD (NEON) for arm32
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set_source_files_properties(3rdparty/stb/stb_impl.c
PROPERTIES COMPILE_FLAGS "-mfpu=neon-vfpv4 -mfp16-format=ieee")
endif()
endif()

# Need to add -Wno-unknown-warning-option since only newer clang versions have
Expand All @@ -438,6 +444,12 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR APPLE)
# We are deliberately testing self-assign here
set_source_files_properties(replay/basic_types_tests.cpp
PROPERTIES COMPILE_FLAGS "-Wno-unknown-warning-option -Wno-self-assign-overloaded")

# stb_image requires these flags to enable ARM SIMD (NEON) for arm32
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set_source_files_properties(3rdparty/stb/stb_impl.c
PROPERTIES COMPILE_FLAGS "-mfpu=neon-vfpv4")
endif()
endif()
endif()

Expand Down
5 changes: 3 additions & 2 deletions renderdoc/os/win32/win32_shellext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
#include "maths/formatpacking.h"
#include "maths/half_convert.h"
#include "serialise/rdcfile.h"
#include "stb/stb_image_resize.h"

#include "stb/stb_image_resize2.h"

// {5D6BF029-A6BA-417A-8523-120492B1DCE3}
static const GUID CLSID_RDCThumbnailProvider = {0x5d6bf029,
Expand Down Expand Up @@ -625,7 +626,7 @@ struct RDCThumbnailProvider : public IThumbnailProvider, IInitializeWithStream
byte *resizedpixels = (byte *)malloc(3 * bi.bV5Width * bi.bV5Height);

stbir_resize_uint8_srgb(thumbpixels, thumbwidth, thumbheight, 0, resizedpixels, bi.bV5Width,
bi.bV5Height, 0, 3, -1, 0);
bi.bV5Height, 0, STBIR_RGB);

free(thumbpixels);

Expand Down
2 changes: 1 addition & 1 deletion renderdoc/renderdoc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<ClInclude Include="3rdparty\pugixml\pugiconfig.hpp" />
<ClInclude Include="3rdparty\pugixml\pugixml.hpp" />
<ClInclude Include="3rdparty\stb\stb_image.h" />
<ClInclude Include="3rdparty\stb\stb_image_resize.h" />
<ClInclude Include="3rdparty\stb\stb_image_resize2.h" />
<ClInclude Include="3rdparty\stb\stb_image_write.h" />
<ClInclude Include="3rdparty\stb\stb_truetype.h" />
<ClInclude Include="3rdparty\superluminal\PerformanceAPI_capi.h" />
Expand Down
2 changes: 1 addition & 1 deletion renderdoc/renderdoc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
<ClInclude Include="3rdparty\plthook\plthook.h">
<Filter>3rdparty\plthook</Filter>
</ClInclude>
<ClInclude Include="3rdparty\stb\stb_image_resize.h">
<ClInclude Include="3rdparty\stb\stb_image_resize2.h">
<Filter>3rdparty\stb</Filter>
</ClInclude>
<ClInclude Include="api\replay\version.h">
Expand Down
4 changes: 2 additions & 2 deletions renderdoc/replay/capture_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "serialise/rdcfile.h"
#include "serialise/serialiser.h"
#include "stb/stb_image.h"
#include "stb/stb_image_resize.h"
#include "stb/stb_image_resize2.h"
#include "stb/stb_image_write.h"

static void writeToBytebuf(void *context, void *data, int size)
Expand Down Expand Up @@ -624,7 +624,7 @@ Thumbnail CaptureFile::GetThumbnail(FileType type, uint32_t maxsize)
byte *resizedpixels = (byte *)malloc(3 * clampedWidth * clampedHeight);

stbir_resize_uint8_srgb(thumbpixels, thumbwidth, thumbheight, 0, resizedpixels,
clampedWidth, clampedHeight, 0, 3, -1, 0);
clampedWidth, clampedHeight, 0, STBIR_RGB);

free(allocatedBuffer);

Expand Down

0 comments on commit bcb7dfd

Please sign in to comment.