我試圖使用方法:glTexSubImage2D 1282 - 無效操作GL ES 3.1
layout (binding = 0, rgba8ui) readonly uniform uimage2D input;
在計算着色器
。爲了將紋理綁定到該我使用:
glBindImageTexture(0, texture_name, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);
,似乎爲了這個綁定工作紋理必須是不可變的,所以我已經從切換:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
到:
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8UI, width, height);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
但這產生 「操作無效」(特別是glTexSubImage2D()調用生成它)。查看文檔,我發現這個調用可能會導致1282,原因如下:
GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous glTexImage2D or glCopyTexImage2D operation whose internalformat matches the format of glTexSubImage2D.
GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_SHORT_5_6_5 and format is not GL_RGB.
GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_SHORT_4_4_4_4 or GL_UNSIGNED_SHORT_5_5_5_1 and format is not GL_RGBA
但這些都不是我的情況。
第一人似乎是問題(考慮到我使用glTexStorage2D(),而不是glTexImage2D()),但由於浮紋的情況下,同樣的機制,這是沒有問題的:
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, width, height);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_FLOAT, pixels);
代替:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, pixels);
這可能是無關緊要的,但是這兩種方法在PC上運行良好。
關於爲什麼會發生這種情況的任何建議?
你試過我的解決方案嗎? – 246tNt