NVIDIA IndeX API nvidia_logo_transpbg.gif Up
iindex_canvas.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright 2023 NVIDIA Corporation. All rights reserved.
3 *****************************************************************************/
6
7#ifndef NVIDIA_INDEX_IINDEX_CANVAS_H
8#define NVIDIA_INDEX_IINDEX_CANVAS_H
9
10#include <mi/dice.h>
11
12namespace nv
13{
14namespace index
15{
16
31 public mi::base::Interface_declare<0x46c5a5f7,0x31de,0x468d,0x9b,0x6c,0xb0,0x35,0x77,0xed,0xfe,0x61>
32{
33public:
36 {
46 };
47
51 virtual mi::Uint32 get_nb_frame_buffer_layers() const = 0;
52
60 virtual Frame_buffer_layer_type get_layer_type(mi::Uint32 layer_id) const = 0;
61
67 virtual void prepare() = 0;
68
81 virtual void render_tile(
82 mi::Uint32 layer_id,
83 Frame_buffer_layer_type layer_type,
84 const mi::math::Bbox_struct<mi::Uint32, 2>& area,
85 mi::Uint8* buffer) = 0;
86
100 virtual void receive_tile(
101 mi::Uint8* buffer,
102 mi::Uint32 buffer_size,
103 const mi::math::Bbox_struct<mi::Uint32, 2>& area) = 0;
104
120 virtual void receive_tile_blend(
121 mi::Uint8* buffer,
122 mi::Uint32 buffer_size,
123 const mi::math::Bbox_struct<mi::Uint32, 2>& area) = 0;
124
128 virtual void finish() = 0;
129
138 virtual bool is_multi_thread_capable() const = 0;
139
144 virtual mi::math::Vector_struct<mi::Uint32, 2> get_resolution() const = 0;
145
150 virtual mi::neuraylib::ICanvas* get_canvas() const = 0;
151};
152
161 public mi::base::Interface_declare<0x631ca66c,0x5ed7,0x4275,0xb7,0xb8,0x10,0x23,0x85,0xf8,0x36,0x55, nv::index::IIndex_canvas>
162{
163public:
169 virtual mi::neuraylib::ICanvas_cuda* get_cuda_canvas() const = 0;
170
177 virtual mi::Sint32 get_device_id() const = 0;
178};
179
182class Index_cuda_canvas : public mi::base::Interface_implement<nv::index::IIndex_cuda_canvas>
183{
184public:
189 virtual void set_resolution(const mi::math::Vector_struct<mi::Uint32, 2>& resolution) = 0;
190};
191
192
198class Index_canvas : public mi::base::Interface_implement<nv::index::IIndex_canvas>
199{
200public:
205 virtual mi::Uint32 get_nb_frame_buffer_layers() const
206 {
207 return 0;
208 }
209
214 virtual Frame_buffer_layer_type get_layer_type(mi::Uint32 /*layer_id*/) const
215 {
217 }
218
227 virtual void render_tile(
228 mi::Uint32 /*layer_id*/,
229 Frame_buffer_layer_type layer_type,
230 const mi::math::Bbox_struct<mi::Uint32, 2>& area,
231 mi::Uint8* buffer)
232 {
233 // Ignore the layer id but consider the layer type.
234
235 const mi::Uint32 x_range = area.max.x - area.min.x;
236 const mi::Uint32 y_range = area.max.y - area.min.y;
237 const mi::Uint32 buffer_size = (x_range * y_range);
238
239 if (layer_type == IIndex_canvas::FB_LAYER_RGB8)
240 {
241 this->receive_tile(buffer, buffer_size*3, area);
242 }
243 else if (layer_type == IIndex_canvas::FB_LAYER_RGBA8)
244 {
245 this->receive_tile_blend(buffer, buffer_size*4, area);
246 }
247 }
248
255 virtual mi::neuraylib::ICanvas* get_canvas() const { return NULL; }
256};
257
258} // namespace index
259} // namespace nv
260
261#endif // NVIDIA_INDEX_IINDEX_CANVAS_H
Enables rendering to a user-defined canvas.
Definition: iindex_canvas.h:32
virtual mi::Uint32 get_nb_frame_buffer_layers() const =0
The number of layers hosted by the canvas' frame buffer.
virtual mi::neuraylib::ICanvas * get_canvas() const =0
Returns the canvas that hosts the rendered pixels.
virtual void render_tile(mi::Uint32 layer_id, Frame_buffer_layer_type layer_type, const mi::math::Bbox_struct< mi::Uint32, 2 > &area, mi::Uint8 *buffer)=0
This interface method receives multiple tiles for each layer.
virtual Frame_buffer_layer_type get_layer_type(mi::Uint32 layer_id) const =0
Query the type of the frame buffer layer.
virtual mi::math::Vector_struct< mi::Uint32, 2 > get_resolution() const =0
Returns the resolution of the canvas in pixels.
virtual void receive_tile(mi::Uint8 *buffer, mi::Uint32 buffer_size, const mi::math::Bbox_struct< mi::Uint32, 2 > &area)=0
This interface method receives multiple tiles.
Frame_buffer_layer_type
Frame buffer layer types that are or will be supported by a canvas layer.
Definition: iindex_canvas.h:36
@ FB_LAYER_FLOAT32
Not supported yet // 32-bit float enabling scalar value encoding.
Definition: iindex_canvas.h:45
@ FB_LAYER_DEPTH32
32-bit depth in float.
Definition: iindex_canvas.h:42
@ FB_LAYER_RGBA8
8-bit per rgba component.
Definition: iindex_canvas.h:39
@ FB_LAYER_UNDEFINED
Undefined frame buffer.
Definition: iindex_canvas.h:37
@ FB_LAYER_DEPTH16
Not supported yet // 16-bit depth.
Definition: iindex_canvas.h:41
@ FB_LAYER_UINT8
Not supported yet // 8-bit unsigned int enabling index encoding.
Definition: iindex_canvas.h:43
@ FB_LAYER_RGB8
Not supported yet // 8-bit per rgb component.
Definition: iindex_canvas.h:38
@ FB_LAYER_UINT32
Not supported yet // 32-bit unsigned int enabling index encoding.
Definition: iindex_canvas.h:44
@ FB_LAYER_RGBE
Not supported yet // RGBe hdr support.
Definition: iindex_canvas.h:40
virtual void finish()=0
This method is called after all tiles are rendered, i.e, after all call to receive_tile().
virtual bool is_multi_thread_capable() const =0
The tiles can either be rendered in separate threads or in the main application thread.
virtual void receive_tile_blend(mi::Uint8 *buffer, mi::Uint32 buffer_size, const mi::math::Bbox_struct< mi::Uint32, 2 > &area)=0
This interface method receives multiple tiles.
virtual void prepare()=0
Before rendering, a buffer typically needs to be flushed or front- and back buffers need to be swappe...
CUDA-memory based canvas.
Definition: iindex_canvas.h:162
virtual mi::Sint32 get_device_id() const =0
The CUDA memory canvas is hosted on a CUDA device.
virtual mi::neuraylib::ICanvas_cuda * get_cuda_canvas() const =0
Returns the CUDA memory based canvas for external use, e.g., by a video encoder as input.
Mixin class for implementing the IIndex_canvas interface.
Definition: iindex_canvas.h:199
virtual void render_tile(mi::Uint32, Frame_buffer_layer_type layer_type, const mi::math::Bbox_struct< mi::Uint32, 2 > &area, mi::Uint8 *buffer)
Implemented render tile method of the canvas interface.
Definition: iindex_canvas.h:227
virtual mi::neuraylib::ICanvas * get_canvas() const
Returns the canvas that hosts the rendered pixels.
Definition: iindex_canvas.h:255
virtual Frame_buffer_layer_type get_layer_type(mi::Uint32) const
Return the frame buffer layer type.
Definition: iindex_canvas.h:214
virtual mi::Uint32 get_nb_frame_buffer_layers() const
Return number of layers.
Definition: iindex_canvas.h:205
Application managed interface class of a CUDA canvas implemented inside the NVIDIA IndeX library.
Definition: iindex_canvas.h:183
virtual void set_resolution(const mi::math::Vector_struct< mi::Uint32, 2 > &resolution)=0
Sets the resolution of the internal/built-in canvas.
Common namespace for all NVIDIA APIs.
Definition: iindex.h:349