-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenGL] Replay issue with glUniformHandleui64ARB #911
Comments
I captured a trace using AMD Radeon RX 7900, if using current apitrace to replay this trace on NV GPU or old ASIC AMD GPU, will observe a black window. if modify the apitrace with above patch, then replay, will observe a blue square inside the black window. |
@jrfonseca do you know which "part of code"/"functions" in which file shoud I modify to add some special handling code to the glUniformHandleui64ARB function in glretrace_gl.cpp file? I have no idea where to insert the patch code because the glretrace_gl.cpp file is automatically generated, I would like to quickly push a PR to fix this issue by myself if someone can give me some hints. |
Hi @baozholu , Apologies for the silence. This should help in theory, but doesn't seem to make much difference in practice: diff --git a/specs/glapi.py b/specs/glapi.py
index 6db0933f..69aa3b68 100644
--- a/specs/glapi.py
+++ b/specs/glapi.py
@@ -1021,10 +1021,10 @@ glapi.addFunctions([
GlFunction(GLimageHandle, "glGetImageHandleARB", [(GLtexture, "texture"), (GLint, "level"), (GLboolean, "layered"), (GLint, "layer"), (GLenum, "format")]),
GlFunction(Void, "glMakeImageHandleResidentARB", [(GLimageHandle, "handle"), (GLenum, "access")]),
GlFunction(Void, "glMakeImageHandleNonResidentARB", [(GLimageHandle, "handle")]),
- GlFunction(Void, "glUniformHandleui64ARB", [(GLlocation, "location"), (GLuint64, "value")]),
+ GlFunction(Void, "glUniformHandleui64ARB", [(GLlocation, "location"), (GLtextureHandle, "value")]),
GlFunction(Void, "glUniformHandleui64vARB", [(GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLuint64), "count"), "value")]),
- GlFunction(Void, "glProgramUniformHandleui64ARB", [(GLprogram, "program"), (GLlocation, "location"), (GLuint64, "value")]),
- GlFunction(Void, "glProgramUniformHandleui64vARB", [(GLprogram, "program"), (GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLuint64), "count"), "values")]),
+ GlFunction(Void, "glProgramUniformHandleui64ARB", [(GLprogram, "program"), (GLlocation, "location"), (GLtextureHandle, "value")]),
+ GlFunction(Void, "glProgramUniformHandleui64vARB", [(GLprogram, "program"), (GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLtextureHandle), "count"), "values")]),
GlFunction(GLboolean, "glIsTextureHandleResidentARB", [(GLtextureHandle, "handle")], sideeffects=False),
GlFunction(GLboolean, "glIsImageHandleResidentARB", [(GLimageHandle, "handle")], sideeffects=False),
GlFunction(Void, "glVertexAttribL1ui64ARB", [(GLuint, "index"), (GLuint64, "x")]),
```
Not sure why.
You can debug this running `./glretrace -v -v -v ARB_bindless_texture.trace |& grep -C 10 Handle` you can see glretrace attempting to swizzle the texture handles.
Full bindless support will be extremely difficult with apitrace, if not outright impossible.
The problem is that the `glGetTextureHandleARB` result values are not just used by `glUniformHandleui64ARB` can be written as plain data vertex attributes, or any texture/resource. Even if glretrace scavenges all buffer/texture uploads and does a search and replace for recorded->replayed handle, it might do too much (replacing data that happens to have the same value as a handle) or do too little (e.g,, one passes handle+offset somewhere.)
The only way to fully support bindless would be if the OpenGL driver provided special extension that allowed glretrace to ask for a specific handle.. |
The return handle of glGetTextureHandleARB will differ between different vender/ASIC GPUs, current apitrace uses a _textureHandle_map and _imageHandle_map to store the original handle (Obtained during trace) and the new handle (Obtained during replay), but apitrace still uses the original handle when replaying the glUniformHandleui64ARB call, it should find the new handle through the _textureHandle_map and _imageHandle_map, then use it in glUniformHandleui64ARB.
Extension: GL_ARB_bindless_texture
All of the following APIs have this issue.
glUniformHandle*
glProgramUniformHandle*
For other APIs in the GL_ARB_bindless_texture extension, they used the _textureHandle_map/_imageHandle_map to store/get the real handle during replay
glGetTextureHandle*
glGetTextureSamplerHandle*
glGetImageHandle*
glMakeTextureHandle*
glMakeImageHandle*
So we should find the new handle through the _textureHandle_map/_imageHandle_map and use it in glUniformHandle and glProgramUniformHandle, just like glMakeTextureHandle and glMakeImageHandle does
The text was updated successfully, but these errors were encountered: