Git Product home page Git Product logo

Comments (2)

mame avatar mame commented on August 20, 2024 1

Good question.

The explanation is super-exaggerated. In fact, Optcarrot have no screen buffer. Instead, it caches an intermediate calculation result between VRAM and the screen.

For each pixel, GPU does three processes: (1) read values from VRAM and VROM, (2) perform some calculation with the values, and (3) decide the color and send it to the monitor.

Note that, unless VRAM changes, the result of (2) does not change. Optcarrot performs (and caches) this calculation whenever VRAM changes, but not in per-pixel loop. The per-pixel loop completely omits the processes (1) and (2), by reading the calculation result from the cache.

Here is the actual source code:

https://github.com/mame/optcarrot/blob/master/lib/optcarrot/ppu.rb#L481-L483

  • The method poke_2007 handles an update request to VRAM.
  • @name_ref is an array of integer arrays that represents VRAM.
  • @name_lut and @attr_lut are the caches that preserve the intermediate calculation result.

In essence, this method executes @nmt_ref[addr >> 10 & 0x3][addr & 0x03ff] = data, which alters a byte of VRAM. Not only that, but it updates some bytes of @name_lut and @attr_lut that corresponding to the altered byte of VRAM. I think that @lut_update maintains the correspondence between them. (Sorry, I forgot the details.)

The optimization effects may vary, but I think that it will always work positively because GPU works much faster than CPU instructions. While CPU updates one byte of VRAM, GPU handles at least several tens of pixels. This optimization slightly degrades the performance of VRAM update, and improves GPU per-pixel task. The latter is much more frequent than the former. But I could be wrong, I just investigated some limited ROMs.

from optcarrot.

pitr-ch avatar pitr-ch commented on August 20, 2024

Thanks you.

from optcarrot.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.