Draw SkImage to second surface "glGetError 0x502(Invalid Operation)"

101 views
Skip to first unread message

Jona

unread,
Sep 18, 2015, 3:34:16 PM9/18/15
to skia-discuss
I'm getting some GPU errors when testing my code on a different device on Android.

- Nexus 4 [NO ISSUES]
- Samsung S6 [BUGS]

I have two surfaces, one my main surface and my second surface for backend drawing. These two surfaces share the same context and are called from the same thread as you would expect.

This is in a simplified level how my code works:

--------
Surface s1;
Surface s2;

-------- Drawing into surface 2
Canvas c = s2.getCanvas();
c.drawCircle(..);
c.flush();

-------- Adding current surface2 drawings into current drawing state image
SkImage image = s2.newImageSnapshot();

Canvas c = s2.getCanvas();

c.drawImage(currentState, 0, 0, NULL);
c.drawImage(image, 0, 0, NULL);
c.flush();

image.unref();

currentState  = s2.newImageSnapshot();

Canvas c = s2.getCanvas();
c.clear(TRANSPARENT);
c.flush();

-------- Finally drawing into surface

Canvas c = s1.getCanvas();

c.drawImage(currentState, 0, 0, NULL);

SkImage image = s2.newImageSnapshot();
c.drawImage(image, 0, 0, NULL);
image.unref();

c.flush();
context.flush();

--------


Android Logs
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ ---- glGetError 0x502(Invalid Operation)
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ at
    ../../../../src/gpu/gl/GrGLGpu.cpp(2995) :
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ UseProgram(fCopyProgram.fProgram)
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ [ 09-18 15:00:45.431 14781:14886 D/skia     ]
    ---- glGetError 0x502(Invalid Operation)
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ at
    ../../../../src/gpu/gl/GrGLGpu.cpp(3031) :
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0, sx0, sy0)
09-18 15:00:45.431  14781-14886/com.vblast.smasher D/skia﹕ [ 09-18 15:00:45.451  5470: 5470 D/ConnectivityManager ]
    getMobileDataEnabled()+ subId=2

Jona

unread,
Sep 18, 2015, 3:38:17 PM9/18/15
to skia-discuss
Let me add that the issue is gone if I omit the following peace of code.

Jona

unread,
Sep 18, 2015, 3:48:21 PM9/18/15
to skia-discuss
Well, I have resolved the issue by chance! :D


So I noticed that omitting this call caused the GPU errors to stop and the surface to draw properly.
c.drawImage(image, 0, 0, NULL);

Then I just wanted to try calling the following with the flag kNo_Budgeted.
SkImage image = s2.newImageSnapshot(kNo_Budgeted);

and bam! the issue is gone!

I guess I'm not super aware of what budget means and the current set limit... 

Hope this helps anyone here :)

cruz...@gmail.com

unread,
Sep 21, 2015, 4:48:16 PM9/21/15
to skia-discuss
Did you pass kNo_Budgeted to both calls of newImageSnapshot or just the first one?  I'm not familiar with the mechanisms behind budgets but I'm curious as to what the difference is in this case.

Jona

unread,
Sep 21, 2015, 5:22:36 PM9/21/15
to skia-discuss
I added it only to the first call to newImageSnapshot. That solved the issue. However, I went on to use kNo_Budgeted to all calls for newImageSnapshot since they are very important to the drawing process I created.

Hope that answers your question.
Reply all
Reply to author
Forward
0 new messages