Commit Graph
373 Commits
Author SHA1 Message Date
Vincent Pelletier 5ab94de318 TINYGL: Avoid unneeded calls in writePixel. 2017-04-26 13:11:00 +00:00
Vincent Pelletier fc37fabf0d TINYGL: Fix assertion failure during EMI intro video.
This is a regression introduced by
commit 6a63f544f0
    TINYGL: Avoid duplicating gl_transform_to_viewport.
2017-04-25 00:58:24 +00:00
Vincent Pelletier 2a1ab0a622 TINYGL: Do not queue invisible draw calls.
When dirty rectangles are enabled, we know at this point whether a draw
operation will have any effect on screen. Do not queue it if it will not.
2017-04-23 12:30:00 +00:00
Vincent Pelletier bf319b5437 TINYGL: Cache and clip dirty rect on all DrawCall subclasses.
getDirtyRegion will be called twice on each DrawCall instance, so make
repeated work as short as possible.
2017-04-23 12:30:00 +00:00
Vincent Pelletier 6a63f544f0 TINYGL: Avoid duplicating gl_transform_to_viewport.
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.
2017-04-23 12:30:00 +00:00
Vincent Pelletier 50c5aef6e5 Revert "TINYGL: Reuse renderRect instead of accessing fb size."
This reverts commit ec418a9769.
2017-04-23 12:25:58 +00:00
Vincent Pelletier ec418a9769 TINYGL: Reuse renderRect instead of accessing fb size. 2017-04-23 12:03:52 +00:00
Vincent Pelletier 064bd1d47b fixup! TINYGL: ClearBufferDrawCall should obey its parameters.
Fixes an undeclared property error.
2017-04-23 11:54:53 +00:00
Vincent Pelletier 6087492dbd TINYGL: Simplify setting & disabling scissors. 2017-04-23 10:35:04 +00:00
Vincent Pelletier e1de3407f1 TINYGL: Make scissors follow Common::Rect semantics.
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.
2017-04-23 10:35:04 +00:00
Vincent Pelletier 3acde7d900 TINYGL: static-ify zdirtyrect.cpp 2017-04-23 10:35:04 +00:00
Vincent Pelletier 2fb2d87dc9 TINYGL: Skip drawing when there is no dirty rectangle 2017-04-23 10:35:04 +00:00
Vincent Pelletier 72389d23df TINYGL: Simplify _drawCallAllocator switch & reset. 2017-04-23 10:35:04 +00:00
Vincent Pelletier 580578fa20 TINYGL: Containment is just a special case of intersection. 2017-04-23 10:35:04 +00:00
Vincent Pelletier 3f4a22354e TINYGL: Remove redundant condition.
Empty call queue condition is tested in contained "for" loop already.
2017-04-23 10:35:04 +00:00
Vincent Pelletier 5cbdabb69d TINYGL: Continue comparing past first divergence
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.
2017-04-23 10:35:04 +00:00
Vincent Pelletier ce97ff4e8f TINYGL: ClearBufferDrawCall should obey its parameters.
Given dirty rectangle may cover more buffer area than what it was told to
clear.
2017-04-23 10:35:04 +00:00
Vincent Pelletier cc42d5cb24 TINYGL: Fix scissor testing in ztriangle.
When dirty rectangles are enabled, fixes drawing outside (below) set scissor
rectangle.
y and pp1 must stay consistent for scissor testing to be relevant. y is
already incremented along with pp1, and pp1 does not get re-assigned on
part == 2, so do not set y either.
2017-04-23 10:35:04 +00:00
Vincent Pelletier 500803fc38 TINYGL: Implement tglDrawArrays. 2017-04-22 16:42:14 +00:00
Vincent Pelletier 0b823ac2e9 TINYGL: Expose array functions outside of TinyGL namespace.
And prefix them with "tgl" instead of "gl", as in header.
2017-04-22 16:42:14 +00:00
Vincent Pelletier 13ad766b31 Merge pull request #1294 from vpelletier/tinygl_memory
Tinygl memory
2016-08-27 04:58:56 +02:00
Vincent Pelletier 112ca82363 TINYGL: Manage BlitImages with a refcount.
So that zdirtyrect can keep an image alive for longer than its creator
intended.
2016-07-28 23:32:43 +00:00
Vincent Pelletier 8cd029aac7 TINYGL: Add support for 4-bytes words in FrameBuffer::clear{,Region} 2016-07-28 23:29:17 +00:00
Vincent Pelletier 7e51d78480 TINYGL: Fix FrameBuffer::clearRegion color clearing line length. 2016-07-28 15:26:14 +00:00
Vincent Pelletier e7e1df886e TINYGL: Merge dead kInterpST code path into kInterpSTZ one.
Texture coordinates interpolation along Z coordinate is an extra behaviour
over texture coordinates interpolation along X and Y coordinates.
2016-07-28 02:46:41 +00:00
Vincent Pelletier a577b4c6a6 TINYGL: Free disposed textures before images.
Reusing function already defined in zdirtyrect.cpp doing both.
2016-07-28 01:55:48 +00:00
Vincent Pelletier 47a1e826e7 TINYGL: Free draw call lists in glClose. 2016-07-28 01:55:48 +00:00
Vincent Pelletier 3221146de9 TINYGL: Always initialise normal and eye coordinates (valgrind) 2016-07-28 01:55:48 +00:00
Vincent Pelletier 786311652a TINYGL: Initialise all light properties (valgrind).
Also, sort initialisation in the same order as declaration, for easier
difference-spotting.
2016-07-28 01:55:48 +00:00
Vincent Pelletier f272c85704 TINYGL: Initialise z buffer (valgrind) 2016-07-28 01:55:48 +00:00
Vincent Pelletier 369332e464 TINYGL: Treat alpha the same way as other color components.
When kLightsMode (aka kInterpRGB) is false, "a" is always 0 (vertice data is
not used in caller in corresponding branches), so taking it into account makes
all triangles transparent.
This is not visible in practice, because putPixelTextureMappingPerspective is
only called when (kInterpST || kInterpSTZ) is true, and kInterpRGB is always
true when that's the case. But unifying color processing allows further code
simplification.
2016-07-28 01:55:14 +00:00
Vincent Pelletier 0065f38251 TINYGL: Reuse global const. 2016-07-28 01:55:14 +00:00
Vincent Pelletier e1d5b811e1 Revert "GRIM: fixed transparency in TinyGL renderer"
This reverts commit b8bddf64da.

Since 9b7548ccf7, alpha test is enabled
when drawing model faces, fixing transparency issues in GRIM which were
corrected by reverted commit.
It is incorrect to test transparency when caller did not enable it.
Also, this change bypasses increments done at the end of
putPixelTextureMappingPerspective, so transparent textures in 16 bits mode
would be stuck on the transparent pixel for the current line's 8-pixel run
in filTriangle, and would ignore z coordinate.
2016-07-28 01:55:14 +00:00
Vincent Pelletier 8b6d362c58 TINYGL: Reuse _enableScissor property.
Should have been part of:
  commit db764b1ca5
  TINYGL: Entirely avoid calling scissorPixel in putPixel when possible.
2016-07-28 01:55:14 +00:00
Vincent Pelletier 18342118dc TINYGL: Fix y coordinate tracking when drawing triangles.
Increment y inside the loop, not outside.
Set y to the topmost vertex y coordinate, which depends on which half of
the triangle is being drawn.
Should have been part of:
  commit 3c2689a65f
  TINYGL: Optimise scissorPixel.

This does not (should not) fix any visible regression, as pixel scissor is
only (?) used when dirty rectangle mecanism is enabled (and it is disabled).
2016-07-28 01:55:10 +00:00
Vincent Pelletier 0a41574079 TINYGL: Process colors in RGBA 32bits internaly. 2016-07-24 01:20:50 +02:00
Paweł Kołodziejski ac9986452e Merge pull request #1279 from vpelletier/tinygl_reunroll
TINYGL: reduce code duplication in ztriangles (was: [RFC] TINYGL: unroll some loops)
2016-07-23 13:59:14 +02:00
Vincent Pelletier 80983c1b69 TINYGL: Unroll FrameBuffer::blitOffscreenBuffer.
This method is used to blit large buffers, so a large unrolling is still
beneficial. As it is the second hottest-spot in grim, the frame rate
increase is most significant there (compared to emi).
2016-07-22 14:58:58 +02:00
Vincent Pelletier cf53e8871d TINYGL: Unroll DRAW_SHADOW and DRAW_SHADOW_MASK.
Also, update z in the second DRAW_SHADOW loop like it is done in the first.
Also, check each shadow mask pixel in DRAW_SHADOW, instead of 1 every 4.
2016-07-22 14:49:16 +02:00
Vincent Pelletier 93c6dc6027 TINYGL: Avoid calling memset_{s,l} when possible.
It is possible to convert calls to memset_{s,l} into call to memset when
all bytes of the depth or color value are the same (which is the likely
case), improving buffer clearing speed.
2016-07-22 07:19:48 +02:00
Paweł Kołodziejski 74ffd37dbe Merge pull request #1278 from vpelletier/tinygl_scissorpixel
Tinygl: optimise scissorpixel
2016-07-21 21:57:05 +02:00
Paweł Kołodziejski 4ffde5f680 Merge pull request #1282 from vpelletier/tinygl_loaddata_pixelformat
TINYGL: Expect colorKey in the same pixel format as surface.
2016-07-21 18:30:02 +02:00
Vincent Pelletier 46329cca87 TINYGL: Do not compute dirty region when its result is not used. 2016-07-21 16:42:24 +02:00
Vincent Pelletier d2defcd1cc TINYGL: Actually check if alpha test and blending are enabled. 2016-07-21 16:42:10 +02:00
Vincent Pelletier a1418732ec TINYGL: Typo in disabled code. 2016-07-21 16:41:24 +02:00
Vincent Pelletier 8ec310468d TINYGL: Replace multiplications by iterative additions.
As an iteration is done already anyway.
2016-07-21 16:41:18 +02:00
Vincent Pelletier a831238a96 TINYGL: Drop some unused locals. 2016-07-21 16:40:36 +02:00
Vincent Pelletier 4ff03d060e TINYGL: Call tglColor4f from tglColor4fv. 2016-07-21 16:40:07 +02:00
Vincent Pelletier d437892538 TINYGL: Get rid of PSZB as it duplicates pixelbytes. 2016-07-21 16:39:40 +02:00
Vincent Pelletier 7c1a15c6e8 TINYGL: Expect colorKey in the same pixel format as surface.
So caller does not have to depend on the pixel format used internally to
BlitImage.
Update callers which do request for color keying (GRIM/EMI only).
Also, remove a special-casing of transparent color when converting image
format which sets a color in a packed format independent from actual
destination format.
Also, in GfxTinyGL::createTextObject, prefer changing invisible colorKey
value than actually-visible color.
2016-07-21 16:17:32 +02:00