Git Product home page Git Product logo

Comments (4)

fadden avatar fadden commented on May 5, 2024 1

You can use a single EGL context for multiple surfaces, or have separate EGL contexts for each surface and configure them to share state. The former is probably easier. You can see an example in the "continuous capture" activity, which receives camera frames in a SurfaceTexture and then renders each frame twice (once to a display surface, once to a video encoder surface).

If you really want to keep your GLES state separate, you can create separate EGL contexts for each SurfaceView, and just pass the EGLContext from the first to the EglCore constructor for the others. The "show + capture camera" activity uses this approach, though it's a bit convoluted because it's not easy to get the EGLContext out of a GLSurfaceView.

It will be much more efficient to use a single SurfaceView. Each additional SurfaceView means an additional layer composited by the system; once you hit the hardware composer's limit you're placing an additional burden on the GPU. It will also be faster to switch shader programs than entire EGL contexts, so using a single EGLContext is best. See "hardware scaler exerciser" for an example of using multiple programs to draw one frame -- it uses different shaders for flat-shaded and textured rendering.

(In the future, please post questions on stackoverflow.com. There's a larger set of people who can answer questions, and other people will be able to find and benefit from the answers.)

from grafika.

dthib avatar dthib commented on May 5, 2024

Hi,

Thanks for your quick answer! I have to admit that I do not understand
everything in your post but now I have all the material and I can dive into
it.

Regarding the "hardware scaler exercise", the thing is the shader is
changed for the whole scene. In my case, I want to change the shader only
for one of the two items. Is that possible?

Thanks again,
Best,
Thibaut

Ps: I tried posting to stackoverflow.com but it seems to me that the post
is already deep in the list. (
http://stackoverflow.com/questions/27194321/multi-view-of-a-video) Have you
seen it? Did I do something wrong with it?
Le 3 déc. 2014 18:13, "Andy McFadden" [email protected] a écrit :

You can use a single EGL context for multiple surfaces, or have separate
EGL contexts for each surface and configure them to share state. The former
is probably easier. You can see an example in the "continuous capture"
activity, which receives camera frames in a SurfaceTexture and then renders
each frame twice (once to a display surface, once to a video encoder
surface).

If you really want to keep your GLES state separate, you can create
separate EGL contexts for each SurfaceView, and just pass the EGLContext
from the first to the EglCore constructor for the others. The "show +
capture camera" activity uses this approach, though it's a bit convoluted
because it's not easy to get the EGLContext out of a GLSurfaceView.

It will be much more efficient to use a single SurfaceView. Each
additional SurfaceView means an additional layer composited by the system;
once you hit the hardware composer's limit you're placing an additional
burden on the GPU. It will also be faster to switch shader programs than
entire EGL contexts, so using a single EGLContext is best. See "hardware
scaler exerciser" for an example of using multiple programs to draw one
frame -- it uses different shaders for flat-shaded and textured rendering.

(In the future, please post questions on stackoverflow.com. There's a
larger set of people who can answer questions, and other people will be
able to find and benefit from the answers.)


Reply to this email directly or view it on GitHub
#15 (comment).

from grafika.

fadden avatar fadden commented on May 5, 2024

If you look at draw() (currently https://github.com/google/grafika/blob/master/src/com/android/grafika/HardwareScalerActivity.java#L666) you can see it rendering the rect/triangle with either flat or textured shading, and then drawing the edge rects with flat. The draw() methods are actually re-selecting the program for every mesh, which isn't ideal, but Grafika isn't attempting to be a high-performance game engine.

For stackoverflow, it's important to get the right set of keywords. Keeping up with "android" is nearly impossible, but "surfaceview" rarely gets more than one question per day. I have a set of favorite keywords that I poke through. android-camera is one of them, but apparently I missed your question.

from grafika.

dthib avatar dthib commented on May 5, 2024

Hi,

Thanks for your answer again! That's very nice. I got it for the shader
thing. I will give it a try soon and let you know.

Best regards,
Thibaut
Le 4 déc. 2014 17:27, "Andy McFadden" [email protected] a écrit :

If you look at draw() (currently
https://github.com/google/grafika/blob/master/src/com/android/grafika/HardwareScalerActivity.java#L666)
you can see it rendering the rect/triangle with either flat or textured
shading, and then drawing the edge rects with flat. The draw() methods are
actually re-selecting the program for every mesh, which isn't ideal, but
Grafika isn't attempting to be a high-performance game engine.

For stackoverflow, it's important to get the right set of keywords.
Keeping up with "android" is nearly impossible, but "surfaceview" rarely
gets more than one question per day. I have a set of favorite keywords that
I poke through. android-camera is one of them, but apparently I missed your
question.


Reply to this email directly or view it on GitHub
#15 (comment).

from grafika.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.