mupen64plus / mupen64plus-video-rice

Video plugin for the Mupen64Plus v2.0 project, using OpenGL. This plugin is based on the RiceVideoLinux plugin from earlier versions of Mupen64Plus.
31 stars 40 forks source link

Replace old Texture Unit to Texture Image Unit #18

Closed Narann closed 9 years ago

Narann commented 9 years ago

OGL Texture Units (TU) where created for fixed pipeline multitexturing. As Rice now rely on GLSL for blending, this is not relevant anymore. Official OpenGL wiki mark this as a common mistake. It seems that Texture Units are in a way to be removed from modern GPUS (a database here)

Before start, any advise from experienced devs with Texture Image Units would be welcome (are they both compatible OGL 2.1 and OGLES 2? What does it imply? etc...).

Narann commented 9 years ago

@fayvel point a good place to start investigations: 7f20efdb6f3d9d399eadd11ffb08309a3ab73d2d

richard42 commented 9 years ago

I don't know about GLES, but regarding OpenGL, the deprecated Texture Units were only used with the fixed pipeline. So if you were using GLSL shaders, then you are already using the new Texture Image Units. There is no need to replace anything in Rice video now that the old non-shader combiners are gone. You may want to grep through the code for GL_MAX_TEXTURE_UNITS and fix any places that request this parameter, as it is no longer necessary to query.

Narann commented 9 years ago

Thanks for feebacks.

So if you were using GLSL shaders, then you are already using the new Texture Image Units.

Ok, after dig into this I realize I maybe missunderstood the definitions of TU vs TIU. This because glActiveTexture is use for both.

I will do what you say and replace GL_MAX_TEXTURE_UNITS to GL_MAX_TEXTURE_IMAGE_UNITS.

But this doesn't solve this fact:

Rice work as with 8 texture units (this is why fayvel had to clamp the value to avoid overflow) but only texture unit 0 and 1 are ever bind... I need to understand why.

From a ColorCombiner (CC) perspective it make sense because from what I know, only N64 texture units 0 and 1 can be used by the CC. But I know N64 has 8 texture units. I still lack of knowledge to know what this texture units are used for has they seems to never be binded...

EDIT: Additional infos here

Narann commented 9 years ago

Technically this issue is fixed in https://github.com/Narann/mupen64plus-video-rice/commit/d24eff7ee98832f909a74b4b892a2ab668c4fc39.

But I consider the way Rice code deal with texture units has no sens anymore as there is no more fixed pipeline multitexturing feature in rice.