Project

General

Profile

Actions

Emulator Issues #581

closed

Use more compact formats for intensity textures

Added by magumagu9 almost 16 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
Category:
GFX
% Done:

0%

Operating system:
N/A
Issue type:
Feature request
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
Yes
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

Patch at http://paste2.org/p/145919. The idea is that it should be a lot faster to deal with
textures if we pass 8 bits per pixel to the graphics API rather than 32 bits per pixel. To this
end, a new output pixel format is introduced.

The issue is, this code is used across both the OpenGL and the DirectX plugins, and I have
no clue how to implement this for DirectX... it would be nice if someone could figure that
out.


Related issues 1 (0 open1 closed)

Has duplicate Emulator - Emulator Issues #2126: Native DXT textures required for some gamesDuplicate

Actions
Actions #1

Updated by omegadox almost 16 years ago

Just do it for OpenGL for now, deal with Direct3D9 when we figure out all the
graphics bugs and optimizations.

Actions #2

Updated by magumagu9 almost 16 years ago

Okay... how do you suggest I do that? Add a parameter to TexDecoder_Decode?

Actions #3

Updated by XTra.KrazzY almost 16 years ago

Wow... That's one way to not use SSE where you don't actually need it, and stop
unpacking 8 bits into 32.

TextureDecoder is all about unpacking, so please, if you can, please do it for the
other formats(there are more unpacks IIRC)

Actions #4

Updated by XTra.KrazzY almost 16 years ago

Let's extend this idea, what about A4R4G4B4? (4-bit argb)

I'm creating a D3D patch right now.

Actions #5

Updated by XTra.KrazzY almost 16 years ago

I meant 16-bit ARGB, 4 bits per channel

Actions #6

Updated by XTra.KrazzY almost 16 years ago

D3D patch:

Index: Plugins/Plugin_VideoDX9/Src/TextureCache.cpp

--- Plugins/Plugin_VideoDX9/Src/TextureCache.cpp (revision 2211)
+++ Plugins/Plugin_VideoDX9/Src/TextureCache.cpp (working copy)
@@ -176,6 +176,12 @@
case PC_TEX_FMT_BGRA32:
d3d_fmt = D3DFMT_A8R8G8B8;
break;

  • /*case PC_TEX_FMT_BGRA16: is this of any use?

  •   d3d_fmt = D3DFMT_A4R4G4B4;
    
  •   break;*/
    
  • case PC_TEX_FMT_I8:

  •   d3d_fmt = D3DFMT_L8;
    
  •   break;
    

    }

    //Make an entry in the table

Actions #7

Updated by XTra.KrazzY almost 16 years ago

