Giter Site home page Giter Site logo

Comments (15)

zmike avatar zmike commented on May 31, 2024 1

It works!

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

You did pretty much what I had in mind with #874 (comment)

Maybe there's a non obvious bug here or the crash mechanism is different.

Can you share the trace or dump of last couple dozen of calls ?

from apitrace.

zmike avatar zmike commented on May 31, 2024

trace here

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

My hunch was actually right -- the issue is indeed the polymorphism of the indirect parameter:

...
3975364 @0 glMultiDrawElementsIndirect(mode = GL_TRIANGLES, type = GL_UNSIGNED_INT, indirect = 0x55560c2ff470, drawcount = 1, stride = 20)
warning: passing high address 0x55560c2ff470 as uintptr_t
apitrace: warning: caught signal 11

indirect should have been a blob here, instead of an offset pointer.

Was this trace recorded with your patch? Because I completely forgot to mention(!): that change zmike@5e9428d will not change the glretrace's behavior, but rather the tracing.

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

BTW, this is a very odd/useless thing for an OpenGL app to do: do an indirect draw, with the indirect parameters in CPU memory...! 🤦

It was to avoid weird state combinations with legacy like that the core profiles were created. But in the end everybody yielded: compatibility profiles are widely expected and supported. The only way to avoid legacy is to avoid OpenGL altogether and use something like Vulkan.

from apitrace.

zmike avatar zmike commented on May 31, 2024

Yeah, I'm just trying to fix (possible) driver bugs that people report 🤕

I don't recall if this specific trace was recorded with or without the change, but I just did another capture locally to verify and it still crashes. I'm uploading it now...

from apitrace.

zmike avatar zmike commented on May 31, 2024

trace

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

Same problem:

