Skip to content

Commit

Permalink
Fixes #423: Added implementations of texture and surface references.
Browse files Browse the repository at this point in the history
* Returning raw reference objects; we don't have wrappers for these kinds of textures nor for surfaces
* Dropped the pointers in the return types of the getters - they were redundant
  • Loading branch information
eyalroz authored and Eyal Rozenberg committed Oct 13, 2022
1 parent 564c8a3 commit 952386b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cuda/api/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class module_t {

// TODO: Implement a surface reference and texture reference class rather than these raw pointers.

CUsurfref* get_surface(const char* name) const;
CUtexref* get_texture_reference(const char* name) const;
CUsurfref get_surface(const char* name) const;
CUtexref get_texture_reference(const char* name) const;

protected: // constructors

Expand Down
21 changes: 21 additions & 0 deletions src/cuda/api/multi_wrapper_impls/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ inline module_t load_from_file(
inline context_t module_t::context() const { return context::detail_::from_handle(context_handle_); }
inline device_t module_t::device() const { return device::get(context::detail_::get_device_id(context_handle_)); }

inline CUsurfref module_t::get_surface(const char* name) const
{
context::current::detail_::scoped_override_t set_context_for_this_scope(context_handle_);
CUsurfref raw_surface_reference;
auto status = cuModuleGetSurfRef(&raw_surface_reference, handle_, name);
throw_if_error(status, ::std::string("Failed obtaining a reference to surface \"") + name + "\" from "
+ module::detail_::identify(*this));
return raw_surface_reference;
}

inline CUtexref module_t::get_texture_reference(const char* name) const
{
context::current::detail_::scoped_override_t set_context_for_this_scope(context_handle_);
CUtexref raw_texture_reference;
auto status = cuModuleGetTexRef(&raw_texture_reference, handle_, name);
throw_if_error(status, ::std::string("Failed obtaining a reference to texture \"") + name + "\" from "
+ module::detail_::identify(*this));
return raw_texture_reference;
}


} // namespace cuda

#endif // MULTI_WRAPPER_IMPLS_MODULE_HPP_
Expand Down

0 comments on commit 952386b

Please sign in to comment.