ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 1 | // 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 Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 7 | #include <algorithm> |
| 8 | |
Chris Blume | 29bf536 | 2019-09-06 02:34:45 | [diff] [blame] | 9 | #include "gpu/config/gpu_blocklist.h" |
Zhenyao Mo | 2eb1fe5 | 2018-01-13 05:49:25 | [diff] [blame] | 10 | #include "gpu/config/gpu_driver_bug_list.h" |
Zhenyao Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 11 | #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 12 | #include "ui/gl/gl_context.h" |
| 13 | |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 14 | namespace gpu { |
| 15 | |
| 16 | GpuFeatureInfo::GpuFeatureInfo() { |
| 17 | for (auto& status : status_values) |
| 18 | status = kGpuFeatureStatusUndefined; |
| 19 | } |
| 20 | |
Zhenyao Mo | d4dba105 | 2017-07-27 23:02:39 | [diff] [blame] | 21 | GpuFeatureInfo::GpuFeatureInfo(const GpuFeatureInfo&) = default; |
| 22 | |
| 23 | GpuFeatureInfo::GpuFeatureInfo(GpuFeatureInfo&&) = default; |
| 24 | |
Chris Watkins | 8103077 | 2017-12-07 01:20:56 | [diff] [blame] | 25 | GpuFeatureInfo::~GpuFeatureInfo() = default; |
Zhenyao Mo | d4dba105 | 2017-07-27 23:02:39 | [diff] [blame] | 26 | |
| 27 | GpuFeatureInfo& GpuFeatureInfo::operator=(const GpuFeatureInfo&) = default; |
| 28 | |
| 29 | GpuFeatureInfo& GpuFeatureInfo::operator=(GpuFeatureInfo&&) = default; |
| 30 | |
Zhenyao Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 31 | void 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 | |
| 44 | bool 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 Mo | 2eb1fe5 | 2018-01-13 05:49:25 | [diff] [blame] | 51 | bool GpuFeatureInfo::IsInitialized() const { |
Zhenyao Mo | f920e13 | 2017-12-19 20:16:50 | [diff] [blame] | 52 | // Check if any feature status is undefined. |
Sean Gilhuly | 1e54ddb | 2019-11-28 18:52:28 | [diff] [blame] | 53 | return status_values[GPU_FEATURE_TYPE_ACCELERATED_GL] != |
Zhenyao Mo | f920e13 | 2017-12-19 20:16:50 | [diff] [blame] | 54 | kGpuFeatureStatusUndefined; |
| 55 | } |
| 56 | |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 57 | } // namespace gpu |