Commit graph

78 commits

Author SHA1 Message Date
Orgad Shaneh
a05e54f00c JANITORIAL: Remove trailing whitespaces 2021-05-04 11:46:30 +03:00
Vincent Pelletier
f8c72b5967 TINYGL: Move texture resampling from create time to render time
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.
2020-11-12 08:15:39 +01:00
Pawel Kolodziejski
b321938c7b TINYGL: Restored ability to create internal buffer based on pixel format 2020-10-05 08:09:20 +02:00
Vincent Pelletier
7988c696d9 TINYGL: Drop unused Framebuffer pixelbits property 2017-05-01 08:34:53 +00:00
Vincent Pelletier
4bcc95f217 TINYGL: Fix ARGBST scaling.
I based ARGB scaling on ST scaling without giving it enough thought.
It accidentally uncovered an older bug in glopClear, which made me recheck
these formulas.
ST scaling maps [0.0, 1.0] to [0x01.0000, 0xff.0000], meaning the first and
last texture rows and columns are never shown.
Treating s and t as proportions of ST_MAX fixes this by mapping to
[0x00.0000, 0xff.fffc] (last two fractional bits being off-precision, as
there are only 14 bits), covering the whole available range.
2017-05-01 08:34:25 +00:00
Vincent Pelletier
92a54a5969 fixup! TINYGL: Fix line color
These shifts are now handled in zline (only user of this macri),
consistently with ztriangle.
I have removed this macro from my working copy, but I missed the breakage
while resolving the conflict.
2017-05-01 04:45:11 +00:00
Vincent Pelletier
39656ce5c5 TINYGL: Store colors with 8-bits integer part
Before this change vertex data (post-shading) was limited to 6 (green) or
5 (all others) bits of precision.
Interpolation happened with 8-bits precision, so the visual effect is
minor: about 4 off at vertices.
2017-05-01 02:22:17 +00:00
Vincent Pelletier
054a2bd920 TINYGL: Fix line color
As in ztriangle, vertex color must be shifted from internal 16-bits
fixed-point format to 8-bits colors.
To do so, define values similar to the ones describing for ST fixed-point
format.
Also, use these in tglClear instead of hard-coded multiplicands, as is
done in tglColor4f and gl_transform_to_viewport.
Also, make tglClear take into account requested clear depth.
2017-05-01 02:21:40 +00:00
Vincent Pelletier
5ab94de318 TINYGL: Avoid unneeded calls in writePixel. 2017-04-26 13:11:00 +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
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
Paweł Kołodziejski
74ffd37dbe Merge pull request #1278 from vpelletier/tinygl_scissorpixel
Tinygl: optimise scissorpixel
2016-07-21 21:57:05 +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
d437892538 TINYGL: Get rid of PSZB as it duplicates pixelbytes. 2016-07-21 16:39:40 +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
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
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
Pawel Kolodziejski
b8bddf64da GRIM: fixed transparency in TinyGL renderer 2014-12-25 15:16:50 +01:00
Stefano Musumeci
2cf70d6d76 Merge branch 'master' into tinygl-dirty-rects-fixed
Conflicts:
	graphics/tinygl/ztriangle.cpp
2014-08-16 16:03:27 +02:00
Stefano Musumeci
f9332da316 TINYGL: Refactored if-else sequence with progressive function calls. 2014-08-13 22:38:24 +02:00
Pawel Kolodziejski
1b48414d7e TINYGL: cleanup license headers 2014-08-13 18:52:52 +02:00
Stefano Musumeci
92d8ecc34c TINYGL: Added depth test enabled state tracking to dirty rects. 2014-08-13 14:33:54 +02:00
Stefano Musumeci
e3acac6187 TINYGL: Merged conflicts 2014-08-13 14:27:10 +02:00
Stefano Musumeci
8abb5b008c Merge branch 'master' into tinygl-dirty-rects
Conflicts:
	graphics/tinygl/zbuffer.cpp
	graphics/tinygl/zbuffer.h
