We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4991 - Pixel shader problem when recreating a texture for direct3d renderer
Summary: Pixel shader problem when recreating a texture for direct3d renderer
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.10
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.12
Depends on:
Blocks:
 
Reported: 2020-02-17 22:23 UTC by cmediaplayer
Modified: 2020-03-09 02:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cmediaplayer 2020-02-17 22:23:39 UTC
Hi, i already mentioned in the SDL discourse a bug that recreating of a texture occours pixel shader problem on direct3d renderer. There is no problem for direct3d11. You can see the issue by using my app named C Media Player which is available for Windows for free using my web site www.cmediaplayer.com. Just follow the steps:

*Open a media file
*When playing the file change the scale quality under the video menu.
*You will see the problem.

I already fixed this issue by editing the source code of SDL library in SDL_render_d3d.c source file in the function D3D_CreateTexture at line 554 by adding those pieces of code:

if (data->drawstate.shader)
{
  const HRESULT result = IDirect3DDevice9_SetPixelShader(data->device, data->drawstate.shader);
  if (FAILED(result)) {
    return D3D_SetError(“IDirect3DDevice9_SetPixelShader()”, result);
 }
} 

If you push this patch, it would be nice for everyone who needs this patch.

Thanks in advance
Kadir
Comment 1 Sam Lantinga 2020-02-18 06:02:39 UTC
Why was this change necessary? The shader is reset when the texture is changed, and when the device is reset. Why would it need to be changed when creating a new texture that isn't bound to the rendering pipeline?
Comment 2 cmediaplayer 2020-02-18 14:54:36 UTC
(In reply to Sam Lantinga from comment #1)
> Why was this change necessary? The shader is reset when the texture is
> changed, and when the device is reset. Why would it need to be changed when
> creating a new texture that isn't bound to the rendering pipeline?

Thanks for your reply. Yes, you are right about the shader is reset when the texture is changed, and when the device is reset. But it has to be set back after resetting the texture. Otherwise the image on the screen becomes gray even it's not colored gray if you want to create new one. Because the device lost the shader. But when you resize the main window after recreated the texture, the problem goes away. Nobody wants to resize the window after changed the scale quality in the app. So that's why it's necessary.
Comment 3 Sam Lantinga 2020-03-09 02:24:08 UTC
Okay, thanks for the report. I used your application and found the problem. It's fixed for the next release:
https://hg.libsdl.org/SDL/rev/663f2daa3e4f

Cheers,