src/render


Log

Author Commit Date CI Message
Ryan C. Gordon fcb46813 2018-10-01T13:41:15 render: D3D9 doesn't need to check for stream offset support anymore. We don't use offsets at all now. Too slow.
Ryan C. Gordon 709f5ee4 2018-10-01T11:32:08 render: Set the D3D9 stream source once and choose offsets during draw calls. This is _much_ faster than setting the offsets with SetStreamSource!
Ryan C. Gordon 9870746b 2018-10-01T03:02:54 render: Patched to compile.
Ryan C. Gordon 5e644cfd 2018-10-01T01:23:02 render: first shot at moving Direct3D 9 backend to new interface. Untested!
Ryan C. Gordon fdc52a65 2018-09-29T04:00:38 render: patched to compile on C89 compilers, other untested code fixes.
Ryan C. Gordon daad53af 2018-09-28T19:48:14 opengles1: set some non-zero drawstate defaults.
Ryan C. Gordon c20a858d 2018-09-28T19:47:44 render: moved opengles2 over to new interface.
Ryan C. Gordon 0d588cc4 2018-09-25T21:35:09 render: Do state cache improvements for GLES1, too.
Ryan C. Gordon d04e5524 2018-09-25T19:20:31 render: OpenGL renderer now caches some state, to improve non-batching mode. (other minor bug fixes in here, too)
Ryan C. Gordon 06461bba 2018-09-25T17:04:47 render: Move non-batching flushes to different place. This lets us batch up a few commands that are all related to the same API call.
Ryan C. Gordon 43f15e05 2018-09-25T16:17:10 render: opengles renderer actually works now. :)
Ryan C. Gordon b2db99cb 2018-09-25T10:41:25 render: First shot at converting opengles renderer to new interfaces.
Ryan C. Gordon c01da217 2018-09-24T12:30:47 render: get rid of the predeclared functions in the GL and Metal renderers. (others to come as I continue to update render backends!)
Ryan C. Gordon 051d1cfc 2018-09-24T02:08:34 render: Make opengl backend take advantage of new high-level features.
Ryan C. Gordon 8ac5c00a 2018-09-24T02:07:35 render: Add command queue debug logging.
Ryan C. Gordon 2241b33f 2018-09-23T23:22:56 render: Update Metal and GL backends to use new high-level features, etc. Now nothing is uploaded as dynamic data with Metal's setVertexBytes, etc; it's all in the one big vertex buffer, now.
Ryan C. Gordon cc56de44 2018-09-23T23:20:40 render: A bunch of high-level improvements. - high-level filters out duplicate render commands from the queue so backends don't have to. - Setting draw color is now a render command, so backends can put color information into the vertex buffer to upload with everything else instead of setting it with slower dynamic data later. - backends can request that they always batch, even for legacy programs, since the lowlevel API can deal with it (Metal, and eventually Vulkan and such...) - high-level makes sure the queue has at least one setdrawcolor and setviewport command before any draw calls, so the backends don't ever have to manage cases where this hasn't been explicitly set yet. - backends allocating vertex buffer space can specify alignment, and the high-level will keep track of gaps in the buffer between the last used positions and the aligned data that can be used for later allocations (Metal and such need to specify some constant data on 256 byte boundaries, but we don't want to waste all that space we had to skip to meet alignment requirements).
Ryan C. Gordon 8955fb9b 2018-09-20T16:40:04 render: First shot at moving metal backend over to new batching system.
Ryan C. Gordon 55cb9966 2018-09-20T16:36:54 render: first shot at reworking opengl backend for new batching system.
Ryan C. Gordon 5fb67f9f 2018-09-20T15:46:02 render: Move to a batching system for rendering (work in progress).
Ryan C. Gordon a2f7af9a 2018-09-09T15:09:38 gles2: Make render command queue dynamic. It now uses a growable linked list that keeps a pool of allocated items for reuse, and reallocs the vertex array as necessary. Testsprite2 can scale to 20,000 (or more!) draws now without drama.
Ryan C. Gordon 0d327529 2018-09-08T18:26:11 gles2: Major renderer optimization. Work in progress! This moves all the rendering to a command list that is flushed to the GL as necessary, making most common activities upload a single vertex buffer per frame and dramatically reducing state changes. In pathological cases, like Emscripten running on iOS's Safari, performance can go from a dozen draw calls killing your performance to 1000 draw calls running smoothly. This is work in progress, and not ready to ship. Among other things, it has a hardcoded array that isn't checked for overflow. But the basic idea is sound!
Ryan C. Gordon 264b81b4 2018-09-06T00:56:13 metal: Make sure layer drawableSize is adjusted on resize. Fixes Bugzilla #4250.
Ryan C. Gordon 3634e563 2018-09-01T20:47:12 metal: SDL_UpdateYUVTexture shouldn't swap planes based on format.
Sam Lantinga 90a5607d 2018-08-29T20:23:42 Fixed compiler warning and use higher precision in angle calculation
Sam Lantinga 92396f7d 2018-08-28T16:19:31 Fixed Windows build
Andreas M?ller 87bc1fb5 2018-08-28T12:57:51 GLES2: Get sin/cos out of vertex shader The only place angle is activated and causes effect is RenderCopyEx. All other methods which use vertex shader, leave angle disabled and cause useless sin/cos calculation in shader. To get around shader's interface is changed to a vector that contains results of sin and cos. To behave properly when disabled, cos value is set with offset -1.0 making 0.0 default when deactivated. As nice side effect it simplifies GLES2_UpdateVertexBuffer: All attributes are vectors now. Additional background: * On RaspberryPi it gives a performace win for operations. Tested with [1] numbers go down for 5-10% (not easy to estimate due to huge variation). * SDL_RenderCopyEx was tested with [2] * It works around left rotated display caused by low accuracy sin implemetation in RaspberryPi/VC4 [3] [1] https://github.com/schnitzeltony/sdl2box [2] https://github.com/schnitzeltony/sdl2rendercopyex [3] https://github.com/anholt/mesa/issues/110 Signed-off-by: Andreas M?ller <schnitzeltony@gmail.com>
Ryan C. Gordon 915a7e03 2018-06-25T01:57:28 gles2: Whoops, overzealous copy/paste on my part. :)
Ryan C. Gordon 5308a245 2018-06-24T12:16:58 Fixed some possible malloc(0) calls reported by static analysis.
Sam Lantinga 74ec7cab 2018-06-18T13:13:56 Fixed race condition where Android touch events could get scaled by a render target's viewport
Ozkan Sezer fe032ff4 2018-05-10T08:25:23 do the direct3d tap dance for overscan hint only if SDL_VIDEO_RENDER_D3D == 1
Sam Lantinga eb14b635 2018-05-07T19:52:25 Fixed bug 4134 - Render targets lose scale quality after minimizing a fullscreen window Olli-Samuli Lehmus If one creates a window with the SDL_WINDOW_FULLSCREEN_DESKTOP flag, and creates a render target with SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"), and afterwards sets SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"), after minimizing the window, the scale quality hint is lost on the render target. Textures however do keep their interpolation modes.
Ryan C. Gordon 8891f591 2018-02-21T22:53:52 Backed out changeset 6c8521d53507 Apparently this still triggers a compiler warning, have to dig further.
Ryan C. Gordon fd8f12d2 2018-02-21T22:35:17 android: apparently they fixed this header at some point.
sezero 40b27fd5 2018-02-12T17:00:00 revert the recent typecast assignment changes (see bug #4079) also change the void* typedefs for the two vulkan function pointers added in vulkan_internal.h into generic function pointer typedefs.
Sam Lantinga d5f293a7 2018-02-09T16:31:57 Fixed compile warning
Sam Lantinga 90e72bf4 2018-01-30T18:08:34 Fixed ISO C99 compatibility SDL now builds with gcc 7.2 with the following command line options: -Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
Sam Lantinga 72d45079 2018-01-10T10:42:40 Added availability check to fix compiler warning for symbol only available on tvOS 11.0 and newer
Alex Szpakowski 7d5437bb 2018-01-07T22:00:37 metal: set max texture size based on device capability.
Alex Szpakowski a8c0532c 2018-01-07T16:57:32 metal: Fix pipeline states to use the pixel format of the current render target, instead of a hard-coded format.
Alex Szpakowski 740a90af 2018-01-06T18:54:12 metal: Add support for YUV/NV12 texture formats.
Alex Szpakowski 9a8683b2 2018-01-04T22:16:42 metal: use a private instead of managed buffer for the renderer's non-changing constant data. Recommended by Xcode's Metal frame capture analysis.
Alex Szpakowski 990ebba5 2018-01-04T19:29:33 metal: Implement fast hardware clearing when possible, by deferring the start of a render pass until a clear or draw operation happens.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Alex Szpakowski 888198ee 2018-01-03T00:43:01 metal: Misc. improvements. - Use a single buffer for various non-changing constants accessed by the GPU, instead of multiple buffers. - Do the half-pixel offset for points and lines using a transform matrix so we don't need a malloc when rendering. - Don't add a half-pixel offset for other primitives and textures. This matches D3D and GL render behaviour. - Remove the half-texel texture coordinate offset since it's not needed now that there's no more half-pixel position offset when rendering a texture. - Don't try to set texture usage on iOS 8 since it doesn't exist there.
Alex Szpakowski f9cd7650 2018-01-02T21:44:28 metal and moltenvk: fix highdpi.
Sam Lantinga b3b5c473 2018-01-02T14:32:15 Fixed direction of y adjustment for new orthographic projection in the metal renderer
Sam Lantinga fa86807c 2018-01-02T14:11:10 Fixed metal renderer pixel centers when drawing
Alex Szpakowski 07f08b47 2018-01-01T23:06:08 metal: Fix a typo preventing iOS compilation...
Alex Szpakowski 1cc66033 2018-01-01T23:03:50 metal: Clean up manual reference counting. Fixes some memory leaks.
Alex Szpakowski a452a084 2018-01-01T19:40:29 iOS: fix build
Alex Szpakowski 639ea9fd 2018-01-01T19:37:16 metal: Use sampler state objects instead of shader-declared samplers for linear vs nearest filtering. This avoids a ton of shader duplication once multiple shaders that use samplers are added (e.g. the currently missing YUV shaders).
Alex Szpakowski cf45cf70 2018-01-01T18:06:27 metal: Add support for custom blend modes.
Alex Szpakowski 85470a2f 2017-12-31T21:06:16 metal: implement SDL_RenderCopyEx, and fix a memory leak in SDL_CreateTexture.
Alex Szpakowski 047d387b 2017-12-31T15:30:08 metal: Use the existing cocoa code for creating a Metal view on macOS. Fixes the renderer size when the window is resized.
Alex Szpakowski 42b19c97 2017-12-30T22:39:55 metal: Respect the vsync flag on macOS 10.13+.
Alex Szpakowski e24dc905 2017-12-30T20:32:22 metal: use a projection matrix instead of manually transforming vertices into clip space on the CPU.
Alex Szpakowski 49df65c2 2017-12-30T18:48:07 metal: only 4 (instead of 5) vertices are needed to draw rectangles and textures, and only 3 (instead of 5) vertices are needed to cover the screen for the 'full-screen quad' when clearing.
Sam Lantinga 87894224 2017-12-12T16:34:16 Fixed bug 3981 - Inverted logic bug in SDL_renderer "overscan" feature Eric wing There is a tiny bug in the new overscan code for the SDL_renderer. In SDL_renderer.c, line 1265, the if check for SDL_strcasecmp with "direct3d" needs to be inverted. Instead of: if(SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) { It should be: if(0 == SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) { This bug causes the "overscan" mode to pretty much be completely ignored in all cases and all things remain letterboxed (as before the feature).
Sam Lantinga e8bbbb37 2017-12-12T12:52:17 Added support for Android video textures
Sam Lantinga bed7fd80 2017-12-12T12:52:09 Merged latest changes from rel/streaming_client
Sam Lantinga 7ac46a74 2017-12-11T11:34:53 The newer compilers generate the property boilerplate automatically
Sam Lantinga 358e4d9c 2017-12-11T11:02:51 Fixed Mac OS X build
Sam Lantinga c2cc9c16 2017-12-09T19:48:38 Backed out using pixel texture coordinates, it had weird visual side effects
Sam Lantinga 8aad4923 2017-12-09T19:41:08 Fixed normalized coordinates when the viewport is set
Sam Lantinga 441d3095 2017-12-09T15:00:41 Added support for linear sampling and pixel coordinates in the metal renderer
Sam Lantinga f55c9988 2017-12-09T12:58:41 Fixed pixel positioning and size for the Metal renderer
Ryan C. Gordon 7dac177c 2017-12-09T03:28:23 metal: fixed render target support.
Ryan C. Gordon 85d12d8f 2017-12-09T03:27:52 metal: Added some comments and FIXMEs.
Ryan C. Gordon 686fc093 2017-12-08T18:26:26 metal: Cleaned up some reference count politics.
Sam Lantinga cf3d4503 2017-12-08T14:30:10 Added SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder()
Sam Lantinga c403c0fa 2017-12-08T13:20:20 Fixed Metal renderer memory leak
Sam Lantinga b733dcc2 2017-12-08T12:02:23 Minor cleanup
Sam Lantinga 5182c23c 2017-12-08T11:35:19 Fixed minor memory leak in the Metal renderer
Sam Lantinga cac4e312 2017-12-08T11:34:32 Added check for failure of D3D_ActivateRenderer()
Sam Lantinga 1a1cd8c1 2017-12-08T11:09:05 Fixed bug 1878 - Scaled texture draws with filtering produce wrapping artifacts. Yuri K. Schlesner When using texture filtering, there are filtering artifacts visible on the edges of scaled textures, where the texture filtering pulls in texels from the other side of the texture. Using clamping texture modes wouldn't completely fix this since source rectangles don't need to cover the whole texture. (See screenshot attached in next post.) The opengl driver uses clamping on textures and so avoid this at least in the cases where the source rect is the whole texture. The direct3d driver does not and so has problems in every case. I'm not sure if it can actually completely be fixed, but at least enabling clamping for direct3d would be one step in the right direction.
Ryan C. Gordon 81a33985 2017-12-08T14:03:36 metal: Don't check if Metal is available if targeting modern macOS versions.
Sam Lantinga dc04f290 2017-12-08T08:58:02 Defer getting the next drawable until we actually start rendering This works better for games where there may be a bunch of simulation logic that needs to be run before the next rendering pass, and prevents blocking if the next drawable is busy.
Sam Lantinga 104decd1 2017-12-07T18:08:51 Fixed runtime errors on iOS
Sam Lantinga ba9c336e 2017-12-07T17:47:01 Fixed building for simulators or older iOS SDKs
Sam Lantinga 6deb1e75 2017-12-07T17:12:03 Fixed compiling Metal renderer on iOS
Sam Lantinga 1ae73a2b 2017-12-07T16:08:47 Added iOS and OSX versions of the Metal shaders
Sam Lantinga b2859af6 2017-12-07T16:08:09 Enable building the Metal renderer by default, and weak link the Metal framework so the SDL library is safe to use on older Macs Also generate iOS versions of the Metal shaders
Sam Lantinga a6a4e27a 2017-11-12T22:51:12 Updated SDL's YUV support, many thanks to Adrien Descamps New functions get and set the YUV colorspace conversion mode: SDL_SetYUVConversionMode() SDL_GetYUVConversionMode() SDL_GetYUVConversionModeForResolution() SDL_ConvertPixels() converts between all supported RGB and YUV formats, with SSE acceleration for converting from planar YUV formats (YV12, NV12, etc) to common RGB/RGBA formats. Added a new test program, testyuv, to verify correctness and speed of YUV conversion functionality.
Sam Lantinga 9fd0d619 2017-10-18T08:52:04 Fixed bug 3821 - Allow SDL_CreateWindow and SDL_CreateRenderer with OpenGL ES 3.0 (GLES3) for Angle (Windows) Carlos Angle supports GLES3 but when using these functions (SDL_CreateWindow and SDL_CreateRenderer), defaults again to GLES2.0. A current workaround (hack) to retrieve a GLES3.0 context with Angle is: 1) set SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); after InitSDL AND after calling SDL_CreateWindow (before SDL_CreateRenderer) 2) Comment lines 2032-2044 in SDL_render_gles2.c, funtion GLES2_CreateRenderer window_flags = SDL_GetWindowFlags(window); if (!(window_flags & SDL_WINDOW_OPENGL) || profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { changed_window = SDL_TRUE; SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) { goto error; } } This retrives a GLES3 context as confirmed using glGetString(GL_VERSION). This should be fixed by modifying a few if's.
Sam Lantinga a7c79c5e 2017-10-12T08:37:55 Normalize touch events to the render viewport (thanks Sylvain!)
Sam Lantinga e9652b19 2017-10-06T16:50:24 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions Sylvain Few issues with YUV on SDL2 when using odd dimensions, and missing conversions from/back to YUV formats. 1) The big part is that SDL_ConvertPixels() does not convert to/from YUV in most cases. This now works with any format and also with odd dimensions, by adding two internal functions SDL_ConvertPixels_YUV_to_ARGB8888 and SDL_ConvertPixels_ARGB8888_to_YUV (could it be XRGB888 ?). The target format is hard coded to ARGB888 (which is the default in the internal of the software renderer). In case of different YUV conversion, it will do an intermediate conversion to a ARGB8888 buffer. SDL_ConvertPixels_YUV_to_ARGB8888 is somehow redundant with all the "Color*Dither*Mod*". But it allows some completeness of SDL_ConvertPixels to handle all YUV format. It also works with odd dimensions. Moreover, I did some benchmark(SDL_ConvertPixel vs Color32DitherYV12Mod1X and Color32DitherYUY2Mod1X). gcc-6.3 and clang-4.0. gcc performs better than clang. And, with gcc, SDL_ConvertPixels() performs better (20%) than the two C function Color32Dither*(). For instance, to convert 10 times a 3888x2592 image, it takes ~195 ms with SDL_ConvertPixels and ~235 ms with Color32Dither*(). Especially because of gcc vectorize feature that optimises all conversion loops (-ftree-loop-vectorize). Nb: I put no image pitch for the YUV buffers. because it complexify a little bit the code and the API : There would be some ambiguity when setting the pitch exactly to image width: would it a be pitch of image width (for luma and chroma). or just contiguous data ? (could set pitch=0 for the later). 2) Small issues with odd dimensions: If width "w" is odd, luma plane width is still "w" whereas chroma planes will be "(w + 1)/2". Almost the same for odd h. Solution is to strategically substitute "w" by "(w+1)/2" at the good places ... - In the repository, SDL_ConvertPixels() handles YUV only if yuv source format is exactly the same as YUV destination format. It basically does a memcpy of pixels, but it's done incorrectly when width or height is odd (wrong size of chroma planes). This is fixed. - SDL Renderers don't support odd width/height for YUV textures. This is fixed for software, opengl, opengles2. (opengles 1 does not support it and fallback to software rendering). This is *not* fixed for D3D and D3D11 ... (and others, psp ?) Only *two* Dither function are fixed ... not sure if others are really used. - This is not possible to create a NV12/NV12 texture with the software renderer, whereas other renderers allow it. This is fixed, by using SDL_ConvertPixels underneath. - It was not possible to SDL_UpdateTexture() of format NV12/NV21 with the software renderer. this is fixed. Here's also two testcases: - that do all combination of conversion. - to test partial UpdateTexture
Sam Lantinga 5ae90ef6 2017-09-21T01:22:40 Fixed bug 3788 - software renderer crashes in SDL_RenderCopyEx with rotation and dstrect w or h is 0 Anthony This is what's making the software renderer crash with rotated destination rectangles of w or h = 0: SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
Sam Lantinga e98fc897 2017-09-10T12:54:40 Fixed bug 3812 - Fallthrough warnings gcc-7
Sam Lantinga 30d554e3 2017-08-19T03:07:44 Fixed building SDL applications with Visual Studio and the clang toolset Also fixed building 64-bit SDL with clang. 32-bit doesn't build because of the inline assembly for C runtime support.
Ozkan Sezer c68d3ab7 2017-08-17T21:35:46 Watcom supports __FUNCTION__ identifier (and surely not __PRETTY_FUNCTION__) Partially fixes Bugzilla #3758.
Sam Lantinga 04e76499 2017-08-14T20:37:07 Fixed build warning
Sam Lantinga 9451cd81 2017-08-14T20:07:30 Fixed compiler warnings
Sam Lantinga aebe17d3 2017-08-14T16:34:54 Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__ Martin Gerhardy just for easier debugging issues in the own code... SDL_CreateRenderer should maybe also use this macro Ryan C. Gordon I'll go one better: it should have an SDL_assert().
Sam Lantinga 36ba9248 2017-08-14T10:04:59 Fixed setting the texture blend mode in the OpenGL ES2 renderer
Sam Lantinga c59d9923 2017-08-14T05:51:44 Implemented more flexible blending modes for accelerated renderers This fixes bug 2594 - Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD); This fixes bug 2828 - Subtractive Blending blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); This goes partway to fixing bug 3684 - Add support for a pre-multiplied alpha blending mode blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
Sam Lantinga f8e1874d 2017-08-13T22:50:23 Fixed bug 2646 - Problems with software renderer when SDL_SetRenderLogicalSize set Fixed setting the software renderer clip rectangle when a viewport is set
Sam Lantinga 7af3786d 2017-08-13T21:55:42 Fixed bug 2755 - SDL2 fails to build on Solaris 10 u3 UX-admin I am compiling with the Sun Studio 12 u2 compiler. There are multiple issues with the build, but this particular issue appears to be that it is illegal to declare a union of a struct of floats and a float. While GCC 4.8.1 does not flag this as an error, Sun Studio is much more standards compliant and strict, halting further compilation with an error.
Sam Lantinga ca5c3048 2017-08-13T21:06:52 Fixed bug 3744 - missing SDLCALL in several functions Ozkan Sezer The attached patch adds missing SDLCALL to several functions, so that they properly match the headers as intended.
Sam Lantinga af9ec8f6 2017-08-13T20:13:11 Fixed copy-paste error, thanks Alen!