Jetson Inference
DNN Vision Library
glTexture.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __GL_TEXTURE_H__
24 #define __GL_TEXTURE_H__
25 
26 
27 #include "cudaUtility.h"
28 #include "cuda_gl_interop.h"
29 
30 
35 class glTexture
36 {
37 public:
38  static glTexture* Create( uint32_t width, uint32_t height, uint32_t format, void* data=NULL );
39  ~glTexture();
40 
41  void Render( float x, float y );
42  void Render( float x, float y, float width, float height );
43  void Render( const float4& rect );
44 
45  inline uint32_t GetID() const { return mID; }
46  inline uint32_t GetWidth() const { return mWidth; }
47  inline uint32_t GetHeight() const { return mHeight; }
48  inline uint32_t GetFormat() const { return mFormat; }
49  inline uint32_t GetSize() const { return mSize; }
50 
51  void* MapCUDA();
52  void Unmap();
53 
54  bool UploadCPU( void* data );
55 
56 private:
57  glTexture();
58  bool init(uint32_t width, uint32_t height, uint32_t format, void* data);
59 
60  uint32_t mID;
61  uint32_t mDMA;
62  uint32_t mWidth;
63  uint32_t mHeight;
64  uint32_t mFormat;
65  uint32_t mSize;
66 
67  cudaGraphicsResource* mInteropCUDA;
68  void* mInteropHost;
69  void* mInteropDevice;
70 };
71 
72 
73 #endif
bool UploadCPU(void *data)
uint32_t GetID() const
Definition: glTexture.h:45
static glTexture * Create(uint32_t width, uint32_t height, uint32_t format, void *data=NULL)
uint32_t GetHeight() const
Definition: glTexture.h:47
uint32_t GetFormat() const
Definition: glTexture.h:48
void Unmap()
void * MapCUDA()
void Render(float x, float y)
uint32_t GetWidth() const
Definition: glTexture.h:46
OpenGL texture with CUDA interoperability.
Definition: glTexture.h:35
uint32_t GetSize() const
Definition: glTexture.h:49