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 1874 - Texture filtering doesn't work in direct3d
Summary: Texture filtering doesn't work in direct3d
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.0
Hardware: x86 Windows 8
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-29 06:17 UTC by Yuri K. Schlesner
Modified: 2013-05-30 23:57 UTC (History)
0 users

See Also:


Attachments
Testcase (3.11 KB, text/x-c)
2013-05-29 06:59 UTC, Yuri K. Schlesner
Details
Proposed patch (806 bytes, patch)
2013-05-29 07:33 UTC, Yuri K. Schlesner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri K. Schlesner 2013-05-29 06:17:21 UTC
It appears that using SDL_HINT_RENDER_SCALE_QUALITY to use linear or anisotropic filtering doesn't work when using the direct3d driver. If I force the opengl driver then linear filtering works correctly.

I investigated and if I comment out the "if (texturedata->scaleMode != data->scaleMode) {" test inside SDL_RenderCopy in SDL_render_d3d.c then the filter setting take effect. However, the sampler state is being set correctly once (verified using some debug prints in SDL). Furthermore, calling IDirect3DDevice9_GetSamplerState to query the current filter returns the expected value of D3DTEXF_LINEAR or D3DTEXF_ANISOTROPIC, even though rendering takes place using the point filter. If the test is commented out and the sampler state is set every time SDL_RenderCopy is called, then it works correctly.

Since I don't have much knowledge of D3D I don't know what could be causing this odd behaviour.
Comment 1 Sam Lantinga 2013-05-29 06:30:56 UTC
Can you attach a complete sample program with source and data that shows the problem?
Also, what video card and driver revision are you using?

Thanks!
Comment 2 Yuri K. Schlesner 2013-05-29 06:59:51 UTC
Created attachment 1154 [details]
Testcase
Comment 3 Yuri K. Schlesner 2013-05-29 07:01:32 UTC
Doing the testcase I noticed that the filter is correct at first, but when you resize the window it gets set to point filtering (and ID9DD9_GetSamplerState also starts returning point sampling, I missed that during my previous testing.)

So it seems that resizing the windows is resetting the context state and SDL isn't noticing that?
Comment 4 Yuri K. Schlesner 2013-05-29 07:02:52 UTC
Oh, and this is an Intel HD4000 driver version 9.17.10.2932
Comment 5 Yuri K. Schlesner 2013-05-29 07:33:40 UTC
Created attachment 1155 [details]
Proposed patch

This patch fixes the problem, it was indeed not restoring the state on a reset. This patch resets scaleMode to D3DTEXF_FORCE_WORD so that the state will be reset next time a draw happens. I'm not sure if I did it at the correct place, but I wasn't able to reproduce the problem anymore.

An alternative solution would be to actually restore the sampler state on reset, but this is a smaller change.
Comment 6 Sam Lantinga 2013-05-30 23:57:27 UTC
Fix looks good, thanks!
http://hg.libsdl.org/SDL/rev/bbb6b079cfe5