chromium/gpu/command_buffer/service/service_utils.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/command_buffer/service/service_utils.h"

#include <string>
#include <string_view>

#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/config/gpu_finch_features.h"
#include "skia/buildflags.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/gl_surface_egl.h"

namespace gpu {
namespace gles2 {

namespace {

bool GetUintFromSwitch(const base::CommandLine* command_line,
                       std::string_view switch_string,
                       uint32_t* value) {}

// Parse the value of --use-vulkan from the command line. If unspecified and
// features::kVulkan is enabled (GrContext is going to use vulkan), default to
// the native implementation.
VulkanImplementationName ParseVulkanImplementationName(
    const base::CommandLine* command_line) {}

WebGPUAdapterName ParseWebGPUAdapterName(
    const base::CommandLine* command_line) {}

WebGPUPowerPreference ParseWebGPUPowerPreference(
    const base::CommandLine* command_line) {}

}  // namespace

gl::GLContextAttribs GenerateGLContextAttribsForDecoder(
    const ContextCreationAttribs& attribs_helper,
    const ContextGroup* context_group) {}

gl::GLContextAttribs GenerateGLContextAttribsForCompositor(
    bool use_passthrough_cmd_decoder) {}

bool UsePassthroughCommandDecoder(const base::CommandLine* command_line) {}

bool PassthroughCommandDecoderSupported() {}

GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {}

GrContextType ParseGrContextType(const base::CommandLine* command_line) {}

bool MSAAIsSlow(const GpuDriverBugWorkarounds& workarounds) {}

}  // namespace gles2

#if BUILDFLAG(IS_MAC)
uint32_t GetTextureTargetForIOSurfaces() {
  // On MacOS, the default texture target for native GpuMemoryBuffers is
  // GL_TEXTURE_RECTANGLE_ARB. This is due to CGL's requirements for creating
  // a GL surface. However, when ANGLE is used on top of SwiftShader or Metal,
  // it's necessary to use GL_TEXTURE_2D instead.
  // TODO(crbug.com/40676774): The proper behavior is to check the config
  // parameter set by the EGL_ANGLE_iosurface_client_buffer extension
  if (gl::GetGLImplementation() == gl::kGLImplementationEGLANGLE &&
      (gl::GetANGLEImplementation() == gl::ANGLEImplementation::kSwiftShader ||
       gl::GetANGLEImplementation() == gl::ANGLEImplementation::kMetal)) {
    return GL_TEXTURE_2D;
  }
  return GL_TEXTURE_RECTANGLE_ARB;
}
#endif  // BUILDFLAG(IS_MAC)

}  // namespace gpu