[Bf-blender-cvs] [5050582] opensubdiv-modifier: Update CUEW in order to solve compilation error on Windows

Sergey Sharybin noreply at git.blender.org
Fri Jun 20 10:41:30 CEST 2014


Commit: 505058222dd48a1e32b8c71036409e49300d0a28
Author: Sergey Sharybin
Date:   Fri Jun 20 14:40:59 2014 +0600
https://developer.blender.org/rB505058222dd48a1e32b8c71036409e49300d0a28

Update CUEW in order to solve compilation error on Windows

===================================================================

M	extern/cuew/auto/cuew_gen.py
M	extern/cuew/auto/cuew_gen.sh
M	extern/cuew/include/cuew.h
M	extern/cuew/src/cuew.c

===================================================================

diff --git a/extern/cuew/auto/cuew_gen.py b/extern/cuew/auto/cuew_gen.py
index c0575ff..3f2f6ff 100644
--- a/extern/cuew/auto/cuew_gen.py
+++ b/extern/cuew/auto/cuew_gen.py
@@ -12,12 +12,22 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
+# This script generates either header or implementation file from
+# a CUDA header files.
+#
+# Usage: cuew hdr|impl [/path/to/cuda/includes]
+#  - hdr means header file will be generated and printed to stdout.
+#  - impl means implementation file will be generated and printed to stdout.
+#  - /path/to/cuda/includes is a path to a folder with cuda.h and cudaGL.h
+#    for which wrangler will be generated.
+
 import os
 import sys
 from cuda_errors import CUDA_ERRORS
 from pycparser import c_parser, c_ast, parse_file
 from subprocess import Popen, PIPE
 
+INCLUDE_DIR = "/usr/include"
 LIB = "CUEW"
 REAL_LIB = "CUDA"
 VERSION_MAJOR = "1"
@@ -142,14 +152,14 @@ class FuncDefVisitor(c_ast.NodeVisitor):
                     typedef += self._get_quals_string(func_decl_type)
                     typedef += self._get_ident_type(func_decl_type.type)
                     typedef += ' CUDAAPI'
-                    typedef += ' (*t' + symbol_name + ') '
+                    typedef += ' t' + symbol_name
                 elif isinstance(func_decl_type, c_ast.PtrDecl):
                     ptr_type = func_decl_type.type
                     symbol_name = ptr_type.declname
                     typedef += self._get_quals_string(ptr_type)
                     typedef += self._get_ident_type(func_decl_type)
                     typedef += ' CUDAAPI'
-                    typedef += ' (*t' + symbol_name + ') '
+                    typedef += ' t' + symbol_name
 
                 typedef += '(' + \
                     self._stringify_params(func_decl.args.params) + \
@@ -223,10 +233,11 @@ def parse_files():
     cpp_path = get_latest_cpp()
 
     for filename in FILES:
+        filepath = os.path.join(INCLUDE_DIR, filename)
         dummy_typedefs = {}
-        text = preprocess_file(filename, cpp_path)
+        text = preprocess_file(filepath, cpp_path)
 
