Fermat
rt.h
1 /*
2  * Fermat
3  *
4  * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the NVIDIA CORPORATION nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #pragma once
30 
31 #include <types.h>
32 #include <ray.h>
33 
34 #include <internal/optix_declarations.h>
35 
38 
42 
43 enum ERayGenPrograms
44 {
45  NULL_RAY_GEN = 0,
46  TMIN_INTERSECTION_RAY_GEN = 1,
47  MASKED_INTERSECTION_RAY_GEN = 2
48 };
49 
50 struct RTContextImpl;
51 
55 struct FERMAT_API RTContext
56 {
57  RTContext();
58  ~RTContext();
59 
60  void create_geometry(
61  const uint32 triCount,
62  const int* index_ptr,
63  const uint32 vertex_count,
64  const float* vertex_ptr,
65  const int* normal_index_ptr,
66  const float* normal_vertex_ptr,
67  const int* tex_index_ptr,
68  const float* tex_vertex_ptr,
69  const int* material_index_ptr);
70 
71  void bind_buffer(
72  const char* name,
73  const uint32 size,
74  const uint32 element_size,
75  void* ptr,
76  const RTformat format);
77 
78  void bind_var(
79  const char* name,
80  const uint32 size,
81  void* ptr);
82 
83  template <typename T>
84  void bind_var(const char* name, const T value) { bind_var(name, sizeof(T), (void*)&value); }
85 
86  void bind_var(const char* name, const int32 value);
87  void bind_var(const char* name, const uint32 value);
88  void bind_var(const char* name, const float value);
89 
90  uint32 create_program(
91  const char* filename,
92  const char* program_name);
93 
94  uint32 add_ray_generation_program(const uint32 program);
95 
96  void launch(const uint32 index, const uint32 width);
97  void launch(const uint32 index, const uint32 width, const uint32 height);
98 
99  void trace(const uint32 count, const Ray* rays, Hit* hits);
100  void trace(const uint32 count, const MaskedRay* rays, Hit* hits);
101  void trace_shadow(const uint32 count, const MaskedRay* rays, Hit* hits);
102  void trace_shadow(const uint32 count, const MaskedRay* rays, uint32* binary_hits);
103 
104  RTContextImpl* impl;
105 };
106 
108 ///@} Fermat
Definition: rt.h:55
Definition: rt.cpp:64
Definition: ray.h:42
Definition: ray.h:68
Definition: ray.h:55