OWL
Loading...
Searching...
No Matches
UserGeom.h
1// ======================================================================== //
2// Copyright 2019-2020 Ingo Wald //
3// //
4// Licensed under the Apache License, Version 2.0 (the "License"); //
5// you may not use this file except in compliance with the License. //
6// You may obtain a copy of the License at //
7// //
8// http://www.apache.org/licenses/LICENSE-2.0 //
9// //
10// Unless required by applicable law or agreed to in writing, software //
11// distributed under the License is distributed on an "AS IS" BASIS, //
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
13// See the License for the specific language governing permissions and //
14// limitations under the License. //
15// ======================================================================== //
16
17#pragma once
18
19#include "Geometry.h"
20
21namespace owl {
22
29 struct UserGeomType : public GeomType {
30 typedef std::shared_ptr<UserGeomType> SP;
31
35 typedef std::shared_ptr<DeviceData> SP;
36
38 DeviceData(const DeviceContext::SP &device);
39
42 void fillPGDesc(OptixProgramGroupDesc &pgDesc,
43 GeomType *gt,
44 int rayType) override;
45
48 CUfunction boundsFuncKernel = 0;
49
52 CUfunction motionBoundsFuncKernel = 0;
53 };
54
57 UserGeomType(Context *const context,
58 size_t varStructSize,
59 const std::vector<OWLVarDecl> &varDecls);
60
62 void setIntersectProg(int rayType,
63 Module::SP module,
64 const std::string &progName);
65
67 void setBoundsProg(Module::SP module,
68 const std::string &progName);
69
71 void setMotionBoundsProg(Module::SP module,
72 const std::string &progName);
73
76
79
81 std::string toString() const override;
82
85 virtual std::shared_ptr<Geom> createGeom() override;
86
88 inline DeviceData &getDD(const DeviceContext::SP &device) const;
89
91 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
92
95
98
101 std::vector<ProgramDesc> intersectProg;
102 };
103
104
109 struct UserGeom : public Geom {
110 typedef std::shared_ptr<UserGeom> SP;
111
114 struct DeviceData : public Geom::DeviceData {
115 DeviceData(const DeviceContext::SP &device)
117 {};
118
124
127 DeviceMemory internalBufferForBoundsProgramKey2;
128
131
132 /* if this is true, then the above buffers come from the user, and should not be
133 malloced/freed on tree rebuilds */
134 bool useExternalBoundsBuffer = false;
135 };
136
138 UserGeom(Context *const context,
139 GeomType::SP geometryType);
140
142 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
143
145 inline DeviceData &getDD(const DeviceContext::SP &device);
146
148 UserGeomType::DeviceData &getTypeDD(const DeviceContext::SP &device) const;
149
151 std::string toString() const override;
152
154 void setPrimCount(size_t count);
155
157 void setBoundsBuffer(Buffer::SP buffer);
158
160 void setMotionBoundsBuffers(Buffer::SP buffer1, Buffer::SP buffer2);
161
163 void executeBoundsProgOnPrimitives(const DeviceContext::SP &device);
164
166 void executeMotionBoundsProgOnPrimitives(const DeviceContext::SP &device);
167
169 size_t primCount = 0;
170 };
171
172
173 // ------------------------------------------------------------------
174 // implementation section
175 // ------------------------------------------------------------------
176
179 UserGeomType::getDD(const DeviceContext::SP &device) const
180 {
181 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
182 return deviceData[device->ID]->as<UserGeomType::DeviceData>();
183 }
184
186 inline UserGeom::DeviceData &
187 UserGeom::getDD(const DeviceContext::SP &device)
188 {
189 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
190 return deviceData[device->ID]->as<UserGeom::DeviceData>();
191 }
192
195 UserGeom::getTypeDD(const DeviceContext::SP &device) const
196 {
197 return (UserGeomType::DeviceData &)type->getDD(device);
198 }
199} // ::owl
Definition: Context.h:32
Definition: DeviceMemory.h:23
Definition: Geometry.h:48
Definition: Geometry.h:41
Definition: Geometry.h:108
Definition: Object.h:36
DeviceContext::SP device
Definition: Object.h:53
std::vector< DeviceData::SP > deviceData
Definition: Object.h:86
Definition: Geometry.h:31
const std::vector< OWLVarDecl > varDecls
Definition: SBTObject.h:70
const size_t varStructSize
Definition: SBTObject.h:66
std::shared_ptr< GeomType > const type
Definition: SBTObject.h:134
Definition: UserGeom.h:34
DeviceData(const DeviceContext::SP &device)
void fillPGDesc(OptixProgramGroupDesc &pgDesc, GeomType *gt, int rayType) override
CUfunction boundsFuncKernel
Definition: UserGeom.h:48
CUfunction motionBoundsFuncKernel
Definition: UserGeom.h:52
Definition: UserGeom.h:29
std::vector< ProgramDesc > intersectProg
Definition: UserGeom.h:101
ProgramDesc boundsProg
Definition: UserGeom.h:94
std::string toString() const override
UserGeomType(Context *const context, size_t varStructSize, const std::vector< OWLVarDecl > &varDecls)
void setBoundsProg(Module::SP module, const std::string &progName)
void buildMotionBoundsProg()
void setIntersectProg(int rayType, Module::SP module, const std::string &progName)
ProgramDesc motionBoundsProg
Definition: UserGeom.h:97
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: UserGeom.h:179
void setMotionBoundsProg(Module::SP module, const std::string &progName)
virtual std::shared_ptr< Geom > createGeom() override
Definition: UserGeom.h:114
DeviceMemory internalBufferForBoundsProgram
Definition: UserGeom.h:123
DeviceMemory tempMem
Definition: UserGeom.h:130
DeviceMemory internalBufferForBoundsProgramKey1
Definition: UserGeom.h:126
Definition: UserGeom.h:109
void setMotionBoundsBuffers(Buffer::SP buffer1, Buffer::SP buffer2)
UserGeom(Context *const context, GeomType::SP geometryType)
DeviceData & getDD(const DeviceContext::SP &device)
Definition: UserGeom.h:187
void setBoundsBuffer(Buffer::SP buffer)
std::string toString() const override
void setPrimCount(size_t count)
void executeBoundsProgOnPrimitives(const DeviceContext::SP &device)
UserGeomType::DeviceData & getTypeDD(const DeviceContext::SP &device) const
Definition: UserGeom.h:195
void executeMotionBoundsProgOnPrimitives(const DeviceContext::SP &device)
size_t primCount
Definition: UserGeom.h:169
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override