JayFoxRox / xqemu

Personal development repository for XQEMU (original Xbox Emulator)
14 stars 1 forks source link

nv2a: Always specify GL texture swizzle #39

Open JayFoxRox opened 5 years ago

JayFoxRox commented 5 years ago

This adds explicit swizzle information to each texture format.

Currently, we have a manual check if the mask is {0,0,0,0} to figure out if we want want to avoid the GL texture swizzle. However {0,0,0,0} is the same as {GL_ZERO,GL_ZERO,GL_ZERO,GL_ZERO} (a valid state). But when we don't want GL texture swizzle, we'd actually need {GL_RED,GL_GREEN,GL_BLUE,GL_ALPHA}.

So instead of falling back to {0,0,0,0}, this adds the default mask instead. For texture storage formats without alpha, I've modified the default mask to {GL_RED,GL_GREEN,GL_BLUE,GL_ONE}. If this has a performance impact, we can change it back to the default mask.

Motivation:

When we have signed textures, we will probably have to read the swizzle mask elsewhere, so copying the check for {0,0,0,0} is very annoying.

Also, we might need more fields for textures in the near future, so it's good to have the struct fully initialized.


TODO: