ValveSoftware/openvr

SetOverlayTexture is broken on AMD (OpenGL)

UnivEngineer opened this issue · 1 comments

Every time I trying to set texture to overlay I got this error (through debug OpenGL callback function) on all AMD graphics cards:

OPENGL: ERROR: glCopyImageSubData has generated an error (GL_INVALID_OPERATION)

And overlay is not visible in the HMD (HTC Vive). My app (SpaceEngine) worked just fine few months ago with exactly this code:

`hudFBO.Create(hudW, hudH, keys, 0); // hudFBO.colorTexture is a regular RGBA8 GL_TEXTURE_2D with mipmaps; tried BGRA with the same error

vr::IVROverlay * ov = vr::VROverlay();
vr::Texture_t texture = { (void*)hudFBO.colorTexture, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
vr::VRTextureBounds_t bounds = { 0.0f, 0.0f, 1.0f, 1.0f };

 err = ov->SetOverlayInputMethod(overlayHandle, vr::VROverlayInputMethod_Mouse);
 err = ov->SetOverlayTexture(overlayHandle, &texture); // <--- error here
 err = ov->ShowOverlay(overlayHandle);`

Debugging in AMD CodeXL reveals weird behavior. I don't know how to attach screenshot, so copying output from the function calls history window here. This is inside vr::SetOverlayTexture(). It binds my texture (661), retrieves its dimensions and format, then generates its own texture, binds it (662), and immediately calls glCopyImageSubData(). GL_INVALID_OPERATION generated, because this is incorrect, new texture must be allocated first.

glBindTexture(GL_TEXTURE_2D, 661)
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, 0x000000BAA1D2D8EC)
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, 0x000000BAA1D2DDD8)
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, 0x000000BAA1D2D8E8)
glGenTextures(1, {0})
glBindTexture(GL_TEXTURE_2D, 662)
glCopyImageSubData(661, GL_TEXTURE_2D, 0, 0, 0, 0, 662, GL_TEXTURE_2D, 0, 0, 0, 0, 1024, 1024, 1)

It looks like either a bug in SetOverlayTexture code, or a non standard texture initialization, which is okay with NVidia, but not with AMD.

This is duplicate of a report in Steam community, because that one still have no answer. https://steamcommunity.com/app/250820/discussions/3/1606022547913471880/

Bump, same problem here