Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:zhmars:arch
chromium122
0001-231006-Refactor-TexturePassthrough-LevelIn...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-231006-Refactor-TexturePassthrough-LevelInfo.patch of Package chromium122
Index: chromium_vaapi/gpu/command_buffer/service/abstract_texture_android.cc =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/abstract_texture_android.cc +++ chromium_vaapi/gpu/command_buffer/service/abstract_texture_android.cc @@ -44,9 +44,10 @@ std::unique_ptr<AbstractTextureAndroid> AbstractTextureAndroid::CreateForPassthrough(gfx::Size size) { GLuint service_id = CreateTextureWithLinearFilter(); auto texture = base::MakeRefCounted<gles2::TexturePassthrough>( - service_id, GL_TEXTURE_EXTERNAL_OES); + service_id, GL_TEXTURE_EXTERNAL_OES, GL_RGBA, size.width(), size.height(), + 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); - return std::make_unique<AbstractTextureAndroid>(std::move(texture), size); + return std::make_unique<AbstractTextureAndroid>(std::move(texture)); } std::unique_ptr<AbstractTextureAndroid> @@ -61,14 +62,9 @@ AbstractTextureAndroid::AbstractTextureA AbstractTextureAndroid::AbstractTextureAndroid(gles2::Texture* texture) : texture_(texture), api_(gl::g_current_gl_context) {} AbstractTextureAndroid::AbstractTextureAndroid( - scoped_refptr<gles2::TexturePassthrough> texture, - const gfx::Size& size) + scoped_refptr<gles2::TexturePassthrough> texture) : texture_passthrough_(std::move(texture)), - texture_passthrough_size_(size), - api_(gl::g_current_gl_context) { - DCHECK(texture_passthrough_ && - texture_passthrough_->target() == GL_TEXTURE_EXTERNAL_OES); -} + api_(gl::g_current_gl_context) {} AbstractTextureAndroid::~AbstractTextureAndroid() { // If context is not lost, then the texture should be destroyed on same @@ -95,21 +91,6 @@ void AbstractTextureAndroid::BindToServi texture_->SetLevelCleared(texture_->target(), /*level=*/0, true); } else if (texture_passthrough_) { texture_passthrough_->BindToServiceId(service_id); - - if (gl::g_current_gl_driver->ext.b_GL_ANGLE_texture_external_update) { - // Notify the texture that its size has changed. - unsigned int target = texture_passthrough_->target(); - GLint prev_texture = 0; - glGetIntegerv(gles2::GetTextureBindingQuery(target), &prev_texture); - glBindTexture(target, texture_passthrough_->service_id()); - - glTexImage2DExternalANGLE( - target, /*level=*/0, /*internalformat=*/GL_RGBA, - texture_passthrough_size_.width(), texture_passthrough_size_.height(), - /*border=*/0, /*format=*/GL_RGBA, /*type=*/GL_UNSIGNED_BYTE); - - glBindTexture(target, prev_texture); - } } } Index: chromium_vaapi/gpu/command_buffer/service/abstract_texture_android.h =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/abstract_texture_android.h +++ chromium_vaapi/gpu/command_buffer/service/abstract_texture_android.h @@ -44,8 +44,7 @@ class GPU_GLES2_EXPORT AbstractTextureAn explicit AbstractTextureAndroid(std::unique_ptr<TextureBase> texture); explicit AbstractTextureAndroid(gles2::Texture* texture); explicit AbstractTextureAndroid( - scoped_refptr<gles2::TexturePassthrough> texture, - const gfx::Size& size); + scoped_refptr<gles2::TexturePassthrough> texture); // The texture is guaranteed to be around while |this| exists, as long as // the decoder isn't destroyed / context isn't lost. @@ -74,7 +73,6 @@ class GPU_GLES2_EXPORT AbstractTextureAn std::unique_ptr<TextureBase> texture_for_testing_; raw_ptr<gles2::Texture> texture_ = nullptr; scoped_refptr<gles2::TexturePassthrough> texture_passthrough_; - gfx::Size texture_passthrough_size_; raw_ptr<gl::GLApi, DanglingUntriaged> api_ = nullptr; }; Index: chromium_vaapi/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc +++ chromium_vaapi/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc @@ -1643,7 +1643,8 @@ GLES2DecoderPassthroughImpl::CreateAbstr GLuint service_id = 0; api()->glGenTexturesFn(1, &service_id); scoped_refptr<TexturePassthrough> texture( - new TexturePassthrough(service_id, target)); + new TexturePassthrough(service_id, target, internal_format, width, height, + depth, border, format, type)); // Unretained is safe, because of the destruction cb. std::unique_ptr<PassthroughAbstractTextureImpl> abstract_texture = Index: chromium_vaapi/gpu/command_buffer/service/shared_image/egl_image_backing.cc =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/shared_image/egl_image_backing.cc +++ chromium_vaapi/gpu/command_buffer/service/shared_image/egl_image_backing.cc @@ -494,8 +494,11 @@ EGLImageBacking::GenEGLImageSibling(base if (use_passthrough_) { auto texture_passthrough = - base::MakeRefCounted<gpu::gles2::TexturePassthrough>(service_id, - GL_TEXTURE_2D); + base::MakeRefCounted<gpu::gles2::TexturePassthrough>( + service_id, GL_TEXTURE_2D, format_info_.gl_format, size().width(), + size().height(), + /*depth=*/1, /*border=*/0, format_info_.gl_format, + format_info_.gl_type); return base::MakeRefCounted<TextureHolder>(std::move(texture_passthrough)); } Index: chromium_vaapi/gpu/command_buffer/service/shared_image/external_vk_image_backing.cc =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/shared_image/external_vk_image_backing.cc +++ chromium_vaapi/gpu/command_buffer/service/shared_image/external_vk_image_backing.cc @@ -838,7 +838,10 @@ bool ExternalVkImageBacking::CreateGLTex if (is_passthrough) { auto texture = base::MakeRefCounted<gpu::gles2::TexturePassthrough>( - texture_service_id, GL_TEXTURE_2D); + texture_service_id, GL_TEXTURE_2D, format_desc.storage_internal_format, + plane_size.width(), plane_size.height(), + /*depth=*/1, /*border=*/0, format_desc.data_format, + format_desc.data_type); gl_texture.InitializeWithTexture(format_desc, std::move(texture)); } else { auto* texture = gles2::CreateGLES2TextureWithLightRef(texture_service_id, Index: chromium_vaapi/gpu/command_buffer/service/shared_image/gl_ozone_image_representation.cc =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/shared_image/gl_ozone_image_representation.cc +++ chromium_vaapi/gpu/command_buffer/service/shared_image/gl_ozone_image_representation.cc @@ -290,9 +290,16 @@ GLOzoneImageRepresentationShared::Create return nullptr; } + // TODO(crbug.com/1468989): Make sure these match with corresponding formats + // from ToGLFormatDesc{ExternalSampler}. + GLuint internal_format = np_gl_binding->GetInternalFormat(); + GLenum gl_format = GetDataFormatFromInternalFormat(internal_format); + GLenum gl_type = np_gl_binding->GetDataType(); scoped_refptr<gles2::TexturePassthrough> texture_passthrough = base::MakeRefCounted<gpu::gles2::TexturePassthrough>( - gl_texture_service_id, target); + gl_texture_service_id, target, internal_format, + backing->size().width(), backing->size().height(), + /*depth=*/1, /*border=*/0, gl_format, gl_type); return base::MakeRefCounted<TextureHolder>(std::move(np_gl_binding), std::move(texture_passthrough)); Index: chromium_vaapi/gpu/command_buffer/service/texture_manager.cc =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/texture_manager.cc +++ chromium_vaapi/gpu/command_buffer/service/texture_manager.cc @@ -500,13 +500,41 @@ void TextureManager::Destroy() { DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); } +TexturePassthrough::LevelInfo::LevelInfo() = default; + +TexturePassthrough::LevelInfo::LevelInfo(const LevelInfo& rhs) = default; + +TexturePassthrough::LevelInfo::~LevelInfo() = default; + TexturePassthrough::TexturePassthrough(GLuint service_id, GLenum target) : TextureBase(service_id), owned_service_id_(service_id), - have_context_(true) { + have_context_(true), + level_images_(target == GL_TEXTURE_CUBE_MAP ? 6 : 1) { TextureBase::SetTarget(target); } +TexturePassthrough::TexturePassthrough(GLuint service_id, + GLenum target, + GLenum internal_format, + GLsizei width, + GLsizei height, + GLsizei depth, + GLint border, + GLenum format, + GLenum type) + : TexturePassthrough(service_id, target) { + DCHECK(target != GL_TEXTURE_CUBE_MAP); + LevelInfo* level_info = GetLevelInfo(target, 0); + level_info->internal_format = internal_format; + level_info->width = width; + level_info->height = height; + level_info->depth = depth; + level_info->border = border; + level_info->format = format; + level_info->type = type; +} + TexturePassthrough::~TexturePassthrough() { DeleteFromMailboxManager(); if (have_context_) { @@ -537,6 +565,21 @@ void TexturePassthrough::BindToServiceId if (service_id != 0 && service_id != service_id_) { service_id_ = service_id; } + + if (gl::g_current_gl_driver->ext.b_GL_ANGLE_texture_external_update) { + // Notify the texture that its size has changed. + LevelInfo* level_0_info = GetLevelInfo(target_, 0); + GLint prev_texture = 0; + glGetIntegerv(GetTextureBindingQuery(target_), &prev_texture); + glBindTexture(target_, service_id_); + + glTexImage2DExternalANGLE( + target_, /*level=*/0, level_0_info->internal_format, + level_0_info->width, level_0_info->height, level_0_info->border, + level_0_info->format, level_0_info->type); + + glBindTexture(target_, prev_texture); + } } #endif @@ -544,6 +587,41 @@ void TexturePassthrough::SetEstimatedSiz estimated_size_ = size; } +bool TexturePassthrough::LevelInfoExists(GLenum target, + GLint level, + size_t* out_face_idx) const { + DCHECK(out_face_idx); + + if (GLES2Util::GLFaceTargetToTextureTarget(target) != target_) { + return false; + } + + size_t face_idx = GLES2Util::GLTargetToFaceIndex(target); + DCHECK(face_idx < level_images_.size()); + DCHECK(level >= 0); + + if (static_cast<GLint>(level_images_[face_idx].size()) <= level) { + return false; + } + + *out_face_idx = face_idx; + return true; +} + +TexturePassthrough::LevelInfo* TexturePassthrough::GetLevelInfo(GLenum target, + GLint level) { + size_t face_idx = GLES2Util::GLTargetToFaceIndex(target); + DCHECK(face_idx < level_images_.size()); + DCHECK(level >= 0); + + // Don't allocate space for the images until needed + if (static_cast<GLint>(level_images_[face_idx].size()) <= level) { + level_images_[face_idx].resize(level + 1); + } + + return &level_images_[face_idx][level]; +} + Texture::Texture(GLuint service_id) : TextureBase(service_id), owned_service_id_(service_id) {} Index: chromium_vaapi/gpu/command_buffer/service/texture_manager.h =================================================================== --- chromium_vaapi.orig/gpu/command_buffer/service/texture_manager.h +++ chromium_vaapi/gpu/command_buffer/service/texture_manager.h @@ -56,6 +56,15 @@ class GPU_GLES2_EXPORT TexturePassthroug public base::SupportsWeakPtr<TexturePassthrough> { public: TexturePassthrough(GLuint service_id, GLenum target); + TexturePassthrough(GLuint service_id, + GLenum target, + GLenum internal_format, + GLsizei width, + GLsizei height, + GLsizei depth, + GLint border, + GLenum format, + GLenum type); TexturePassthrough(const TexturePassthrough&) = delete; TexturePassthrough& operator=(const TexturePassthrough&) = delete; @@ -80,6 +89,8 @@ class GPU_GLES2_EXPORT TexturePassthroug ~TexturePassthrough() override; private: + bool LevelInfoExists(GLenum target, GLint level, size_t* out_face_idx) const; + friend class base::RefCounted<TexturePassthrough>; const GLuint owned_service_id_ = 0; @@ -87,6 +98,25 @@ class GPU_GLES2_EXPORT TexturePassthroug bool have_context_; size_t estimated_size_ = 0; + + // Bound images divided into faces and then levels + struct LevelInfo { + LevelInfo(); + LevelInfo(const LevelInfo& rhs); + ~LevelInfo(); + + GLenum internal_format = 0; + GLsizei width = 0; + GLsizei height = 0; + GLsizei depth = 0; + GLint border = 0; + GLenum format = 0; + GLenum type = 0; + }; + + LevelInfo* GetLevelInfo(GLenum target, GLint level); + + std::vector<std::vector<LevelInfo>> level_images_; }; // Info about Textures currently in the system.
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor