Emulation ideas ..

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Emulation ideas ..

Postby Ian » Thu Sep 17, 2020 11:39 am

I had some thoughts about a somewhat of a refactoring of the model3 opengl code .. in my renderer.
Basically how the texturing works currently is when a model references a texture, the new3d renderer cuts out that texture from the texture sheet and well makes a standard opengl texture from it.
This works nicely, but due to the way models reference overlapping textures, quite often we'll make say 8+ textures out of the 4 textures in the sheet.
It also makes invalidation quite expensive because we have to loop through memory and check for overlapping textures.

Basically instead of this we could simply pass the entire texture sheet to the shaders unmodified, and read the textures directly out of memory. Opengl 4+ can read unsigned16 bit textures, which is what the model3 uses. In opengl 4+ you can also do unsigned integer math in shaders, which is simply not possible in glsl 1.0 or 1.2. With unsigned integer math we can do code like this

Code: Select all
            texel = src[yi * 2048 + xi] & 0xFF;
            c = ((texel >> 4) & 0xF) * 17;
            scratch[i++] = c;
            scratch[i++] = c;
            scratch[i++] = c;
            scratch[i++] = (c == 255 ? 0 : 255);


Anyway this might potentially (on decent gpus) give us a speed up. It would also simplify the code a lot.

But we would need opengl 4+, and I know there are people out there on OLD gpus.
But like with nvidia now releasing 8nm GPUs with totally insane performance, do we really want to be stuck in the past forever? :s

OpenGL 4.1 came out 10 years ago now.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Emulation ideas ..

Postby Bart » Thu Sep 17, 2020 1:43 pm

This is similar to what the legacy engine does, isn't it? Except that I don't upload the raw texture data. Rather, it is pre-decoded into multiple texture sheets based on each possible format. I think since the legacy engine was designed, we've discovered that there are far more permutations of textures than initially anticipated (e.g., the 4-bit textures), so maybe this isn't practical?
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Emulation ideas ..

Postby Ian » Thu Sep 17, 2020 1:54 pm

Yes the legacy engine is similar. But you are uploading like X amount of texture sheets, one for each texture type.
My idea is to just upload the raw data, and extract the relevant colour information directly in the shader itself. So really only need to bind 1 texture.

The problem is we can't do the integer math required with gl2 ..
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Emulation ideas ..

Postby SegaLover2020 » Thu Sep 17, 2020 11:21 pm

Ian wrote:But like with nvidia now releasing 8nm GPUs with totally insane performance, do we really want to be stuck in the past forever? :s
OpenGL 4.1 came out 10 years ago now.


As a side note, even intel integrated graphics support opengl 4.4 now. In fact I've noticed a fair increase in performance with recent drivers, and these "video cards" are part of many modern processors.
User avatar
SegaLover2020
 
Posts: 63
Joined: Wed Aug 19, 2020 10:49 pm

Re: Emulation ideas ..

Postby Bart » Fri Sep 18, 2020 10:49 am

Ian wrote:Yes the legacy engine is similar. But you are uploading like X amount of texture sheets, one for each texture type.
My idea is to just upload the raw data, and extract the relevant colour information directly in the shader itself. So really only need to bind 1 texture.


Right. Your idea sounds better. And simpler on the CPU side. I think we should go for it :) IIRC, OpenGL isn't being updated anymore anyway, right?

I wish I had time to fix up the legacy engine a bit. I don't think there's much I can do on the texture and alpha front but the lighting could probably be improved.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada


Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest