Commit Graph
3567 Commits
Author SHA1 Message Date
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 4dc540ffeb Merge pull request #1280 from vpelletier/graphics_optimise_pixelops
GRAPHICS: Optimise PixelBuffer::getValueAt and PixelBuffer::setPixelAt.
2016-07-21 21:01:09 +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
Vincent Pelletier db764b1ca5 TINYGL: Entirely avoid calling scissorPixel in putPixel when possible. 2016-07-21 16:02:22 +02:00
Vincent Pelletier 3c2689a65f TINYGL: Optimise scissorPixel.
Scissor operations happen in a 2d rectangle, but it used to take a buffer
offset as a parameter. As a result, it had to divide that value with its
width, which is an expensive operation, which has to be done for each
pixel candidate for display (even before z-buffer comparison when
applicable, in current implementatoin).
But callers actually generate the buffer offset from rectangular
coordinates, so propagate these instead.
This sadly increases API redundancy, but saves a lot of time in a very
frequent occurrence (especially when enabling dirty rect mechanism,
which is not yet enabled by default).
2016-07-21 15:56:29 +02:00
Paweł Kołodziejski d1be78ca49 Merge pull request #1269 from vpelletier/tinygl_optimise_light
Tinygl: optimise gl_shade_vertex
2016-07-20 14:39:05 +02:00
Paweł Kołodziejski 9acb1b9039 Merge pull request #1275 from vpelletier/valgrind
TINYGL, GRIM: Fix various errors (mostly memory leaks) found by valgrind
2016-07-20 14:09:52 +02:00
Vincent Pelletier f4554c1541 GRAPHICS: Optimise PixelBuffer::getValueAt and PixelBuffer::setPixelAt.
Avoid doing a lot of operations just to move 2 or 4 bytes around.
Inline these methods as they are hot-spots and do very little: call
overhead becomes significant.
2016-07-19 11:08:35 +02:00
Vincent Pelletier 638b841c74 TINYGL: Simplify zline.cpp .
drawLine was broken for dx = 0 lines.
Also, the split between fillLineGeneric and drawLine, along with the many
parameters exchanged (with obscure names with subtle differences), made
the code hard to understand.
This implementation should be easier to check.
There was no visible CPU usage change.
Fixes GRIM's ticket printer, which are composed of a lot of vertical
segments.
2016-07-18 15:55:08 +02:00
Paweł Kołodziejski d467980499 Merge pull request #1262 from vpelletier/tinygl_dirty2d
GRIM: Fix drawLine/Rect/Polygon in TinyGL renderer
2016-07-18 05:17:35 +02:00
Vincent Pelletier db8cee2a69 TINYGL: Free BlitImage memory on close. 2016-07-18 04:36:37 +02:00
Vincent Pelletier 97dc3881e0 TINYGL: Add free_texture variant taking a GLTexture * argument.
To avoid looking texture up in the hash table when caller has a pointer to
it already. Aka, O(0) is better than O(1).
2016-07-18 04:34:09 +02:00
Vincent Pelletier 306fdff963 TINYGL: Dispose of textures beyond the first hash table entry. 2016-07-17 15:06:30 +00:00
Vincent Pelletier 95cc5127e0 TINYGL: Consistently consider Texture::handle as unsigned.
Texture handles are unsigned integers everywhere else.
2016-07-17 15:06:30 +00:00
Vincent Pelletier ed2fdb3aba TINYGL: Correct dot-product after its sign is known.
Normalising d when light is not in front of surface (nor behind when in
two-sides mode) is not needed as the value will not be used.
The same optimisation is already done when handling specular lights.
Also, remove "if (... > 1E-3)" conditions: as dot-product is not zero,
neither operand is zero, so this test (as a divide-by-zero protection) can
be removed.
2016-07-16 14:38:41 +00:00
Vincent Pelletier f66026a8aa TINYGL: Only do spotlight & specular computations when actually needed.
Spotlight and specular requires normalized d.
Skip specular if the light source or the material have no specular
component.
2016-07-16 12:17:59 +00:00
Vincent Pelletier 411e16fba5 TINYGL: Fix default diffuse and specular values for lights > 0. 2016-07-16 12:17:59 +00:00
Vincent Pelletier 342cf9a60d TINYGL: Simplify a bit updateTmp . 2016-07-15 22:20:41 +00:00
Vincent Pelletier 03da50312b TINYGL: Move the task of writing to z-buffer to FrameBuffer::writePixel.
Because writePixel may decide to not write anything (alpha test), in which
case no z-buffer write should happen.
Factorises code.
Fixes apparent back-face culling in GRIM behind transparent textures, like
the tube (the 3d-shape Manny takes out, not the flat image in foreground)
in set mo.
2016-07-14 21:30:18 +00:00
Vincent Pelletier a336422811 TINYGL: Fix clipped triangle vertices alpha channel.
In all 4 updateTmp call places, q is not initialised, so there is nothing
of value in the alpha channel (it's 0). So just apply the same rule as for
other color channels.
2016-07-14 15:36:28 +00:00
Bastien Bouclet 08fd76686d Merge pull request #1256 from bgK/sdl-split
SDL: Split the OpenGL code to a separate GraphicsManager
2016-07-14 12:06:30 +02:00
Bastien Bouclet 7a52f226e7 OPENGL: Modify SurfaceRenderer to allow alpha blending 2016-07-14 12:02:55 +02:00
Bastien Bouclet b718d86a6f OPENGL: Add TiledSurface to be used for drawing large 2D surfaces 2016-07-14 12:02:55 +02:00
Paweł Kołodziejski 863548efeb Merge pull request #1261 from vpelletier/tinygl_texture_matrix
Tinygl texture matrix
2016-07-14 09:57:52 +02:00
Bastien Bouclet 6b266a9179 OPENGL: Unbind the active program when destroying the active shader
Fixes switching renderers from Shaders to OpenGL in Grim with SDL2
2016-07-12 06:29:32 +02:00
Vincent Pelletier 46fa5eb373 TINYGL: Fix off-by-one in TGL_LINE_LOOP/TGL_LINE_STRIP .
Also, draw last line from last point to first instead of first point to
last as the latter leaves an unpainted pixel for some reason.
2016-07-11 14:52:36 +00:00
Torbjörn Andersson 11ec5ad5a3 GRAPHICS: Fix copy/paste error in blitAlphaBitmapClip() (CID 1357410) 2016-07-11 05:43:24 +02:00
Torbjörn Andersson 6eabc887e1 GRAPHICS: Fix copy/paste error in blitSurfaceClip (CID 1357411) 2016-07-11 05:41:04 +02:00
Vincent Pelletier 98696865df TINYGL: Fix TGL_QUADS with more than one quad.
Fixes checkbox border on Copal's computer.
2016-07-11 00:30:58 +00:00
Vincent Pelletier e72db42ef0 TINYGL: Fix tglOrtho matrix definition.
As per glOrtho documentation, bottom-right must be 1.
Also, in TinyGL, matrices are row-major, so m._m[0][3] is r[3], not
r[12].
2016-07-11 00:00:30 +00:00
Vincent Pelletier 6f1e46d6b4 TINYGL: Implement tglColor3ub. 2016-07-11 00:00:30 +00:00
Vincent Pelletier 93d23656fa TINYGL: Do not clear matrix_model_projection_updated in gl_matrix_update.
Changing texture or color matrices must not prevent a model projection
update, even if it is done last.
2016-07-10 13:19:45 +00:00
Vincent Pelletier f75767fc78 TINYGL: Always check if texture matrix need applying.
matrix_model_projection_updated is not set when texture matrix alone is
modified.
2016-07-10 13:13:46 +00:00
Alexander Tkachev 6de5324742 JANITORIAL: Fix a few warnings 2016-07-03 12:24:55 +02:00
Alexander Tkachev cea58cc61c JANITORIAL: Remove trailing spaces 2016-07-03 12:24:53 +02:00
Alexander Tkachev 6fd6043391 GUI: Fix blitAlphaBitmapClip() 2016-07-03 12:24:11 +02:00
Alexander Tkachev 4b87563792 GUI: Add blipClip() 2016-07-03 12:23:57 +02:00