blob: 74106efc0f28495043c873a64039dd7641d14275 [file] [log] [blame]
ericrk41a1579e2017-02-10 20:56:281// Copyright (c) 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "gpu/config/gpu_feature_info.h"
6
Zhenyao Mo08c91492017-08-24 22:57:577#include <algorithm>
8
Chris Blume29bf5362019-09-06 02:34:459#include "gpu/config/gpu_blocklist.h"
Zhenyao Mo2eb1fe52018-01-13 05:49:2510#include "gpu/config/gpu_driver_bug_list.h"
Zhenyao Mo08c91492017-08-24 22:57:5711#include "gpu/config/gpu_driver_bug_workaround_type.h"
12#include "ui/gl/gl_context.h"
13
ericrk41a1579e2017-02-10 20:56:2814namespace gpu {
15
16GpuFeatureInfo::GpuFeatureInfo() {
17 for (auto& status : status_values)
18 status = kGpuFeatureStatusUndefined;
19}
20
Zhenyao Mod4dba1052017-07-27 23:02:3921GpuFeatureInfo::GpuFeatureInfo(const GpuFeatureInfo&) = default;
22
23GpuFeatureInfo::GpuFeatureInfo(GpuFeatureInfo&&) = default;
24
Chris Watkins81030772017-12-07 01:20:5625GpuFeatureInfo::~GpuFeatureInfo() = default;
Zhenyao Mod4dba1052017-07-27 23:02:3926
27GpuFeatureInfo& GpuFeatureInfo::operator=(const GpuFeatureInfo&) = default;
28
29GpuFeatureInfo& GpuFeatureInfo::operator=(GpuFeatureInfo&&) = default;
30
Zhenyao Mo08c91492017-08-24 22:57:5731void GpuFeatureInfo::ApplyToGLContext(gl::GLContext* gl_context) const {
32 DCHECK(gl_context);
33 gl::GLWorkarounds gl_workarounds;
34 if (IsWorkaroundEnabled(gpu::CLEAR_TO_ZERO_OR_ONE_BROKEN)) {
35 gl_workarounds.clear_to_zero_or_one_broken = true;
36 }
37 if (IsWorkaroundEnabled(RESET_TEXIMAGE2D_BASE_LEVEL)) {
38 gl_workarounds.reset_teximage2d_base_level = true;
39 }
40 gl_context->SetGLWorkarounds(gl_workarounds);
41 gl_context->SetDisabledGLExtensions(this->disabled_extensions);
42}
43
44bool GpuFeatureInfo::IsWorkaroundEnabled(int32_t workaround) const {
45 return std::find(this->enabled_gpu_driver_bug_workarounds.begin(),
46 this->enabled_gpu_driver_bug_workarounds.end(),
47 workaround) !=
48 this->enabled_gpu_driver_bug_workarounds.end();
49}
50
Zhenyao Mo2eb1fe52018-01-13 05:49:2551bool GpuFeatureInfo::IsInitialized() const {
Zhenyao Mof920e132017-12-19 20:16:5052 // Check if any feature status is undefined.
Sean Gilhuly1e54ddb2019-11-28 18:52:2853 return status_values[GPU_FEATURE_TYPE_ACCELERATED_GL] !=
Zhenyao Mof920e132017-12-19 20:16:5054 kGpuFeatureStatusUndefined;
55}
56
ericrk41a1579e2017-02-10 20:56:2857} // namespace gpu