I want to use a share texture provided by another process, represented by HardwareBuffer.
When I try to pass it to Filament Texture, but setExternalImage takes the EGLImage as parameter.
So I tried to add an API to OpenGLDriver, it looks like that:
void OpenGLDriver::setExternalHardwareBuffer(Handle<HwTexture> th, void* hwbuffer) {
GLTexture* t = handle_cast<GLTexture*>(th);
assert(t);
AcquiredImage acquiredImage = mPlatform.transformAcquiredImage({
hwbuffer, nullptr, nullptr, nullptr });
bindTexture(OpenGLContext::DUMMY_TEXTURE_BINDING, t);
if (mPlatform.setExternalImage(acquiredImage.image, t->externalTexture)) {
// the target and id can be reset each time
t->gl.target = t->externalTexture->target;
t->gl.id = t->externalTexture->id;
t->gl.targetIndex = (uint8_t)OpenGLContext::getIndexForTextureTarget(t->gl.target);
bindTexture(OpenGLContext::DUMMY_TEXTURE_BINDING, t);
}
}
Then a Texture JNI interface will be OK as usual, an I call it
I am certain that the hardwareBuffer can lock right value in native(OpenGLDriver::setExternalHardwareBuffer), it just dose not work.
So, where did I go wrong, and how can I fix it?
By the way, if I gen Texture in Java directly and then bind texId with HardwareBuffer, it works very well.
It looks like as bellow:
At fisrt, I create Engine use Java EGL context, engine = Engine.create(sharedContext)
and then gen Texture ID and prepare AHardwareBuffer, pass them to native cpp
I want to use a share texture provided by another process, represented by HardwareBuffer. When I try to pass it to Filament Texture, but
setExternalImage
takes the EGLImage as parameter.So I tried to add an API to OpenGLDriver, it looks like that:
Then a Texture JNI interface will be OK as usual, an I call it
I am certain that the hardwareBuffer can lock right value in native(OpenGLDriver::setExternalHardwareBuffer), it just dose not work. So, where did I go wrong, and how can I fix it?
By the way, if I gen Texture in Java directly and then bind texId with HardwareBuffer, it works very well. It looks like as bellow: At fisrt, I create Engine use Java EGL context,
engine = Engine.create(sharedContext)
and then gen Texture ID and prepare AHardwareBuffer, pass them to native cppIn Java, pass the texId to Filament Texture
Or how can I share Texture between two Filament processes?