2014-08-13 14:06:34 +02:00
Joni Vähämäki
c420196014 TINYGL: Always pass the depth test if TGL_DEPTH_TEST is disabled. 2014-08-12 17:46:48 +03:00
Stefano Musumeci
6e75f6b594 TINYGL: Renamed rasterization functions template parameters with constants naming convention. 2014-08-10 20:31:07 +02:00
Stefano Musumeci
a59c1de0ff TINYGL: Fixed misspelt function name. 2014-08-10 19:05:32 +02:00
Stefano Musumeci
b83dc09f84 TINYGL: Added const to member function. 2014-08-09 12:02:42 +02:00
Stefano Musumeci
f107e7cf6b TINYGL: Renamed variables to camelCase. 2014-08-09 12:00:43 +02:00
Stefano Musumeci
a4b57371e2 TINYGL: Refactored out duplicated code. 2014-08-08 13:09:44 +02:00
Stefano Musumeci
5ae16bd1fe TINYGL: Added const modifier to equality operator. 2014-08-07 17:31:45 +02:00
Stefano Musumeci
8c94a65a70 TINYGL: Optimized rasterization routines by moving more data from dynamic evaluation to static evaluation. 2014-08-06 21:52:41 +02:00
Stefano Musumeci
6afe1c6f14 TINYGL: Fixup formatting. 2014-08-05 20:00:24 +02:00
Stefano Musumeci
e4526b3ed5 TINYGL: Separated pixel scissoring logic from pixel writing one. 2014-08-05 13:21:03 +02:00
Stefano Musumeci
1220e5373f TINYGL: Moved a check down, optimizing away a case where the pixel is ignored. 2014-08-02 21:43:27 +02:00
Stefano Musumeci
2189e97409 TINYGL: Implemented partial screen clearing. 2014-08-01 19:45:55 +02:00
Stefano Musumeci
79ea06e41d TINYGL: Implemented scissor rectangle in frame buffer. 2014-08-01 19:45:32 +02:00
Stefano Musumeci
5049413d24 TINYGL: Minor optimization.
Note: removed a duplicated if check.
2014-08-01 19:08:43 +02:00
Stefano Musumeci
4332aaf378 TINYGL: Implemented equality operator for ZBufferPoint 2014-07-31 15:24:41 +02:00
Stefano Musumeci
a96597b0e0 TINYGL: Added a getter function to FrameBuffer. 2014-07-25 16:02:25 +02:00
Stefano Musumeci
b5720b425f TINYGL: Added tglBlitZBuffer as a way to render to the Z buffer. 2014-07-25 16:02:24 +02:00
Stefano Musumeci
b5bb75cc9e TINYGL: Change a detail in the API implementation.
Reason: changing this allows to get a valid value of alphaTestFunc from the function instead of a value that will always be
transformed inside the setter when it could be transformed somewhere else without hurting anyone.
2014-07-25 16:02:22 +02:00
Stefano Musumeci
46ff1767ab TINYGL: Moved a few member function of FrameBuffer from source to header file to favor inlining. 2014-07-24 19:51:07 +02:00
Stefano Musumeci
7808f7190a TINYGL: Added some getter functions to FrameBuffer 2014-07-23 21:39:47 +02:00
Stefano Musumeci
ff32b64212 TINYGL: Added utility function in FrameBuffer. 2014-07-18 18:50:08 +02:00
Pawel Kolodziejski
9a81f8997c TINYGL: properly handle color for FLAT mode and lines drawing. Respect FLAT/SMOOTH mode for triangle drawing 2014-07-05 20:54:14 +02:00
Pawel Kolodziejski
97b03aed01 TINYGL: changed code to allow initialize TinyGL with specific internal texture dimension.
Grim: 256x256, Myst3: 1024x1024
2014-07-05 13:08:34 +02:00
Pawel Kolodziejski
f477946646 TINYGL: allow change internal texture size at compilation time. Now it's 1024x1024 pixels. 2014-07-05 12:13:03 +02:00