Thanks to pixel repacking using cpu data cache, this has a low runtime
cost even for TGL_LINEAR.
Adds support for TGL_NEAREST.
Adds support for TGL_MIRRORED_REPEAT, TGL_CLAMP_TO_EDGE and TGL_REPEAT.
Also, add support for more texture clamping and resampling options.
Mipmaps are not supported, although their sampling modes will be
applied - but to the full-size texture instead of selected mipmap.
Note: Texture sampler is still chosen at texture creation time.
The function end() of a list does not return the last element but a fake element
after the last one, for the need of the iterator.
Trying to access to the data of the element returned by end() and that has no
such field, that caused a stack buffer overflow, reading uninitialized data.
Called function back() instead, to get the last element of the list.
longcurrent_color is assigned per vertex, but it is not saved on each
vertex on creation (unlike their "color" attribute, used when lighting
is enabled).
As a consequence, and because rendering happens asynchronously (rather,
following the draw call queue managed by zdirtyrect.cpp when requested
to flip current buffer), longcurrent_color at clipping time can be
different to the one at vertex declaration time, causing color artifacts.
The effect is most noticeable in EMI set shi, in the grog dispenser +
shipyard manager closeup angle, when Guybrush exits the screen by
crossing its right border: dark triangles become visible on his face.
Instead, always use the color attribute, which is already properly
initialised on vertex creation.
As all dirty rectangles are inflated by 1 pixel to the right and one to the
bottom, they may exceed render rectangle. So clip them again. There should
be very few rectangles at this point, so this should be cheap.
Replace local implementation by always setting GLVertex zp property.
Replace pointInsideVolume by clip_code, allowing to properly handle
polygons whose vertices are all off-screen but still have a part visible.
Also, replace 2-pixels offset with a more accurate bounding box
computation.
As per Common::Rect data model, right and bottom border are excluded, so:
- Make FrameBuffer::scissorPixel reject bottom & right borders.
- Update bounding rectangle definition for dirty rectangle operations
ClearBufferDrawCall::getDirtyRegion is already correct.
- zblit was almost following, except for an off-by-one mistake.
It is common that the same number of calls are done in the same order, so
do not stop comparing after the first divergence. This saves a significant
number of dirty rectangle in crowded scenes, like sets cn and bi where a few
calls may differ in the middle of call sequence, but later calls would stay
the same.
As a consequence, move current-frame-has-fewer-calls handling to its own
loop.
Also, factorise and extend code appending dirty rectangles.
Also, skip conseutive identical rectangles.