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 1523

Summary: Inconsistent use of texture->access
Product: SDL Reporter: Pallav Nawani <pallavnawani>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: HG 2.0   
Hardware: x86   
OS: All   

Description Pallav Nawani 2012-06-19 04:08:22 UTC
The access property of SDL_texture is used inconsistently. Some places it is used as a Bitflag, other places it used as an exclusive value. Eg:

(a) At SDL_render.c, line 769, inside the function SDL_LockTexture(), we have:

if (texture->access != SDL_TEXTUREACCESS_STREAMING) {

(b) At SDL_render.c, line 884, inside SDL_SetRenderTarget(), the texture is used as a Flag.

if (!(texture->access & SDL_TEXTUREACCESS_TARGET)) {

The usage in (a) prevents one from having a texture which has both SDL_TEXTUREACCESS_STREAMING and SDL_TEXTUREACCESS_TARGET set. Looking at the enum at SDL_render.h (Line 90) is inconclusive about how the property should be used.

Now the flags SDL_TEXTUREACCESS_STATIC and SDL_TEXTUREACCESS_STREAMING have to be exclusive, but there's no reason why we can't have both SDL_TEXTUREACCESS_TARGET and SDL_TEXTUREACCESS_STATIC set at the same time.
Comment 1 Pallav Nawani 2012-06-19 05:03:39 UTC
In SDL_render_d3d.c, line no. 707:

    if (texture->access == SDL_TEXTUREACCESS_TARGET) {
Comment 2 Gabriel Jacobo 2012-06-19 10:28:35 UTC
From SDL_render.h: 

typedef enum
{
    SDL_TEXTUREACCESS_STATIC,    /**< Changes rarely, not lockable */
    SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
    SDL_TEXTUREACCESS_TARGET     /**< Texture can be used as a render target */
} SDL_TextureAccess;

Given the fact that no values are assigned to each item in the enum, technically you can't use these values as flags (you would need to assign power of 2 values to them). Also, on some backends (at least GL ES2), SDL_TEXTUREACCESS_TARGET is treated differently when rendering to it, so you can't really combine it with any of the other two values.
So, if we are to fix this, I think we should make sure these values are used as mutually exclusive, not as flags.
Comment 3 Gabriel Jacobo 2012-06-21 07:17:31 UTC
http://hg.libsdl.org/SDL/rev/3c91a153f398