diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 6 | ||||
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 2 | ||||
-rw-r--r-- | drivers/gles2/shaders/stdlib.glsl | 20 | ||||
-rw-r--r-- | drivers/png/image_loader_png.cpp | 5 | ||||
-rw-r--r-- | drivers/png/png_driver_common.cpp | 7 | ||||
-rw-r--r-- | drivers/png/png_driver_common.h | 2 | ||||
-rw-r--r-- | drivers/unix/ip_unix.h | 4 |
7 files changed, 36 insertions, 10 deletions
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 6eef04b87f..4dd66c06e6 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -2566,9 +2566,7 @@ Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>()); Surface *surface = mesh->surfaces[p_surface]; -#ifndef TOOLS_ENABLED - ERR_PRINT("OpenGL ES 2.0 does not allow retrieving mesh array data"); -#endif + return surface->data; } @@ -2612,7 +2610,7 @@ Vector<Vector<uint8_t>> RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RI ERR_FAIL_COND_V(!mesh, Vector<Vector<uint8_t>>()); ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Vector<uint8_t>>()); #ifndef TOOLS_ENABLED - ERR_PRINT("OpenGL ES 2.0 does not allow retrieving mesh array data"); + ERR_PRINT("OpenGL ES 2.0 does not allow retrieving blend shape data"); #endif return mesh->surfaces[p_surface]->blend_shape_data; diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index a5e85424b7..1e30f0dfa1 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -1016,6 +1016,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[RS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n"; actions[RS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n"; actions[RS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["fma"] = "#define FMA_USED\n"; /** SPATIAL SHADER **/ @@ -1126,6 +1127,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[RS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n"; actions[RS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n"; actions[RS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["fma"] = "#define FMA_USED\n"; actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n"; diff --git a/drivers/gles2/shaders/stdlib.glsl b/drivers/gles2/shaders/stdlib.glsl index 9c74418743..807036dda6 100644 --- a/drivers/gles2/shaders/stdlib.glsl +++ b/drivers/gles2/shaders/stdlib.glsl @@ -417,4 +417,24 @@ highp mat4 outerProduct(highp vec4 c, highp vec4 r) { #endif +#if defined(FMA_USED) + +highp float fma(highp float a, highp float b, highp float c) { + return a * b + c; +} + +highp vec2 fma(highp vec2 a, highp vec2 b, highp vec2 c) { + return a * b + c; +} + +highp vec3 fma(highp vec3 a, highp vec3 b, highp vec3 c) { + return a * b + c; +} + +highp vec4 fma(highp vec4 a, highp vec4 b, highp vec4 c) { + return a * b + c; +} + +#endif + #endif diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 8af58a7ed7..79924b849c 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -50,7 +50,7 @@ Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force f->close(); } const uint8_t *reader = file_buffer.ptr(); - return PNGDriverCommon::png_to_image(reader, buffer_size, p_image); + return PNGDriverCommon::png_to_image(reader, buffer_size, p_force_linear, p_image); } void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const { @@ -61,7 +61,8 @@ Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) { Ref<Image> img; img.instance(); - Error err = PNGDriverCommon::png_to_image(p_png, p_size, img); + // the value of p_force_linear does not matter since it only applies to 16 bit + Error err = PNGDriverCommon::png_to_image(p_png, p_size, false, img); ERR_FAIL_COND_V(err, Ref<Image>()); return img; diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 77d5e68826..d3e187c501 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -58,7 +58,7 @@ static bool check_error(const png_image &image) { return false; } -Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { +Error png_to_image(const uint8_t *p_source, size_t p_size, bool p_force_linear, Ref<Image> p_image) { png_image png_img; zeromem(&png_img, sizeof(png_img)); png_img.version = PNG_IMAGE_VERSION; @@ -99,6 +99,11 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { return ERR_UNAVAILABLE; } + if (!p_force_linear) { + // assume 16 bit pngs without sRGB or gAMA chunks are in sRGB format + png_img.flags |= PNG_IMAGE_FLAG_16BIT_sRGB; + } + const png_uint_32 stride = PNG_IMAGE_ROW_STRIDE(png_img); Vector<uint8_t> buffer; Error err = buffer.resize(PNG_IMAGE_BUFFER_SIZE(png_img, stride)); diff --git a/drivers/png/png_driver_common.h b/drivers/png/png_driver_common.h index 12129f034e..2099ddc536 100644 --- a/drivers/png/png_driver_common.h +++ b/drivers/png/png_driver_common.h @@ -36,7 +36,7 @@ namespace PNGDriverCommon { // Attempt to load png from buffer (p_source, p_size) into p_image -Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image); +Error png_to_image(const uint8_t *p_source, size_t p_size, bool p_force_linear, Ref<Image> p_image); // Append p_image, as a png, to p_buffer. // Contents of p_buffer is unspecified if error returned. diff --git a/drivers/unix/ip_unix.h b/drivers/unix/ip_unix.h index 0580facac2..7497f64a53 100644 --- a/drivers/unix/ip_unix.h +++ b/drivers/unix/ip_unix.h @@ -38,12 +38,12 @@ class IP_Unix : public IP { GDCLASS(IP_Unix, IP); - virtual IP_Address _resolve_hostname(const String &p_hostname, IP::Type p_type); + virtual IP_Address _resolve_hostname(const String &p_hostname, IP::Type p_type) override; static IP *_create_unix(); public: - virtual void get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const; + virtual void get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const override; static void make_default(); IP_Unix(); |