9 #ifndef CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP 10 #define CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP 22 using raw_handle_t = CUtexObject;
35 using parent = CUDA_TEXTURE_DESC;
36 memset(static_cast<parent*>(
this), 0,
sizeof(parent));
39 this->addressMode[0] = CU_TR_ADDRESS_MODE_BORDER;
40 this->addressMode[1] = CU_TR_ADDRESS_MODE_BORDER;
41 this->addressMode[2] = CU_TR_ADDRESS_MODE_BORDER;
42 this->filterMode = CU_TR_FILTER_MODE_POINT;
62 context::handle_t context_handle_,
63 texture::raw_handle_t handle,
64 bool take_ownership) noexcept;
87 using raw_handle_type = texture::raw_handle_t;
88 using scoped_context_setter = cuda::context::current::detail_::scoped_override_t;
91 bool is_owning()
const noexcept {
return owning; }
92 raw_handle_type raw_handle()
const noexcept {
return raw_view_handle; }
99 raw_view_handle(other.raw_view_handle), owning(other.raw_view_handle)
101 other.owning =
false;
105 template <
typename T, dimensionality_t NumDimensions>
109 context_handle_(arr.context_handle()), owning(
true)
111 scoped_context_setter set_context(context_handle_);
112 CUDA_RESOURCE_DESC resource_descriptor;
113 memset(&resource_descriptor, 0,
sizeof(resource_descriptor));
114 resource_descriptor.resType = CU_RESOURCE_TYPE_ARRAY;
115 resource_descriptor.res.array.hArray = arr.get();
117 auto status = cuTexObjectCreate(&raw_view_handle, &resource_descriptor, &descriptor,
nullptr);
118 throw_if_error_lazy(status,
"failed creating a CUDA texture object");
126 scoped_context_setter set_context(context_handle_);
127 auto status = cuTexObjectDestroy(raw_view_handle);
128 throw_if_error_lazy(status,
"failed destroying texture object");
138 texture_view(context::handle_t context_handle, raw_handle_type handle ,
bool take_ownership) noexcept
139 : context_handle_(context_handle), raw_view_handle(handle), owning(take_ownership) { }
144 device_t device()
const;
148 friend texture_view texture::wrap(context::handle_t, raw_handle_type,
bool) noexcept;
151 context::handle_t context_handle_ { } ;
152 raw_handle_type raw_view_handle { } ;
159 return lhs.raw_handle() == rhs.raw_handle();
164 return lhs.raw_handle() != rhs.raw_handle();
170 context::handle_t context_handle_,
171 texture::raw_handle_t handle,
172 bool take_ownership) noexcept
174 return { context_handle_, handle, take_ownership };
181 #endif // CUDA_API_WRAPPERS_TEXTURE_VIEW_HPP A simplifying rudimentary wrapper wrapper for the CUDA runtime API's internal "texture descriptor" ob...
Definition: texture_view.hpp:32
Wrapper class for a CUDA context.
Definition: context.hpp:220
All definitions and functionality wrapping the CUDA Runtime API.
Definition: array.hpp:22
Owning wrapper for CUDA 2D and 3D arrays.
Definition: array.hpp:27
Use texture memory for optimized read only cache access.
Definition: texture_view.hpp:86
Contains a proxy class for CUDA arrays - GPU memory with 2-D or 3-D locality and hardware support for...
Facilities for exception-based handling of Runtime and Driver API errors, including a basic exception...
freestanding wrapper functions for working with CUDA's various kinds of memory spaces, arranged into a relevant namespace hierarchy.