-        if filename.endswith("GL.h"):
+        if filepath.endswith("GL.h"):
             dummy_typedefs = {
                 "CUresult": "int",
                 "CUgraphicsResource": "void *",
@@ -245,9 +256,9 @@ def parse_files():
             text = "typedef " + dummy_typedefs[typedef] + " " + \
                 typedef + ";\n" + text
 
-        ast = parser.parse(text, filename)
+        ast = parser.parse(text, filepath)
 
-        with open(filename) as f:
+        with open(filepath) as f:
             lines = f.readlines()
             for line in lines:
                 if line.startswith("#define"):
@@ -355,7 +366,7 @@ typedef unsigned int CUdeviceptr;
     print("/* Function declarations. */")
     for symbol in SYMBOLS:
         if symbol:
-            print('extern t%s %s;' % (symbol, symbol))
+            print('extern t%s *%s;' % (symbol, symbol))
         else:
             print("")
 
@@ -394,10 +405,10 @@ typedef void* DynamicLibrary;
 
 def print_dl_helper_macro():
     print("""#define %s_LIBRARY_FIND_CHECKED(name) \\
-        name = (t##name)dynamic_library_find(lib, #name);
+        name = (t##name *)dynamic_library_find(lib, #name);
 
 #define %s_LIBRARY_FIND(name) \\
-        name = (t##name)dynamic_library_find(lib, #name); \\
+        name = (t##name *)dynamic_library_find(lib, #name); \\
         assert(name);
 
 static DynamicLibrary lib;""" % (REAL_LIB, REAL_LIB))
@@ -505,7 +516,7 @@ def print_implementation():
     print("/* Function definitions. */")
     for symbol in SYMBOLS:
         if symbol:
-            print('t%s %s;' % (symbol, symbol))
+            print('t%s *%s;' % (symbol, symbol))
         else:
             print("")
     print("")
@@ -533,12 +544,17 @@ def print_implementation():
     print("}")
 
 if __name__ == "__main__":
-    parse_files()
 
-    if len(sys.argv) != 2:
-        print("Usage: %s hdr|impl" % (sys.argv[0]))
+    if len(sys.argv) != 2 and len(sys.argv) != 3:
+        print("Usage: %s hdr|impl [/path/to/cuda/toolkit/include]" %
+              (sys.argv[0]))
         exit(1)
 
+    if len(sys.argv) == 3:
+        INCLUDE_DIR = sys.argv
+
+    parse_files()
+
     if sys.argv[1] == "hdr":
         print_header()
     elif sys.argv[1] == "impl":
diff --git a/extern/cuew/auto/cuew_gen.sh b/extern/cuew/auto/cuew_gen.sh
index 7f6fbcf..9b491e0 100755
--- a/extern/cuew/auto/cuew_gen.sh
+++ b/extern/cuew/auto/cuew_gen.sh
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+# This script invokes cuew_gen.py and updates the
+# header and source files in the repository.
+
 SCRIPT=`realpath -s $0`
 DIR=`dirname $SCRIPT`
 
diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h
index 4df49fe..7b55806 100644
--- a/extern/cuew/include/cuew.h
+++ b/extern/cuew/include/cuew.h
@@ -668,377 +668,377 @@ typedef enum CUGLmap_flags_enum {
 #endif
 
 /* Function types. */
-typedef CUresult CUDAAPI (*tcuInit) (unsigned Flags);
-typedef CUresult CUDAAPI (*tcuDriverGetVersion) (int* driverVersion);
-typedef CUresult CUDAAPI (*tcuDeviceGet) (CUdevice* device, int ordinal);
-typedef CUresult CUDAAPI (*tcuDeviceGetCount) (int* count);
-typedef CUresult CUDAAPI (*tcuDeviceGetName) (char* name, int len, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuDeviceTotalMem_v2) (size_t* bytes, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuDeviceGetAttribute) (int* pi, CUdevice_attribute attrib, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuDeviceGetProperties) (CUdevprop* prop, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuDeviceComputeCapability) (int* major, int* minor, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuCtxCreate_v2) (CUcontext* pctx, unsigned flags, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuCtxDestroy_v2) (CUcontext ctx);
-typedef CUresult CUDAAPI (*tcuCtxPushCurrent_v2) (CUcontext ctx);
-typedef CUresult CUDAAPI (*tcuCtxPopCurrent_v2) (CUcontext* pctx);
-typedef CUresult CUDAAPI (*tcuCtxSetCurrent) (CUcontext ctx);
-typedef CUresult CUDAAPI (*tcuCtxGetCurrent) (CUcontext* pctx);
-typedef CUresult CUDAAPI (*tcuCtxGetDevice) (CUdevice* device);
-typedef CUresult CUDAAPI (*tcuCtxSynchronize) (void);
-typedef CUresult CUDAAPI (*tcuCtxSetLimit) (CUlimit limit, size_t value);
-typedef CUresult CUDAAPI (*tcuCtxGetLimit) (size_t* pvalue, CUlimit limit);
-typedef CUresult CUDAAPI (*tcuCtxGetCacheConfig) (CUfunc_cache* pconfig);
-typedef CUresult CUDAAPI (*tcuCtxSetCacheConfig) (CUfunc_cache config);
-typedef CUresult CUDAAPI (*tcuCtxGetSharedMemConfig) (CUsharedconfig* pConfig);
-typedef CUresult CUDAAPI (*tcuCtxSetSharedMemConfig) (CUsharedconfig config);
-typedef CUresult CUDAAPI (*tcuCtxGetApiVersion) (CUcontext ctx, unsigned* version);
-typedef CUresult CUDAAPI (*tcuCtxAttach) (CUcontext* pctx, unsigned flags);
-typedef CUresult CUDAAPI (*tcuCtxDetach) (CUcontext ctx);
-typedef CUresult CUDAAPI (*tcuModuleLoad) (CUmodule* module, const char* fname);
-typedef CUresult CUDAAPI (*tcuModuleLoadData) (CUmodule* module, const void* image);
-typedef CUresult CUDAAPI (*tcuModuleLoadDataEx) (CUmodule* module, const void* image, unsigned numOptions, CUjit_option* options, void* optionValues);
-typedef CUresult CUDAAPI (*tcuModuleLoadFatBinary) (CUmodule* module, const void* fatCubin);
-typedef CUresult CUDAAPI (*tcuModuleUnload) (CUmodule hmod);
-typedef CUresult CUDAAPI (*tcuModuleGetFunction) (CUfunction* hfunc, CUmodule hmod, const char* name);
-typedef CUresult CUDAAPI (*tcuModuleGetGlobal_v2) (CUdeviceptr* dptr, size_t* bytes, CUmodule hmod, const char* name);
-typedef CUresult CUDAAPI (*tcuModuleGetTexRef) (CUtexref* pTexRef, CUmodule hmod, const char* name);
-typedef CUresult CUDAAPI (*tcuModuleGetSurfRef) (CUsurfref* pSurfRef, CUmodule hmod, const char* name);
-typedef CUresult CUDAAPI (*tcuMemGetInfo_v2) (size_t* free, size_t* total);
-typedef CUresult CUDAAPI (*tcuMemAlloc_v2) (CUdeviceptr* dptr, size_t bytesize);
-typedef CUresult CUDAAPI (*tcuMemAllocPitch_v2) (CUdeviceptr* dptr, size_t* pPitch, size_t WidthInBytes, size_t Height, unsigned ElementSizeBytes);
-typedef CUresult CUDAAPI (*tcuMemFree_v2) (CUdeviceptr dptr);
-typedef CUresult CUDAAPI (*tcuMemGetAddressRange_v2) (CUdeviceptr* pbase, size_t* psize, CUdeviceptr dptr);
-typedef CUresult CUDAAPI (*tcuMemAllocHost_v2) (void* pp, size_t bytesize);
-typedef CUresult CUDAAPI (*tcuMemFreeHost) (void* p);
-typedef CUresult CUDAAPI (*tcuMemHostAlloc) (void* pp, size_t bytesize, unsigned Flags);
-typedef CUresult CUDAAPI (*tcuMemHostGetDevicePointer_v2) (CUdeviceptr* pdptr, void* p, unsigned Flags);
-typedef CUresult CUDAAPI (*tcuMemHostGetFlags) (unsigned* pFlags, void* p);
-typedef CUresult CUDAAPI (*tcuDeviceGetByPCIBusId) (CUdevice* dev, char* pciBusId);
-typedef CUresult CUDAAPI (*tcuDeviceGetPCIBusId) (char* pciBusId, int len, CUdevice dev);
-typedef CUresult CUDAAPI (*tcuIpcGetEventHandle) (CUipcEventHandle* pHandle, CUevent event);
-typedef CUresult CUDAAPI (*tcuIpcOpenEventHandle) (CUevent* phEvent, CUipcEventHandle handle);
-typedef CUresult CUDAAPI (*tcuIpcGetMemHandle) (CUipcMemHandle* pHandle, CUdeviceptr dptr);
-typedef CUresult CUDAAPI (*tcuIpcOpenMemHandle) (CUdeviceptr* pdptr, CUipcMemHandle handle, unsigned Flags);
-typedef CUresult CUDAAPI (*tcuIpcCloseMemHandle) (CUdeviceptr dptr);
-typedef CUresult CUDAAPI (*tcuMemHostRegister) (void* p, size_t bytesize, unsigned Flags);
-typedef CUresult CUDAAPI (*tcuMemHostUnregister) (void* p);
-typedef CUresult CUDAAPI (*tcuMemcpy) (CUdeviceptr dst, CUdeviceptr src, size_t ByteCount);
-typedef CUresult CUDAAPI (*tcuMemcpyPeer) (CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount);
-typedef CUresult CUDAAPI (*tcuMemcpyHtoD_v2) (CUdeviceptr dstDevice, const void* srcHost, size_t ByteCount);
-typedef CUresult CUDAAPI (*tcuMemcpyDtoH_v2) (void* dstHost, CUdeviceptr srcDevice, size_t ByteCount);
-typedef CUresult CUDAAPI (*tcuMemcpyDtoD_v2) (CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount);
-typedef CUresult CUDAAPI (*tcuMemcpyDtoA_v2) (CUarray dstArray, size_t dstOffset, CUdeviceptr srcDevice, size_t ByteCount);
-typedef

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list