mesa: enable ARB_direct_state_access in OpenGL 4.5 compat profile
[mesa.git] / src / mapi / glapi / gen / glX_proto_recv.py
index 916da94468930c058bb27393db3613f02c17a3e3..946f011818b01d6ed5f3b777197f12a6337eb73b 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2005
 # All Rights Reserved.
@@ -55,15 +54,15 @@ class PrintGlxDispatch_h(gl_XML.gl_print_base):
             if not func.ignore and not func.vectorequiv:
                 if func.glx_rop:
                     print 'extern _X_HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name)
-                    print 'extern _X_HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name)
+                    print 'extern _X_HIDDEN _X_COLD void __glXDispSwap_%s(GLbyte * pc);' % (func.name)
                 elif func.glx_sop or func.glx_vendorpriv:
                     print 'extern _X_HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
-                    print 'extern _X_HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
+                    print 'extern _X_HIDDEN _X_COLD int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
 
                     if func.glx_sop and func.glx_vendorpriv:
                         n = func.glx_vendorpriv_names[0]
                         print 'extern _X_HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
-                        print 'extern _X_HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
+                        print 'extern _X_HIDDEN _X_COLD int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
 
         return
 
@@ -89,8 +88,6 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
         print '#include "indirect_util.h"'
         print '#include "singlesize.h"'
         print ''
-        print '#define __GLX_PAD(x)  (((x) + 3) & ~3)'
-        print ''
         print 'typedef struct {'
         print '    __GLX_PIXEL_3D_HDR;'
         print '} __GLXpixel3DHeader;'
@@ -117,6 +114,9 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
 
         return
 
+    def fptrType(self, name):
+       fptr = "pfngl" + name + "proc"
+       return fptr.upper()
 
     def printFunction(self, f, name):
         if (f.glx_sop or f.glx_vendorpriv) and (len(f.get_images()) != 0):
@@ -134,6 +134,9 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
 
         print '{'
 
+        if not f.is_abi():
+            print '    %s %s = __glGetProcAddress("gl%s");' % (self.fptrType(name), name, name)
+
         if f.glx_rop or f.vectorequiv:
             self.printRenderFunction(f)
         elif f.glx_sop or f.glx_vendorpriv:
@@ -167,11 +170,11 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
                 if t.glx_name not in already_done:
                     real_name = self.real_types[t_size]
 
-                    print 'static %s' % (t_name)
-                    print 'bswap_%s( const void * src )' % (t.glx_name)
+                    print 'static _X_UNUSED %s' % (t_name)
+                    print 'bswap_%s(const void * src)' % (t.glx_name)
                     print '{'
                     print '    union { %s dst; %s ret; } x;' % (real_name, t_name)
-                    print '    x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name)
+                    print '    x.dst = bswap_%u(*(%s *) src);' % (t_size * 8, real_name)
                     print '    return x.ret;'
                     print '}'
                     print ''
@@ -179,12 +182,12 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
 
         for bits in [16, 32, 64]:
             print 'static void *'
-            print 'bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits)
+            print 'bswap_%u_array(uint%u_t * src, unsigned count)' % (bits, bits)
             print '{'
             print '    unsigned  i;'
             print ''
-            print '    for ( i = 0 ; i < count ; i++ ) {'
-            print '        uint%u_t temp = bswap_%u( src[i] );' % (bits, bits)
+            print '    for (i = 0 ; i < count ; i++) {'
+            print '        uint%u_t temp = bswap_%u(src[i]);' % (bits, bits)
             print '        src[i] = temp;'
             print '    }'
             print ''
@@ -218,6 +221,7 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
 
     def emit_function_call(self, f, retval_assign, indent):
         list = []
+        prefix = "gl" if f.is_abi() else ""
 
         for param in f.parameterIterator():
             if param.is_padding:
@@ -230,8 +234,7 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
 
             list.append( '%s        %s' % (indent, location) )
 
-
-        print '%s    %sgl%s(%s);' % (indent, retval_assign, f.name, string.join(list, ',\n'))
+        print '%s    %s%s%s(%s);' % (indent, retval_assign, prefix, f.name, string.join(list, ',\n'))
 
 
     def common_func_print_just_start(self, f, indent):
@@ -431,6 +434,10 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
                 print '        %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size)
                 answer_string = param.name
                 answer_count = param.counter
+                print ''
+                print '        if (%s == NULL) return BadAlloc;' % (param.name)
+                print '        __glXClearErrorOccured();'
+                print ''
             elif c >= 1:
                 print '        %s %s[%u];' % (answer_type, param.name, c)
                 answer_string = param.name