...
4286026 @0 glMultiDrawElementsIndirect(mode = GL_TRIANGLES, type = GL_UNSIGNED_INT, indirect = 0x7fffd8037bf0, drawcount = 1, stride = 20)
spring: /home/jfonseca/projects/apitrace/retrace/retrace_swizzle.cpp:169: std::map<long long unsigned int, retrace::Region>::iterator retrace::lookupRegion(long long unsigned int): Assertion `contains(it, address)' failed.

indirect is still not being recognised as a blob, despite there has never been a single glBindBuffer(GL_DRAW_INDIRECT_BUFFER) call.

Either:

  1. zmike@5e9428d has a bug somewhere
  2. the wrong glxtrace.so is not being used
  3. glGetIntegerv(GL_DRAW_INDIRECT_BUFFER, ...) is giving bogus results

Some carefully added printfs to glMultiDrawElementsIndirect's body should tell which is happenin.

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

I think I found the problem.

I believe this should fix it:

diff --git a/specs/glapi.py b/specs/glapi.py
index 89cf67db..6732ca3b 100644
--- a/specs/glapi.py
+++ b/specs/glapi.py
@@ -778,8 +778,8 @@ glapi.addFunctions([
 
     # GL_VERSION_4_6
     GlFunction(Void, "glSpecializeShader", [(GLshader, "shader"), (GLstringConst, "pEntryPoint"), (GLuint, "numSpecializationConstants"), (Array(Const(GLuint), "numSpecializationConstants"), "pConstantIndex"), (Array(Const(GLuint), "numSpecializationConstants"), "pConstantValue")]),
-    GlFunction(Void, "glMultiDrawArraysIndirectCount", [(GLenum_mode, "mode"), (GLpointerConst, "indirect"), (GLintptr, "drawcount"), (GLsizei, "maxdrawcount"), (GLsizei, "stride")]),
-    GlFunction(Void, "glMultiDrawElementsIndirectCount", [(GLenum_mode, "mode"), (GLenum, "type"), (GLpointerConst, "indirect"), (GLintptr, "drawcount"), (GLsizei, "maxdrawcount"), (GLsizei, "stride")]),
+    GlFunction(Void, "glMultiDrawArraysIndirectCount", [(GLenum_mode, "mode"), (GLdrawArraysIndirectBuffer(), "indirect"), (GLintptr, "drawcount"), (GLsizei, "maxdrawcount"), (GLsizei, "stride")]),
+    GlFunction(Void, "glMultiDrawElementsIndirectCount", [(GLenum_mode, "mode"), (GLenum, "type"), (GLdrawElementsIndirectBuffer(), "indirect"), (GLintptr, "drawcount"), (GLsizei, "maxdrawcount"), (GLsizei, "stride")]),
 
     # GL_VERSION_ES_CM_1_0
     GlFunction(Void, "glClipPlanef", [(GLenum, "plane"), (Array(Const(GLfloat), 4), "equation")]),
@@ -1189,8 +1189,8 @@ glapi.addFunctions([
     GlFunction(Void, "glMultiDrawElementsBaseVertex", [(GLenum_mode, "mode"), (Array(Const(GLsizei), "drawcount"), "count"), (GLenum, "type"), (Array(Const(GLindexBuffer("count[{i}]", "type")), "drawcount"), "indices"), (GLsizei, "drawcount"), (Array(Const(GLint), "drawcount"), "basevertex")]),
 
     # GL_ARB_draw_indirect
-    GlFunction(Void, "glDrawArraysIndirect", [(GLenum_mode, "mode"), (GLdrawArraysIndirectBuffer())]),
-    GlFunction(Void, "glDrawElementsIndirect", [(GLenum_mode, "mode"), (GLenum, "type"), (GLdrawElementsIndirectBuffer())]),
+    GlFunction(Void, "glDrawArraysIndirect", [(GLenum_mode, "mode"), (GLpointerConst, "indirect")]),
+    GlFunction(Void, "glDrawElementsIndirect", [(GLenum_mode, "mode"), (GLenum, "type"), (GLpointerConst, "indirect")]),
 
     # GL_ARB_draw_instanced
     GlFunction(Void, "glDrawArraysInstancedARB", [(GLenum_mode, "mode"), (GLint, "first"), (GLsizei, "count"), (GLsizei, "instancecount")]),
diff --git a/specs/gltypes.py b/specs/gltypes.py
index 2dbd6722..75c020e8 100644
--- a/specs/gltypes.py
+++ b/specs/gltypes.py
@@ -319,7 +319,7 @@ def GLdrawArraysIndirectBuffer():
     # - offsets when element array buffer is bound
     # - or a blob otherwise.
     return Polymorphic('_draw_indirect_buffer_binding()', [
-            ('0', Blob(Const(GLvoid), 16)),
+            ('0', Blob(Const(GLvoid), 'drawcount*16')),
         ],
         IntPointer("const GLvoid *"), 
         contextLess=False,
@@ -330,7 +330,7 @@ def GLdrawElementsIndirectBuffer():
     # - offsets when element array buffer is bound
     # - or a blob otherwise.
     return Polymorphic('_draw_indirect_buffer_binding()', [
-            ('0', Blob(Const(GLvoid), 20)),
+            ('0', Blob(Const(GLvoid), 'drawcount*20')),
         ],
         IntPointer("const GLvoid *"), 
         contextLess=False,

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

https://github.com/apitrace/apitrace/tree/issue-903

from apitrace.

zmike avatar zmike commented on May 31, 2024

Tested your branch and captures still crash the same way on replay.

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

Out of ideas then. Can you confirm whether the crashing glMultiDrawElementsIndirectCount call has a blob or not?

from apitrace.

zmike avatar zmike commented on May 31, 2024

Doesn't appear to be recognized as a blob, no.

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

I just realized that Khronos lacks the man page for glMultiDrawElementsIndirectCount and google was redirecting me to glMultiDrawElementsIndirect's man page which is different.

Per https://registry.khronos.org/OpenGL/extensions/ARB/ARB_indirect_parameters.txt ,
glMultiDrawElementsIndirectCount's drawcount is an int offset into the bound GL_PARAMETER_BUFFER.

It still doesn't explain why though.

from apitrace.

jrfonseca avatar jrfonseca commented on May 31, 2024

I wrote a test case (apitrace/apitrace-tests@b0a8664) did a few more fixes (now catching all "glDrawIndirect*" calls which wasn't the case), and confirmed I'm getting blobs, both with NVIDIA and Mesa:

$ apitrace trace -o drawarraysindirect.trace apps/gl/varray drawarraysindirect && apitrace dump --grep 'Indirect' drawarraysindirect.trace
[...]
7579 glDrawArraysIndirect(mode = GL_TRIANGLE_STRIP, indirect = blob(16))

Please try one more time.

from apitrace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.