Commit Graph

66 Commits

Author SHA1 Message Date
hecktest 28c98f9fa5 Remove unsupported extensions from list in tile.cpp 2021-07-29 21:47:08 +02:00
sfan5 08f1a7fbed Use Irrlicht functions to query npot texture support 2021-05-05 22:49:44 +02:00
sfan5 1da73418cd
Enable cleanTransparent filter for mipmapping and improve its' algorithm (#11145) 2021-04-20 19:50:19 +02:00
Jean-Patrick Guerrero 66b5c08664 Fix deprecated calls with Irrlicht 1.9 2021-03-16 23:27:15 +01:00
sfan5 f018737b06 Fix segfault with invalid texture strings and minimap enabled
closes #10949
2021-02-14 11:28:02 +01:00
rubenwardy 4c76239818
Remove dead code (#10845) 2021-01-22 15:09:26 +00:00
sfan5 74762470b2 Fix some minor code issues all over the place 2020-12-24 13:44:54 +01:00
sfan5 c47a680db7 Stop wasting memory on identical textures when texture filtering is disabled 2020-05-20 22:55:51 +02:00
sfan5 de73f989eb
Overall improvements to log messages (#9598)
Hide some unnecessarily verbose ones behind --trace or disable them entirely.
Remove duplicate ones. Improve their contents in some places.
2020-04-08 20:13:23 +02:00
Warr1024 15b6922ae6 Correction for alpha blending issues in texture mod compositing (#9029) 2019-10-18 19:17:35 +02:00
SmallJoker 61e9c1b0dd
Textures: Load base pack only as last fallback (#8974) 2019-09-29 19:57:29 +02:00
sfan5 6c2ded4cac Unify GLES support in gui scaling filter 2019-08-04 16:12:52 +02:00
sfan5 ca363d3ef8 Unify OpenGL ES support 2019-08-04 16:12:52 +02:00
Jozef Behran eb2bda7d0b Optimize string (mis)handling (#8128)
* Optimize statbar drawing

The texture name of the statbar is a string passed by value.
That slows down the client and creates litter in the heap
as the content of the string is allocated there. Convert the
offending parameter to a const reference to avoid the
performance hit.

* Optimize texture cache

There is an unnecessary temporary created when the texture
path is being generated. This slows down the cache each time
a new texture is encountered and it needs to be loaded into
the cache. Additionally, the heap litter created by this
unnecessary temporary is particularly troublesome here as
the following code then piles another string (the resulting
full path of the texture) on top of it, followed by the
texture itself, which both are quite long term objects as
they are subsequently inserted into the cache where they can
remain for quite a while (especially if the texture turns
out to be a common one like dirt, grass or stone).

Use std::string.append to get rid of the temporary which
solves both issues (speed and heap fragmentation).

* Optimize animations in client

Each time an animated node is updated, an unnecessary copy of
the texture name is created, littering the heap with lots of
fragments. This can be specifically troublesome when looking
at oceans or large lava lakes as both of these nodes are
usually animated (the lava animation is pretty visible).
Convert the parameter of GenericCAO::updateTextures to a
const reference to get rid of the unnecessary copy.

There is a comment stating "std::string copy is mandatory as
mod can be a class member and there is a swap on those class
members ... do NOT pass by reference", reinforcing the
belief that the unnecessary copy is in fact necessary.
However one of the first things the code of the method does
is to assign the parameter to its class member, creating
another copy. By rearranging the code a little bit this
"another copy" can then be used by the subsequent code,
getting rid of the need to pass the parameter by value and
thus saving that copying effort.

* Optimize chat console history handling

The GUIChatConsole::replaceAndAddToHistory was getting the
line to work on by value which turns out to be unnecessary.
Get rid of that unnecessary copy by converting the parameter
to a const reference.

* Optimize gui texture setting

The code used to set the texture for GUI components was
getting the name of the texture by value, creating
unnecessary performance bottleneck for mods/games with
heavily textured GUIs. Get rid of the bottleneck by passing
the texture name as a const reference.

* Optimize sound playing code in GUIEngine

The GUIEngine's code receives the specification of the sound
to be played by value, which turns out to be most likely a
mistake as the underlying sound manager interface receives
the same thing by reference. Convert the offending parameter
to a const reference to get rid of the rather bulky copying
effort and the associated performance hit.

* Silence CLANG TIDY warnings for unit tests

Change "std::string" to "const std::string &" to avoid an
unnecessary local value copy, silencing the CLANG TIDY
process.

* Optimize formspec handling

The "formspec prepend" parameter was passed to the formspec
handling code by value, creating unnecessary copy of
std::string and slowing down the game if mods add things like
textured backgrounds for the player inventory and/or other
forms. Get rid of that performance bottleneck by converting
the parameter to a const reference.

* Optimize hotbar image handling

The code that sets the background images for the hotbar is
getting the name of the image by value, creating an
unnecessary std::string copying effort. Fix that by
converting the relevant parameters to const references.

* Optimize inventory deserialization

The inventory manager deserialization code gets the
serialized version of the inventory by value, slowing the
server and the client down when there are inventory updates.
This can get particularly troublesome with pipeworks which
adds nodes that can mess around with inventories
automatically or with mods that have mobs with inventories
that actively use them.

* Optimize texture scaling cache

There is an io::path parameter passed by value in the
procedure used to add images converted from textures,
leading to slowdown when the image is not yet created and
the conversion is thus needed. The performance hit is
quite significant as io::path is similar to std::string
so convert the parameter to a const reference to get rid of
it.

* Optimize translation file loader

Use "std::string::append" when calculating the final index
for the translation table to avoid unnecessary temporary
strings. This speeds the translation file loader up
significantly as std::string uses heap allocation which
tends to be rather slow. Additionally, the heap is no
longer being littered by these unnecessary string
temporaries, increasing performance of code that gets
executed after the translation file loader finishes.

* Optimize server map saving

When the directory structure for the world data is created
during server map saving, an unnecessary value passing of
the directory name slows things down. Remove that overhead
by converting the offending parameter to a const reference.
2019-05-18 17:19:13 +02:00
Loic Blot f4099192e3
Import strstr function from FreeBSD 11 libc 2019-01-10 00:17:08 +01:00
Loïc Blot 0acdf93683 Android build fixes
This fixes #8079
2019-01-09 14:39:43 +01:00
Loïc Blot 95d4ff6d1b
Fix a crash on Android with Align2Npot2 (#8070)
* Fix a crash on Android with Align2Npot2

glGetString can be NULL. If stored in a string it triggers a SIGSEGV.
Instead do a basic strstr and verify the pointer
* Better Align2Npot2 check (+ performance)
2019-01-07 17:05:18 +01:00
Vitaliy 18a8fbf465 Software inventorycube (#7651)
Fixes missing/upside-down images on Android.
2018-09-29 19:40:17 +01:00
stujones11 22a891a925
Android build fixes for c++11 2018-03-11 16:56:27 +01:00
Vitaliy cf8d579abc Drop texture file list cache (#6660) 2018-03-10 19:33:37 +01:00
number Zero 05d93c7fa1 Load files from subfolders in texturepacks
Updated and rebased version of a PR by red-001
2017-11-17 19:23:08 +00:00
Lars Hofhansl 6be6fb78a4 Do not scale texture unless necessary.
This avoids scaling textures to 'texture_min_size' unless it is actually
required (because either auto-scaling or bi/trilinear filtering is enabled)
2017-11-04 18:05:55 -07:00
Vitaliy 75320e7e88 Real global textures (#6105)
* Real global textures

* Add world-aligned textures
* Update minimal to support world-aligned tiles
* Update minimal
2017-10-15 09:34:14 +02:00
Loïc Blot 88b436e6a9 Code modernization: subfolders (#6283)
* Code modernization: subfolders

Modernize various code on subfolders client, network, script, threading, unittests, util

* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Make connection.cpp readable in a pointed place + typo
2017-08-19 22:23:47 +02:00
Loïc Blot 9dd0f952e0 Modernize client code (#6250)
* Various code style fixes
* Use range based for loops
* Use empty instead of empty objects
* Use C++11 default keyword for trivial constructors and destructors
* Drop some useless casts
* Use emplace_back instead of push_back to improve performance of some vectors push
2017-08-15 20:30:30 +02:00
Loïc Blot b3a36f7378 Isolate irrlicht references and use a singleton (#6041)
* Add Device3D class which will contain IrrlichtDevice interface

move getSupportedVideoDrivers to Device3D

Add Device3D singleton & use it in various places

Rename Device3D to Rendering engine & add helper functions to various device pointers

More singleton work

RenderingEngine owns draw_load_screen

move draw functions to RenderingEngine

Reduce IrrlichtDevice exposure and guienvironment

RenderingEngine: Expose get_timer_time() to remove device from guiEngine

Make irrlichtdevice & scene manager less exposed

* Code style fixes

* Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine

Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly

* enum paralax => enum parallax
2017-06-26 20:11:17 +02:00
ShadowNinja 6c5e5e2023 Remove threads.h and replace its definitions with their C++11 equivalents (#5957)
This also changes threadProc's signature, since C++11 supports arbitrary
thread function signatures.
2017-06-11 09:43:05 +02:00
Loïc Blot d4c0f91275 Use C++11 mutexes only (remove compat code) (#5922)
* Fix event LINT & remove default constructor/destructors
* remove compat code & modernize autolock header
2017-06-06 16:29:28 +02:00
Loïc Blot a98baef5e4 C++11 patchset 2: remove util/cpp11.h and util/cpp11_container.h (#5821) 2017-06-04 21:00:04 +02:00
you 35267406aa Do not create dummy normalmaps (#4180)
fixes #1811
2017-05-19 08:08:12 +02:00
Loic Blot 907be0ab91
Remove an unused variable in Android Build 2017-04-17 09:37:12 +02:00
Loïc Blot 73de17afa8 Android progressbar fix (#5601)
* Fix progressbar for Android

Fixes #5599
Fixed #5403 

* draw_load_screen: use texturesource
  this permits to unify texture loading code
* scale progress bar

* Add gl version check for GL_OES_texture_npot. This fixed the texture on loading screen

* Remove two sanity checks pointed by @celeron55

* sfan5 comments + android ratio fixes
2017-04-16 14:44:15 +02:00
Dániel Juhász 58d83a7bb2 Hardware coloring for itemstacks
Adds the possibility to colorize item stacks based on their metadata.

In the item/node definition you can specify palette (an image file)
and color (fallback color if the item has no palette or metadata).
Then you can add palette_index to the metadata.

Dropped itemstacks with different colors do not merge.
2017-04-08 18:39:15 -07:00
SmallJoker 5a59ad2307 Tile.cpp: Fix MSVC build broken by 072bbba 2017-03-24 20:05:15 +01:00
Loïc Blot 072bbba69a Some performance optimizations (#5424)
* Some performance optimizations

This is globally removing some memory useless copy

* use a const ref return on std::string Settings::get to prevent data copy on getters which doesn't need to copy it
 * pass some stack created strings to static const as they are not modified anywhere
 * Camera: return nametags per const ref instead of a list pointer, we only need to read it
 * INodeDefManager: getAll should be a result ref writer instead of a return copy
 * INodeDefManager: getAlias should return a const std::string ref
 * Minimap: unroll a Scolor creation in blitMinimapPixersToImageRadar to prvent many variable construct/destruct which are unneeded (we rewrite the content in the loop)
 * CNodeDefManager::updateAliases: prevent a idef getall copy
 * Profiler: constness
 * rollback_interface: create real_name later, and use const ref
 * MapBlockMesh updateFastFaceRow: unroll TileSpec next_tile, which has a cost of 1.8% CPU due to variable allocation/destruction,
 * MapBlockMesh updateFastFaceRow: copy next_tile to tile only if it's a different tilespec
 * MapBlockMesh updateFastFaceRow: use memcpy to copy next_lights to lights to do it in a single cpu operation
2017-03-22 21:41:02 +01:00
Auke Kok 3e30731c1a Prevent SIGFPE on entity tile loading issue. (#5178)
While experimenting with entities I ran into this unresolvable
error where the server is sending some texture that the client
crashes on. The crash prevents the client from ever reconnecting,
resulting in a server that has to use clearobjects.

We shouldn't crash but just ignore the object and move on.

```
0x00000000004dc0de in TextureSource::generateImagePart (this=this@entry=0x7118eb0, part_of_name="[applyfiltersformesh",
    baseimg=@0x7fffffffbe98: 0x9f1b010) at /home/sofar/git/minetest/src/client/tile.cpp:1744
    1744					u32 xscale = scaleto / dim.Width;
    (gdb) bt
    #0  0x00000000004dc0de in TextureSource::generateImagePart (this=this@entry=0x7118eb0, part_of_name="[applyfiltersformesh",
        baseimg=@0x7fffffffbe98: 0x9f1b010) at /home/sofar/git/minetest/src/client/tile.cpp:1744
```

After reconnecting, the client now can connect without issues
and displays an error message:

```
ERROR[Main]: generateImagePart(): Illegal 0 dimension for part_of_name="[applyfiltersformesh", cancelling.
ERROR[Main]: generateImage(): Failed to generate "[applyfiltersformesh"
ERROR[Main]: Irrlicht: Invalid size of image for OpenGL Texture.
```
2017-02-05 23:59:18 -08:00
sapier e761b9f486 Add multiply texture modifier
Allows colorizing of textures using a color multiplication method.
2017-01-30 16:37:17 +00:00
Dániel Juhász d04d8aba70 Add hardware node coloring. Includes:
- Increase ContentFeatures serialization version
- Color property and palettes for nodes
- paramtype2 = "color", "colored facedir" or "colored wallmounted"
2017-01-23 07:27:12 +01:00
Luke Puchner-Hardman 7057c196c4 Added "[sheet" to the texture special commands.
"[sheet:WxH:X,Y" assumes the base image is a tilesheet with W*H tiles
on it and crops to the tile at position X,Y.  Basically it works
like "[verticalframe" but in 2D.

For testing, I combined the four default_chest images into one.
2017-01-02 15:28:06 +01:00
sfan5 084cdea686 Irrlicht 1.9 support 2016-12-26 22:36:22 +01:00
Thomas--S 1475c1b1c8 Add an [invert:<mode> texture modifier
Inverts the given channels of the base image.
Mode may contain the characters "r", "g", "b", "a".
Only the channels that are mentioned in the mode string will be inverted.
2016-09-15 05:25:38 +01:00
sfan5 b77cee146b Allow escaping of texture names when passed as an argument to a modifier 2016-09-14 09:19:36 +01:00
Thomas--S f21dae6339 Add an [opacity:<r> texture modifier. Makes the base image transparent according to the given ratio. r must be between 0 and 255. 0 means totally transparent. 255 means totally opaque. Useful for texture overlaying. 2016-08-12 15:20:30 +02:00
SmallJoker 53e9587861 Add [resize texture modifier Resizes the texture to the given dimensions. 2016-05-09 20:48:42 +02:00
SmallJoker 31c1fca6fd tile.cpp: Automatically upscale lower resolution texture 2016-04-25 06:39:32 +01:00
kwolekr c3993f6604 Re-add and disable blit_with_interpolate_overlay 2016-04-07 04:01:43 -04:00
Samuel Sieb 24b32ab09d Fix compiler warnings from "Add an option to colorize to respect the destination alpha"
Fix warnings added by commit 01ae43c480

Fixes #3952
2016-04-06 00:36:24 +02:00
Samuel Sieb 01ae43c480 Add an option to colorize to respect the destination alpha
Also, rework the colorizing code to be more efficient.
2016-04-03 04:24:28 -04:00
ShadowNinja 93887043d9 Clean up Strfnd
Changes:
  * Fix indentation.
  * Pass strings by const reference.
  * Merge Strfnd and WStrfnd into one class instead of copying them.
  * Remove trailing spaces.
  * Fix variable names.
  * Move to util.
  * Other miscellaneous style fixes.
2016-03-19 21:27:57 -04:00
kwolekr 6be74d17df Refactor thread utility interface
- Add "thr_" prefix to thread utility functions
- Compare threadid_ts in a portable manner, where possible
2015-10-16 22:20:24 -04:00