gl::Error BufferGL::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) { BufferGL *sourceGL = GetAs<BufferGL>(source); mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID); mStateManager->bindBuffer(SourceBufferOperationTarget, sourceGL->getBufferID()); mFunctions->copyBufferSubData(SourceBufferOperationTarget, DestBufferOperationTarget, sourceOffset, destOffset, size); return gl::Error(GL_NO_ERROR); }
gl::Error BufferGL::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) { BufferGL *sourceGL = GetAs<BufferGL>(source); mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID); mStateManager->bindBuffer(SourceBufferOperationTarget, sourceGL->getBufferID()); mFunctions->copyBufferSubData(SourceBufferOperationTarget, DestBufferOperationTarget, sourceOffset, destOffset, size); if (mShadowBufferData && size > 0) { ASSERT(sourceGL->mShadowBufferData); memcpy(mShadowCopy.data() + destOffset, sourceGL->mShadowCopy.data() + sourceOffset, size); } return gl::Error(GL_NO_ERROR); }
gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data) { const gl::State &state = *data.state; // If the context has changed, pause the previous context's transform feedback and queries if (data.context != mPrevDrawContext) { if (mPrevDrawTransformFeedback != nullptr) { mPrevDrawTransformFeedback->syncPausedState(true); } for (QueryGL *prevQuery : mPrevDrawQueries) { prevQuery->pause(); } } mPrevDrawTransformFeedback = nullptr; mPrevDrawQueries.clear(); mPrevDrawContext = data.context; // Sync the current program state const gl::Program *program = state.getProgram(); const ProgramGL *programGL = GetImplAs<ProgramGL>(program); useProgram(programGL->getProgramID()); for (size_t uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++) { GLuint binding = program->getUniformBlockBinding(static_cast<GLuint>(uniformBlockIndex)); const OffsetBindingPointer<gl::Buffer> &uniformBuffer = data.state->getIndexedUniformBuffer(binding); if (uniformBuffer.get() != nullptr) { BufferGL *bufferGL = GetImplAs<BufferGL>(uniformBuffer.get()); if (uniformBuffer.getSize() == 0) { bindBufferBase(GL_UNIFORM_BUFFER, binding, bufferGL->getBufferID()); } else { bindBufferRange(GL_UNIFORM_BUFFER, binding, bufferGL->getBufferID(), uniformBuffer.getOffset(), uniformBuffer.getSize()); } } } const std::vector<SamplerBindingGL> &appliedSamplerUniforms = programGL->getAppliedSamplerUniforms(); for (const SamplerBindingGL &samplerUniform : appliedSamplerUniforms) { GLenum textureType = samplerUniform.textureType; for (GLuint textureUnitIndex : samplerUniform.boundTextureUnits) { const gl::Texture *texture = state.getSamplerTexture(textureUnitIndex, textureType); if (texture != nullptr) { const TextureGL *textureGL = GetImplAs<TextureGL>(texture); if (mTextures[textureType][textureUnitIndex] != textureGL->getTextureID()) { activeTexture(textureUnitIndex); bindTexture(textureType, textureGL->getTextureID()); } textureGL->syncState(textureUnitIndex, texture->getTextureState()); } else { if (mTextures[textureType][textureUnitIndex] != 0) { activeTexture(textureUnitIndex); bindTexture(textureType, 0); } } const gl::Sampler *sampler = state.getSampler(textureUnitIndex); if (sampler != nullptr) { const SamplerGL *samplerGL = GetImplAs<SamplerGL>(sampler); samplerGL->syncState(sampler->getSamplerState()); bindSampler(textureUnitIndex, samplerGL->getSamplerID()); } else { bindSampler(textureUnitIndex, 0); } } } const gl::Framebuffer *framebuffer = state.getDrawFramebuffer(); const FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer); bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferGL->getFramebufferID()); framebufferGL->syncDrawState(); // Seamless cubemaps are required for ES3 and higher contexts. setTextureCubemapSeamlessEnabled(data.clientVersion >= 3); // Set the current transform feedback state gl::TransformFeedback *transformFeedback = state.getCurrentTransformFeedback(); if (transformFeedback) { TransformFeedbackGL *transformFeedbackGL = GetImplAs<TransformFeedbackGL>(transformFeedback); bindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedbackGL->getTransformFeedbackID()); transformFeedbackGL->syncActiveState(transformFeedback->isActive(), transformFeedback->getPrimitiveMode()); transformFeedbackGL->syncPausedState(transformFeedback->isPaused()); mPrevDrawTransformFeedback = transformFeedbackGL; } else { bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); mPrevDrawTransformFeedback = nullptr; } // Set the current query state for (GLenum queryType : QueryTypes) { gl::Query *query = state.getActiveQuery(queryType); if (query != nullptr) { QueryGL *queryGL = GetImplAs<QueryGL>(query); queryGL->resume(); mPrevDrawQueries.insert(queryGL); } } return gl::Error(GL_NO_ERROR); }