TheGreyGhost / MinecraftByExample

Working sample code for the basic concepts in Minecraft and Forge.
Other
1.24k stars 187 forks source link

Threaded rendering issue in MBE05 #9

Closed herbix closed 9 years ago

herbix commented 9 years ago

As far as I know there are more than one threads rendering the world. But in MBE05, there's only one CompositeModel instance. Since handleBlockState always returns this, different blocks affect each other when rendered in different threads. For example:

Solution: Although it costs more space, a new IBakedModel should be returned by handleBlockState, I suppose.

TheGreyGhost commented 9 years ago

Hi Herbix Hmmm you could be right. I had assumed it was single-threaded but I'm not certain. I'll do a few tests and see.

Cheers TGG

TheGreyGhost commented 9 years ago

Hi Herbix I did a few tests and rummaged through the vanilla code a bit, and it looks like 1.8 is single threaded for world rendering. But for sure that might change in future, so I'll add a comment about that to the example and a related tutorial I wrote a while back.

Cheers TGG

herbix commented 9 years ago

Hi TGG I'm pretty sure it's rendered multi-threaded. I print current thread in handleBlockState. There's 3 different thread instance. Then I trace the call hierarchy and find ChunkRenderWorker.processTask, which controls rendering a chunk. This method is called in main client thread as well as two other threads, which start at ChunkRenderDispatcher.<init>. Maybe more blocks in different chunks are needed to find out this issue. I thought super flat may help.

TheGreyGhost commented 9 years ago

Ah! You are right. Mine is single-threaded only for some reason, perhaps my computer is not powerful enough! :)

I will change it. Thanks!

-TGG