gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage) { if (size > mMemory.size()) { if (!mMemory.resize(size)) { return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize internal buffer."); } } mSize = size; if (data) { memcpy(mMemory.data(), data, size); } invalidateStaticData(); if (usage == GL_STATIC_DRAW) { initializeStaticData(); } return gl::Error(GL_NO_ERROR); }
// Creates static buffers if sufficient used data has been left unmodified void BufferD3D::promoteStaticUsage(int dataSize) { if (!mStaticVertexBuffer && !mStaticIndexBuffer) { mUnmodifiedDataUse += dataSize; if (mUnmodifiedDataUse > 3 * getSize()) { initializeStaticData(); } } }
gl::Error Buffer11::setData(const void *data, size_t size, GLenum usage) { gl::Error error = setSubData(data, size, 0); if (error.isError()) { return error; } if (usage == GL_STATIC_DRAW) { initializeStaticData(); } return error; }
void BufferD3D::invalidateStaticData() { if ((mStaticVertexBuffer && mStaticVertexBuffer->getBufferSize() != 0) || (mStaticIndexBuffer && mStaticIndexBuffer->getBufferSize() != 0)) { SafeDelete(mStaticVertexBuffer); SafeDelete(mStaticIndexBuffer); // If the buffer was created with a static usage then we recreate the static // buffers so that they are populated the next time we use this buffer. if (mUsage == D3D_BUFFER_USAGE_STATIC) { initializeStaticData(); } } mUnmodifiedDataUse = 0; }
void BufferD3D::invalidateStaticData() { emptyStaticBufferCache(); if (mStaticIndexBuffer && mStaticIndexBuffer->getBufferSize() != 0) { SafeDelete(mStaticIndexBuffer); } // If the buffer was created with a static usage then we recreate the static // buffers so that they are populated the next time we use this buffer. if (mUsage == D3DBufferUsage::STATIC) { initializeStaticData(); } mUnmodifiedDataUse = 0; }
void BufferD3D::updateD3DBufferUsage(GLenum usage) { switch (usage) { case GL_STATIC_DRAW: case GL_STATIC_READ: case GL_STATIC_COPY: mUsage = D3DBufferUsage::STATIC; initializeStaticData(); break; case GL_STREAM_DRAW: case GL_STREAM_READ: case GL_STREAM_COPY: case GL_DYNAMIC_READ: case GL_DYNAMIC_COPY: case GL_DYNAMIC_DRAW: mUsage = D3DBufferUsage::DYNAMIC; break; default: UNREACHABLE(); } }
void BufferD3D::updateD3DBufferUsage(const gl::Context *context, gl::BufferUsage usage) { switch (usage) { case gl::BufferUsage::StaticCopy: case gl::BufferUsage::StaticDraw: case gl::BufferUsage::StaticRead: mUsage = D3DBufferUsage::STATIC; initializeStaticData(context); break; case gl::BufferUsage::DynamicCopy: case gl::BufferUsage::DynamicDraw: case gl::BufferUsage::DynamicRead: case gl::BufferUsage::StreamCopy: case gl::BufferUsage::StreamDraw: case gl::BufferUsage::StreamRead: mUsage = D3DBufferUsage::DYNAMIC; break; default: UNREACHABLE(); } }