blob: 8d809cef7a439c31d1237b7a0b61b6d1d25ff35b [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
9#include "gpu/config/gpu_driver_bug_workaround_type.h"
10#include "ui/gl/gl_context.h"
11
ericrk41a1579e2017-02-10 20:56:2812namespace gpu {
13
14GpuFeatureInfo::GpuFeatureInfo() {
15 for (auto& status : status_values)
16 status = kGpuFeatureStatusUndefined;
17}
18
Zhenyao Mod4dba1052017-07-27 23:02:3919GpuFeatureInfo::GpuFeatureInfo(const GpuFeatureInfo&) = default;
20
21GpuFeatureInfo::GpuFeatureInfo(GpuFeatureInfo&&) = default;
22
Chris Watkins81030772017-12-07 01:20:5623GpuFeatureInfo::~GpuFeatureInfo() = default;
Zhenyao Mod4dba1052017-07-27 23:02:3924
25GpuFeatureInfo& GpuFeatureInfo::operator=(const GpuFeatureInfo&) = default;
26
27GpuFeatureInfo& GpuFeatureInfo::operator=(GpuFeatureInfo&&) = default;
28
Zhenyao Mo08c91492017-08-24 22:57:5729void GpuFeatureInfo::ApplyToGLContext(gl::GLContext* gl_context) const {
30 DCHECK(gl_context);
31 gl::GLWorkarounds gl_workarounds;
32 if (IsWorkaroundEnabled(gpu::CLEAR_TO_ZERO_OR_ONE_BROKEN)) {
33 gl_workarounds.clear_to_zero_or_one_broken = true;
34 }
35 if (IsWorkaroundEnabled(RESET_TEXIMAGE2D_BASE_LEVEL)) {
36 gl_workarounds.reset_teximage2d_base_level = true;
37 }
38 gl_context->SetGLWorkarounds(gl_workarounds);
39 gl_context->SetDisabledGLExtensions(this->disabled_extensions);
40}
41
42bool GpuFeatureInfo::IsWorkaroundEnabled(int32_t workaround) const {
43 return std::find(this->enabled_gpu_driver_bug_workarounds.begin(),
44 this->enabled_gpu_driver_bug_workarounds.end(),
45 workaround) !=
46 this->enabled_gpu_driver_bug_workarounds.end();
47}
48
Zhenyao Mof920e132017-12-19 20:16:5049bool GpuFeatureInfo::IsValid() const {
50 // Check if any feature status is undefined.
51 return status_values[GPU_FEATURE_TYPE_GPU_COMPOSITING] !=
52 kGpuFeatureStatusUndefined;
53}
54
ericrk41a1579e2017-02-10 20:56:2855} // namespace gpu