Skip to content

Commit

Permalink
Merge pull request #81375 from akien-mga/3.x-cherrypicks
Browse files Browse the repository at this point in the history
Cherry-picks for the 3.x branch (future 3.6) - 15th batch
  • Loading branch information
akien-mga authored Oct 30, 2023
2 parents fe7ed98 + b4240ea commit 23c142a
Show file tree
Hide file tree
Showing 78 changed files with 1,138 additions and 407 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/javascript_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
# Only used for the cache key. Increment version to force clean build.
GODOT_BASE_BRANCH: 3.x
SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no
EM_VERSION: 3.1.18
EM_VERSION: 3.1.45
EM_CACHE_FOLDER: "emsdk-cache"

concurrency:
Expand All @@ -16,11 +16,11 @@ concurrency:

jobs:
javascript-template:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Emscripten latest
uses: mymindstorm/setup-emsdk@v12
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
artifact: true

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Linux dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/server_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Linux dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent Azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
Expand Down
8 changes: 5 additions & 3 deletions core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,14 +1004,16 @@ void Object::set_script(const RefPtr &p_script) {
return;
}

Ref<Script> s = p_script;
ERR_FAIL_COND_MSG(s.is_null() && !p_script.is_null(), "Invalid parameter, it should be a reference to a valid script (or null).");

script = p_script;

if (script_instance) {
memdelete(script_instance);
script_instance = nullptr;
}

script = p_script;
Ref<Script> s(script);

if (!s.is_null()) {
if (s->can_instance()) {
OBJ_DEBUG_LOCK
Expand Down
211 changes: 163 additions & 48 deletions main/gamecontrollerdb.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,9 @@ def build_commandline(self, commands):
if env["custom_modules"]:
common_build_postfix.append("custom_modules=%s" % env["custom_modules"])

if env["incremental_link"]:
common_build_postfix.append("incremental_link=yes")

result = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)])
return result

Expand Down
9 changes: 8 additions & 1 deletion platform/javascript/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,15 @@ def configure(env):
else:
env.Append(CPPDEFINES=["NO_THREADS"])

# Get version info for checks below.
cc_semver = tuple(get_compiler_version(env))

if env["lto"] != "none":
# Workaround https://github.com/emscripten-core/emscripten/issues/19781.
if cc_semver >= (3, 1, 42) and cc_semver < (3, 1, 46):
env.Append(LINKFLAGS=["-Wl,-u,scalbnf"])

if env["gdnative_enabled"]:
cc_semver = tuple(get_compiler_version(env))
if cc_semver < (2, 0, 10):
print("GDNative support requires emscripten >= 2.0.10, detected: %s.%s.%s" % cc_semver)
sys.exit(255)
Expand Down
6 changes: 4 additions & 2 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_opts():
BoolVariable("use_llvm", "Use the LLVM compiler", False),
BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
BoolVariable("incremental_link", "Use MSVC incremental linking. May increase or decrease build times.", False),
]


Expand Down Expand Up @@ -214,8 +215,9 @@ def configure_msvc(env, manual_msvc_config):
else:
env.AppendUnique(CCFLAGS=["/MD"])

# MSVC incremental linking is broken and _increases_ link time (GH-77968).
env.Append(LINKFLAGS=["/INCREMENTAL:NO"])
# MSVC incremental linking is broken and may _increase_ link time (GH-77968).
if not env["incremental_link"]:
env.Append(LINKFLAGS=["/INCREMENTAL:NO"])

env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ from the Android NDK r18.
## libwebp

- Upstream: https://chromium.googlesource.com/webm/libwebp/
- Version: 1.3.1 (fd7bb21c0cb56e8a82e9bfa376164b842f433f3b, 2023)
- Version: 1.3.2 (ca332209cb5567c9b249c86788cb2dbf8847e760, 2023)
- License: BSD-3-Clause

Files extracted from upstream source:
Expand All @@ -278,7 +278,7 @@ Files extracted from upstream source:
## mbedtls