OK, I have finally made a WORKING patch. It works great on DX9 (but it requires
unpacking into 16-bit textures because Intensity texture format (XXXX) does not exist
in DX, only luminance and alpha, so to prevent downsampling I unpacked it to A8L8,
which is a 16 bit format. It's still blazing fast.

I am committing this, alright?

Actions #8

Updated by magumagu9 almost 16 years ago

r2222, right? Looks good.

The other potentially interesting output formats are RGB565 (for GX_TF_RGB565), LA8 (for GX_TF_IA4
and GX_TF_IA8), and DXT1 (for GX_TF_CMPR).

Actions #9

Updated by XTra.KrazzY almost 16 years ago

  • Status changed from New to Work started

DX9 has built in DXT1-5 decoding (if the texture's size is a multiply of 4). In order
to save the decoding from the CPU, does OGL have similar support?

Actions #10

Updated by XTra.KrazzY almost 16 years ago

As for RGB565:
-DX9 D3DFORMAT: D3DFMT_R5G6B5
-OGL format: GL_RGB in combination with GL_UNSIGNED_SHORT_5_6_5

Actions #11

Updated by XTra.KrazzY almost 16 years ago

Magumagu9: I have created a new patch for RGB565 textures, but something seems
awfully wrong (since it appears the same in both DX9 and OGL I assume it is in the
decoding area)

http://paste2.org/p/146466

I hope you'll manage to fix it.
Tip: A very common RGB565 is the Wii wrist boot-up screen

Actions #12

Updated by XTra.KrazzY almost 16 years ago

RGB565 is now finished and committed, see r2225

Actions #13

Updated by XTra.KrazzY almost 16 years ago

For DXT1 in OGL: use the following as the internalFormat and GL_RGB as the format:
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0

Actions #14

Updated by XTra.KrazzY almost 16 years ago

  • Issue type set to Feature request
  • Priority set to Normal
  • Category set to gfx
  • Relates to performance set to Yes
  • Operating system N/A added
Actions #15

Updated by magumagu9 almost 16 years ago

For DXT1 in OpenGL, I think you need to call glCompressedTexImage2D instead of the normal
glTexImage2D.

Actions #16

Updated by XTra.KrazzY almost 16 years ago

No, that's another type of unknown compression I think. It only supports
GL_COMPRESSED_* where * is the usual LUMINANCE/INTENSITY/RGB/RGBA. We can not be sure
whether it's DXT1 or some other type of compression

Actions #17

Updated by XTra.KrazzY almost 16 years ago

It's exactly as I said before: GL_COMPRESSED_RGB_S3TC_DXT1 with the usual glTexImage2D

http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_dxt1.txt

Actions #18

Updated by XTra.KrazzY almost 16 years ago

wait, you have to use it with CompressedTexImage2D or it gives you INVALID_OPERATION.

I sure am a real post-bomber in this issue, aren't I? :)

Actions #19

Updated by XTra.KrazzY almost 16 years ago

Made IA8.

Here's a working DX9 IA4 patch but almost working in OGL (I can see double)
http://paste2.org/p/146798

Actions #20

Updated by magumagu9 almost 16 years ago

As far as I know, OpenGL can't load IA4 directly.

Actions #21

Updated by XTra.KrazzY almost 16 years ago

It can be loaded if you choose either GL_LUMINANCE or GL_ALPHA as the format (because
they are 8-bit, it doesn't look correct), but GL_LUMINANCE_ALPHA somehow forces it to
be 16-bit for some unknown reason.

It works great on DX9 though. It boosts speed since all text in the Wind Waker are
actually IA4 textures, and they tend to appear and disappear a lot (the "Attack" text
on the top right is a great example).

This is too bad. Please make sure there is no way.

Actions #22

Updated by XTra.KrazzY almost 16 years ago

Currently though CMPR (DXT1) is the top priority. Please do it since I have RL
commitments :)

Actions #23

Updated by magumagu9 almost 16 years ago

Work in progress on DXT1 at http://paste2.org/p/146966. It seems to work for most textures, but breaks
a few (like a couple of the logos for Tales of Symphonia startup); my guess is that there's something
wrong with the handling of non-power-of-two textures or something like that.

Actions #24

Updated by XTra.KrazzY almost 16 years ago

Looks good except for that CopyDXTBlock. Can it be avoided?

Actions #25

Updated by magumagu9 almost 16 years ago

Avoided? The blocks have to be reorganized to be compatible with the PC version of DXT1.

Actions #26

Updated by hyperiris almost 16 years ago

XTra.KrazzY:

I set

case PC_TEX_FMT_IA4:
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE4_ALPHA4;
gl_type = GL_UNSIGNED_SHORT;
break;

in OpenGL plugin, and it looks correct.

Actions #27

Updated by hyperiris almost 16 years ago

http://i39.tinypic.com/2921hm0.png

I've made two screenshots

Actions #28

Updated by hyperiris almost 16 years ago

Here's a working OpenGL IA4 patch

http://paste2.org/p/147121

Actions #29

Updated by XTra.KrazzY almost 16 years ago

I haven't tried Unsigned short because it seems weird to do so. But if it makes it
correct (and I will try it) I'll commit.

Thanks hyperiris!

Actions #30

Updated by XTra.KrazzY almost 16 years ago

magumagu9: Great job there with DXT1! Here's an updated patch with DX9 support.

http://paste2.org/p/147213

Hope you fix those last Tales of Symphonia textures!

Actions #31

Updated by hyperiris almost 16 years ago

I think it seems weird too, just looks like a driver bug :<

so, we need test on AMD GPUs and linux systems.

Actions #32

Updated by XTra.KrazzY almost 16 years ago

I can see everything perfectly fine in the wind waker. I don't have ToS so I don't care.

Actions #33

Updated by hrydgard almost 16 years ago

well don't submit it until it works with ToS :)

Actions #34

Updated by hrydgard almost 16 years ago

http://www.gamedev.net/community/forums/topic.asp?topic_id=317744

According to this thread, some early Radeons that should be able to support Dolphin
don't actually support A8L8. We should probably at least add a sanity check so that
we can get reports of this.

Actions #35

Updated by XTra.KrazzY almost 16 years ago

"Beware that on the ATI Radeon 9600/9700/9800, D3DFMT_A8 is supported whereas
D3DFMT_A8L8 isn't supported."

This should be tested with OpenGL's GL_INTENSITY format, which is basically A8L8.

Actions #36

Updated by magumagu9 almost 16 years ago

I don't know about D3D, but OpenGL should do the conversion internally even if the card doesn't directly
support the format.

Actions #37

Updated by XTra.KrazzY almost 16 years ago

What about DXT? Are you planning on finishing that?

I know for one that it's a very tough job making the texture overlay work with actual
DXT textures. Maybe we should call it completed as it is? It's already compact.

Actions #38

Updated by death2droid over 15 years ago

Here is a .patch file with XTra.KrazzY's last patch slightly edited so it doesn't
break the OpenGl plugin!

Actions #39

Updated by XTra.KrazzY over 15 years ago

hmm, can anyone test this?

Actions #40

Updated by Nolan.Check over 15 years ago

Texture Stuff Patch seems to work except for one thing: the paratroopas in Super
Smash Bros.' adventure mode have black wings when this patch is applied. Without the
patch, they have normal white wings. Weird!

Actions #41

Updated by death2droid over 15 years ago

I have no idea why!
The original patch made the whole screen not draw so maybe it has something to do
with that.

Actions #42

Updated by death2droid over 15 years ago

I'll look into it when i have time.

Actions #43

Updated by death2droid over 15 years ago

Ok try this please!
I changed a few things!

Actions #44

Updated by Nolan.Check over 15 years ago

That makes no difference.

Actions #45

Updated by Nolan.Check over 15 years ago

The PC requires DXT textures to have dimensions that are multiples of 4. But Smash
Bros. loads some compressed textures that don't meet that requirement. That probably
results in OpenGL refusing to take those textures.

Actions #46

Updated by Nolan.Check over 15 years ago

The attached patch makes corrects the problem for me.

Actions #47

Updated by death2droid over 15 years ago

Awesome thanks Nolan.Check
Here is a newer patch with you're fixes and some other stuff.

Actions #48

Updated by hrydgard over 15 years ago

Wonder if you shouldn't round up instead ... (w + 3) & ~3

Actions #49

Updated by death2droid over 15 years ago

I'm guesing w stands for width??

Actions #50

Updated by death2droid over 15 years ago

So I'm guesting something like this..

	  width &= (width + 3) & ~3;
	  height &= (height + 3) & ~3;
Actions #51

Updated by XTra.KrazzY over 15 years ago

The patch keeps growing and growing. Nice work

Actions #52

Updated by XTra.KrazzY over 15 years ago

sadly, I have no testbed to see whether all DXT textures work.

Actions #53

Updated by death2droid over 15 years ago

Same here XTra.Krazzy :)
I'm going to try and get one as soon as possible!

Actions #54

Updated by Nolan.Check over 15 years ago

Shouldn't it be:

width = (width + 3) & ~3;
height = (height + 3) & ~3;

?

Actions #55

Updated by death2droid over 15 years ago

I don't know try it with and without the & parts.

Actions #56

Updated by Nolan.Check over 15 years ago

Here is Texture Stuff Patch 6.

These are the changes:

  • Add PC-native DXT1 support to VideoCommon and OpenGL plugin
  • Add I4 support to VideoCommon and OpenGL plugin
  • Make paletted texture decoding smarter; they aren't all decoded to ARGB anymore

Includes work by XTra.Krazzy, death2droid, and myself.

Please test!

Actions #57

Updated by death2droid over 15 years ago

Good job Nolan.Check!

Actions #58

Updated by Nolan.Check over 15 years ago

How can I test I4 and IA4 textures? I doubt the current patch handles them correctly
if they're ever used.

Actions #59

Updated by death2droid over 15 years ago

I have no idea.
I don't know any games that use it.

Actions #60

Updated by XTra.KrazzY over 15 years ago

The wind waker utilizes IA4 for the waves in the sea and the copyright below the
logo. As for I4, it is used somewhere but I don't quite recall where

Actions #61

Updated by hrydgard over 15 years ago

To fix the issue with non-multiple-of-4-sized DXT textures, we could decode them to
standard RGBA textures in the old way, and only use PC DXT textures if the size is a
multiple of four (which is the most common case).

Actions #62

Updated by Nolan.Check over 15 years ago

That seems pretty drastic. The paratroopa wing textures at least seem to work fine
with the hack of rounding up the width and height. They also seem to work fine when
rounding DOWN the width and height, but I need to take a closer look before I'm sure.

Actions #63

Updated by Nolan.Check over 15 years ago

Oh, and it looks like OpenGL does not support I4 and IA4 natively. It has the
"internal format" parameters "GL_INTENSITY4" and "GL_LUMINANCE4_ALPHA4", but
apparently these are only performance hints for the driver. The actual data has to
be converted to I8 or IA8 respectively.

That's not confusing at all...

Know what else isn't confusing at all?! Trying to figure out the difference between
"intensity" and "luminance". I'm still not 100% sure.

Actions #64

Updated by hrydgard over 15 years ago

  • Status changed from Work started to Accepted

OpenGL is notorious for undefined behaviour :)

