/** * @glsymbols * @glfunref{FlushMappedNamedBufferRange} * * @pre Mapped() * * @throws Error */ void FlushRange(BufferSize offset, BufferSize length) { OGLPLUS_GLFUNC(FlushMappedNamedBufferRange)( _name, GLintptr(offset.Get()), GLsizeiptr(length.Get()) ); OGLPLUS_CHECK( FlushMappedNamedBufferRange, ObjectError, Object(BufferName(_name)) ); }
/** * @param buffer use the specified buffer * @param offset map offset in units of Type * @param size map size in units of Type * @param access the access specifier for the buffer mapping * * @throws Error */ DSABufferRawMapEXT( BufferName buffer, BufferSize offset, BufferSize size, Bitfield<BufferMapAccess> access ): _offset(GLintptr(offset.Get())) , _size(GLsizeiptr(size.Get())) , _ptr( OGLPLUS_GLFUNC(MapNamedBufferRangeEXT)( GetGLName(buffer), _offset, _size, GLbitfield(access) ) ), _buf_name(GetGLName(buffer)) { OGLPLUS_CHECK( MapNamedBufferRangeEXT, ObjectError, Object(buffer) ); }
/** * @see Data * @see SubData * @throws Error * * @glvoereq{3,1,ARB,copy_buffer} */ static void CopySubData( BufferName readbuffer, BufferName writebuffer, BufferSize readoffset, BufferSize writeoffset, BufferSize size ) { OGLPLUS_GLFUNC(CopyNamedBufferSubData)( GetGLName(readbuffer), GetGLName(writebuffer), GLintptr(readoffset.Get()), GLintptr(writeoffset.Get()), GLsizeiptr(size.Get()) ); OGLPLUS_CHECK( CopyNamedBufferSubData, ObjectPairError, Subject(readbuffer). Object(writebuffer) ); }
void ClearSubData( PixelDataInternalFormat internal_format, BufferSize offset, BufferSize size, PixelDataFormat format, const GLtype* data ) const { OGLPLUS_GLFUNC(ClearNamedBufferSubData)( _name, GLenum(internal_format), GLintptr(offset.Get()), GLsizeiptr(size.Get()), GLenum(format), GLenum(GetDataType<GLtype>()), data ); OGLPLUS_CHECK( ClearNamedBufferSubData, ObjectError, Object(*this). EnumParam(internal_format) ); }
/** * @see Data * @see CopySubData * @throws Error */ void SubData( BufferSize offset, const BufferData& data ) const { OGLPLUS_GLFUNC(NamedBufferSubData)( _name, GLintptr(offset.Get()), GLsizei(data.Size()), data.Data() ); OGLPLUS_CHECK( NamedBufferSubData, ObjectError, Object(*this) ); }
/** This member function allows to (re-)allocate the buffer storage * to the specifies @p size, without uploading any data. * * @glsymbols * @glfunref{NamedBufferData} * * @see SubData * @throws Error */ void Resize( BufferSize size, BufferUsage usage = BufferUsage::StaticDraw ) { OGLPLUS_GLFUNC(NamedBufferData)( _name, size.Get(), nullptr, GLenum(usage) ); OGLPLUS_CHECK( NamedBufferData, ObjectError, Object(*this). EnumParam(usage) ); }
bool zen::filesHaveSameContent(const Zstring& filepath1, const Zstring& filepath2, const std::function<void(std::int64_t bytesDelta)>& onUpdateStatus) { static boost::thread_specific_ptr<std::vector<char>> cpyBuf1; static boost::thread_specific_ptr<std::vector<char>> cpyBuf2; if (!cpyBuf1.get()) cpyBuf1.reset(new std::vector<char>()); if (!cpyBuf2.get()) cpyBuf2.reset(new std::vector<char>()); std::vector<char>& memory1 = *cpyBuf1; std::vector<char>& memory2 = *cpyBuf2; FileInput file1(filepath1); //throw FileError FileInput file2(filepath2); // BufferSize bufferSize; TickVal lastDelayViolation = getTicks(); do { setMinSize(memory1, bufferSize); setMinSize(memory2, bufferSize); const TickVal startTime = getTicks(); const size_t length1 = file1.read(&memory1[0], bufferSize); //throw FileError const size_t length2 = file2.read(&memory2[0], bufferSize); //returns actual number of bytes read //send progress updates immediately after reading to reliably allow speed calculations for our clients! if (onUpdateStatus) onUpdateStatus(std::max(length1, length2)); if (length1 != length2 || ::memcmp(&memory1[0], &memory2[0], length1) != 0) return false; //-------- dynamically set buffer size to keep callback interval between 100 - 500ms --------------------- if (TICKS_PER_SEC > 0) { const TickVal now = getTicks(); const std::int64_t loopTime = dist(startTime, now) * 1000 / TICKS_PER_SEC; //unit: [ms] if (loopTime < 100) { if (dist(lastDelayViolation, now) / TICKS_PER_SEC > 2) //avoid "flipping back": e.g. DVD-Roms read 32MB at once, so first read may be > 500 ms, but second one will be 0ms! { lastDelayViolation = now; bufferSize.inc(); } } else if (loopTime > 500) { lastDelayViolation = now; bufferSize.dec(); } } //------------------------------------------------------------------------------------------------ } while (!file1.eof()); if (!file2.eof()) //highly unlikely, but possible! (but then again, not in this context where both files have same size...) return false; return true; }