Exposed to command line via --[no-]dirtyrects.
As dirty rectangles make the workload vary a lot between frames, it makes
performance regressions harder to spot. Disabling it produces lower, but
much more regular FPS counts.
Fixes
"Allocator out of memory: couldn't allocate more memory from linear allocator."
error with TinyGL in GRIM in several places:
- at the beginning of Year 2, after Meche boards the boat (does not happen
when skipping cutscene)
- when loading set bi
And likely in other places.
The issue is that TinyGL queues draw calls in a fixed-size structure
(linear allocator used to quickly queue vertices), and it emits this error
when running out of space. This queue is not flushed for as long as
_flipEnable is false, and this value is controlled by game scripts.
The longer flipping is forbidden, and the more complex the scene is (more
vertices, like in bi), the more likely it is to run out of space and cause
residualvm to error out.
In set bi, missing one flip is enough to exceed buffer space.
In set lm (the one after meche boarding the boat), it takes 5 missed flips
to exceed buffer space (simpler scene), but it still happens in a split
second.
My initial thought was to empty the queue without drawing, but there is no
way to do this with OpenGL and I prefer to avoid TinyGL-only shortcuts.
It seems likely OpenGL to have larger draw operation buffers (maybe
dynamically extended ?), and/or to forcibly stall caller and execute draw
operations when running out of space. In any case, this would add
complexity to residualvm and use more CPU and GPU time for no purpose.
So instead just skip drawing until flipping is allowed again.
These were present to implement actor freezing in software rendering mode
in the way original engine was intended for performance reason.
In residualvm, software rendering will generalise the principle through
dirty-rectangles management, so off-screen buffers should not be needed.
Also, properly implementing them requires invasive changes (move previous
draw call list from global OpenGL context to individual off-screen buffers,
along with associated linear vertex allocator, adding a new draw call to
track requested buffer changes until final on-screen frame buffer
presentation).
So instead of such added complexity, lie to lua API about actor not being
in set but keep it in so it is part of normal redraw sequence.
Fixes disappearing actors in cn, bi.
Likely also fixes at, ly, sh, mn, dd which uses free/thaw lua API, but
which I did not check.
As is done for OpenGL. It allows TinyGL to take shortcuts in coordinates
transformations of all vertices.
Also, reduce trivial diffs with gfx_opengl.cpp .
Data is already converted to the correct format by copyBuffer, so write
it directly to save file.
This fixes save game screenshots taken with TinyGL renderer: Bitmap
constructor calls graphic driver's createBitmap method, and TinyGL's
converts the buffer to its own buffer pixel format - undoing the conversion
storeSaveGameImage did just before.
Fixes save game screenshots with TinyGL: without this, the screenshot
content is the menu at the time user confirmed the save, and not the
original scene.
This is consistent with OpenGL behaviour, where framebuffer-reading
operations implicitly call glFlush.
As a side effect, fix a lot of graphic glitches where script execution
would resume too late, resulting in inconsistent graphics being drawn for one
frame.