/** @brief Reads data from a buffer back to main RAM. * * @param src_buffer A smart pointer to the beginning of an allocated source buffer * @param src_offset Offset of the first byte to be read from the beginning of src_buffer (in bytes_ * @param bytes_to_copy Number of bytes to be read * @param ptr Location in main RAM where to read data should be written to */ inline void memory_read(handle_type const & src_buffer, std::size_t src_offset, std::size_t bytes_to_copy, void * ptr) { assert( (src_buffer.get() != NULL) && bool("Memory not initialized!")); for (std::size_t i=0; i<bytes_to_copy; ++i) static_cast<char *>(ptr)[i] = src_buffer.get()[i+src_offset]; }
/** @brief Writes data from main RAM identified by 'ptr' to the buffer identified by 'dst_buffer' * * @param dst_buffer A smart pointer to the beginning of an allocated buffer * @param dst_offset Offset of the first written byte from the beginning of 'dst_buffer' (in bytes) * @param bytes_to_copy Number of bytes to be copied * @param ptr Pointer to the first byte to be written */ inline void memory_write(handle_type & dst_buffer, std::size_t dst_offset, std::size_t bytes_to_copy, const void * ptr) { assert( (dst_buffer.get() != NULL) && bool("Memory not initialized!")); for (std::size_t i=0; i<bytes_to_copy; ++i) dst_buffer.get()[i+dst_offset] = static_cast<const char *>(ptr)[i]; }
/** @brief Copies 'bytes_to_copy' bytes from address 'src_buffer + src_offset' to memory starting at address 'dst_buffer + dst_offset'. * * @param src_buffer A smart pointer to the begin of an allocated buffer * @param dst_buffer A smart pointer to the end of an allocated buffer * @param src_offset Offset of the first byte to be written from the address given by 'src_buffer' (in bytes) * @param dst_offset Offset of the first byte to be written to the address given by 'dst_buffer' (in bytes) * @param bytes_to_copy Number of bytes to be copied */ inline void memory_copy(handle_type const & src_buffer, handle_type & dst_buffer, std::size_t src_offset, std::size_t dst_offset, std::size_t bytes_to_copy) { assert( (dst_buffer.get() != NULL) && bool("Memory not initialized!")); assert( (src_buffer.get() != NULL) && bool("Memory not initialized!")); for (std::size_t i=0; i<bytes_to_copy; ++i) dst_buffer.get()[i+dst_offset] = src_buffer.get()[i + src_offset]; }
/** @brief Copies 'bytes_to_copy' bytes from address 'src_buffer + src_offset' on the CUDA device to memory starting at address 'dst_buffer + dst_offset' on the same CUDA device. * * @param src_buffer A smart pointer to the begin of an allocated CUDA buffer * @param dst_buffer A smart pointer to the end of an allocated CUDA buffer * @param src_offset Offset of the first byte to be written from the address given by 'src_buffer' (in bytes) * @param dst_offset Offset of the first byte to be written to the address given by 'dst_buffer' (in bytes) * @param bytes_to_copy Number of bytes to be copied */ inline void memory_copy(handle_type const & src_buffer, handle_type & dst_buffer, std::size_t src_offset, std::size_t dst_offset, std::size_t bytes_to_copy) { assert( (dst_buffer.get() != NULL) && bool("Memory not initialized!")); assert( (src_buffer.get() != NULL) && bool("Memory not initialized!")); cudaMemcpy(reinterpret_cast<void *>(dst_buffer.get() + dst_offset), reinterpret_cast<void *>(src_buffer.get() + src_offset), bytes_to_copy, cudaMemcpyDeviceToDevice); }
/** @brief Reads data from a buffer back to main RAM. * * @param src_buffer A smart pointer to the beginning of an allocated source buffer * @param src_offset Offset of the first byte to be read from the beginning of src_buffer (in bytes_ * @param bytes_to_copy Number of bytes to be read * @param ptr Location in main RAM where to read data should be written to */ inline void memory_read(handle_type const & src_buffer, vcl_size_t src_offset, vcl_size_t bytes_to_copy, void * ptr, bool /*async*/) { assert( (src_buffer.get() != NULL) && bool("Memory not initialized!")); #ifdef VIENNACL_WITH_OPENMP #pragma omp parallel for #endif for (long i=0; i<long(bytes_to_copy); ++i) static_cast<char *>(ptr)[i] = src_buffer.get()[vcl_size_t(i)+src_offset]; }
/** @brief Writes data from main RAM identified by 'ptr' to the buffer identified by 'dst_buffer' * * @param dst_buffer A smart pointer to the beginning of an allocated buffer * @param dst_offset Offset of the first written byte from the beginning of 'dst_buffer' (in bytes) * @param bytes_to_copy Number of bytes to be copied * @param ptr Pointer to the first byte to be written */ inline void memory_write(handle_type & dst_buffer, vcl_size_t dst_offset, vcl_size_t bytes_to_copy, const void * ptr, bool /*async*/) { assert( (dst_buffer.get() != NULL) && bool("Memory not initialized!")); #ifdef VIENNACL_WITH_OPENMP #pragma omp parallel for #endif for (long i=0; i<long(bytes_to_copy); ++i) dst_buffer.get()[vcl_size_t(i)+dst_offset] = static_cast<const char *>(ptr)[i]; }
/** @brief Copies 'bytes_to_copy' bytes from address 'src_buffer + src_offset' to memory starting at address 'dst_buffer + dst_offset'. * * @param src_buffer A smart pointer to the begin of an allocated buffer * @param dst_buffer A smart pointer to the end of an allocated buffer * @param src_offset Offset of the first byte to be written from the address given by 'src_buffer' (in bytes) * @param dst_offset Offset of the first byte to be written to the address given by 'dst_buffer' (in bytes) * @param bytes_to_copy Number of bytes to be copied */ inline void memory_copy(handle_type const & src_buffer, handle_type & dst_buffer, vcl_size_t src_offset, vcl_size_t dst_offset, vcl_size_t bytes_to_copy) { assert( (dst_buffer.get() != NULL) && bool("Memory not initialized!")); assert( (src_buffer.get() != NULL) && bool("Memory not initialized!")); #ifdef VIENNACL_WITH_OPENMP #pragma omp parallel for #endif for (long i=0; i<long(bytes_to_copy); ++i) dst_buffer.get()[vcl_size_t(i)+dst_offset] = src_buffer.get()[vcl_size_t(i) + src_offset]; }
/** @brief Reads data from a CUDA buffer back to main RAM. * * @param src_buffer A smart pointer to the beginning of an allocated CUDA source buffer * @param src_offset Offset of the first byte to be read from the beginning of src_buffer (in bytes_ * @param bytes_to_copy Number of bytes to be read * @param ptr Location in main RAM where to read data should be written to */ inline void memory_read(handle_type const & src_buffer, std::size_t src_offset, std::size_t bytes_to_copy, void * ptr, bool async = false) { assert( (src_buffer.get() != NULL) && bool("Memory not initialized!")); if (async) cudaMemcpyAsync(reinterpret_cast<char *>(ptr), reinterpret_cast<char *>(src_buffer.get()) + src_offset, bytes_to_copy, cudaMemcpyDeviceToHost); else cudaMemcpy(reinterpret_cast<char *>(ptr), reinterpret_cast<char *>(src_buffer.get()) + src_offset, bytes_to_copy, cudaMemcpyDeviceToHost); }
/** @brief Writes data from main RAM identified by 'ptr' to the CUDA buffer identified by 'dst_buffer' * * @param dst_buffer A smart pointer to the beginning of an allocated CUDA buffer * @param dst_offset Offset of the first written byte from the beginning of 'dst_buffer' (in bytes) * @param bytes_to_copy Number of bytes to be copied * @param ptr Pointer to the first byte to be written */ inline void memory_write(handle_type & dst_buffer, std::size_t dst_offset, std::size_t bytes_to_copy, const void * ptr, bool async = false) { assert( (dst_buffer.get() != NULL) && bool("Memory not initialized!")); if (async) cudaMemcpyAsync(reinterpret_cast<char *>(dst_buffer.get()) + dst_offset, reinterpret_cast<const char *>(ptr), bytes_to_copy, cudaMemcpyHostToDevice); else cudaMemcpy(reinterpret_cast<char *>(dst_buffer.get()) + dst_offset, reinterpret_cast<const char *>(ptr), bytes_to_copy, cudaMemcpyHostToDevice); }
/** * \brief Play the sound when the mouse is on the item. */ void bear::mouse_over_manager::play_sound( handle_type item ) { if ( m_sample != NULL ) { bool play(true); engine::with_rendering_attributes* a = dynamic_cast<engine::with_rendering_attributes*>( item.get() ); if ( a != NULL ) play = a->get_rendering_attributes().get_opacity() != 0; if ( play ) { audio::sound_effect effect(m_sample->get_effect()); effect.set_position( this->get_center_of_mass() ); m_sample->play(effect); } } } // mouse_over_manager::play_sound()