Commit graph

117 commits

Author SHA1 Message Date
Ryan C. Gordon
1bfe8fadc9 direct3d: Use D3DPOOL_MANAGED for vertex buffers.
Fixes Bugzilla #4537.
2019-06-11 13:02:56 -04:00
Ryan C. Gordon
39f5a59c7e direct3d: Fixed SDL_RenderSetClipRect usage.
Fixes Bugzilla #4459.
2019-06-11 10:12:47 -04:00
Ryan C. Gordon
ad14c4654c direct3d: don't dereference bogus pointer if current texture was destroyed.
Fixes Bugzilla #4460.
2019-06-11 09:29:48 -04:00
Ryan C. Gordon
6480984e0a direct3d: Fixed more compiler warnings on Visual Studio 64-bit builds. 2019-06-11 02:31:57 -04:00
Sam Lantinga
2085fa0bd7 Fixed Windows RT build 2019-03-19 16:52:09 -07:00
Sam Lantinga
af32a2f4cd Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon
620f5429c4 direct3d: be more aggressive about resetting invalidated cached state.
Fixes Bugzilla #4402.
2018-12-03 09:26:05 -05:00
Ryan C. Gordon
4c72dd1b02 direct3d: Make sure streaming textures update before being used for drawing.
Fixes Bugzilla #4402.
2018-12-03 01:58:23 -05:00
Ryan C. Gordon
a9b658ab1c Patched to compile on C89 compilers. 2018-12-02 21:57:33 -05:00
Ryan C. Gordon
e7b0e3e1b5 direct3d: Release and NULL out vertex buffers on reset.
Otherwise they are irretrievably lost on window resize, etc, which makes
rendering freeze and other disasters.

Fixes Bugzilla #4358.
2018-12-02 20:55:57 -05:00
Sam Lantinga
e1d71b88e1 Back out change initializing renderer blend mode incorrectly. 2018-11-17 12:12:29 -08:00
Sam Lantinga
f1b7d53e6c The default draw blendmode is SDL_BLENDMODE_NONE 2018-11-17 00:58:45 -08:00
Ryan C. Gordon
2b3489261e merge fallout: Patched to compile, fixed some compiler warnings, etc.
--HG--
extra : amend_source : db5107c02c210087f25dea7f0407d09be10e24ba
2018-11-01 12:31:45 -04:00
Ryan C. Gordon
c60a01a082 render: D3D9 doesn't need to check for stream offset support anymore.
We don't use offsets at all now. Too slow.

--HG--
branch : SDL-ryan-batching-renderer
extra : histedit_source : bf5eafc07800e64529ffc423abf3e605aa965264
2018-10-01 13:41:15 -04:00
Ryan C. Gordon
7aab4dc8b9 render: Set the D3D9 stream source once and choose offsets during draw calls.
This is _much_ faster than setting the offsets with SetStreamSource!

--HG--
branch : SDL-ryan-batching-renderer
2018-10-01 11:32:08 -04:00
Ryan C. Gordon
d6753c690b render: Patched to compile.
--HG--
branch : SDL-ryan-batching-renderer
2018-10-01 03:02:54 -04:00
Ryan C. Gordon
8a2013f1c2 render: first shot at moving Direct3D 9 backend to new interface. Untested!
--HG--
branch : SDL-ryan-batching-renderer
2018-10-01 01:23:02 -04:00
Sam Lantinga
40f5b81553 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.
2018-05-07 19:52:25 -07:00
Sam Lantinga
346af016a5 Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga
644fefb7ac Added check for failure of D3D_ActivateRenderer() 2017-12-08 11:34:32 -08:00
Sam Lantinga
2abcf193b5 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.
2017-12-08 11:09:05 -08:00
Sam Lantinga
145d2469ae 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.
2017-11-12 22:51:12 -08:00
Sam Lantinga
e9ee7f6f0d 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.
2017-08-19 03:07:44 -07:00
Sam Lantinga
808e24ac4a 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);
2017-08-14 05:51:44 -07:00
Sam Lantinga
1b24bfad38 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
6bbfff1f43 Fixed bug 2421 for D3D9 - SDL_RenderCopyEx off by one when rotating by 90 and -90
Nader Golbaz

Updated patch for direct3d renderers
2016-11-06 08:42:46 -08:00
Sam Lantinga
1b032a0419 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Sam Lantinga
a64ed63bba Fixed bug 3345 - SDL_RenderClear inconsistency with ClipRect
Simon Hug

The description of the SDL_RenderClear function in the SDL_render.h header says the following:

"This function clears the entire rendering target, ignoring the viewport."

The word "entire" implies that the clipping rectangle set with SDL_RenderSetClipRect also gets ignored. This is left somewhat ambiguous if only the viewport is mentioned. Minor thing, but let's see what the implementations actually do.

The software renderer ignores the clipping rectangle when clearing. It even has a comment on this: /* By definition the clear ignores the clip rect */

