Tool/software: TI C/C++ Compiler
SDK version:PROCESSOR_SDK_VISION_03_08_00_00
The current TI frame camera data is due to the special NV12 format,therefore, the texture target in TI uses GL_TEXTURE_EXTERNAL_OES instead of the usual TEXTURE_2D.
And when GL_TEXTURE_EXTERNAL_OES and TEXTURE_2D are mixed in the same rendering pipeline shader program, they cannot currently render normally.
glGenTextures(1, &pObj->texYuv[texIndex]); System_eglCheckGlError("glGenTextures "); printf("andy debug: gen texture ID %d texIndex %d dmaBufFd %d \n", pObj->texYuv[texIndex],texIndex,dmaBufFd); glBindTexture(GL_TEXTURE_EXTERNAL_OES, pObj->texYuv[texIndex]); System_eglCheckGlError("glBindTexture"); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); System_eglCheckGlError("glTexParameteri");In shader
"" uniform samplerExternalOES fsSampler3; \n" use samplerExternalOES instead of sampler2D
... ...
3、Load rendering
#ifndef STANDALONE glBindTexture(GL_TEXTURE_EXTERNAL_OES, texYuv[tex2]); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #else glBindTexture(GL_TEXTURE_2D, texYuv[tex2]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #endifBut for our own AVM module:
We need to stitch together 4 camera images in real time。
Our shader is as follows:
1. Shader
... ...
uniform mediump sampler2D img1; \n\
uniform mediump sampler2D img2; \n\
uniform mediump sampler2D img3; \n\
uniform mediump sampler2D img4; \n\
uniform mediump sampler2D lut1 \n\
uniform mediump sampler2D lut2; \n\
uniform mediump sampler2D lut3; \n\
uniform mediump sampler2D lut4; \n\
... ...
2.Our image data is UYVY, and the LUT table data format is RGBA
3.Our source code uses GL_TEXTURE_2D for binding:
for (i = 0; i < 4; i++)if (0 == i) glActiveTexture(GL_TEXTURE0);else if (1 == i) glActiveTexture(GL_TEXTURE1);else if (2 == i) glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE3);... ...However, the current TI frame camera data uses samplerExternalOES due to the special NV12 format. We can also use samplerExternalOES for our own images.
But my own model and configuration table need to be loaded into the fragment shader using sampler2D.
If we modify our shader as follows
... ...
uniform mediump samplerExternalOES img1; \n\
uniform mediump samplerExternalOES img2; \n\
uniform mediump samplerExternalOES img3; \n\
uniform mediump samplerExternalOES img4; \n\
uniform mediump sampler2D lut1 \n\
uniform mediump sampler2D lut2; \n\
uniform mediump sampler2D lut3; \n\
uniform mediump sampler2D lut4; \n\
... ...
glBindTexture(GL_TEXTURE_EXTERNAL_OES, pTextureId[nCamId]);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
problem:
1、When GL_TEXTURE_EXTERNAL_OES and TEXTURE_2D are mixed in the same rendering pipeline shader program, they cannot currently render normally
2、How to load our RGBA format table also use GL_TEXTURE_EXTERNAL_OES?