bool Image11::redefine(RendererD3D *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) { if (mWidth != width || mHeight != height || mInternalFormat != internalformat || forceRelease) { // End the association with the TextureStorage, since that data will be out of date. // Also reset mRecoveredFromStorageCount since this Image is getting completely redefined. disassociateStorage(); mRecoveredFromStorageCount = 0; mRenderer = Renderer11::makeRenderer11(renderer); mWidth = width; mHeight = height; mDepth = depth; mInternalFormat = internalformat; mTarget = target; // compute the d3d format that will be used const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat); const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(formatInfo.texFormat); mDXGIFormat = formatInfo.texFormat; mActualFormat = dxgiFormatInfo.internalFormat; mRenderable = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN); releaseStagingTexture(); mDirty = (formatInfo.dataInitializerFunction != NULL); return true; } return false; }
bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) { if (mWidth != size.width || mHeight != size.height || mInternalFormat != internalformat || forceRelease) { // End the association with the TextureStorage, since that data will be out of date. // Also reset mRecoveredFromStorageCount since this Image is getting completely redefined. disassociateStorage(); mRecoveredFromStorageCount = 0; mWidth = size.width; mHeight = size.height; mDepth = size.depth; mInternalFormat = internalformat; mTarget = target; // compute the d3d format that will be used const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps()); mDXGIFormat = formatInfo.formatSet->texFormat; mRenderable = (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN); releaseStagingTexture(); mDirty = (formatInfo.dataInitializerFunction != NULL); return true; } return false; }
gl::Error Image11::recoverFromAssociatedStorage() { if (mRecoverFromStorage) { gl::Error error = createStagingTexture(); if (error.isError()) { return error; } bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this); // This means that the cached TextureStorage has been modified after this Image11 released its copy of its data. // This should not have happened. The TextureStorage should have told this Image11 to recover its data before it was overwritten. ASSERT(textureStorageCorrect); if (textureStorageCorrect) { // CopySubResource from the Storage to the Staging texture gl::Box region(0, 0, 0, mWidth, mHeight, mDepth); error = mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region); if (error.isError()) { return error; } mRecoveredFromStorageCount += 1; } // Reset all the recovery parameters, even if the texture storage association is broken. disassociateStorage(); } return gl::Error(GL_NO_ERROR); }
gl::Error Image11::recoverFromAssociatedStorage(const gl::Context *context) { if (mRecoverFromStorage) { ANGLE_TRY(createStagingTexture()); mAssociatedStorage->verifyAssociatedImageValid(mAssociatedImageIndex, this); // CopySubResource from the Storage to the Staging texture gl::Box region(0, 0, 0, mWidth, mHeight, mDepth); ANGLE_TRY(mAssociatedStorage->copySubresourceLevel( context, mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region)); mRecoveredFromStorageCount += 1; // Reset all the recovery parameters, even if the texture storage association is broken. disassociateStorage(); } return gl::NoError(); }
Image11::~Image11() { disassociateStorage(); releaseStagingTexture(); }