NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/ds3d/glprocess/gl_cuda_utils.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef DS3D_GL_PROCESS_GL_CUDA_UTILSS_H
19 #define DS3D_GL_PROCESS_GL_CUDA_UTILSS_H
20 
21 #include "ds3d/common/common.h"
22 #include "ds3d/glprocess/gl_common.h"
23 #include "ds3d/glprocess/gl_buf.h"
24 #include "ds3d/common/helper/cuda_utils.h"
25 
26 #include <cuda.h>
27 #include <cuda_gl_interop.h>
28 
29 namespace ds3d { namespace gl {
30 
31 class CudaTexture {
32  Ptr<Texture> _texture;
33  cudaGraphicsResource* _cudaRes = nullptr;
34 
35 public:
36  static CudaTexture* create(int width, int height, GLenum type, int internalFormat, int format);
37 
38  CudaTexture() = default;
39  ~CudaTexture() = default;
40  ErrCode initCuda(Ptr<Texture> t, uint32_t flag = 0);
41 
42  const Ptr<Texture>& texture() const { return _texture; }
43  cudaGraphicsResource* cudaRes() const { return _cudaRes; }
44  cudaGraphicsResource*& cudaRes() { return _cudaRes; }
46  std::function<ErrCode(cudaArray_t, cudaStream_t)> cudaOps, cudaStream_t stream = 0);
47 };
48 
50  Ptr<VertexBuf> _vertexBuf;
51  cudaGraphicsResource* _cudaRes = nullptr;
52 
53 public:
54  CudaVertexBuf() = default;
56  ErrCode initCuda(Ptr<VertexBuf> t, uint32_t flag = 0);
57 
58  const Ptr<VertexBuf>& glBuf() const { return _vertexBuf; }
59  cudaGraphicsResource* cudaRes() const { return _cudaRes; }
60  cudaGraphicsResource*& cudaRes() { return _cudaRes; }
62  std::function<ErrCode(void*, size_t, cudaStream_t)> cudaOps, cudaStream_t stream = 0);
63 };
64 
65 }} // namespace ds3d::gl
66 
67 #endif // DS3D_GL_PROCESS_GL_CUDA_UTILSS_H
width
JDIMENSION JDIMENSION * width
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jpeglib.h:1001
ds3d::gl::CudaVertexBuf
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:49
ds3d::gl::CudaTexture::create
static CudaTexture * create(int width, int height, GLenum type, int internalFormat, int format)
ds3d::gl::CudaTexture::CudaTexture
CudaTexture()=default
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: includes/nvbufsurftransform.h:40
ds3d::gl::CudaVertexBuf::cudaRes
cudaGraphicsResource *& cudaRes()
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:60
ds3d::gl::CudaVertexBuf::CudaVertexBuf
CudaVertexBuf()=default
ds3d::gl::CudaTexture::cudaRes
cudaGraphicsResource *& cudaRes()
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:44
ds3d::ErrCode
ErrCode
Definition: includes/ds3d/common/common.h:47
ds3d::gl::CudaTexture
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:31
ds3d::gl::CudaTexture::initCuda
ErrCode initCuda(Ptr< Texture > t, uint32_t flag=0)
ds3d::gl::CudaTexture::texture
const Ptr< Texture > & texture() const
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:42
ds3d::gl::CudaVertexBuf::~CudaVertexBuf
~CudaVertexBuf()
ds3d::gl::CudaTexture::cudaRes
cudaGraphicsResource * cudaRes() const
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:43
ds3d::gl::CudaVertexBuf::cudaRes
cudaGraphicsResource * cudaRes() const
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:59
ds3d::Ptr
ShrdPtr< T > Ptr
Definition: includes/ds3d/common/hpp/obj.hpp:37
ds3d::gl::CudaVertexBuf::cudaProcess
ErrCode cudaProcess(std::function< ErrCode(void *, size_t, cudaStream_t)> cudaOps, cudaStream_t stream=0)
ds3d::gl::CudaTexture::~CudaTexture
~CudaTexture()=default
ds3d
Definition: includes/ds3d/common/abi_dataprocess.h:25
ds3d::gl::CudaTexture::cudaProcess
ErrCode cudaProcess(std::function< ErrCode(cudaArray_t, cudaStream_t)> cudaOps, cudaStream_t stream=0)
ds3d::gl::CudaVertexBuf::glBuf
const Ptr< VertexBuf > & glBuf() const
Definition: sources/libs/ds3d/glprocess/gl_cuda_utils.h:58
ds3d::gl::CudaVertexBuf::initCuda
ErrCode initCuda(Ptr< VertexBuf > t, uint32_t flag=0)
ds3d::v2xinfer::format
static std::string format(const char *fmt,...)
Definition: sources/libs/ds3d/inference_custom_lib/ds3d_v2x_infer_custom_preprocess/tensor.hpp:31