| Summary: | Inconsistent use of texture->access | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Pallav Nawani <pallavnawani> |
| Component: | video | Assignee: | 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 | ||
In SDL_render_d3d.c, line no. 707:
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
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.
|
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.