OWL
Loading...
Searching...
No Matches
Group.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 "RegisteredObject.h"
20#include "Geometry.h"
21#include "LaunchParams.h"
22// #include "ll/DeviceMemory.h"
23// #include "ll/Device.h"
24
25namespace owl {
26
29 struct Group : public RegisteredObject {
30 typedef std::shared_ptr<Group> SP;
31
36 struct DeviceData : public RegisteredObject::DeviceData {
37 typedef std::shared_ptr<DeviceData> SP;
38
40 DeviceData(const DeviceContext::SP &device);
41
43 OptixTraversableHandle traversable = 0;
44
48
50 size_t memFinal = 0;
51
53 size_t memPeak = 0;
54 };
55
57 Group(Context *const context,
59
61 std::string toString() const override;
62
64 virtual void buildAccel(LaunchParams::SP launchParams = nullptr) = 0;
65
67 virtual void refitAccel(LaunchParams::SP launchParams = nullptr) = 0;
68
72 virtual int getSBTOffset() const = 0;
73
75 inline DeviceData &getDD(const DeviceContext::SP &device) const;
76
78 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
79
81 inline OptixTraversableHandle getTraversable(const DeviceContext::SP &device) const;
82
89 void getAccelSize(size_t &memFinal, size_t &memPeak)
90 {
91 DeviceData &dd = deviceData[0]->as<DeviceData>();
92 memFinal = dd.memFinal;
93 memPeak = dd.memPeak;
94 }
95
97 box3f bounds[2];
98 };
99
102 struct GeomGroup : public Group {
103 typedef std::shared_ptr<GeomGroup> SP;
104
107 GeomGroup(Context *const context, size_t numChildren);
108
110 virtual ~GeomGroup();
111
113 void setChild(size_t childID, Geom::SP child);
114
118 int getSBTOffset() const override { return sbtOffset; }
119
121 std::string toString() const;
122
124 std::vector<Geom::SP> geometries;
125
129 };
130
131
132 // ------------------------------------------------------------------
133 // implementation section
134 // ------------------------------------------------------------------
135
137 inline Group::DeviceData &Group::getDD(const DeviceContext::SP &device) const
138 {
139 assert(device->ID < (int)deviceData.size());
140 return deviceData[device->ID]->as<DeviceData>();
141 }
142
144 inline OptixTraversableHandle Group::getTraversable(const DeviceContext::SP &device) const
145 { return getDD(device).traversable; }
146
147} // ::owl
Definition: Context.h:32
Definition: DeviceMemory.h:23
Definition: Group.h:102
virtual ~GeomGroup()
Definition: Group.cpp:71
int sbtOffset
Definition: Group.h:128
void setChild(size_t childID, Geom::SP child)
Definition: Group.cpp:81
std::string toString() const
Definition: Group.cpp:88
std::vector< Geom::SP > geometries
Definition: Group.h:124
int getSBTOffset() const override
Definition: Group.h:118
Definition: Group.h:36
OptixTraversableHandle traversable
Definition: Group.h:43
DeviceMemory bvhMemory
Definition: Group.h:47
size_t memPeak
peak memory uesd during building, last time it was built.
Definition: Group.h:53
size_t memFinal
memory used for the BVH, last time it was built.
Definition: Group.h:50
Definition: Group.h:29
virtual void buildAccel(LaunchParams::SP launchParams=nullptr)=0
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
Definition: Group.cpp:42
virtual int getSBTOffset() const =0
void getAccelSize(size_t &memFinal, size_t &memPeak)
Definition: Group.h:89
virtual void refitAccel(LaunchParams::SP launchParams=nullptr)=0
box3f bounds[2]
Definition: Group.h:97
std::string toString() const override
Definition: Group.cpp:48
OptixTraversableHandle getTraversable(const DeviceContext::SP &device) const
Definition: Group.h:144
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: Group.h:137
Definition: ObjectRegistry.h:30
std::vector< DeviceData::SP > deviceData
Definition: Object.h:86
Definition: RegisteredObject.h:30
ObjectRegistry & registry
Definition: RegisteredObject.h:42