Anyway, if you're confident that the patch as is does not degrade graphics at all, feel
free to apply it. I just gave you SVN write access.

Actions #65

Updated by XTra.KrazzY over 15 years ago

Didn't I document intensity and luminance before? Intensity is alpha and grayscale
color and luminance is grayscale color IIRC. For instance, in the wind waker the sun
is I8, which means that both the alpha and the color (in grayscale, colored later to
orange) are the same value.

Actions #66

Updated by Nolan.Check over 15 years ago

I committed DXT1 support. I'm not very confident in the other stuff.

Dolphin now requires S3TC support on the user's graphics card. Is this reasonable, or
should we detect support and fall back to manual decoding if necessary?

Actions #67

Updated by kenzozusuki over 15 years ago

Your commit glitch more game. Please fix.

Resident evil remake (GC) - Chris
http://img301.imageshack.us/img301/3725/gbie081.jpg

Wario land shake it! (WII) - Press button 2
http://img14.imageshack.us/img14/4475/rwle011.jpg

Actions #68

Updated by hrydgard over 15 years ago

Hm, given these results, I think we should go back to manual decoding but keep the PC
DXT1 option as an experimental option, until it works 100%.

Actions #69

Updated by Nolan.Check over 15 years ago

Darn. I don't have any of those games.
Can someone really quickly try rounding the texture dimensions down instead of up,
please? There's a simple change to make in VideoOGL/TextureMngr.cpp. I'll make a
patch if necessary.
By those screenshots, it looks like the width of the texture is being set to either
one block too short or one block too long.

