You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when a texture is created:
static int D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, int w, int h)
{
HRESULT result;
texture->dirty = SDL_FALSE;
result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
PixelFormatToD3DFMT(format),
D3DPOOL_DEFAULT, &texture->texture, NULL);
if (FAILED(result)) {
return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
}
if (usage != D3DUSAGE_RENDERTARGET) {
result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
PixelFormatToD3DFMT(format),
D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
if (FAILED(result)) {
return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result);
}
}
return 0;
}
if SDL_TEXTUREACCESS_TARGET flag is used, the staging texture is not created and its value is NULL.
Later, there are functions that check if stating is not NULL but there are others that try to use is as:
static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32 format, int x, int y, int w, int h, const void *pixels, int pitch)
{
RECT d3drect;
D3DLOCKED_RECT locked;
const Uint8 *src;
Uint8 *dst;
int row, length;
HRESULT result;
d3drect.left = x;
d3drect.right = x + w;
d3drect.top = y;
d3drect.bottom = y + h;
result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
...
This last call to IDirect3DTexture9_LockRect() caused the application crash as staging is set to NULL.
I think this check on D3D_CreateTextureRep():
if (usage != D3DUSAGE_RENDERTARGET) {
is not needed but dont have enough Direct3D knowledge for assuring it at 100%.
As soon as I replaced it with:
if(1) {
to force to create the staging memory even for SDL_TEXTUREACCESS_TARGET textures, the application does not crash anymore.
This could be the fix for this bug but... could anyone with better Direct3D knowledge validate it please?
Thanks in advance!
Regards
could anyone with better understanding of Direct
On 2014-07-04 19:47:47 +0000, Roberto Prieto wrote:
After doing more tests, it seems that the application does not crash because the call to create the staging texture just fail (no SDL_TEXTUREACCESS_TARGET textures can be created on D3DPOOL_SYSTEMMEM?).
And checking testrendertarget application, it does not suffer the same issue I have so I think the issue is on my code and not on SDL2.
I did several tests before opening the bug(obviously not enough..) so sorry, I didnt want to waste developers time.
Regards
On 2014-07-08 04:42:32 +0000, Sam Lantinga wrote:
Even if updating a target texture is invalid it still shouldn't crash. Thanks for the report! I'll look into it. :)
On 2014-08-08 16:57:12 +0000, Damian Kaczmarek wrote:
On 2015-02-19 02:55:18 +0000, Ryan C. Gordon wrote:
Just pinging to see if we can close this bug with the changes Sam made, or if it needs further work.
--ryan.
On 2015-02-19 06:32:16 +0000, Ryan C. Gordon wrote:
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!
On 2015-05-29 16:24:37 +0000, Roberto Prieto wrote:
Hi,
During this weekend I will check if the issue was fixed.
Cheers
Roberto
On 2015-05-29 22:12:49 +0000, Roberto Prieto wrote:
Sam, Ryan,
I just checked it and with current SDL2 code when trying to use SDL_UpdateTexture() on a texture created with SDL_TEXTUREACCESS_TARGET, the application does not crash anymore on Direct3D mode (note OpenGL and software worked fine).
Of course, it still does not update the texture because it is not supported on Direct3D mode but no more crashes.
This bug is solved!!!
Thanks you very much!
Roberto
P.S.: bug 2677 is also fixed as it is the same one.
On 2015-05-30 03:26:00 +0000, Sam Lantinga wrote:
Looking at the code I don't see any reason it shouldn't work for target textures. Can you grab the latest snapshot and debug why it doesn't work? http://www.libsdl.org/tmp/SDL-2.0.zip
Thanks!
On 2015-05-31 05:57:12 +0000, Ryan C. Gordon wrote:
*** Bug 2677 has been marked as a duplicate of this bug. ***
On 2015-06-03 19:55:57 +0000, Roberto Prieto wrote:
Hi Sam,
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.
The call that fails, is using D3DUSAGE_RENDERTARGET with D3DPOOL_SYSTEMMEM which is unsupported, hence the INVALIDCALL return code.
In addition, I tried myself to modify that D3DPOOL_SYSTEMMEM by a D3DPOOL_DEFAULT, in this case, the texture creation is OK but a call to IDirect3DTexture9_LockRect() right after calling D3D_CreateStagingTexture() in D3D_UpdateTextureRep() causes the same issue, an INVALIDCALL and that is whatever Microsoft says:
Textures created with D3DPOOL_DEFAULT are not lockable. (https://msdn.microsoft.com/en-us/library/windows/desktop/bb205913%28v=vs.85%29.aspx)
Just guessing... should render target textures on direct3d renderer not use the staging texture creation for avoiding this issue?
At this point, please let me know if I can help you on something else.
Cheers
Roberto
This bug report was migrated from our old Bugzilla tracker.
Reported in version: 2.0.3
Reported for operating system, platform: Windows 7, x86
Comments on the original bug report:
On 2014-07-04 19:03:10 +0000, Roberto Prieto wrote:
On 2014-07-04 19:47:47 +0000, Roberto Prieto wrote:
On 2014-07-08 04:42:32 +0000, Sam Lantinga wrote:
On 2014-08-08 16:57:12 +0000, Damian Kaczmarek wrote:
On 2014-08-17 06:19:13 +0000, Sam Lantinga wrote:
On 2015-02-19 02:55:18 +0000, Ryan C. Gordon wrote:
On 2015-02-19 06:32:16 +0000, Ryan C. Gordon wrote:
On 2015-05-29 16:24:37 +0000, Roberto Prieto wrote:
On 2015-05-29 22:12:49 +0000, Roberto Prieto wrote:
On 2015-05-30 03:26:00 +0000, Sam Lantinga wrote:
On 2015-05-31 05:57:12 +0000, Ryan C. Gordon wrote:
On 2015-06-03 19:55:57 +0000, Roberto Prieto wrote:
On 2015-06-04 07:57:18 +0000, Sam Lantinga wrote:
On 2015-06-04 12:05:39 +0000, Roberto Prieto wrote:
On 2015-06-06 22:46:14 +0000, Sam Lantinga wrote:
The text was updated successfully, but these errors were encountered: