OWL
Loading...
Searching...
No Matches
LaunchParams.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 "SBTObject.h"
20#include "Module.h"
21
22namespace owl {
23
31 typedef std::shared_ptr<LaunchParamsType> SP;
32
34 LaunchParamsType(Context *const context,
35 size_t varStructSize,
36 const std::vector<OWLVarDecl> &varDecls);
37
38 virtual std::string toString() const { return "LaunchParamsType"; }
39 };
40
44 struct LaunchParams : public SBTObject<LaunchParamsType> {
45 typedef std::shared_ptr<LaunchParams> SP;
46
51 struct DeviceData : public RegisteredObject::DeviceData {
52
54 DeviceData(const DeviceContext::SP &device, size_t dataSize);
56
57 const size_t dataSize;
58
59 OptixShaderBindingTable sbt = {};
60
66
69
72 cudaStream_t stream = nullptr;
73 };
74
76 LaunchParams(Context *const context,
77 LaunchParamsType::SP type);
81 std::string toString() const override;
82
90 CUstream getCudaStream(const DeviceContext::SP &device);
91
93 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
94
96 inline DeviceData &getDD(const DeviceContext::SP &device) const;
97
101 void sync();
102 };
103
104 // ------------------------------------------------------------------
105 // implementation section
106 // ------------------------------------------------------------------
107
109 inline LaunchParams::DeviceData &LaunchParams::getDD(const DeviceContext::SP &device) const
110 {
111 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
112 return deviceData[device->ID]->as<LaunchParams::DeviceData>();
113 }
114
115} // ::owl
116
Definition: Context.h:32
Definition: DeviceMemory.h:23
Definition: LaunchParams.h:30
virtual std::string toString() const
Definition: LaunchParams.h:38
Definition: LaunchParams.h:51
PinnedHostMem hostMemory
Definition: LaunchParams.h:65
cudaStream_t stream
Definition: LaunchParams.h:72
DeviceMemory deviceMemory
Definition: LaunchParams.h:68
Definition: LaunchParams.h:44
std::string toString() const override
Definition: LaunchParams.cpp:70
CUstream getCudaStream(const DeviceContext::SP &device)
Definition: LaunchParams.cpp:89
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
Definition: LaunchParams.cpp:77
void sync()
Definition: LaunchParams.cpp:97
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: LaunchParams.h:109
std::vector< DeviceData::SP > deviceData
Definition: Object.h:86
Definition: DeviceMemory.h:127
Definition: SBTObject.h:33
const std::vector< OWLVarDecl > varDecls
Definition: SBTObject.h:70
const size_t varStructSize
Definition: SBTObject.h:66
Definition: SBTObject.h:118
std::shared_ptr< LaunchParamsType > const type
Definition: SBTObject.h:134