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 2973 - SDL_LockTexture() & SDL_RENDER_PRESENTVSYNC causes tearing
Summary: SDL_LockTexture() & SDL_RENDER_PRESENTVSYNC causes tearing
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.3
Hardware: x86_64 Mac OS X (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-01 20:09 UTC by 15gixh+64kt8tozpu6p0
Modified: 2016-10-08 00:36 UTC (History)
0 users

See Also:


Attachments
Test probelm (1.70 KB, text/x-csrc)
2015-05-01 20:09 UTC, 15gixh+64kt8tozpu6p0
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 15gixh+64kt8tozpu6p0 2015-05-01 20:09:16 UTC
Created attachment 2145 [details]
Test probelm

In the documentation, it's recommended to use SDL_LockTexture() over SDL_UpdateTexture() (https://wiki.libsdl.org/SDL_UpdateTexture) for streaming textures (contradicting the advice given in the migration guide, https://wiki.libsdl.org/MigrationGuide#If_your_game_just_wants_to_get_fully-rendered_frames_to_the_screen).

The problem is that under the OpenGL render driver on Mac OS X, using SDL_LockTexture() causes tearing when SDL_RENDER_PRESENTVSYNC is set.

I've attached a sample program that demonstrates the behavior.

I'm guessing it's because SDL_LockTexture() retrieves a pointer to memory shared with the GPU. That's fine, but it should be the memory for the texture buffer not currently being displayed on the screen.

The workaround is to use SDL_UpdateTexture(). This workaround isn't ideal because it generates an extra buffer copy when the software renderer is used. It would be better to fix the OpenGL renderer so that each SDL texture references two different OpenGL textures if memory-sharing is being used.