| Summary: | Texture filtering doesn't work in direct3d | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Yuri K. Schlesner <yuriks> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Windows 8 | ||
| Attachments: |
Testcase
Proposed patch |
||
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! Created attachment 1154 [details]
Testcase
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? Oh, and this is an Intel HD4000 driver version 9.17.10.2932 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.
Fix looks good, thanks! http://hg.libsdl.org/SDL/rev/bbb6b079cfe5 |
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.