问题描述
我有一个使用 OpenTK 1.0 的 Visual Studio 2019 用 C# 编写的 3D 图形 Xamarin 项目。 Xamarin 是 5.0.0.1905 版,OpenTK 是 4.0.30319 版。 该应用程序在某些 Android 设备上运行良好,但在调用 DrawArrays 方法并将纹理应用于表面时会在其他设备上崩溃。由于所有堆栈跟踪都引用了“libGLESv2_adreno”,我猜测受影响的设备都具有 Qualcomm Adreno GPU。
这是一个典型的堆栈跟踪:
signal 11 (SIGSEGV),code 1 (SEGV_MAPERR)
backtrace:
#00 pc 000000000001dc18 /system/lib64/libc.so (memcpy+232)
#00 pc 00000000001d0d64 /vendor/lib64/egl/libGLESv2_adreno.so (EsxVertexArrayObject::UpdateInternalVbos(EsxDrawDescriptor const*,unsigned int,EsxAttributeDesc const*)+1644)
#00 pc 00000000003374f4 /vendor/lib64/egl/libGLESv2_adreno.so (A5xVertexArrayObject::CalcVfdregs(EsxDrawDescriptor const*,A5xVfdregs*,int)+892)
#00 pc 000000000034ff54 /vendor/lib64/egl/libGLESv2_adreno.so (A5xContext::ValidateState(EsxDrawDescriptor const*)+1212)
#00 pc 000000000033c820 /vendor/lib64/egl/libGLESv2_adreno.so (A5xContext::HwValidateGfxState(EsxDrawDescriptor const*)+16)
#00 pc 0000000000115178 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::ValidateGfxState(EsxDrawDescriptor const*)+1968)
#00 pc 00000000000fd240 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::DrawArraysInstanced(EsxPrimType,int,unsigned int)+416)
#00 pc 0000000000014f08 <anonymous>
这里有两个似乎与问题有关的代码片段。它们是从相关项目中提取的,因此某些变量可能需要进一步说明(请告诉我)。
首先设置纹理:
using OpenTK.Graphics.ES31;
...
int[] textures = new int[1];
GL.GenTextures(1,textures);
GL.BindTexture(TextureTarget.Texture2D,textures[0]);
if (bitMap != null)
{
//allocate memory on the graphics card for the texture.
glutils.TexImage2D((int)All.Texture2D,bitMap,0);
GL.GenerateMipmap(TextureTarget.Texture2D);
GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureMagFilter,(int)All.Nearest);
GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureMinFilter,(int)All.NearestMipmapLinear);
GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureWrapS,(int)All.Repeat);
GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureWrapT,(int)All.Repeat);
b.Recycle();
}
GL.BindTexture(TextureTarget.Texture2D,0);
其次,绘制曲面:
worldGLView.vertices = vertexLists[bufferIndex].ToArray();
worldGLView.texture_coordinates = textureVertexLists[bufferIndex].ToArray();
unsafe
{
fixed (Vector4* pvertices = worldGLView.vertices)
{
// Prepare the triangle coordinate data
GL.VertexAttribPointer(worldGLView.tShaderProgram.mPositionHandle,Vector4.SizeInBytes / 4,VertexAttribPointerType.Float,false,new IntPtr(pvertices));
}
fixed (Vector2* ptexturecoordinates = worldGLView.texture_coordinates)
{
// Prepare the triangle texture data
GL.VertexAttribPointer(worldGLView.tShaderProgram.mTextureCoordinatesHandle,Vector2.SizeInBytes / 4,new IntPtr(ptexturecoordinates));
}
}
GL.DrawArrays(BeginMode.Triangles,worldGLView.vertices.Length);
任何人都可以建议可能导致问题的原因以及我如何解决它?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)