9 #ifndef CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP 10 #define CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP 31 CAW_SET_SCOPE_CONTEXT(context_handle);
32 auto status = cuTexObjectDestroy(handle);
48 using parent = CUDA_TEXTURE_DESC;
49 memset(static_cast<parent*>(
this), 0,
sizeof(parent));
52 this->addressMode[0] = CU_TR_ADDRESS_MODE_BORDER;
53 this->addressMode[1] = CU_TR_ADDRESS_MODE_BORDER;
54 this->addressMode[2] = CU_TR_ADDRESS_MODE_BORDER;
55 this->filterMode = CU_TR_FILTER_MODE_POINT;
77 bool take_ownership) noexcept;
101 using scoped_context_setter = cuda::context::current::detail_::scoped_override_t;
108 raw_handle_type raw_handle()
const noexcept {
return raw_view_handle; }
109 bool is_owning()
const noexcept {
return owning_; }
117 device_id_(other.device_id_),
118 context_handle_(other.context_handle_),
119 raw_view_handle(other.raw_view_handle),
120 owning_(other.raw_view_handle)
122 other.owning_ =
false;
125 template <
typename T, dimensionality_t NumDimensions>
129 device_id_(arr.device_id()),
130 context_handle_(arr.context_handle()),
133 scoped_context_setter set_context(context_handle_);
134 CUDA_RESOURCE_DESC resource_descriptor;
135 memset(&resource_descriptor, 0,
sizeof(resource_descriptor));
136 resource_descriptor.resType = CU_RESOURCE_TYPE_ARRAY;
137 resource_descriptor.res.array.hArray = arr.get();
139 auto status = cuTexObjectCreate(&raw_view_handle, &resource_descriptor, &descriptor,
nullptr);
148 #ifdef THROW_IN_DESTRUCTORS 152 texture::detail_::destroy_view(raw_view_handle, context_handle_);
154 #ifdef THROW_IN_DESTRUCTORS 169 raw_handle_type handle ,
170 bool take_ownership) noexcept
172 device_id_(device_id),
173 context_handle_(context_handle),
174 raw_view_handle(handle),
175 owning_(take_ownership) { }
192 raw_handle_type raw_view_handle;
199 return lhs.raw_handle() == rhs.raw_handle();
204 return lhs.raw_handle() != rhs.raw_handle();
213 bool take_ownership) noexcept
215 return { device_id, context_handle, handle, take_ownership };
222 #endif // CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP typename ::std::conditional< NumDimensions==2, CUDA_ARRAY_DESCRIPTOR, CUDA_ARRAY3D_DESCRIPTOR >::type descriptor_t
Raw CUDA driver descriptor structure for an array of dimension.
Definition: array.hpp:38
device::id_t device_id() const noexcept
Getters for this object's raw fields.
Definition: texture_view.hpp:106
A simplifying rudimentary wrapper wrapper for the CUDA runtime API's internal "texture descriptor" ob...
Definition: texture_view.hpp:45
Wrapper class for a CUDA context.
Definition: context.hpp:249
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:880
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:852
Use texture memory for optimized read only cache access.
Definition: texture_view.hpp:99
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:327
bool operator==(const context_t &lhs, const context_t &rhs) noexcept
Definition: context.hpp:768
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.