Jump to content

[1.7.10] Significant frame rate drop when looking at block with custom model..


Recommended Posts

Posted

Hello there,

 

I created a custom model for my furnace using Tabula by iChun. Everything works as it should, but there are some frame rate issues when looking at or near the block. If there are only one or two blocks down, it doesn't affect your FPS too much, but once you place ten or so down, your FPS can go from over 300+ to only 70 or 80 (and that's on a quite powerful GPU. Some computers which only run ~80 FPS can go as low as ~25 FPS). I don't use any large for loops or anything like that, so I don't see why the frame rate would drop so much.

 

Here's my code:

Model:

-Deactivated.

-Activated.

 

Renderer: Click me.

 

Thanks for reading!

~Geforce

Potato's have skin. I have skin. Therefore, i am a potato.

 

Follow me on Twitter!

http://www.twitter.com/I_Mod_Minecraft

Posted

I'm not sure but in your renderTileEntityAt() method instead of creating new ResourceLocations each time, put them into a field during the constructor. ResourceLocation I expect does file access which would be an unnecessary perf hit.

 

It's this.  You're causing Minecraft to load the texture from disk and reallocate memory for it (and then immediately discard it) every frame.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Ah, that fixed it. Thanks!

 

A lot of beginning programmers make the mistake of overusing the new instantiations on the fly. Don't keep creating the same thing over and over as it both affects perf (especially in the case where it includes file access) and also memory (as mentioned by Draco). If you've already got an instance, use it. If you know you need an instance over and over, make it a field for the class, or at least instantiate it outside the code that repeats.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I don't know why

new ResourceLocation(...)

takes so much time then.  Because it does.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Also: There are 2 different constructors, once does some parsing of the input. Which do you use?

 

In the OP's code at top of thread he's using the one big string, which I would assume needs parsing.

 

It may not be the ResourceLocation itself but he's using that for binding the texture every time he renders as well. So that must do some sort of file access or at least cache access, right? Basically his code is binding a "new" (really repeating the old) texture every render tick.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

The ResourceLocation is just used as a key to look up the actual texture object. If you just create a new ResourceLocation or re-use the old one, you will get the same texture object, ResourceLocation implements equals and hashCode properly.

 

Sure, it looks like it handles avoiding the loading if the mapping is already present, but there is still a GL binding occurring repeatedly.

 

Based on this thread, and the numerous hits about gl bind texture performance issues when I search for them, I suspect you do want to avoid binding the texture unnecessarily: https://www.opengl.org/discussion_boards/showthread.php/182629-glBindTexture-has-deferred-processing

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

But if you use a static ResourceLocation the texture will be bound just the same way...

 

Yeah, I know you can't get away without doing a binding for the render, but thought maybe the binding would still trigger something different if ResourceLocation was refreshed (same key or not). But looking through the code it like you said -- the binding should be same if ResourceLocation key is the same, whether or not the ResourceLocation is created freshly.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.