src/render/opengles2/SDL_render_gles2.c


Log

Author Commit Date CI Message
ds-sloth 038ccd76 2023-01-22T17:16:13 Support MIN/MAX blend on opengles2
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Sam Lantinga aefc6b5b 2022-10-18T08:40:03 Renamed variables, index is the singular of indices
Sylvain dfbb93dd 2022-10-18T11:31:30 SDL_Renderer / GLES2: add specific list of indice to render rect (see #6401)
Ryan C. Gordon 321ca109 2022-10-03T12:00:38 opengles2: Texture names are GLuint, not GLenum.
Ryan C. Gordon 01c5554f 2022-10-03T11:57:10 opengles2: SDL_GL_BindTexture() should bind all YUV textures. This matches what the non-GLES OpenGL renderer does. Fixes #6070.
Sam Lantinga d744aafb 2022-09-15T01:00:12 Added support for simulated vsync in the renderer This kicks in if the platform doesn't support vsync directly, or if the present fails for some reason (e.g. minimized on some platforms) Fixes https://github.com/libsdl-org/SDL/issues/5134
Sam Lantinga 5bc85d67 2022-09-16T06:15:45 Only advertise the SDL_PIXELFORMAT_EXTERNAL_OES format if we can build the shader for it
Sam Lantinga 2970710b 2022-09-15T07:41:29 Pretty print shaders for debugging purposes
Sam Lantinga bc57d3e3 2022-09-15T06:57:41 Fixed OpenGL ES shader compilation on Linux
Sam Lantinga 8a15a738 2022-09-15T06:21:19 Fixed uninitialized variable warning
Sam Lantinga b5102a55 2022-09-14T08:03:46 Fixed OpenGLES shaders failing after renderer has been created Cache all the shaders up front, so we can verify that they won't silently fail at runtime. If compiling the fragment shaders with the precision hint fails, try again without specifying precision. Fixes https://github.com/libsdl-org/SDL/issues/6166 Fixes https://github.com/libsdl-org/SDL/issues/6174
Sam Lantinga 29f4a5ba 2022-09-06T15:55:27 Add GLES2 shader prologue infrastructure. (by @eloj) There is supposedly an OpenGL ES2 target that does not support precision specifiers. However, the existing logic to detect this is currently broken in two ways: 1) There's a typo of the `#ifdef` as `#if`. 2) Checking for `GL_FRAGMENT_PRECISION_HIGH` can not be the correct way to detect this platform. Other targets, including some desktops, will also not have this defined (for various reasons). Because some of the shader code is missing precision specifiers, and because a default is ONLY provided if `GL_FRAGMENT_PRECISION_HIGH` is set, these other targets break. Instead of 'hard-coding' the prologue string into shaders in the C source, use our ability to provide a list of strings to `glShaderSource` instead, leaving the determination to run-time. This commit closes https://github.com/libsdl-org/SDL/pull/6182
Sam Lantinga adc68758 2022-06-17T10:22:28 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!) Closes https://github.com/libsdl-org/SDL/pull/5811
Sylvain 04256a53 2022-03-09T15:12:25 Fix compilation (see #5313)
pionere 3f8b450d 2022-02-05T12:22:34 extend the code hidden by SDL_HAVE_YUV
Sylvain f5911bdc 2022-01-28T15:31:56 GLES2: disable texcoord when not using it (see bug #5235) similar to opengl backend code: - glDisableVertexAttribArray doesn't need to depend on 'drawstate.texture' value - move binding code to SetCopyState()
Sylvain 096fe37b 2022-01-28T14:19:10 GLES2: revert https://github.com/libsdl-org/SDL/commit/7bf8c5a388bc41dde830e4baabcb53d507e64448
Sylvain 7bf8c5a3 2022-01-27T14:19:52 GLES2: disable texcoord when not using it (see bug #5235)
Ryan C. Gordon 426c1f4b 2022-01-19T14:27:58 opengles2: fix comment about client-side arrays.
Ryan C. Gordon f9b918ff 2022-01-11T16:15:45 opengles2: Use client-side arrays on everything but Emscripten. Turns out they're much faster! Fixes #5206.
Ryan C. Gordon c275436f 2022-01-09T00:39:02 opengles2: Batching lines/points used wrong var for summing vertex counts. Fixed this in the vitagxm backend too, but I don't know what the state of that code is otherwise. Reference Issue #5061.
Sam Lantinga 18e4d9fe 2022-01-08T09:02:25 Re-enable line drawing path in render drivers This is still used for scaled line drawing in RenderDrawLinesWithRects()
Sylvain 9aac5531 2022-01-07T22:42:52 Remove QueueDrawLines from GL, GLES, GLES2
Ryan C. Gordon 88ac517d 2022-01-07T15:03:47 opengles2: Fix point drawing.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sylvain 44c84c0d 2021-12-17T17:44:34 GLES2/Big-endian: donĀ“t swap datas for yuv textures (Thanks 0x1F9F1 !)
Sylvain 3a69828e 2021-12-17T13:15:39 Fixed GLES2 back-end on Big Endian Platform (see #5093)
Sylvain 50d49c63 2021-12-16T10:52:36 GLES2 backend: cast with SDL_Vertex and SDL_VertexSolid
Alex Szpakowski 3a5e148b 2021-12-14T11:02:07 Renderer backends use SDL_Color instead of int for geometry colors.
Sylvain d7f66ba1 2021-12-11T20:04:53 Remove strict aliasing warning in opengles2 backend
Sylvain 8dd6edec 2021-11-23T09:30:42 Fixed bug #3232 - Integer overflow generates Illegal instruction under sanitizers + see bug #4995
Sylvain d4df5d33 2021-11-15T09:43:44 GLES2: prevent batching if blend mode changes (see bug #4964)
Sylvain 92f2fdfc 2021-11-15T09:36:18 GLES2: batch non joined lines (see #4964)
Sylvain 17f156fa 2021-11-15T09:08:09 Fixed bug #4964 - opengles2 & batching = conjoined lines put back the initial switch case because groups of joined lines cannot be batched.
Sylvain d8888e46 2021-11-15T08:37:49 Fixed bug #4964 - opengles2 & batching = conjoined lines
Sam Lantinga c55ab963 2021-11-13T22:21:57 Added a hint for alternate OpenGL NV12 data format
Sylvain 502e9c3b 2021-10-24T17:16:49 SDL_Renderer simplifications: - Factorize PrepQueueCmdDraw{,DrawTexture,Solid) into one single function - Change SDL_Texture/Renderer r,g,b,a Uint8 into an SDL_Color, so that it can be passed directly to RenderGeometry - Don't automatically queue a SET_DRAW_COLOR cmd for RenderGeometry (and update GLES2 renderer)
Sylvain 99a34643 2021-09-24T09:42:04 OpenGLES2: LINES and POINTS successive commands are combined into a single draw call (using the same case for DRAW_GEOMETRY)
Sylvain f0cdc1d0 2021-09-24T09:38:25 OpenGLES2: remove FillRects, since it's can be done with RenderGeometry
Sylvain b0eef52f 2021-09-23T22:32:29 GLES2 batching: probably need to check for blendMode changes
Sylvain b92056bb 2021-09-20T16:33:03 OpenGLES2: remove RenderCopy and RenderCopyEx from back-end
Ryan C. Gordon 08797ada 2021-09-19T00:39:28 opengles2: Attempt to batch RenderCopy calls into a single glDrawArrays call.
Ryan C. Gordon ca9a3217 2021-09-19T15:47:24 render: GL/GLES now draw lines almost perfectly matching software renderer. One place known to differ in a significant way is a single line segment that starts and ends on the same point; the GL renderers will light up a single pixel here, whereas the software renderer will not. My current belief is this is a bug in the software renderer, based on the wording of the docs: "SDL_RenderDrawLine() draws the line to include both end points." You can see an example program that triggers that difference in Bug #2006. As it stands, the GL renderers might _also_ render diagonal lines differently, as the the Bresenham step might vary between implementations (one does three pixels and then two, the other does two and then three, etc). But this patch causes those lines to start and end on the correct pixel, and that's the best we can do, and all anyone really needs here. Not closing any bugs with this patch (yet!), but here are several that it appears to fix. If no other corner cases pop up, we'll call this done. Reference Bug #2006. Reference Bug #1626. Reference Bug #4001. ...and probably others...
Ryan C. Gordon 5faea84c 2021-09-18T11:54:25 render: Mark viewport/cliprect dirty when window is resized. Fixes #4751.
Misa 4549769d 2021-03-07T15:20:45 Add `SDL_RenderSetVSync()` Currently, if an application wants to toggle VSync, they'd have to tear down the renderer and recreate it. This patch fixes that by letting applications call SDL_RenderSetVSync(). This is the same as the patch in #3673, except it applies to all renderers (including PSP, even thought it seems that the VSync flag is disabled for that renderer). Furthermore, the renderer flags also change as well, which #3673 didn't do. It is also an API instead of using hint callbacks (which could be potentially dangerous). Closes #3673.
Sylvain 54ca1d19 2021-08-27T07:44:03 SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600)
Sylvain 154384a7 2021-08-18T23:59:27 Add (uintptr_t) casts
Sylvain a8f89a01 2021-04-23T12:00:14 Change 'size_indice' to 'size_indices'
Sylvain 47db47c1 2021-04-06T21:32:02 Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support
Sylvain b9bd9da7 2021-04-04T22:34:17 OpenGLES2: transfert color as 4 bytes, instead of 4 floats
Sylvain 32e79101 2021-04-01T20:27:22 Fix warnings
Sylvain cd0663e0 2021-04-01T11:47:45 Fix declaration-after-statement and remove tabs
Sylvain e4812611 2021-04-01T09:49:16 Move to SDL_RenderGeometryRaw prototype with separate xy/uv/color pointer parameters
Sylvain f73c1eff 2021-03-17T09:58:49 Use normalized texture coordinates
Sylvain faded41a 2021-03-16T15:11:13 Add OpenGLES2 implementation
Sylvain 53a2608b 2021-03-14T22:32:17 Renderer opengles2: turn color Uniform into Attribute. all attributes are copied interleaved (based on rmg-nik initial patch+ + minor clean up of data structure + add check for colorswap
Jessica Clarke 8f38ba4d 2021-07-29T18:02:47 Fix casts that should be using uintptr_t This is needed to support CHERI, and thus Arm's experimental Morello prototype, where pointers are implemented using unforgeable capabilities that include bounds and permissions metadata to provide fine-grained spatial and referential memory safety, as well as revocation by sweeping memory to provide heap temporal memory safety. On most systems (anything with a flat memory hierarchy rather than using segment-based addressing), size_t and uintptr_t are the same type. However, on CHERI, size_t is just an integer offset, whereas uintptr_t is still a capability as described above. Casting a pointer to size_t will strip the metadata and validity tag, and casting from size_t to a pointer will result in a null-derived capability whose validity tag is not set, and thus cannot be dereferenced without faulting. The audio and cursor casts were harmless as they intend to stuff an integer into a pointer, but using uintptr_t is the idiomatic way to do that and silences our compiler warnings (which our build tool makes fatal by default as they often indicate real problems). The iconv and egl casts were true positives as SDL_iconv_t and iconv_t are pointer types, as is NativeDisplayType on most OSes, so this would have trapped at run time when using the round-tripped pointers. The gles2 casts were also harmless; the OpenGL API defines this argument to be a pointer type (and uses the argument name "pointer"), but it in fact represents an integer offset, so like audio and cursor the additional idiomatic cast is needed to silence the warning.
Ivan Epifanov 2e3dd0a6 2020-11-02T18:14:57 Remove debug log
Ivan Epifanov 80036230 2020-11-02T18:10:09 Cg shaders for vita gles2
Sylvain Becker f40551c5 2021-01-25T22:17:11 GLES2 SDL_Renderer: remove old ZUNE_HD defines and simplify shader cache
Ryan C. Gordon b99543b6 2021-01-11T20:40:11 opengl: More work on making line drawing match software renderer.
Sylvain Becker 958e5d5b 2021-01-11T10:01:24 SDL_UpdateNVTexture: fixed pitch/bpp for GLES2 (bug #5430)
Sylvain Becker c0df40e0 2021-01-05T17:39:48 Add more SDL_HAVE_YUV defines
Sylvain Becker be4cfd51 2021-01-05T11:56:22 Add SDL_UpdateNVTexture() to update NV12/21 Texture (bug #5430) for renderer software, opengl, and opengles2
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sylvain Becker 754286c6 2020-12-02T13:45:24 SDL Renderer: specify the correct flag when recreating the window
Ryan C. Gordon 0e4ce848 2020-11-08T20:57:17 opengl: Make diagonal lines match the software renderer. OpenGL leaves the final line segment open, SDL's software renderer does not, so we need a tiny bit of trigonometry here to move one more pixel in the right direction.
Ryan C. Gordon da49f795 2020-11-08T19:56:12 opengles: use glDrawArrays() correctly with GL_LINE_STRIP.
Ryan C. Gordon 93a2c58c 2020-11-08T12:37:09 opengl: Use GL_LINE_STRIP instead of breaking down into seperate GL_LINES. Surely GL drivers have improved in the last seven years. I hope...?
Ryan C. Gordon c33f8083 2020-10-20T11:12:49 render: Restoring line rendering fixes that were previously put on hold. (Backed out hg changeset 7a4240daba46)
Ryan C. Gordon 93b26f17 2020-02-17T16:15:04 opengl: Backed out hg changeset 94f9f40a957f This is the OpenGL line drawing fix for Bugzilla #3182, but there's some disagreement about what the renderers should do here, so I'm backing this out until after 2.0.12 ships, and then we'll reevaluate all the renderer backends to decide what's correct, and make them all work the same.
Ryan C. Gordon ed10d947 2020-02-10T12:53:54 opengl: Build out full GL_LINES and respect the diamond-exit rule. Likewise for the GLES1 and GLES2 renderers. This solves the missing pixel at the end of a line and removes all the heuristics for various platforms/drivers. It's possible we could still use GL_LINE_STRIP with this and save some vertex buffer space, assuming this doesn't upset some driver somewhere, but this seems to be a clean fix that makes the GL renderers match the software renderer output. Diamond-exit rule explanation: http://graphics-software-engineer.blogspot.com/2012/04/rasterization-rules.html Fixes Bugzilla #3182.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 5e19e66c 2019-12-22T13:39:44 Fixed bug 4914 - Expose SDL_ScaleMode and add SDL_SetTextureScaleMode/SDL_GetTextureScaleMode Konrad This was something rather trivial to add, but asked at least several times before (I did google about it as well). It should be possible to dynamically change scaling mode of the texture. It is actually trivial task, but until now it was only possible with a hint before creating a texture. I needed it for my game as well, so I took the liberty of writing it myself. This patch adds following functions: SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode); SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode); That way you can change texture scaling on the fly.
Sylvain Becker 9e509e4a 2019-10-30T16:45:53 SDL_render_gles2: remove ineffective widening cast warning: either cast from 'int' to 'size_t' (aka 'unsigned long') is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
Sylvain Becker 60d3965e 2019-10-30T15:36:17 Readability: remove redundant return, continue, enum declaration
Alex Szpakowski 0c263738 2019-08-26T18:49:04 gl/gles/gles2 render: fix SDL_RenderClear being affected by the clip rect in some situations.
Ryan C. Gordon 8ab698af 2019-03-21T10:39:49 opengles2: Fix static analysis warning. Not clear if this could ever dereference NULL in real life, but better safe than sorry!
Sam Lantinga b2e76d86 2019-03-19T16:52:09 Fixed Windows RT build
Sylvain Becker b28e956b 2019-03-12T07:59:53 Fixed bug 4542 - Image flipped vertically when rendering on texture Have to recompute viewport because projection/glOrtho is different wether rendering is on target texture or not
Ryan C. Gordon 40781dfb 2019-02-04T23:35:18 opengles2: patched to compile.
Ryan C. Gordon b7504f31 2019-02-04T23:32:28 opengles2: keep cached texturing state correct.
Sylvain Becker be991f3a 2019-01-12T13:34:03 Fixed bug 4453 - GLES / GLES2: first white renderer clear cmd is drawn as black
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Alex Szpakowski dc344360 2018-12-21T20:53:31 render: Fix internal state getting out of sync when destroying a texture that was just rendered and then creating a new one, in the GL and GLES2 backends. Fixes bug #4433.
Sam Lantinga 9719f89d 2018-11-17T12:12:29 Back out change initializing renderer blend mode incorrectly.
Ryan C. Gordon 782f1685 2018-11-17T14:37:51 Fixed a few compiler warnings.
Sam Lantinga 29e15ce6 2018-11-17T00:58:45 The default draw blendmode is SDL_BLENDMODE_NONE
Ryan C. Gordon 4659e738 2018-11-01T12:31:45 merge fallout: Patched to compile, fixed some compiler warnings, etc.
Cameron Gutman 329f2eb9 2018-10-31T20:17:53 Fix crash when GL_LoadFunctions()/GLES2_LoadFunctions() fails https://bugzilla.libsdl.org/show_bug.cgi?id=4350 We can't safely call GL_DestroyRenderer() until GL_LoadFunctions() succeeds because we will be missing functions that we try to use when activating the renderer for destruction if we have an GL context.
Ryan C. Gordon 62494a2e 2018-10-31T15:03:41 Merge SDL-ryan-batching-renderer branch to default.
Ryan C. Gordon b262b0eb 2018-10-22T20:50:32 Small stack allocations fall back to malloc if they're unexpectedly large.
Ryan C. Gordon eedf2c96 2018-10-06T17:08:04 opengles2: Fixed several incorrect things.
Ryan C. Gordon 6ecd0b2c 2018-10-04T21:10:42 opengles2: removed useless memcpy.
Ryan C. Gordon ef3d970a 2018-10-04T20:22:28 opengles2: Fixed incorrect cliprect state.