OWL
Loading...
Searching...
No Matches
Module.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
21namespace owl {
22
25 struct Module : public RegisteredObject {
26 typedef std::shared_ptr<Module> SP;
27
30 struct DeviceData : public RegisteredObject::DeviceData {
31
33 DeviceData(Module *parent, DeviceContext::SP device);
34
36 virtual ~DeviceData();
37
39 void build();
40
43 void destroy();
44
46 Module *const parent;
47
52 OptixModule module = 0;
53
57 CUmodule computeModule = 0;
58 };
59
62 Module(Context *context, const std::string &ptxCode);
63
65 Module(Context *context, const std::vector<uint8_t> &IR);
66
68 virtual ~Module();
69
71 std::string toString() const override;
72
74 inline DeviceData &getDD(const DeviceContext::SP &device) const;
75
77 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
78
80 bool useIR = false;
81
83 const std::string ptxCode;
84
86 const std::vector<uint8_t> optixIRCode;
87 };
88
89 // ------------------------------------------------------------------
90 // implementation section
91 // ------------------------------------------------------------------
92
94 inline Module::DeviceData &Module::getDD(const DeviceContext::SP &device) const
95 {
96 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
97 return deviceData[device->ID]->as<Module::DeviceData>();
98 }
99
100} // ::owl
Definition: Context.h:32
Definition: Module.h:30
void build()
Definition: Module.cpp:105
CUmodule computeModule
Definition: Module.h:57
void destroy()
Definition: Module.cpp:91
virtual ~DeviceData()
Definition: Module.cpp:84
OptixModule module
Definition: Module.h:52
Module *const parent
Definition: Module.h:46
Definition: Module.h:25
const std::vector< uint8_t > optixIRCode
Definition: Module.h:86
std::string toString() const override
Definition: Module.cpp:231
const std::string ptxCode
Definition: Module.h:83
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
Definition: Module.cpp:225
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: Module.h:94
virtual ~Module()
Definition: Module.cpp:218
bool useIR
Definition: Module.h:80
std::vector< DeviceData::SP > deviceData
Definition: Object.h:86
Definition: RegisteredObject.h:30