Most other render drivers (opengl, opengles, opengles2, direct3d, and psp [I assume. Can't test it.]) use the scissor test for the ClipRect and don't disable it when clearing. Clearing will only happen within the clipping rectangle for these drivers.

An exception is direct3d11 which uses a clear function that ignores the scissor test.
2016-10-01 11:46:32 -07:00
David Ludwig
86b7c57477 Fixed Bug 3147 - Windows: Crash when resizing Window since hg 333216331863
Thanks for the fix, Gab!
2016-06-24 22:17:56 -04:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
ce7104f384 Fixed bug 2625 - Direct3D9 with SDL_TEXTUREACCESS_TARGET textures causes an application crash
Roberto

I have debugged the code checking the function calls when Direct3D is the renderer, remember that with software and OpenGL renderers, this issue is not happening.

- Create the texture:
SDL_Texture *pTex = SDL_CreateTexture(pRenderer, iFormat, SDL_TEXTUREACCESS_TARGET, pSurf->w, pSurf->h);

- Update the texture:
SDL_UpdateTexture(pTex, NULL, pSurf->pixels, pSurf->pitch);
  SDL_render.c, SDL_UpdateTexture(): return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
    SDL_render_d3d.c, D3D_UpdateTexture(): if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->format, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) {
      SDL_render_d3d.c, D3D_UpdateTextureRep(): if (D3D_CreateStagingTexture(device, texture) < 0) {
        SDL_render_d3d.c, D3D_CreateStagingTexture(): result = IDirect3DDevice9_CreateTexture(..., D3DPOOL_SYSTEMMEM, ...) --> FAIL! with INVALIDCALL code

After checking a bit the Microsoft documentation, I found this:

D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT. (bb172625%28v=vs.85%29.aspx)

The call that fails, is using D3DUSAGE_RENDERTARGET with D3DPOOL_SYSTEMMEM which is unsupported, hence the INVALIDCALL return code.
2015-06-04 00:56:11 -07:00
Sam Lantinga
d727fa668a Fixed clip rectangle calculation when there is a viewport offset 2015-05-28 18:57:10 -07:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Sam Lantinga
cba9f49587 Fixed bug 2685 - SDL_RenderReadPixels() doesn't work with offscreen targets
Andreas Falkenhahn

SDL_RenderReadPixels() doesn't seem to work when trying to read pixels from a texture that has been created using SDL_TEXTUREACCESS_TARGET and has been selected as the render target using SDL_SetRenderTarget().

I am attaching a small program that demonstrates the issue. I get the following result here:

READ PIXEL RETURN: 0 --- COLOR CHECK: ff000000

But it should be:

READ PIXEL RETURN: 0 --- COLOR CHECK: ffff0000

Tested with SDL 2.0.3 on Windows 7.
2014-08-17 14:44:53 -07:00
Sam Lantinga
5619521805 Fixed bugs 2677 and 2625, made it possible to lock render targets in D3D 2014-08-16 23:17:47 -07:00
Sam Lantinga
9d42bf534d Fixed mingw64 build and warnings 2014-07-07 10:26:28 -07:00
Alfred Reynolds
156e48e6bf The YUV offset is 16 / 255, not 16 / 256 2014-07-03 10:22:12 -07:00
Sam Lantinga
4a1537da07 Setting the window size changes the fullscreen display mode, unless a window display mode has been set.
Testing:
* Ran testsprite2 --fullscreen, used Ctrl+ and Ctrl- to change window sizes, verified that the display mode changed as well.
2014-06-04 10:57:52 -07:00
Sam Lantinga
297d5c065a Fixed crash and lost pixel data when recovering from a lost device situation (e.g. alt-tab from fullscreen) 2014-06-04 10:57:40 -07:00
Sam Lantinga
7ab938363f Use D3D9Ex when available
This hopefully works around crashes in Intel D3D9 support in Windows 8.1.
2014-05-31 11:37:12 -07:00
Philipp Wiesemann
ed89f98f5b Changed C++ style comments. 2014-05-18 21:11:30 +02:00
Jørgen P. Tjernø
431aca234b Render: Allow empty cliprect.
This fixes an issue where an empty cliprect is treated the same as a NULL
cliprect, causing the render backends to disable clipping.

Also adds a new API, SDL_RenderIsClipEnabled(render) that allows you to
differentiate between:
 - SDL_RenderSetClipRect(render, NULL)
 - SDL_Rect r = {0,0,0,0}; SDL_RenderSetClipRect(render, &r);

Fixes https://bugzilla.libsdl.org/show_bug.cgi?id=2504

--HG--
extra : amend_source : 9e5ac76e3f009d9ae49bc61c350df3ba891267b5
extra : histedit_source : b92b8be4d05b19a89fa0dee57f7ed6b1e924cb99%2Cce419f6ade87bafc78ff42702c1f263d2469e7e7
2014-04-19 13:15:41 -07:00
Sam Lantinga
d16a9a6781 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX 2014-03-10 17:19:19 -07:00
Sam Lantinga
e012b4eb5d Fixed renderer flags to include support for target textures after the renderer is created. 2014-03-09 22:48:38 -07:00
Sam Lantinga
0fe823b5cd Fixed crash if the input data pitch is larger than the locked texture pitch 2014-02-25 10:04:49 -08:00
Sam Lantinga
efdbdb5ae7 Fixed infinite recursion in D3D_Reset() 2014-02-20 21:07:56 -08:00
Sam Lantinga
6b4444c027 Fixed resetting the current render target if the D3D device is reset while using a non-default render target. 2014-02-17 22:20:33 -08:00
Sam Lantinga
9eb2cc5c7a Fixed crash if render target textures are used while the device is lost 2014-02-10 13:40:02 -08:00
Sam Lantinga
f656316b9f Recreate render target textures when the D3D device is being reset, and notify the application using the SDL_RENDER_TARGETS_RESET event when this happens. 2014-02-10 10:02:51 -08:00
Sam Lantinga
018d3e8094 Fixed bug 2385 - error: unknown type name 'IDirect3DDevice9'
Sandu Liviu Catalin

I'm unable to compile the latest SDL (directly from the repository) even though I disabled every DirectX option since I don't need DirectX.

I allways het these errors:
D:\DevLibs\SDL\src\render\direct3d\SDL_render_d3d.c:1897:1: error: unknown type name 'IDirect3DDevice9'
D:\DevLibs\SDL\src\render\direct3d\SDL_render_d3d.c:1898:25: error: unknown type name 'SDL_Renderer'
2014-02-09 01:56:41 -08:00