Skip to content

Commit 38f9ad8

Browse files
authored
Update EMSCRIPTEN_WEBGL_CONTEXT_HANDLE to handle full pointer range (#21281)
In particular this changes the return type of `emscripten_webgl_create_context` such that negative values can no longer be returned. This allows pointers (specifically 32-bit pointers over 2gb) to be returned which is needed for pthread builds. The only valid failure return code for `emscripten_webgl_create_context` is now 0/NULL. As it happens this function never fails with anything except 0 so this should not be an impactful change. Split out from #21268 Fixes: #21278
1 parent 21f2533 commit 38f9ad8

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ jobs:
816816
browser_2gb.test_emscripten_animate_canvas_element_size_manual_css
817817
browser_2gb.test_fulles2_sdlproc
818818
browser_2gb.test_cubegeom*
819+
browser_2gb.test_html5_webgl_create_context*
819820
"
820821
test-browser-chrome-wasm64-4gb:
821822
executor: bionic
@@ -831,6 +832,7 @@ jobs:
831832
browser64_4gb.test_fetch*
832833
browser64_4gb.test_emscripten_animate_canvas_element_size_manual_css
833834
browser64_4gb.test_fulles2_sdlproc
835+
browser64_4gb.test_html5_webgl_create_context*
834836
"
835837
test-browser-firefox:
836838
executor: bionic

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.54 (in development)
2222
-----------------------
23+
- The type of `EMSCRIPTEN_WEBGL_CONTEXT_HANDLE` was changed to unsigned and
24+
the only valid error returned from `emscripten_webgl_create_context` is
25+
now zero. This allows `EMSCRIPTEN_WEBGL_CONTEXT_HANDLE` to hold a pointer
26+
to memory even in 2GB+ mode. Since `emscripten_webgl_create_context` never
27+
returns anything except zero for its errors today this change should not
28+
require any action. (#21268)
2329
- Added `--use-port` option to `emcc`. This option allows ports to be enabled
2430
by name and is designed to replace all existing `-sUSE_XXX` settings for
2531
ports. You can use `--show-ports` to get the list of available ports that

site/source/docs/api_reference/html5.h.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ Functions
20862086
:type target: const char*
20872087
:param attributes: The attributes of the requested context version.
20882088
:type attributes: const EmscriptenWebGLContextAttributes*
2089-
:returns: On success, a strictly positive value that represents a handle to the created context. On failure, a negative number that can be cast to an |EMSCRIPTEN_RESULT| field to get the reason why the context creation failed.
2089+
:returns: On success, a non-zero value that represents a handle to the created context. On failure, 0.
20902090
:rtype: |EMSCRIPTEN_WEBGL_CONTEXT_HANDLE|
20912091
20922092

system/include/emscripten/html5_webgl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
extern "C" {
1515
#endif
1616

17-
typedef intptr_t EMSCRIPTEN_WEBGL_CONTEXT_HANDLE;
17+
typedef uintptr_t EMSCRIPTEN_WEBGL_CONTEXT_HANDLE;
1818

1919
typedef int EMSCRIPTEN_WEBGL_CONTEXT_PROXY_MODE;
2020
#define EMSCRIPTEN_WEBGL_CONTEXT_PROXY_DISALLOW 0

0 commit comments

Comments
 (0)