Actions #70

Updated by aleingara over 15 years ago

many games looks, more awesome, with this commit, incredible texture :D

Actions #71

Updated by elainebkkz over 15 years ago

a few games show this...
http://i41.tinypic.com/11skuuu.jpg

Actions #72

Updated by Anonymous over 15 years ago

I tried the games with rounding up and down, I don't get distortion either way. Just a
fyi I guess...

Actions #73

Updated by hrydgard over 15 years ago

Could be a case of bad drivers too...

Actions #74

Updated by hrydgard over 15 years ago

hey death2droid, missed you on IRC. You have been added.

Actions #75

Updated by Nolan.Check over 15 years ago

Alright, please test this patch. I am now rounding width and height up to the next
multiple of EIGHT in both VideoCommon and VideoOGL. It actually seems to fix some
distortion on the koopa shell items in SSBM, and I haven't seem any regressions so far.

Actions #76

Updated by Anonymous over 15 years ago

In recent revisions I saw the distortion bug on the wario shake it menu screen. perhaps
my build was not completely up to date before :(

Anyways, using that patch to round up to the next multiple of 8 does fix the distortion
for me.

Actions #77

Updated by kenzozusuki over 15 years ago

Test your patch. Glitch with Zelda WW.

http://img13.imageshack.us/img13/9770/zelda01.jpg

Actions #78

Updated by Nolan.Check over 15 years ago

Crud. I made a rather silly error in that patch. Can you find it?

Here's a new one. Revert the previous patch first.

Actions #79

Updated by elainebkkz over 15 years ago

hmmm why don't you submit this into the svn?

Actions #80

Updated by death2droid over 15 years ago

Because he wants to make sure it works.

Actions #81

Updated by tomrich_92 over 15 years ago

dont know is this might help anyone. but i can confirm that there are distortions in
Paper Mario:TTYD most of the textures are corrupted including mario and his partners
as well as the enemies and 2d backgrounds.

Actions #82

Updated by baby.lueshi over 15 years ago

Your new patch fixes the corruptions in Super Paper Mario for me.

Actions #83

Updated by Anonymous over 15 years ago

ya nolan, i had removed that part of the patch when i tested before :p

Actions #84

Updated by Nolan.Check over 15 years ago

I noticed the "expandedWidth" variable used by VideoOGL's texture loader, and I'm
wondering if we should introduce an "expandedHeight." VideoCommon's
TextureDecoder_Decode_real function should not round up the width and height; it
should be up to the video plugin, correct?

Actions #85

Updated by Nolan.Check over 15 years ago

Sorry, I'm just thinking.

Actions #86

Updated by Nolan.Check over 15 years ago

I've committed a fix.

Actions #87

Updated by Anonymous over 15 years ago

looks good

Actions #88

Updated by elainebkkz over 15 years ago

alot of games how doesnt display anything....gives alot of error like 09:25:106 E: *
Warning: Invalid PC texture format 268437664...

Actions #89

Updated by elainebkkz over 15 years ago

now*

Actions #90

Updated by death2droid over 15 years ago

Odd did this start happening in r3187 or r3188
If it's r3187 i might revert the change.

Actions #91

Updated by death2droid over 15 years ago

Of course if there is anymore reports

Actions #92

Updated by death2droid over 15 years ago

Reverted changes in r3187 because of the problem.

Actions #93

Updated by elainebkkz over 15 years ago

weell, it's cause by r3187 but then r3159 cause this
http://i41.tinypic.com/11skuuu.jpg

Actions #94

Updated by elainebkkz over 15 years ago

is it just me? im using geforce 7900GTX with 185.85 WHQL drivers

Actions #95

Updated by death2droid over 15 years ago

I have no problems like in the screenshot.
But i did get the Invalid PC texture format which i reverted the patch which caused
that to happen.

Also what game are you using.

Actions #96

Updated by elainebkkz over 15 years ago

wii games like ssbb, bust a move ,ZTP, and a couple of other games. only happens on
the wiimote screen though....and a few distorted graphics in game.....

Actions #97

Updated by Nolan.Check over 15 years ago

I don't see how my patch could have caused TexDecoder_Decode_real to return
PC_TEX_FMT_NONE, thus causing OpenGL to throw that error message...any ideas?

Actions #98

Updated by death2droid over 15 years ago

I have no idea.

Actions #99

Updated by Nolan.Check over 15 years ago

Try reverting r3188 instead. I notice that r3188 changes the conditions for when
TexDecoder_Decode is called.

Actions #100

Updated by Nolan.Check over 15 years ago

Actually, it looks like VideoOGL throws that error message also when dfmt is some
completely unknown value. I think dfmt is getting corrupted somewhere.

Actions #101

Updated by death2droid over 15 years ago

Its fixed in the newest revision by baby.lueshi

Actions #102

Updated by elainebkkz over 15 years ago

i still got distorted graphics in the wiimote screen

Actions #103

Updated by Nolan.Check over 15 years ago

Which video plugin are you using? I'm wondering because the FPS indicator is blue. I
thought it was supposed to be yellow.

Actions #104

Updated by Nolan.Check over 15 years ago

Never mind, I'm obviously clueless about that.

Is the Wii Remote warning screen an S3TC texture?

Actions #105

Updated by kenzozusuki over 15 years ago

It has fixed. You must update opengl plugin.

Blue color is better...

Actions #106

Updated by Nolan.Check over 15 years ago

OK, good.

Actions #107

Updated by death2droid over 15 years ago

The FPS color should be aqua.

Actions #108

Updated by elainebkkz over 15 years ago

no, it has not been fixed yet, btw im using the opengl plugin. this happens to some
games only. some games works perfectly, others show distorted graphics....

Actions #109

Updated by elainebkkz over 15 years ago

im using latest SVN, DirectX March Update 2009, Nvidia 185.85 WHQL Drivers, E8400,
7900GTX, 64Bit Dolphin

Actions #110

Updated by elainebkkz over 15 years ago

just to add that all these distortion graphics happens after r3158.

Actions #111

Updated by kenzozusuki over 15 years ago

What's your game?

Actions #112

Updated by elainebkkz over 15 years ago

ssbb (pal)

Actions #113

Updated by elainebkkz over 15 years ago

what's your gfx card?

Actions #114

Updated by hrydgard over 15 years ago

With PC-native DXT texturing, the black fringes on grass in Zelda Wind Waker are back.
GC handles transparency differently.

I'm not sure PC-native DXT is worth all this trouble. If it is, it should only be used
if (1) the texture contains no transparency (could scan it quickly for that before
decoding) and (2) the dimensions are exact multiples of 8.

Actions #115

Updated by Nolan.Check over 15 years ago

"GC handles transparency differently." Is that related to premultiplied alpha? i.e.
the difference between DXT1 and DXT2

Actions #116

Updated by Nolan.Check over 15 years ago

Never mind. It's clearly not.

Actions #117

Updated by hrydgard over 15 years ago

Transparent pixels have the color black on PC, while on GC, they get the mid color
(or one of the two reference colors, not entirely sure but the mid color looks good)
of the current block. The color of transparent pixels might seem to be irrelevant but
due to bilinear filtering it does matter.

Actions #118

Updated by Sonicadvance1 about 15 years ago

Is this done now?

Actions #119

Updated by Anonymous almost 15 years ago

Or now?

Actions #120

Updated by hrydgard almost 15 years ago

  • Status changed from Accepted to Fixed
Actions #121

Updated by Anonymous almost 15 years ago

Issue 2126 has been merged into this issue.

Actions #122

Updated by Anonymous almost 15 years ago

  • Status changed from Fixed to Accepted

re-opened due to issue 2126

Actions #123

Updated by pauloconstanca almost 15 years ago

Are you guys sure that this is the same issue as 2126?

DXT native was enabled only in a few revisions (50 max), in this one, the problem is
on older than the DXT native change.

Later i'm going to try in older builds than the 3200, to see win with one the game
stops showing graphics, and then ill pass here for feedback.

Actions #125

Updated by Anonymous over 13 years ago

  • Status changed from Accepted to Fixed
Actions

Also available in: Atom PDF