Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCTextureAtlas _indices overflow #19160

Closed

Conversation

PatriceJiang
Copy link
Contributor

@PatriceJiang PatriceJiang commented Nov 9, 2018

ref: #18755

_indices can exceed 2^16-1 which leads to overflow.

fix:
change type to GLuint

@PatriceJiang
Copy link
Contributor Author

PatriceJiang commented Nov 9, 2018

when i*4+3 > 2^16 - 1 _indices go wrong.

for( int i=0; i < _capacity; i++)
{
_indices[i*6+0] = i*4+0;
_indices[i*6+1] = i*4+1;
_indices[i*6+2] = i*4+2;
// inverted index. issue #179
_indices[i*6+3] = i*4+3;
_indices[i*6+4] = i*4+2;
_indices[i*6+5] = i*4+1;
}
}

_capacity was limited to 16383

@PatriceJiang PatriceJiang changed the title Texturealtas index overflow CCTextureAtlas _indices overflow Nov 9, 2018
@stevetranby
Copy link
Contributor

I may be wrong ... but I don't believe this PR is acceptable unless it were refactored to only apply conditionally based on capability support by extension?

I think to use UINT as index type would require availability and support of the extension 'GL_OES_element_index_uint' and I don't believe this is required with OpenGL ES 2 (WebGL 1)??

I believe OpenGL ES 3 (and thus WebGL 2) requires supporting this extension.

https://www.khronos.org/registry/OpenGL/specs/es/2.0/es_cm_spec_2.0.pdf

"Indexing support with ubyte and ushort indices is supported. Support for uint indices is not required
by OpenGL ES 2.0. If an implementation supports uint indices, it will export the OES element index -
uint extension."

Let me know if I'm mistaken.

@stevetranby
Copy link
Contributor

The full spec doesn't even mention the extension.
https://www.khronos.org/registry/OpenGL/specs/es/2.0/es_full_spec_2.0.pdf

type must be one of UNSIGNED_BYTE or UNSIGNED_SHORT, indicating that
the values in indices are indices of GL type ubyte or ushort, respectively. mode
specifies what kind of primitives are constructed;

@PatriceJiang
Copy link
Contributor Author

@stevetranby you are correct. I would try to fix this issue in another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants