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 - [PATCH] D3D9 debug runtime error: Vertex buffer cannot be of zero size
Summary: [PATCH] D3D9 debug runtime error: Vertex buffer cannot be of zero size
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.10
Hardware: x86 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-07 21:54 UTC by Cameron Gutman
Modified: 2020-03-08 01:38 UTC (History)
0 users

See Also:


Attachments
Don't attempt to create zero sized vertex buffer (867 bytes, patch)
2020-03-07 21:55 UTC, Cameron Gutman
Details | Diff
Don't attempt to create zero sized vertex buffer (v2) (1.12 KB, patch)
2020-03-07 22:01 UTC, Cameron Gutman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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