Part Number: TDA4VM
Hello Expert
LINUX
gpu version is 1.13.5776728
SDK 7.2
I found that a segment of shader code can cause performance degradation and black screen issues
// vertex shader
static std::string getVS(){
CREATE()
SS("#version 320 es")
SS("uniform mat4 aMatrixV;")
SS("uniform vec4 std0;")
SS("uniform vec4 std2;")
SS("uniform vec4 offset;")
SS("layout(location = 0) in vec3 aPosition;")
SS("void main(){ ")
SS("precision highp float;")
SS("vec4 pos = vec4(aPosition,1.0);")
// SS("vec4 offset = vec4(2.00776f, 1.06246924f, 1.07718694f, 0.0f);")
SS("pos = pos + offset;")
SS("pos = aMatrixV * pos;")
#if ORIGINAL
//The following calculations have been found to cause two problems
//1. Compared to not executing the following code, 100% increases the calculation time by more than twice
//2. In actual shaders, there is a probability of causing 'black screen'
SS(" pos = pos / pos.w;")
#endif
#if CURRENT_TEST_OK
//We found that having a large range of variables can cause performance issues,
//so we have excluded some "invalid points" when the pos range is known
//This modification did not cause a "black screen" issue in the actual shader
SS(" if(abs(pos.w) < 0.01f){pos.z = 10.0f; pos.w = 1.0f;}")
SS(" pos = pos / pos.w;")
#endif
SS(" float sx = (2.0 / (std0[2] - std0[0]));")
SS(" float sy = (2.0 / (std0[1] - std0[3]));")
SS(" pos.x = (pos.x - std0[0]) * sx - 1.0;")
SS(" pos.y = (pos.y - std0[3]) * sy - 1.0;")
SS(" float disp_scale_x = (std2[2] / 2.0);")
SS(" float disp_scale_y = (std2[3] / 2.0);")
SS(" pos.x = pos.x * disp_scale_x + (std2[0] - (-1.0 * disp_scale_x));")
SS(" pos.y = pos.y * disp_scale_y + (std2[1] - (1.0 * disp_scale_y));")
SS(" gl_Position = pos;}")
return TOShaderStr()
}
There are some differences between the above code and the actual code. Currently, it has been found that the most relevant issue is " pos = pos / pos. w "
"performance degradation" : Performing this division will double the calculation time,
We have found that the range of pos values becomes larger after division. May I ask if this will cause such a poor performance problem and what is the reason?
“ black screen” : Following the general process, there is a probability that the output will be completely black out
glBindFrameBuffer -> glClear() "black color" -> draw 1 ... Draw Problem Shader ... draw N -> glFinish() -> glReadPix -> output is all black
Draw Problem Shader :please refer demo/shader.h
We have collected logs of the problem time through : pvrdebug -loggroups main,mts,hwr

Please help us find out what is the cause of the black screen. Is it effective to avoid "excessive range calculation"?
Regards




