Page 6 of 8

Re: [Patch] Textures

PostPosted: Wed Dec 20, 2017 10:51 am
by HarryTuttle
If you want to skip some repeated math you can do:

Code: Select all
            indexByte1 = (yy^1) * tileX + ((xx + 0)^1);
            indexByte2 = (yy^1) * tileX + ((xx + 1)^1);

before the series of "if (TileX ==..." and substitute accordingly. And when (tileX == 1) use indexByte2

Re: [Patch] Textures

PostPosted: Wed Dec 20, 2017 12:03 pm
by Bart
HarryTuttle wrote:I've to add that it's not the first time Supermodel compiled with gcc doesn't crash for out of bounds array indices. The last case was an off-by-one-error that should give, as I've read, unexpected results.


There are only three really hard problems in computer science:

1. Naming things.
2. Off-by-1 errors.

Someone here suggested to compile with these arguments: -fsanitize=address -ggdb, explanation here.

I've tried that but when linking it throws out an insane amount of errors relating to m68kmake.c, PPCDisasm.cpp, Z80Debug.cpp, etc... plus some other MSYS2 includes... :shock:

I don't want to even remotely mess with those things.


One day I'll go through and fix these issues. Musashi 68K is really old code and probably not standards compliant anymore. Shouldn't be too hard to fix, though.

Re: [Patch] Textures

PostPosted: Wed Dec 20, 2017 12:14 pm
by Ian
If you use std::array instead of just array[1]
You get checked interators in debug mode, which is kind of handy. But it's also very slow in debug mode.

Re: [Patch] Textures

PostPosted: Wed Dec 20, 2017 7:30 pm
by HarryTuttle
PATCH for r684:

- Improved/Simplified algorithm for 8 bit textures in StoreTexture function
- Deleted StoreTexelByte function
- Fixed the smallest texture lods (1x1, 1x2, 2x1) for 8 bit textures, now they're graphically correct.

Re: [Patch] Textures

PostPosted: Thu Jan 11, 2018 9:26 am
by scd
HarryTuttle wrote: The performance impact is almost imperceptible. Patch pending.


does it means more fps harry? :o

Re: [Patch] Textures

PostPosted: Thu Jan 11, 2018 9:46 am
by HarryTuttle
scd wrote:does it means more fps harry?

Well, actually means that there's a little, if any, fps loss. But considering that soon I'm going to post a new patch to improve texture uploading mechanism, I think in the end there will be a general gain in fps.

Re: [Patch] Textures

PostPosted: Fri Jan 12, 2018 5:47 am
by scd
HarryTuttle wrote:
scd wrote:does it means more fps harry?

Well, actually means that there's a little, if any, fps loss. But considering that soon I'm going to post a new patch to improve texture uploading mechanism, I think in the end there will be a general gain in fps.


sound very promising. there is any name for this patch? i will look forward too.

Re: [Patch] Textures

PostPosted: Fri Jan 12, 2018 10:36 am
by HarryTuttle
scd wrote:there is any name for this patch? i will look forward too.


Keep looking at this topic, since I created it for everything I'm working on related to texture. I'll also update from time to time the first post which contains a summary of this subproject.

Re: [Patch] Textures

PostPosted: Sat Jan 13, 2018 12:05 pm
by scd
thanks harry :)

Re: [Patch] Textures

PostPosted: Sat Jan 13, 2018 12:53 pm
by HarryTuttle
PATCH for r700 (1st of two "interim" patches before next big update):

- Reworked micro texture scaling factor, now it matches the arcade.
- Removed from SetMeshValues() two checks for "textured" and "microTexture" state, since it's always ok to fetch those values from polygon header. Shader uniforms, in this case "microTextureScale", will receive valid values anyway.

Micro texture mapping coordinates are scaled by a certain factor before fetching texture data. It turns out that the scale is the ratio between the base texture size and the micro texture size (which is assumed to be always 128x128) *pre-divided* by "2" for "N" times. This "N" is the value obtained with 2^ph.MicroTextureMinLOD().

In pseudo-code:
Code: Select all
microTexCoord = baseTexCoord * (baseTexSize / (128 >> (1 << ph.MicroTextureMinLOD())))

This is apparent in Daytona 2 because ph.MicroTextureMinLOD() is "0", "1" or "2". Other games usually set only "0". Skichamp also uses many values and could be a good reference but there're no good quality videos around.