PxCudaContextManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 
11 
12 #ifndef PX_CUDA_CONTEXT_MANAGER_H
13 #define PX_CUDA_CONTEXT_MANAGER_H
14 
16 
17 /* Forward decl to avoid inclusion of cuda.h */
18 typedef struct CUctx_st *CUcontext;
19 typedef struct CUgraphicsResource_st *CUgraphicsResource;
20 
21 #ifndef PX_DOXYGEN
22 namespace physx
23 {
24 #endif
25 
26 class PxProfileZoneManager;
27 
30 {
34  enum Enum
35  {
36  NO_INTEROP = 0,
40 
41  COUNT
42  };
43 };
44 
45 
48 {
49 public:
72 
81 
82 #if PX_SUPPORT_GPU_PHYSX
83 
90  const char* appGUID;
91 #endif
92 
100 
101 
115 
123 
128 
130  {
131  ctx = NULL;
132  interopMode = PxCudaInteropMode::NO_INTEROP;
133  graphicsDevice = 0;
134 #if PX_SUPPORT_GPU_PHYSX
135  appGUID = NULL;
136 #endif
137  for(PxU32 i = 0; i < PxCudaBufferMemorySpace::COUNT; i++)
138  {
139  memoryBaseSize[i] = 0;
140  memoryPageSize[i] = 2 * 1024*1024;
141  maxMemorySize[i] = PX_MAX_U32;
142  }
143  }
144 };
145 
146 
165 {
166 public:
182  virtual void acquireContext() = 0;
183 
191  virtual void releaseContext() = 0;
192 
197  virtual PxCudaMemoryManager *getMemoryManager() = 0;
198 
203  virtual class PxGpuDispatcher *getGpuDispatcher() = 0;
204 
214  virtual bool contextIsValid() const = 0;
215 
216  /* Query CUDA context and device properties, without acquiring context */
217 
218  virtual bool supportsArchSM10() const = 0;
219  virtual bool supportsArchSM11() const = 0;
220  virtual bool supportsArchSM12() const = 0;
221  virtual bool supportsArchSM13() const = 0;
222  virtual bool supportsArchSM20() const = 0;
223  virtual bool supportsArchSM30() const = 0;
224  virtual bool supportsArchSM35() const = 0;
225  virtual bool supportsArchSM50() const = 0;
226  virtual bool supportsArchSM52() const = 0;
227  virtual bool isIntegrated() const = 0;
228  virtual bool canMapHostMemory() const = 0;
229  virtual int getDriverVersion() const = 0;
230  virtual size_t getDeviceTotalMemBytes() const = 0;
231  virtual int getMultiprocessorCount() const = 0;
232  virtual unsigned int getClockRate() const = 0;
233  virtual int getSharedMemPerBlock() const = 0;
234  virtual unsigned int getMaxThreadsPerBlock() const = 0;
235  virtual const char *getDeviceName() const = 0;
236  virtual PxCudaInteropMode::Enum getInteropMode() const = 0;
237 
238  virtual void setUsingConcurrentStreams(bool) = 0;
239  virtual bool getUsingConcurrentStreams() const = 0;
240  /* End query methods that don't require context to be acquired */
241 
261  virtual bool registerResourceInCudaGL(CUgraphicsResource &resource, PxU32 buffer) = 0;
262 
282  virtual bool registerResourceInCudaD3D(CUgraphicsResource &resource, void *resourcePointer) = 0;
283 
291  virtual bool unregisterResourceInCuda(CUgraphicsResource resource) = 0;
292 
300  virtual int usingDedicatedPhysXGPU() const = 0;
301 
317  virtual void release() = 0;
318 
319 protected:
320 
325 };
326 
331 {
332 public:
337  {
338  mCtx->acquireContext();
339  }
340 
345  {
346  mCtx->releaseContext();
347  }
348 
349 protected:
350 
355 };
356 
357 #if PX_SUPPORT_GPU_PHYSX
358 
363 int PxGetSuggestedCudaDeviceOrdinal(PxErrorCallback& errc);
364 
370 PxCudaContextManager* PxCreateCudaContextManager(PxFoundation& foundation, const PxCudaContextManagerDesc& desc, physx::PxProfileZoneManager* mgr);
371 
375 void* PxLoadPhysxGPUModule(const char* appGUID = NULL);
376 #endif
377 
378 #ifndef PX_DOXYGEN
379 } // end physx namespace
380 #endif
381 
382 #endif


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com