summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/variant/variant_call.cpp29
-rw-r--r--drivers/vulkan/vulkan_context.cpp2
-rw-r--r--drivers/vulkan/vulkan_context.h1
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp12
-rw-r--r--main/main.cpp4
-rw-r--r--thirdparty/README.md2
-rw-r--r--thirdparty/nanosvg/nanosvg.h81
7 files changed, 59 insertions, 72 deletions
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 49a8fac80a..f6fe642493 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -123,6 +123,31 @@ static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...) const, void *p_bas
}
template <class R, class T, class... P>
+static _FORCE_INLINE_ void vc_change_return_type(R (T::*method)(P...), Variant *v) {
+ TypeAdjust<R>::adjust(v);
+}
+
+template <class R, class T, class... P>
+static _FORCE_INLINE_ void vc_change_return_type(R (T::*method)(P...) const, Variant *v) {
+ TypeAdjust<R>::adjust(v);
+}
+
+template <class T, class... P>
+static _FORCE_INLINE_ void vc_change_return_type(void (T::*method)(P...), Variant *v) {
+ VariantInternal::clear(v);
+}
+
+template <class T, class... P>
+static _FORCE_INLINE_ void vc_change_return_type(void (T::*method)(P...) const, Variant *v) {
+ VariantInternal::clear(v);
+}
+
+template <class R, class... P>
+static _FORCE_INLINE_ void vc_change_return_type(R (*method)(P...), Variant *v) {
+ TypeAdjust<R>::adjust(v);
+}
+
+template <class R, class T, class... P>
static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...)) {
return sizeof...(P);
}
@@ -258,7 +283,7 @@ static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) con
vc_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \
} \
static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
- TypeAdjust<m_class>::adjust(r_ret); \
+ vc_change_return_type(m_method_ptr, r_ret); \
vc_validated_call(m_method_ptr, base, p_args, r_ret); \
} \
static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
@@ -301,7 +326,7 @@ static _FORCE_INLINE_ void vc_ptrcall(R (*method)(T *, P...), void *p_base, cons
call_with_variant_args_retc_static_helper_dv(VariantGetInternalPtr<m_class>::get_ptr(base), m_method_ptr, p_args, p_argcount, r_ret, p_defvals, r_error); \
} \
static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
- TypeAdjust<m_class>::adjust(r_ret); \
+ vc_change_return_type(m_method_ptr, r_ret); \
call_with_validated_variant_args_static_retc(base, m_method_ptr, p_args, r_ret); \
} \
static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index f56507532b..ecf9dac61b 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -302,7 +302,7 @@ Error VulkanContext::_create_physical_device() {
/*flags*/ 0,
/*pApplicationInfo*/ &app,
/*enabledLayerCount*/ enabled_layer_count,
- /*ppEnabledLayerNames*/ (const char *const *)instance_validation_layers,
+ /*ppEnabledLayerNames*/ (const char *const *)enabled_layers,
/*enabledExtensionCount*/ enabled_extension_count,
/*ppEnabledExtensionNames*/ (const char *const *)extension_names,
};
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h
index 26d4b76e86..62b97a7e60 100644
--- a/drivers/vulkan/vulkan_context.h
+++ b/drivers/vulkan/vulkan_context.h
@@ -120,7 +120,6 @@ class VulkanContext {
uint32_t enabled_extension_count = 0;
const char *extension_names[MAX_EXTENSIONS];
- const char **instance_validation_layers = nullptr;
uint32_t enabled_layer_count = 0;
const char *enabled_layers[MAX_LAYERS];
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 266df78949..0c860a8965 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1304,12 +1304,14 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
String uri = d["uri"];
if (uri.begins_with("data:")) { // Embedded data using base64.
- // Validate data MIME types and throw an error if it's one we don't know/support.
+ // Validate data MIME types and throw a warning if it's one we don't know/support.
if (!uri.begins_with("data:application/octet-stream;base64") &&
!uri.begins_with("data:application/gltf-buffer;base64") &&
!uri.begins_with("data:image/png;base64") &&
!uri.begins_with("data:image/jpeg;base64")) {
- ERR_PRINT("glTF: Got image data with an unknown URI data type: " + uri);
+ WARN_PRINT(vformat("glTF: Image index '%d' uses an unsupported URI data type: %s. Skipping it.", i, uri));
+ state.images.push_back(Ref<Texture2D>()); // Placeholder to keep count.
+ continue;
}
data = _parse_base64_uri(uri);
data_ptr = data.ptr();
@@ -1344,7 +1346,8 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
}
} else if (d.has("bufferView")) {
// Handles the third bullet point from the spec (bufferView).
- ERR_FAIL_COND_V_MSG(mimetype.empty(), ERR_FILE_CORRUPT, "glTF: Image specifies 'bufferView' but no 'mimeType', which is invalid.");
+ ERR_FAIL_COND_V_MSG(mimetype.empty(), ERR_FILE_CORRUPT,
+ vformat("glTF: Image index '%d' specifies 'bufferView' but no 'mimeType', which is invalid.", i));
const GLTFBufferViewIndex bvi = d["bufferView"];
@@ -1381,7 +1384,8 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
}
}
- ERR_FAIL_COND_V_MSG(img.is_null(), ERR_FILE_CORRUPT, "glTF: Couldn't load image with its given mimetype: " + mimetype);
+ ERR_FAIL_COND_V_MSG(img.is_null(), ERR_FILE_CORRUPT,
+ vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype));
Ref<ImageTexture> t;
t.instance();
diff --git a/main/main.cpp b/main/main.cpp
index 51d2cbfe71..09f16e9d75 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -334,8 +334,8 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n");
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
-#if DEBUG_ENABLED
OS::get_singleton()->print(" --vk-layers Enable Vulkan Validation layers for debugging.\n");
+#if DEBUG_ENABLED
OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
#endif
OS::get_singleton()->print(" --remote-debug <uri> Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).\n");
@@ -698,9 +698,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-w" || I->get() == "--windowed") { // force windowed window
init_windowed = true;
-#ifdef DEBUG_ENABLED
} else if (I->get() == "--vk-layers") {
Engine::singleton->use_validation_layers = true;
+#ifdef DEBUG_ENABLED
} else if (I->get() == "--gpu-abort") {
Engine::singleton->abort_on_gpu_errors = true;
#endif
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 40a0047362..f590acaa0b 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -435,7 +435,7 @@ Collection of single-file libraries used in Godot components.
## nanosvg
- Upstream: https://github.com/memononen/nanosvg
-- Version: git (cc6c08d3a80f1a305021af3d6394cdf1535d02a2, 2020)
+- Version: git (25241c5a8f8451d41ab1b02ab2d865b01600d949, 2019)
- License: zlib
Files extracted from the upstream source:
diff --git a/thirdparty/nanosvg/nanosvg.h b/thirdparty/nanosvg/nanosvg.h
index a110a00a3d..e5f6900614 100644
--- a/thirdparty/nanosvg/nanosvg.h
+++ b/thirdparty/nanosvg/nanosvg.h
@@ -225,6 +225,11 @@ static int nsvg__isdigit(char c)
return c >= '0' && c <= '9';
}
+static int nsvg__isnum(char c)
+{
+ return strchr("0123456789+-.eE", c) != 0;
+}
+
static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
@@ -731,11 +736,9 @@ static void nsvg__lineTo(NSVGparser* p, float x, float y)
static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y)
{
- if (p->npts > 0) {
- nsvg__addPoint(p, cpx1, cpy1);
- nsvg__addPoint(p, cpx2, cpy2);
- nsvg__addPoint(p, x, y);
- }
+ nsvg__addPoint(p, cpx1, cpy1);
+ nsvg__addPoint(p, cpx2, cpy2);
+ nsvg__addPoint(p, x, y);
}
static NSVGattrib* nsvg__getAttr(NSVGparser* p)
@@ -805,9 +808,7 @@ static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig,
static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id)
{
NSVGgradientData* grad = p->gradients;
- if (id == NULL || *id == '\0')
- return NULL;
- while (grad != NULL) {
+ while (grad) {
if (strcmp(grad->id, id) == 0)
return grad;
grad = grad->next;
@@ -824,26 +825,19 @@ static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const f
NSVGgradient* grad;
float ox, oy, sw, sh, sl;
int nstops = 0;
- int refIter;
data = nsvg__findGradientData(p, id);
if (data == NULL) return NULL;
// TODO: use ref to fill in all unset values too.
ref = data;
- refIter = 0;
while (ref != NULL) {
- NSVGgradientData* nextRef = NULL;
if (stops == NULL && ref->stops != NULL) {
stops = ref->stops;
nstops = ref->nstops;
break;
}
- nextRef = nsvg__findGradientData(p, ref->ref);
- if (nextRef == ref) break; // prevent infite loops on malformed data
- ref = nextRef;
- refIter++;
- if (refIter > 32) break; // prevent infite loops on malformed data
+ ref = nsvg__findGradientData(p, ref->ref);
}
if (stops == NULL) return NULL;
@@ -1046,10 +1040,6 @@ static void nsvg__addPath(NSVGparser* p, char closed)
if (closed)
nsvg__lineTo(p, p->pts[0], p->pts[1]);
- // Expect 1 + N*3 points (N = number of cubic bezier segments).
- if ((p->npts % 3) != 1)
- return;
-
path = (NSVGpath*)malloc(sizeof(NSVGpath));
if (path == NULL) goto error;
memset(path, 0, sizeof(NSVGpath));
@@ -1468,15 +1458,6 @@ static int nsvg__parseUnits(const char* units)
return NSVG_UNITS_USER;
}
-static int nsvg__isCoordinate(const char* s)
-{
- // optional sign
- if (*s == '-' || *s == '+')
- s++;
- // must have at least one digit
- return nsvg__isdigit(*s);
-}
-
static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
{
NSVGcoordinate coord = {0, NSVG_UNITS_USER};
@@ -1616,32 +1597,25 @@ static int nsvg__parseRotate(float* xform, const char* str)
static void nsvg__parseTransform(float* xform, const char* str)
{
float t[6];
- int len;
nsvg__xformIdentity(xform);
while (*str)
{
if (strncmp(str, "matrix", 6) == 0)
- len = nsvg__parseMatrix(t, str);
+ str += nsvg__parseMatrix(t, str);
else if (strncmp(str, "translate", 9) == 0)
- len = nsvg__parseTranslate(t, str);
+ str += nsvg__parseTranslate(t, str);
else if (strncmp(str, "scale", 5) == 0)
- len = nsvg__parseScale(t, str);
+ str += nsvg__parseScale(t, str);
else if (strncmp(str, "rotate", 6) == 0)
- len = nsvg__parseRotate(t, str);
+ str += nsvg__parseRotate(t, str);
else if (strncmp(str, "skewX", 5) == 0)
- len = nsvg__parseSkewX(t, str);
+ str += nsvg__parseSkewX(t, str);
else if (strncmp(str, "skewY", 5) == 0)
- len = nsvg__parseSkewY(t, str);
+ str += nsvg__parseSkewY(t, str);
else{
++str;
continue;
}
- if (len != 0) {
- str += len;
- } else {
- ++str;
- continue;
- }
nsvg__xformPremultiply(xform, t);
}
@@ -1902,11 +1876,8 @@ static int nsvg__getArgsPerElement(char cmd)
case 'a':
case 'A':
return 7;
- case 'z':
- case 'Z':
- return 0;
}
- return -1;
+ return 0;
}
static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
@@ -2216,7 +2187,6 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr)
float args[10];
int nargs;
int rargs = 0;
- char initPoint;
float cpx, cpy, cpx2, cpy2;
const char* tmp[4];
char closedFlag;
@@ -2239,14 +2209,13 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr)
nsvg__resetPath(p);
cpx = 0; cpy = 0;
cpx2 = 0; cpy2 = 0;
- initPoint = 0;
closedFlag = 0;
nargs = 0;
while (*s) {
s = nsvg__getNextPathItem(s, item);
if (!*item) break;
- if (cmd != '\0' && nsvg__isCoordinate(item)) {
+ if (nsvg__isnum(item[0])) {
if (nargs < 10)
args[nargs++] = (float)nsvg__atof(item);
if (nargs >= rargs) {
@@ -2259,7 +2228,6 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr)
cmd = (cmd == 'm') ? 'l' : 'L';
rargs = nsvg__getArgsPerElement(cmd);
cpx2 = cpx; cpy2 = cpy;
- initPoint = 1;
break;
case 'l':
case 'L':
@@ -2309,6 +2277,7 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr)
}
} else {
cmd = item[0];
+ rargs = nsvg__getArgsPerElement(cmd);
if (cmd == 'M' || cmd == 'm') {
// Commit path.
if (p->npts > 0)
@@ -2317,11 +2286,7 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr)
nsvg__resetPath(p);
closedFlag = 0;
nargs = 0;
- } else if (initPoint == 0) {
- // Do not allow other commands until initial point has been set (moveTo called once).
- cmd = '\0';
- }
- if (cmd == 'Z' || cmd == 'z') {
+ } else if (cmd == 'Z' || cmd == 'z') {
closedFlag = 1;
// Commit path.
if (p->npts > 0) {
@@ -2337,12 +2302,6 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr)
closedFlag = 0;
nargs = 0;
}
- rargs = nsvg__getArgsPerElement(cmd);
- if (rargs == -1) {
- // Command not recognized
- cmd = '\0';
- rargs = 0;
- }
}
}
// Commit path.