CPU lightmapper fixes.
- Fix Embree runtime when using MinGW (patch by @RandomShaper). - Fix baking of lightmaps on GridMaps. - Fix some GLSL errors. - Fix overflow in the number of shader variants (GLES2).
This commit is contained in:
parent
d909592fc5
commit
b1ca82c43a
30 changed files with 217 additions and 57 deletions
|
@ -1182,7 +1182,7 @@
|
|||
Lower-end override for [member rendering/quality/intended_usage/framebuffer_allocation] on mobile devices, due to performance concerns or driver support.
|
||||
</member>
|
||||
<member name="rendering/quality/lightmapping/use_bicubic_sampling" type="bool" setter="" getter="" default="true">
|
||||
Enable usage of bicubic sampling in baked lightmaps. This results in smoother looking lighting at the expense of more bandwidth usage.
|
||||
Enable usage of bicubic sampling in baked lightmaps. This results in smoother looking lighting at the expense of more bandwidth usage. On GLES2, changes to this setting will only be applied upon restarting the application.
|
||||
</member>
|
||||
<member name="rendering/quality/lightmapping/use_bicubic_sampling.mobile" type="bool" setter="" getter="" default="false">
|
||||
Lower-end override for [member rendering/quality/lightmapping/use_bicubic_sampling] on mobile devices, in order to reduce bandwidth usage.
|
||||
|
|
|
@ -4050,14 +4050,16 @@ void RasterizerSceneGLES2::initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
if (storage->config.use_lightmap_filter_bicubic) {
|
||||
state.scene_shader.add_custom_define("#define USE_LIGHTMAP_FILTER_BICUBIC\n");
|
||||
}
|
||||
|
||||
shadow_filter_mode = SHADOW_FILTER_NEAREST;
|
||||
|
||||
glFrontFace(GL_CW);
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::iteration() {
|
||||
storage->config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling");
|
||||
state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP_FILTER_BICUBIC, storage->config.use_lightmap_filter_bicubic);
|
||||
shadow_filter_mode = ShadowFilterMode(int(GLOBAL_GET("rendering/quality/shadows/filter_mode")));
|
||||
}
|
||||
|
||||
|
|
|
@ -6299,6 +6299,8 @@ void RasterizerStorageGLES2::initialize() {
|
|||
|
||||
config.force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading");
|
||||
config.use_fast_texture_filter = GLOBAL_GET("rendering/quality/filters/use_nearest_mipmap_filter");
|
||||
GLOBAL_DEF_RST("rendering/quality/lightmapping/use_bicubic_sampling", true);
|
||||
GLOBAL_DEF_RST("rendering/quality/lightmapping/use_bicubic_sampling.mobile", false);
|
||||
config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling");
|
||||
}
|
||||
|
||||
|
|
|
@ -98,4 +98,4 @@ public:
|
|||
ShaderCompilerGLES2();
|
||||
};
|
||||
|
||||
#endif // SHADERCOMPILERGLES3_H
|
||||
#endif // SHADERCOMPILERGLES2_H
|
||||
|
|
|
@ -890,7 +890,7 @@ void reflection_process(samplerCube reflection_map,
|
|||
uniform mediump sampler2D lightmap; //texunit:-4
|
||||
uniform mediump float lightmap_energy;
|
||||
|
||||
#ifdef USE_LIGHTMAP_FILTER_BICUBIC
|
||||
#if defined(USE_LIGHTMAP_FILTER_BICUBIC)
|
||||
uniform mediump vec2 lightmap_texture_size;
|
||||
|
||||
// w0, w1, w2, and w3 are the four cubic B-spline basis functions
|
||||
|
@ -951,11 +951,6 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) {
|
|||
return (g0(fuv.y) * (g0x * texture2D(tex, p0) + g1x * texture2D(tex, p1))) +
|
||||
(g1(fuv.y) * (g0x * texture2D(tex, p2) + g1x * texture2D(tex, p3)));
|
||||
}
|
||||
#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D_bicubic(m_tex, m_uv)
|
||||
|
||||
#else //!USE_LIGHTMAP_FILTER_BICUBIC
|
||||
#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D(m_tex, m_uv)
|
||||
|
||||
#endif //USE_LIGHTMAP_FILTER_BICUBIC
|
||||
#endif
|
||||
|
||||
|
@ -1728,8 +1723,12 @@ FRAGMENT_SHADER_CODE
|
|||
}
|
||||
|
||||
#ifdef USE_LIGHTMAP
|
||||
//ambient light will come entirely from lightmap is lightmap is used
|
||||
ambient_light = LIGHTMAP_TEXTURE_SAMPLE(lightmap, uv2_interp).rgb * lightmap_energy;
|
||||
//ambient light will come entirely from lightmap is lightmap is used
|
||||
#if defined(USE_LIGHTMAP_FILTER_BICUBIC)
|
||||
ambient_light = texture2D_bicubic(lightmap, uv2_interp).rgb * lightmap_energy;
|
||||
#else
|
||||
ambient_light = texture2D(lightmap, uv2_interp).rgb * lightmap_energy;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_LIGHTMAP_CAPTURE
|
||||
|
|
|
@ -8555,6 +8555,8 @@ void RasterizerStorageGLES3::initialize() {
|
|||
|
||||
String renderer = (const char *)glGetString(GL_RENDERER);
|
||||
|
||||
GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling", true);
|
||||
GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling.mobile", false);
|
||||
config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling");
|
||||
|
||||
config.use_depth_prepass = bool(GLOBAL_GET("rendering/quality/depth_prepass/enable"));
|
||||
|
|
|
@ -1488,7 +1488,7 @@ float h1(float a) {
|
|||
return 1.0 + w3(a) / (w2(a) + w3(a));
|
||||
}
|
||||
|
||||
vec4 texture2D_bicubic(sampler2D tex, vec2 uv) {
|
||||
vec4 texture_bicubic(sampler2D tex, vec2 uv) {
|
||||
vec2 texel_size = vec2(1.0) / lightmap_texture_size;
|
||||
|
||||
uv = uv * lightmap_texture_size + vec2(0.5);
|
||||
|
@ -1508,11 +1508,11 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) {
|
|||
vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * texel_size;
|
||||
vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * texel_size;
|
||||
|
||||
return (g0(fuv.y) * (g0x * texture2D(tex, p0) + g1x * texture2D(tex, p1))) +
|
||||
(g1(fuv.y) * (g0x * texture2D(tex, p2) + g1x * texture2D(tex, p3)));
|
||||
return (g0(fuv.y) * (g0x * texture(tex, p0) + g1x * texture(tex, p1))) +
|
||||
(g1(fuv.y) * (g0x * texture(tex, p2) + g1x * texture(tex, p3)));
|
||||
}
|
||||
|
||||
vec4 texture_bicubic(sampler2DArray tex, vec3 uv) {
|
||||
vec4 textureArray_bicubic(sampler2DArray tex, vec3 uv) {
|
||||
vec2 texel_size = vec2(1.0) / lightmap_texture_size;
|
||||
|
||||
uv.xy = uv.xy * lightmap_texture_size + vec2(0.5);
|
||||
|
@ -1536,11 +1536,11 @@ vec4 texture_bicubic(sampler2DArray tex, vec3 uv) {
|
|||
(g1(fuv.y) * (g0x * texture(tex, vec3(p2, uv.z)) + g1x * texture(tex, vec3(p3, uv.z))));
|
||||
}
|
||||
|
||||
#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D_bicubic(m_tex, m_uv)
|
||||
#define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) texture_bicubic(m_tex, m_uv)
|
||||
#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture_bicubic(m_tex, m_uv)
|
||||
#define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) textureArray_bicubic(m_tex, m_uv)
|
||||
|
||||
#else //!USE_LIGHTMAP_FILTER_BICUBIC
|
||||
#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D(m_tex, m_uv)
|
||||
#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture(m_tex, m_uv)
|
||||
#define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) texture(m_tex, m_uv)
|
||||
|
||||
#endif //USE_LIGHTMAP_FILTER_BICUBIC
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -370,6 +370,13 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
|
|||
Array bmeshes = p_at_node->call("get_bake_meshes");
|
||||
if (bmeshes.size() && (bmeshes.size() & 1) == 0) {
|
||||
Transform xf = get_global_transform().affine_inverse() * s->get_global_transform();
|
||||
Ref<Material> all_override;
|
||||
|
||||
GeometryInstance *gi = Object::cast_to<GeometryInstance>(p_at_node);
|
||||
if (gi) {
|
||||
all_override = mi->get_material_override();
|
||||
}
|
||||
|
||||
for (int i = 0; i < bmeshes.size(); i += 2) {
|
||||
Ref<Mesh> mesh = bmeshes[i];
|
||||
if (!mesh.is_valid()) {
|
||||
|
@ -385,6 +392,18 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
|
|||
mf.lightmap_scale = 1;
|
||||
mf.mesh = mesh;
|
||||
|
||||
if (gi) {
|
||||
mf.cast_shadows = mi->get_cast_shadows_setting() != GeometryInstance::SHADOW_CASTING_SETTING_OFF;
|
||||
mf.generate_lightmap = mi->get_generate_lightmap();
|
||||
} else {
|
||||
mf.cast_shadows = true;
|
||||
mf.generate_lightmap = true;
|
||||
}
|
||||
|
||||
for (int j = 0; j < mesh->get_surface_count(); j++) {
|
||||
mf.overrides.push_back(all_override);
|
||||
}
|
||||
|
||||
meshes.push_back(mf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
|
|
@ -2446,9 +2446,6 @@ VisualServer::VisualServer() {
|
|||
GLOBAL_DEF(sz_balance_render_tree, 0.0f);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info(sz_balance_render_tree, PropertyInfo(Variant::REAL, sz_balance_render_tree, PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
|
||||
|
||||
GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling", true);
|
||||
GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling.mobile", false);
|
||||
|
||||
GLOBAL_DEF("rendering/quality/2d/use_software_skinning", true);
|
||||
GLOBAL_DEF("rendering/quality/2d/ninepatch_mode", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/quality/2d/ninepatch_mode", PROPERTY_HINT_ENUM, "Default,Scaling"));
|
||||
|
|
14
thirdparty/embree/common/sys/intrinsics.h
vendored
14
thirdparty/embree/common/sys/intrinsics.h
vendored
|
@ -11,6 +11,12 @@
|
|||
|
||||
#include <immintrin.h>
|
||||
|
||||
// -- GODOT start --
|
||||
#if defined(__WIN32__) && defined(__MINGW32__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
|
||||
#if defined(__BMI__) && defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
||||
#if !defined(_tzcnt_u32)
|
||||
#define _tzcnt_u32 __tzcnt_u32
|
||||
|
@ -419,8 +425,16 @@ namespace embree
|
|||
|
||||
__forceinline void pause_cpu(const size_t N = 8)
|
||||
{
|
||||
// -- GODOT start --
|
||||
for (size_t i=0; i<N; i++)
|
||||
#if !(defined(__WIN32__) && defined(__MINGW32__))
|
||||
// -- GODOT end --
|
||||
_mm_pause();
|
||||
// -- GODOT start --
|
||||
#else
|
||||
usleep(1);
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
}
|
||||
|
||||
/* prefetches */
|
||||
|
|
16
thirdparty/embree/common/sys/mutex.h
vendored
16
thirdparty/embree/common/sys/mutex.h
vendored
|
@ -47,8 +47,16 @@ namespace embree
|
|||
{
|
||||
while (flag.load())
|
||||
{
|
||||
// -- GODOT start --
|
||||
#if !(defined (__WIN32__) && defined (__MINGW32__))
|
||||
// -- GODOT end --
|
||||
_mm_pause();
|
||||
_mm_pause();
|
||||
// -- GODOT start --
|
||||
#else
|
||||
usleep(1);
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
}
|
||||
|
||||
bool expected = false;
|
||||
|
@ -74,8 +82,16 @@ namespace embree
|
|||
{
|
||||
while(flag.load())
|
||||
{
|
||||
// -- GODOT start --
|
||||
#if !(defined (__WIN32__) && defined(__MINGW32__))
|
||||
// -- GODOT end --
|
||||
_mm_pause();
|
||||
_mm_pause();
|
||||
// -- GODOT start --
|
||||
#else
|
||||
usleep(1);
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
thirdparty/embree/common/sys/sysinfo.cpp
vendored
2
thirdparty/embree/common/sys/sysinfo.cpp
vendored
|
@ -233,7 +233,7 @@ namespace embree
|
|||
|
||||
__noinline int64_t get_xcr0()
|
||||
{
|
||||
#if defined (__WIN32__)
|
||||
#if defined (__WIN32__) /* -- GODOT start -- */ && !defined (__MINGW32__) /* -- GODOT end -- */
|
||||
int64_t xcr0 = 0; // int64_t is workaround for compiler bug under VS2013, Win32
|
||||
xcr0 = _xgetbv(0);
|
||||
return xcr0;
|
||||
|
|
|
@ -361,7 +361,15 @@ namespace embree
|
|||
if ((loopIndex % LOOP_YIELD_THRESHOLD) == 0)
|
||||
yield();
|
||||
else
|
||||
// -- GODOT start --
|
||||
#if !defined(__MINGW32__)
|
||||
// -- GODOT end --
|
||||
_mm_pause();
|
||||
// -- GODOT start --
|
||||
#else
|
||||
usleep(1);
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
loopIndex++;
|
||||
#else
|
||||
yield();
|
||||
|
|
105
thirdparty/embree/pathces/godot-changes.patch
vendored
105
thirdparty/embree/pathces/godot-changes.patch
vendored
|
@ -12,10 +12,23 @@ index 5af0691a2..1982c27c1 100644
|
|||
namespace std
|
||||
{
|
||||
diff --git a/common/sys/intrinsics.h b/common/sys/intrinsics.h
|
||||
index 3f0619cac..6948e4a74 100644
|
||||
index 3f0619cac..58f5c3bb4 100644
|
||||
--- a/common/sys/intrinsics.h
|
||||
+++ b/common/sys/intrinsics.h
|
||||
@@ -30,8 +30,14 @@
|
||||
@@ -11,6 +11,12 @@
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
+// -- GODOT start --
|
||||
+#if defined(__WIN32__) && defined(__MINGW32__)
|
||||
+#include <unistd.h>
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
+
|
||||
#if defined(__BMI__) && defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
||||
#if !defined(_tzcnt_u32)
|
||||
#define _tzcnt_u32 __tzcnt_u32
|
||||
@@ -30,8 +36,14 @@
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
|
@ -32,6 +45,23 @@ index 3f0619cac..6948e4a74 100644
|
|||
#endif
|
||||
|
||||
/* normally defined in pmmintrin.h, but we always need this */
|
||||
@@ -413,8 +425,16 @@ namespace embree
|
||||
|
||||
__forceinline void pause_cpu(const size_t N = 8)
|
||||
{
|
||||
+// -- GODOT start --
|
||||
for (size_t i=0; i<N; i++)
|
||||
+#if !(defined(__WIN32__) && defined(__MINGW32__))
|
||||
+// -- GODOT end --
|
||||
_mm_pause();
|
||||
+// -- GODOT start --
|
||||
+#else
|
||||
+ usleep(1);
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
}
|
||||
|
||||
/* prefetches */
|
||||
diff --git a/common/sys/library.cpp b/common/sys/library.cpp
|
||||
index e448b195d..8ec918660 100644
|
||||
--- a/common/sys/library.cpp
|
||||
|
@ -47,6 +77,44 @@ index e448b195d..8ec918660 100644
|
|||
}
|
||||
|
||||
/* closes the shared library */
|
||||
diff --git a/common/sys/mutex.h b/common/sys/mutex.h
|
||||
index 1164210f2..f0f55340a 100644
|
||||
--- a/common/sys/mutex.h
|
||||
+++ b/common/sys/mutex.h
|
||||
@@ -47,8 +47,16 @@ namespace embree
|
||||
{
|
||||
while (flag.load())
|
||||
{
|
||||
+// -- GODOT start --
|
||||
+#if !(defined (__WIN32__) && defined (__MINGW32__))
|
||||
+// -- GODOT end --
|
||||
_mm_pause();
|
||||
_mm_pause();
|
||||
+// -- GODOT start --
|
||||
+#else
|
||||
+ usleep(1);
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
}
|
||||
|
||||
bool expected = false;
|
||||
@@ -74,8 +82,16 @@ namespace embree
|
||||
{
|
||||
while(flag.load())
|
||||
{
|
||||
+// -- GODOT start --
|
||||
+#if !(defined (__WIN32__) && defined(__MINGW32__))
|
||||
+// -- GODOT end --
|
||||
_mm_pause();
|
||||
_mm_pause();
|
||||
+// -- GODOT start --
|
||||
+#else
|
||||
+ usleep(1);
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/common/sys/platform.h b/common/sys/platform.h
|
||||
index 96f9aab01..08617452f 100644
|
||||
--- a/common/sys/platform.h
|
||||
|
@ -71,6 +139,39 @@ index 96f9aab01..08617452f 100644
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Error handling and debugging
|
||||
diff --git a/common/sys/sysinfo.cpp b/common/sys/sysinfo.cpp
|
||||
index eb0a10eaf..74438260d 100644
|
||||
--- a/common/sys/sysinfo.cpp
|
||||
+++ b/common/sys/sysinfo.cpp
|
||||
@@ -233,7 +233,7 @@ namespace embree
|
||||
|
||||
__noinline int64_t get_xcr0()
|
||||
{
|
||||
-#if defined (__WIN32__)
|
||||
+#if defined (__WIN32__) /* -- GODOT start -- */ && !defined (__MINGW32__) /* -- GODOT end -- */
|
||||
int64_t xcr0 = 0; // int64_t is workaround for compiler bug under VS2013, Win32
|
||||
xcr0 = _xgetbv(0);
|
||||
return xcr0;
|
||||
diff --git a/common/tasking/taskschedulerinternal.cpp b/common/tasking/taskschedulerinternal.cpp
|
||||
index 2152e92f4..923d62f83 100644
|
||||
--- a/common/tasking/taskschedulerinternal.cpp
|
||||
+++ b/common/tasking/taskschedulerinternal.cpp
|
||||
@@ -361,7 +361,15 @@ namespace embree
|
||||
if ((loopIndex % LOOP_YIELD_THRESHOLD) == 0)
|
||||
yield();
|
||||
else
|
||||
+// -- GODOT start --
|
||||
+#if !defined(__MINGW32__)
|
||||
+// -- GODOT end --
|
||||
_mm_pause();
|
||||
+// -- GODOT start --
|
||||
+#else
|
||||
+ usleep(1);
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
loopIndex++;
|
||||
#else
|
||||
yield();
|
||||
diff --git a/common/tasking/taskschedulertbb.h b/common/tasking/taskschedulertbb.h
|
||||
index 98dba2687..369e5edf0 100644
|
||||
--- a/common/tasking/taskschedulertbb.h
|
||||
|
|
Loading…
Reference in a new issue