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 5016

Summary: [PATCH] D3D9 debug runtime error: Vertex buffer cannot be of zero size
Product: SDL Reporter: Cameron Gutman <cameron.gutman>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.10   
Hardware: x86   
OS: Windows 7   
Attachments: Don't attempt to create zero sized vertex buffer
Don't attempt to create zero sized vertex buffer (v2)

Description Cameron Gutman 2020-03-07 21:54:31 UTC
When calling SDL_RenderPresent() using the D3D9 renderer with the debug D3D9 runtime, and not having created any vertex state, the D3D9 debug runtime throws an error:
Direct3D9: (ERROR) :Vertex buffer cannot be of zero size
Direct3D9: (ERROR) :Failure trying to create Vertex Buffer

Reproducer (assuming m_Renderer is newly created):
    SDL_SetRenderDrawColor(m_Renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
    SDL_RenderClear(m_Renderer);
    SDL_RenderPresent(m_Renderer);


The problem is that D3D_RunCommandQueue() always creates a VBO if one doesn't exist. This is incorrect if there's no vertex data. The attached patch fixes the issue.
Comment 1 Cameron Gutman 2020-03-07 21:55:18 UTC
Created attachment 4239 [details]
Don't attempt to create zero sized vertex buffer
Comment 2 Cameron Gutman 2020-03-07 22:01:42 UTC
Created attachment 4240 [details]
Don't attempt to create zero sized vertex buffer (v2)

Whoops, forgot to zero vertexBufferSize[i] in D3D_Reset(). That's probably the reason for the !vbo check in the first place.
Comment 3 Sam Lantinga 2020-03-08 01:38:47 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/9b5e16574ea9