Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item render-to-texture: Texture modifier, speedup #10570

Closed
wants to merge 2 commits into from

Conversation

appgurueu
Copy link
Contributor

@appgurueu appgurueu commented Oct 27, 2020

#10003 splitoff, code redundancy still needs to be fixed

@@ -798,6 +798,10 @@ autoscale_mode (Autoscaling mode) enum disable disable,enable,force
# A restart is required after changing this.
show_entity_selectionbox (Show entity selection boxes) bool false

# Speed up item rendering through RTT (render-to-texture)
# Set to 0 to disable, numbers > 0 are resolutions in pixels
item_rtt_speedup_resolution (Item render-to-texture speedup) int 0 0 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is 128 (not 0), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@paramat paramat added Feature ✨ PRs that add or enhance a feature @ Script API labels Oct 28, 2020
if (w != "") {
width = stoi(w);
const std::string h = sf.next("");
if (h != "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (h != "")
if (!h.empty())

const std::string w = sf.next("x");
u32 width = g_settings->getU16("item_rtt_speedup_resolution");
u32 height = width;
if (w != "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (w != "") {
if (!w.empty()) {


rt->unlock(); // wondering whether this is required
driver->removeTexture(rt);
// rt->drop(); isn't required
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it must not be dropped, it's a good notice to programmers. However, wondering whether this is required is much worse for being unclear. Perhaps this needs a valgrind run to ensure there are no memory leaks.

width = stoi(w);
const std::string h = sf.next("");
if (h != "")
height = stoi(h);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

height and width aren't zero and print a message to error stream if they are?

@v-rob
Copy link
Member

v-rob commented Nov 3, 2020

What types of video cards don't have support for render textures? Irrlicht's documentation implies that this does not have universal support. I don't know how common it is to not have support, but if it's more than just a very few, it should be documented that it may not work depending on the video card.


* If `[item:<modname>:<itemname>` is used, width & height default to `item_rtt_speedup_resolution` (client setting)
* If `[item:<modname>:<itemname>:W` is used, width & height are set to W
* If `[item:<modname>:<itemname>:WxH` is used, width is set to W & height is set to H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Item names may be in this format, but it's not enforced. [item:air is a valid item. Thus consider using , as second argument delimiter, despite being inconsistent to other modifiers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm currently considering using [item:<serialized_itemstack>:WxH


core::matrix4 ViewMatrix;
ViewMatrix.buildProjectionMatrixOrthoLH(2.0f, 2.0f, -1.0f, 100.0f);
ViewMatrix.setTranslation(core::vector3df(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why copy & paste? tile.cpp and hud.cpp are both client files, thus it would make sense to move this code to a separate function which both files can access.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pyrollo noted the same.

code redundancy still needs to be fixed

@kilbith
Copy link
Contributor

kilbith commented Nov 22, 2020

Please rebase and address the remaining comments. I'd like to see it merged as it speedup the inventory rendering by a lot (versus the drawItemStack scene per item).

@appgurueu
Copy link
Contributor Author

Please rebase and address the remaining comments. I'd like to see it merged as it speedup the inventory rendering by a lot (versus the drawItemStack scene per item).

@kilbith Currently I'm busy. Will probably do until the end of the month.

@Warr1024
Copy link
Contributor

Warr1024 commented Sep 9, 2021

Concerns expressed by erlehmann on IRC:

minetest on that branch has NOTICEABLE LAG in hotbar inventory item rendering on my already slow computer, where it did not have that with 5.5-dev. the PR description claims it would speedup item rendering – if it does not do that on a slow computer, the whole thing is wrong.

the lag means there is nothing shown in the hotbar for some amount of time (prob slightly under a second) after picking up an item

i also got a segfault, no idea why. i rarely get those.
[89878.146141] Emerge-0[24369]: segfault at f522dc3c ip 00ae8923 sp 9a081ab0 error 7 in minetest[56d000+66a000]
[89878.146174] Code: c0 29 d6 0f b7 54 24 02 09 c1 8d 44 24 0c 89 4c 24 18 8d 4c 24 18 66 89 54 24 1c 8b 54 24 40 01 ee e8 11 fe ff ff 8b 4c 24 0c <89> 0c b7 03 73 1c 80 26 fd c6 43 20 01 83 c4 2c 5b 5e 5f 5d c3 8d

@appgurueu
Copy link
Contributor Author

Closing this for now; the best way to resolve the conflicts is to redo it. I don't quite see why this would cause the mentioned lag; the rendered textures should be cached. What has the resolution been set to?

@appgurueu appgurueu closed this Sep 9, 2021
@kilbith
Copy link
Contributor

kilbith commented Dec 9, 2021

Care to redo it?

@sfan5 sfan5 added the Adoption needed The pull request needs someone to adopt it. Adoption welcomed! label Dec 9, 2021
@appgurueu
Copy link
Contributor Author

Care to redo it?

Probably not, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Adoption needed The pull request needs someone to adopt it. Adoption welcomed! Feature ✨ PRs that add or enhance a feature Possible close @ Script API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants