diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.08k stars 794 forks source link

Optimize floor drawing (WIP) #7327

Open glebm opened 3 months ago

AJenbo commented 3 months ago

Do you check to make sure that the tiles you do this for do not have content drawn on them from other ones and that they do not draw outside of the general rectangular area?

glebm commented 3 months ago

The floor is drawn before everything else and I think floor tiles never overlap with each other

That said, so far I haven't been able to get any performance improvement out of this so far (and I tried quite a few things). The floor drawing gets faster but DrawDungeon, which I haven't change at all, gets slower. It's a mystery.

AJenbo commented 3 months ago

The floor is drawn before everything else and I think floor tiles never overlap with each other

That said, so far I haven't been able to get any performance improvement out of this so far (and I tried quite a few things). The floor drawing gets faster but DrawDungeon, which I haven't change at all, gets slower. It's a mystery.

the foliage part is for tiles that do not limit them selfs to the "tile" shape. I think for floor this is only and issue in town, for the dungeons they all appears to adhere to the shape.

image

I guess you can simply handle it by not applying this optimization to any where foliage is true.

glebm commented 3 months ago

foliage is only checked in DrawCell, which is not used for drawing floor tiles:

https://github.com/diasurgical/devilutionX/blob/7d5bef724dbfadb16cb1e36fb18f136a39929350/Source/engine/render/scrollrt.cpp#L475

Floor tiles are always drawn without mask (MaskType::Solid), doesn't look like our code supports foliage for them:

https://github.com/diasurgical/devilutionX/blob/7d5bef724dbfadb16cb1e36fb18f136a39929350/Source/engine/render/scrollrt.cpp#L572-L597

AJenbo commented 3 months ago

😑 We might want to look in to that then

glebm commented 3 months ago

I think what happens is that foliage is drawn again in DrawCell, after the floor.

The condition for whether something is a floor tile is exactly the same as foliage:

!TileHasAny(tilePosition, TileProperties::Solid); 

Moreover, we only draw foliage for tiles of TransparentSquare type.

So for a transparent square tile, we first draw it fully in DrawFloor. Then, in DrawCell, we draw only the masked part again.

I think the foliage condition is not very precise. Not all TransparentSquare tiles have foliage. However, I don't know of a more precise way to detect whether a tile has foliage.

AJenbo commented 3 months ago

Thanks for investigating that.