- Upstream: https://github.com/Mbed-TLS/mbedtls
- Version: 2.28.4 (aeb97a18913a86f051afab11b2c92c6be0c2eb83, 2023)
- Version: 2.28.5 (47e8cc9db2e469d902b0e3093ae9e482c3d87188, 2023)
- License: Apache 2.0

File extracted from upstream release tarball:
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/libwebp/src/dec/vp8i_dec.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {
// version numbers
#define DEC_MAJ_VERSION 1
#define DEC_MIN_VERSION 3
#define DEC_REV_VERSION 1
#define DEC_REV_VERSION 2

// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
// Constraints are: We need to store one 16x16 block of luma samples (y),
Expand Down
46 changes: 25 additions & 21 deletions thirdparty/libwebp/src/dec/vp8l_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ static int ReadHuffmanCodeLengths(
int symbol;
int max_symbol;
int prev_code_len = DEFAULT_CODE_LENGTH;
HuffmanCode table[1 << LENGTHS_TABLE_BITS];
HuffmanTables tables;

if (!VP8LBuildHuffmanTable(table, LENGTHS_TABLE_BITS,
code_length_code_lengths,
NUM_CODE_LENGTH_CODES)) {
if (!VP8LHuffmanTablesAllocate(1 << LENGTHS_TABLE_BITS, &tables) ||
!VP8LBuildHuffmanTable(&tables, LENGTHS_TABLE_BITS,
code_length_code_lengths, NUM_CODE_LENGTH_CODES)) {
goto End;
}

Expand All @@ -277,7 +277,7 @@ static int ReadHuffmanCodeLengths(
int code_len;
if (max_symbol-- == 0) break;
VP8LFillBitWindow(br);
p = &table[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK];
p = &tables.curr_segment->start[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK];
VP8LSetBitPos(br, br->bit_pos_ + p->bits);
code_len = p->value;
if (code_len < kCodeLengthLiterals) {
Expand All @@ -300,14 +300,16 @@ static int ReadHuffmanCodeLengths(
ok = 1;

End:
VP8LHuffmanTablesDeallocate(&tables);
if (!ok) dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
return ok;
}

// 'code_lengths' is pre-allocated temporary buffer, used for creating Huffman
// tree.
static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec,
int* const code_lengths, HuffmanCode* const table) {
int* const code_lengths,
HuffmanTables* const table) {
int ok = 0;
int size = 0;
VP8LBitReader* const br = &dec->br_;
Expand Down Expand Up @@ -362,8 +364,7 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
VP8LMetadata* const hdr = &dec->hdr_;
uint32_t* huffman_image = NULL;
HTreeGroup* htree_groups = NULL;
HuffmanCode* huffman_tables = NULL;
HuffmanCode* huffman_table = NULL;
HuffmanTables* huffman_tables = &hdr->huffman_tables_;
int num_htree_groups = 1;
int num_htree_groups_max = 1;
int max_alphabet_size = 0;
Expand All @@ -372,6 +373,10 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
int* mapping = NULL;
int ok = 0;

// Check the table has been 0 initialized (through InitMetadata).
assert(huffman_tables->root.start == NULL);
assert(huffman_tables->curr_segment == NULL);

if (allow_recursion && VP8LReadBits(br, 1)) {
// use meta Huffman codes.
const int huffman_precision = VP8LReadBits(br, 3) + 2;
Expand Down Expand Up @@ -434,16 +439,15 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,

code_lengths = (int*)WebPSafeCalloc((uint64_t)max_alphabet_size,
sizeof(*code_lengths));
huffman_tables = (HuffmanCode*)WebPSafeMalloc(num_htree_groups * table_size,
sizeof(*huffman_tables));
htree_groups = VP8LHtreeGroupsNew(num_htree_groups);

if (htree_groups == NULL || code_lengths == NULL || huffman_tables == NULL) {
if (htree_groups == NULL || code_lengths == NULL ||
!VP8LHuffmanTablesAllocate(num_htree_groups * table_size,
huffman_tables)) {
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
goto Error;
}

huffman_table = huffman_tables;
for (i = 0; i < num_htree_groups_max; ++i) {
// If the index "i" is unused in the Huffman image, just make sure the
// coefficients are valid but do not store them.
Expand All @@ -468,19 +472,20 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
int max_bits = 0;
for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
int alphabet_size = kAlphabetSize[j];
htrees[j] = huffman_table;
if (j == 0 && color_cache_bits > 0) {
alphabet_size += (1 << color_cache_bits);
}
size = ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_table);
size =
ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_tables);
htrees[j] = huffman_tables->curr_segment->curr_table;
if (size == 0) {
goto Error;
}
if (is_trivial_literal && kLiteralMap[j] == 1) {
is_trivial_literal = (huffman_table->bits == 0);
is_trivial_literal = (htrees[j]->bits == 0);
}
total_size += huffman_table->bits;
huffman_table += size;
total_size += htrees[j]->bits;
huffman_tables->curr_segment->curr_table += size;
if (j <= ALPHA) {
int local_max_bits = code_lengths[0];
int k;
Expand Down Expand Up @@ -515,14 +520,13 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
hdr->huffman_image_ = huffman_image;
hdr->num_htree_groups_ = num_htree_groups;
hdr->htree_groups_ = htree_groups;
hdr->huffman_tables_ = huffman_tables;

Error:
WebPSafeFree(code_lengths);
WebPSafeFree(mapping);
if (!ok) {
WebPSafeFree(huffman_image);
WebPSafeFree(huffman_tables);
VP8LHuffmanTablesDeallocate(huffman_tables);
VP8LHtreeGroupsFree(htree_groups);
}
return ok;
Expand Down Expand Up @@ -1358,7 +1362,7 @@ static void ClearMetadata(VP8LMetadata* const hdr) {
assert(hdr != NULL);

WebPSafeFree(hdr->huffman_image_);
WebPSafeFree(hdr->huffman_tables_);
VP8LHuffmanTablesDeallocate(&hdr->huffman_tables_);
VP8LHtreeGroupsFree(hdr->htree_groups_);
VP8LColorCacheClear(&hdr->color_cache_);
VP8LColorCacheClear(&hdr->saved_color_cache_);
Expand Down Expand Up @@ -1673,7 +1677,7 @@ int VP8LDecodeImage(VP8LDecoder* const dec) {

if (dec == NULL) return 0;

assert(dec->hdr_.huffman_tables_ != NULL);
assert(dec->hdr_.huffman_tables_.root.start != NULL);
assert(dec->hdr_.htree_groups_ != NULL);
assert(dec->hdr_.num_htree_groups_ > 0);

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/libwebp/src/dec/vp8li_dec.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct {
uint32_t* huffman_image_;
int num_htree_groups_;
HTreeGroup* htree_groups_;
HuffmanCode* huffman_tables_;
HuffmanTables huffman_tables_;
} VP8LMetadata;

typedef struct VP8LDecoder VP8LDecoder;
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/libwebp/src/demux/demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define DMUX_MAJ_VERSION 1
#define DMUX_MIN_VERSION 3
#define DMUX_REV_VERSION 1
#define DMUX_REV_VERSION 2

typedef struct {
size_t start_; // start location of the data
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/libwebp/src/enc/vp8i_enc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {
// version numbers
#define ENC_MAJ_VERSION 1
#define ENC_MIN_VERSION 3
#define ENC_REV_VERSION 1
#define ENC_REV_VERSION 2

enum { MAX_LF_LEVELS = 64, // Maximum loop filter level
MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/libwebp/src/mux/muxi.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {

#define MUX_MAJ_VERSION 1
#define MUX_MIN_VERSION 3
#define MUX_REV_VERSION 1
#define MUX_REV_VERSION 2

// Chunk object.
typedef struct WebPChunk WebPChunk;
Expand Down
Loading

0 comments on commit 23c142a

Please sign in to comment.