Merge pull request #55354 from Faless/js/3.x_no_asm_old_emcc
[HTML5] Use compatibility function for glGetBufferSubData.
This commit is contained in:
commit
eb19618fd1
6 changed files with 91 additions and 5 deletions
|
@ -45,11 +45,6 @@
|
||||||
#include "shaders/cubemap_filter.glsl.gen.h"
|
#include "shaders/cubemap_filter.glsl.gen.h"
|
||||||
#include "shaders/particles.glsl.gen.h"
|
#include "shaders/particles.glsl.gen.h"
|
||||||
|
|
||||||
// WebGL 2.0 has no MapBufferRange/UnmapBuffer, but offers a non-ES style BufferSubData API via glGetBufferSubData instead.
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
#include <webgl/webgl2.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
class ThreadedCallableQueue;
|
class ThreadedCallableQueue;
|
||||||
class RasterizerCanvasGLES3;
|
class RasterizerCanvasGLES3;
|
||||||
|
|
|
@ -4,6 +4,7 @@ Import("env")
|
||||||
|
|
||||||
javascript_files = [
|
javascript_files = [
|
||||||
"audio_driver_javascript.cpp",
|
"audio_driver_javascript.cpp",
|
||||||
|
"godot_webgl2.cpp",
|
||||||
"http_client_javascript.cpp",
|
"http_client_javascript.cpp",
|
||||||
"javascript_singleton.cpp",
|
"javascript_singleton.cpp",
|
||||||
"javascript_main.cpp",
|
"javascript_main.cpp",
|
||||||
|
|
39
platform/javascript/godot_webgl2.cpp
Normal file
39
platform/javascript/godot_webgl2.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*************************************************************************/
|
||||||
|
/* godot_webgl2.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
#include "godot_webgl2.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern void godot_js_display_glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) {
|
||||||
|
godot_js_display_glGetBufferSubData(target, offset, size, data);
|
||||||
|
}
|
37
platform/javascript/godot_webgl2.h
Normal file
37
platform/javascript/godot_webgl2.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*************************************************************************/
|
||||||
|
/* godot_webgl2.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GODOT_WEBGL2_H
|
||||||
|
#include "GLES3/gl3.h"
|
||||||
|
|
||||||
|
// We could include "webgl/webgl2.h", but old (< 2.0.17) emscripten versions do not have it, so use our own wrapper instead.
|
||||||
|
void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
|
||||||
|
|
||||||
|
#endif
|
|
@ -320,6 +320,18 @@ const GodotDisplay = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// This is implemented as "glGetBufferSubData" in new emscripten versions.
|
||||||
|
// Since we have to support older (pre 2.0.17) emscripten versions, we add this wrapper function instead.
|
||||||
|
godot_js_display_glGetBufferSubData__sig: 'viiii',
|
||||||
|
godot_js_display_glGetBufferSubData__deps: ['$GL', 'emscripten_webgl_get_current_context'],
|
||||||
|
godot_js_display_glGetBufferSubData: function (target, offset, size, data) {
|
||||||
|
const gl_context_handle = _emscripten_webgl_get_current_context(); // eslint-disable-line no-undef
|
||||||
|
const gl = GL.getContext(gl_context_handle);
|
||||||
|
if (gl) {
|
||||||
|
gl.GLctx['getBufferSubData'](target, offset, HEAPU8, data, size);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
godot_js_display_is_swap_ok_cancel__sig: 'i',
|
godot_js_display_is_swap_ok_cancel__sig: 'i',
|
||||||
godot_js_display_is_swap_ok_cancel: function () {
|
godot_js_display_is_swap_ok_cancel: function () {
|
||||||
const win = (['Windows', 'Win64', 'Win32', 'WinCE']);
|
const win = (['Windows', 'Win64', 'Win32', 'WinCE']);
|
||||||
|
|
|
@ -29,3 +29,5 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
|
||||||
|
#define GLES3_INCLUDE_H "platform/javascript/godot_webgl2.h"
|
||||||
|
|
Loading…
Reference in a new issue