2016-08-17 114 views
0

我正在寫一個OpenGL ES 3.1程序,並且想知道我正在運行的設備(運行在Android 6上)的最大工作組大小。獲取計算着色器的最大工作組大小?

對於PC查詢GL_MAX_COMPUTE_WORK_GROUP_COUNTGL_MAX_COMPUTE_WORK_GROUP_SIZE工作正常,但我似乎無法在Android,我得到OpenGL error: InvalidEnum當我嘗試像

OpenTK代碼做了相同的:

int[] work_grp_cnt = new int[3]; 
GL.GetInteger(All.MaxComputeWorkGroupCount, work_grp_cnt); 

同樣的,原生Android API:

int[] work_grp_cnt = new int[3]; 
IntBuffer maxCount = IntBuffer.Allocate(3); 
GLES20.GlGetIntegerv(GLES31.GlMaxComputeWorkGroupCount, maxCount); 
maxCount.Get(work_grp_cnt); 

(在這兩種情況下,GLGetInteger都會產生相同的InvalidEnum錯誤) OpenGL ES 3.1有可能嗎?
我正在使用索尼Xperia Z5

回答

1

在C中,您必須調用glGetIntegeri_v,該索引需要一個索引。對於GL_MAX_COMPUTE_WORK_GROUP_COUNT,索引是您要查詢的維度。它一次只返回一個值。

您將需要找到並使用此功能的Java等價物。

+0

我已經添加了相當於Java我的功能,其同樣的錯誤。另外,錯誤出現在OpenGL端,這讓我認爲我調用了錯誤的API,而不是像我們所說的那樣,我的語法錯了。 – sydd

+0

這不一樣的功能。 「i_」部分很重要。 –

+0

謝謝,你說得對。我發佈了工作代碼作爲另一個答案。 – sydd

2

由於@NicolBoas指出我稱錯誤的功能。繼承人的工作代碼:

OpenTK:

 GL.GetInteger(All.MaxComputeWorkGroupCount, 0, out work_grp_cnt[0]); 
     GL.GetInteger(All.MaxComputeWorkGroupCount, 1, out work_grp_cnt[1]); 
     GL.GetInteger(All.MaxComputeWorkGroupCount, 2, out work_grp_cnt[2]); 

     GL.GetInteger(All.MaxComputeWorkGroupSize, 0, out work_grp_size[0]); 
     GL.GetInteger(All.MaxComputeWorkGroupSize, 1, out work_grp_size[1]); 
     GL.GetInteger(All.MaxComputeWorkGroupSize, 2, out work_grp_size[2]); 

機Android:

 GLES31.GlGetIntegeri_v(GLES31.GlMaxComputeWorkGroupCount, 0, work_grp_cnt, 0); 
     GLES31.GlGetIntegeri_v(GLES31.GlMaxComputeWorkGroupCount, 1, work_grp_cnt, 1); 
     GLES31.GlGetIntegeri_v(GLES31.GlMaxComputeWorkGroupCount, 2, work_grp_cnt, 2); 

     GLES31.GlGetIntegeri_v(GLES31.GlMaxComputeWorkGroupSize, 0, work_grp_size, 0); 
     GLES31.GlGetIntegeri_v(GLES31.GlMaxComputeWorkGroupSize, 1, work_grp_size, 1); 
     GLES31.GlGetIntegeri_v(GLES31.GlMaxComputeWorkGroupSize, 2, work_grp_size, 2);