oizma / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

glTexImage2D, glTexSubImage2D and similar functions doesn't have or have incorrect max level-of-detail value checkings. #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Execute glTexImage2D (GL_TEXTURE_2D, 12, GL_RGBA, 2048, 2048, 0, GL_RGBA, 
GL_UNSIGNED_BYTE, NULL);
2. Crash

What is the expected output? What do you see instead?
GL_INVALID_VALUE is expected, but instead the library crashes.
According to OpenGL ES 2.0 documentation:
"GL_INVALID_VALUE may be generated if level is greater than log 2 ⁡ max , 
where max is the returned value of GL_MAX_TEXTURE_SIZE when target is 
GL_TEXTURE_2D or GL_MAX_CUBE_MAP_TEXTURE_SIZE when target is not GL_TEXTURE_2D."
So in this case max possible level value is 11

I saw that there are checks like level > gl::MAX_TEXTURE_LEVELS in 
src\libGLESv2\libGLESv2.cpp, though it should be 
level >= gl::MAX_TEXTURE_LEVELS instead

But there's no check in glTexImage2D function

What version of the product are you using? On what operating system?
Using rev 414

Please provide any additional information below.

Original issue reported on code.google.com by tom...@gmail.com on 9 Sep 2010 at 12:38

GoogleCodeExporter commented 9 years ago
Was a bit wrong... level > gl::MAX_TEXTURE_LEVELS is actually the correct 
check...
But then array "Image mImageArray[MAX_TEXTURE_LEVELS];" declared in Texture.h 
is too small, if you specify level as MAX_TEXTURE_LEVELS, the array will be 
accessed out of bounds

Original comment by tom...@gmail.com on 9 Sep 2010 at 1:29

GoogleCodeExporter commented 9 years ago
One more thing, MAX_TEXTURE_LEVELS must be 13, not 12... because 2^13 is 8192 
which is the max texture size.

Original comment by tom...@gmail.com on 9 Sep 2010 at 1:55

GoogleCodeExporter commented 9 years ago
I can't reproduce this. glTexImage2D returns GL_INVALID_VALUE, as demanded by 
the spec, because the "width > (gl::MAX_TEXTURE_SIZE >> level)" parameter check 
fails.

ANGLE's MAX_TEXTURE_SIZE is currently limited to 2048 to support a maximum 
range of devices. So MAX_TEXTURE_LEVELS is 12 (don't forget to count 2^0).

Did you encounter this crash after increasing MAX_TEXTURE_SIZE to 8192 without 
increasing MAX_TEXTURE_LEVELS to 14?

Original comment by nicolas....@gmail.com on 24 Sep 2010 at 12:56

GoogleCodeExporter commented 9 years ago
My bad... this is related to issue Issue 29, I just removed that weird 
restriction (width > (gl::MAX_TEXTURE_SIZE >> level) ---> width > 
gl::MAX_TEXTURE_SIZE, same for height), after removing it opened path to this 
new bug...
Because level checking is performed like this

        if (level < 0 || width < 0 || height < 0)
        {
            return error(GL_INVALID_VALUE);
        }
it wasn't checking for max value.

Anyways this should be reviewed after Issue 29 is resolved

Original comment by tomas%un...@gtempaccount.com on 24 Sep 2010 at 9:18

GoogleCodeExporter commented 9 years ago
closing as I don't think there is anything to do here in light of the status of 
Issue 29

Original comment by dan...@transgaming.com on 27 Oct 2010 at 4:00