9 #ifndef CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP 10 #define CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP 38 using parent = CUDA_TEXTURE_DESC;
39 memset(static_cast<parent*>(
this), 0,
sizeof(parent));
42 this->addressMode[0] = CU_TR_ADDRESS_MODE_BORDER;
43 this->addressMode[1] = CU_TR_ADDRESS_MODE_BORDER;
44 this->addressMode[2] = CU_TR_ADDRESS_MODE_BORDER;
45 this->filterMode = CU_TR_FILTER_MODE_POINT;
67 bool take_ownership) noexcept;
91 using scoped_context_setter = cuda::context::current::detail_::scoped_override_t;
98 raw_handle_type raw_handle()
const noexcept {
return raw_view_handle; }
99 bool is_owning()
const noexcept {
return owning_; }
107 device_id_(other.device_id_),
108 context_handle_(other.context_handle_),
109 raw_view_handle(other.raw_view_handle),
110 owning_(other.raw_view_handle)
112 other.owning_ =
false;
115 template <
typename T, dimensionality_t NumDimensions>
119 device_id_(arr.device_id()),
120 context_handle_(arr.context_handle()),
123 scoped_context_setter set_context(context_handle_);
124 CUDA_RESOURCE_DESC resource_descriptor;
125 memset(&resource_descriptor, 0,
sizeof(resource_descriptor));
126 resource_descriptor.resType = CU_RESOURCE_TYPE_ARRAY;
127 resource_descriptor.res.array.hArray = arr.get();
129 auto status = cuTexObjectCreate(&raw_view_handle, &resource_descriptor, &descriptor,
nullptr);
138 scoped_context_setter set_context(context_handle_);
139 auto status = cuTexObjectDestroy(raw_view_handle);
153 raw_handle_type handle ,
154 bool take_ownership) noexcept
156 device_id_(device_id),
157 context_handle_(context_handle),
158 raw_view_handle(handle),
159 owning_(take_ownership) { }
176 raw_handle_type raw_view_handle;
183 return lhs.raw_handle() == rhs.raw_handle();
188 return lhs.raw_handle() != rhs.raw_handle();
197 bool take_ownership) noexcept
199 return { device_id, context_handle, handle, take_ownership };
206 #endif // CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP device::id_t device_id() const noexcept
Getters for this object's raw fields.
Definition: texture_view.hpp:96
A simplifying rudimentary wrapper wrapper for the CUDA runtime API's internal "texture descriptor" ob...
Definition: texture_view.hpp:35
Wrapper class for a CUDA context.
Definition: context.hpp:244
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
CUcontext handle_t
Raw CUDA driver handle for a context; see {context_t}.
Definition: types.hpp:878
Owning wrapper for CUDA 2D and 3D arrays.
Definition: array.hpp:29
CUdevice id_t
Numeric ID of a CUDA device used by the CUDA Runtime API.
Definition: types.hpp:850
Use texture memory for optimized read only cache access.
Definition: texture_view.hpp:89
Contains a proxy class for CUDA arrays - GPU memory with 2-D or 3-D locality and hardware support for...
#define throw_if_error_lazy(status__,...)
A macro for only throwing an error if we've failed - which also ensures no string is constructed unle...
Definition: error.hpp:316
bool operator==(const context_t &lhs, const context_t &rhs) noexcept
Definition: context.hpp:762
Facilities for exception-based handling of Runtime and Driver API errors, including a basic exception...
CUtexObject raw_handle_t
The CUDA driver's raw, opaque handle for texture objects.
Definition: texture_view.hpp:25
Wrapper class for a CUDA device.
Definition: device.hpp:135
freestanding wrapper functions for working with CUDA's various kinds of memory spaces, arranged into a relevant namespace hierarchy.