diff options
-rw-r--r-- | VMWX_map_buffer_debug.txt | 116 | ||||
-rw-r--r-- | dispatch/glimports.hpp | 4 | ||||
-rw-r--r-- | wrappers/glcaps.cpp | 1 | ||||
-rw-r--r-- | wrappers/gltrace.py | 35 |
4 files changed, 149 insertions, 7 deletions
diff --git a/VMWX_map_buffer_debug.txt b/VMWX_map_buffer_debug.txt new file mode 100644 index 00000000..254e08d3 --- /dev/null +++ b/VMWX_map_buffer_debug.txt @@ -0,0 +1,116 @@ +Name + + VMWX_map_buffer_debug + +Name Strings + + GL_VMWX_map_buffer_debug + +Contact + + Jose Fonseca, VMware (jfonseca 'at' vmware.com) + +IP Status + + No known IP claims. + +Status + + Implemented by Apitrace + +Version + + Last Modified Date: December 14, 2014 + Version: 1 + +Number + + TBD. + +Dependencies + + GL_ARB_buffer_storage is required. + +Overview + + This extension provides a mechanism for the application to notify OpenGL + debugging tools that it modified ranges of persistent buffer mappings, + without explicitly flushing buffer ranges. + +New Procedures and Functions + + void NotifyMappedBufferRangeVMWX(const void * start, sizeiptr length); + +New Tokens + + Accepted in the <flags> parameter of BufferStorage: + + MAP_NOTIFY_EXPLICIT_BIT_VMWX 0x80000000 + + Accepted as part of the <access> parameter to MapBufferRange and + MapNamedBufferRange: + + MAP_NOTIFY_EXPLICIT_BIT_VMWX 0x80000000 + +Additions to Chapter 6 of the OpenGL Core Profile Specification, Version 4.3, +"Buffer Objects" + + Modify Section 6.2, "Creating and Modifying Buffer Object Data Stores" + + Add to the bulleted list describing flags that modify buffer storage + flags, p.57. + + * MAP_NOTIFY_EXPLICIT_BIT_VMWX indicates that the application will + notify whenever discrete subranges of coherent mappings are + notified. + + This flag may only be used in conjunction with MAP_PERSISTENT_BIT. + + Modify Section 6.3, "Mapping and Unmapping Buffer Data" + + Add to the bulleted list describing flags that modify buffer mappings, + p.62. + + * MAP_NOTIFY_EXPLICIT_BIT_VMWX indicates that discrete subranges of the + mapping will be notified explicitly when modified. + + When this flag is set, modifications to each subrange must be + explicitly flushed by calling NotifyMappedBufferRangeVMWX. + + This flag may only be used in conjunction with MAP_PERSISTENT_BIT. + + If this bit is set, the value of BUFFER_STORAGE_FLAGS for the buffer + being mapped must include MAP_NOTIFY_EXPLICIT_BIT_VMWX. + +Issues + + 1) Why is this extension necessary? + + It is true that an application may be friendly towards OpenGL debugging + tools that intercept calls by ensuring that MAP_PERSISTENT_BIT is always + set with MAP_FLUSH_EXPLICIT_BIT, and never with MAP_COHERENT_BIT. But + this restricts/deviates from intended behavior. This extensions provides + a mechanism for applications to notify debugging tools without affecting + behavior. + + + 2) Why the new MAP_NOTIFY_EXPLICIT_BIT_VMWX token? + + To be future-proof. + + In order to record complete traces, OpenGL tracing tools may choose to + mask out support for coherent mappings by failing BufferStorage calls with + OUT_OF_MEMORY when MAP_COHERENT_BIT is set without + MAP_NOTIFY_EXPLICIT_BIT_VMWX; or use techniques to approximately detect + writes to coherent mappings if the application calls MapBufferRange with + MAP_COHERENT_BIT and MAP_NOTIFY_EXPLICIT_BIT_VMWX. + + It is therefore crucial that applications that want to explicitily notify + modified subranges with calls NotifyMappedBufferRangeVMWX set the + MAP_NOTIFY_EXPLICIT_BIT_VMWX bit both on BufferStorage and MapBufferRange + calls, to opt-out of further interference from debugging tools. + + +Revision History + + Version 1, 2014/12/14 - Initial version diff --git a/dispatch/glimports.hpp b/dispatch/glimports.hpp index 44f2a0f3..e82b1231 100644 --- a/dispatch/glimports.hpp +++ b/dispatch/glimports.hpp @@ -85,6 +85,10 @@ #define GL_TRANSPOSE_PROJECTIVE_3D_NV 0x9099 +// GL_VMWX_map_buffer_debug +#define GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX 0x80000000 + + #if defined(_WIN32) #include <GL/wglext.h> diff --git a/wrappers/glcaps.cpp b/wrappers/glcaps.cpp index 292020a8..2b4c30a9 100644 --- a/wrappers/glcaps.cpp +++ b/wrappers/glcaps.cpp @@ -62,6 +62,7 @@ extraExtension_stringsFull[] = { "GL_KHR_debug", "GL_EXT_debug_marker", "GL_EXT_debug_label", + "GL_VMWX_map_buffer_debug", }; static const char * diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py index 078afab1..5b044416 100644 --- a/wrappers/gltrace.py +++ b/wrappers/gltrace.py @@ -294,6 +294,14 @@ class GlTracer(Tracer): print '}' print + # VMWX_map_buffer_debug + print r'extern "C" PUBLIC' + print r'void APIENTRY' + print r'glNotifyMappedBufferRangeVMWX(const void * start, GLsizeiptr length) {' + self.emit_memcpy('start', 'length') + print r'}' + print + getProcAddressFunctionNames = [] def traceApi(self, api): @@ -658,8 +666,21 @@ class GlTracer(Tracer): print ' }' # FIXME: We don't support coherent/pinned memory mappings + if function.name in ('glBufferStorage', 'glNamedBufferStorage', 'glNamedBufferStorageEXT'): + print r' if (!(flags & GL_MAP_PERSISTENT_BIT)) {' + print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);' + print r' }' + print r' flags &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;' if function.name in ('glMapBufferRange', 'glMapNamedBufferRange', 'glMapNamedBufferRangeEXT'): - print r' if (access & GL_MAP_COHERENT_BIT) {' + print r' if (access & GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX) {' + print r' if (!(access & GL_MAP_PERSISTENT_BIT)) {' + print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);' + print r' }' + print r' if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {' + print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/ MAP_FLUSH_EXPLICIT_BIT\n", __FUNCTION__);' + print r' }' + print r' access &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;' + print r' } else if (access & GL_MAP_COHERENT_BIT) {' print r' os::log("apitrace: warning: %s: MAP_COHERENT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);' print r' } else if ((access & GL_MAP_PERSISTENT_BIT) &&' print r' !(access & GL_MAP_FLUSH_EXPLICIT_BIT)) {' @@ -795,14 +816,14 @@ class GlTracer(Tracer): print ' }' if function.name in self.getProcAddressFunctionNames: - else_ = '' + nameArg = function.args[0].name + print ' if (strcmp("glNotifyMappedBufferRangeVMWX", (const char *)%s) == 0) {' % (nameArg,) + print ' _result = (%s)&glNotifyMappedBufferRangeVMWX;' % (function.type,) for marker_function in self.marker_functions: if self.api.getFunctionByName(marker_function): - print ' %sif (strcmp("%s", (const char *)%s) == 0) {' % (else_, marker_function, function.args[0].name) + print ' } else if (strcmp("%s", (const char *)%s) == 0) {' % (marker_function, nameArg) print ' _result = (%s)&%s;' % (function.type, marker_function) - print ' }' - else_ = 'else ' - print ' %s{' % else_ + print ' } else {' Tracer.doInvokeFunction(self, function) # Replace function addresses with ours @@ -810,7 +831,7 @@ class GlTracer(Tracer): # contain the addresses of the wrapper functions, and not the real # functions, but in practice this should make no difference. if function.name in self.getProcAddressFunctionNames: - print ' _result = _wrapProcAddress(%s, _result);' % (function.args[0].name,) + print ' _result = _wrapProcAddress(%s, _result);' % (nameArg,) print ' }' return |