Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: gpu/command_buffer/common/activity_flags.h

Issue 2744363002: Clear shader disk cache after glProgramBinary failure. (Closed)
Patch Set: Remove singleton and clean up init Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/common/DEPS ('k') | gpu/command_buffer/common/activity_flags.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #ifndef GPU_COMMAND_BUFFER_COMMON_ACTIVITY_FLAGS_H_
6 #define GPU_COMMAND_BUFFER_COMMON_ACTIVITY_FLAGS_H_
7
8 #include "base/atomicops.h"
9 #include "gpu/gpu_export.h"
10 #include "mojo/public/cpp/system/buffer.h"
11
12 namespace gpu {
13
14 // Base class for GpuProcessActivityFlags and GpuProcessHostActivityFlags,
15 // can not be used directly.
16 class GPU_EXPORT ActivityFlagsBase {
17 public:
18 enum Flag : uint32_t { FLAG_LOADING_PROGRAM_BINARY = 0x1 };
19
20 protected:
21 ActivityFlagsBase();
22 ActivityFlagsBase(ActivityFlagsBase&& other);
23 ~ActivityFlagsBase();
24
25 void Initialize(mojo::ScopedSharedBufferHandle handle);
26 const mojo::SharedBufferHandle& handle() const { return handle_.get(); }
27 bool is_initialized() const { return handle().is_valid(); }
28
29 protected:
30 volatile base::subtle::Atomic32* AsAtomic();
31
32 private:
33 mojo::ScopedSharedBufferHandle handle_;
34 mojo::ScopedSharedBufferMapping mapping_;
35 };
36
37 // Provides write-only access to activity flags for the gpu process. Each gpu
38 // process has a singleton GpuProcessActivityFlags retreived via GetInstance().
39 //
40 // Note that we currently assume that the GPU process never sets/unsets flags
41 // from multiple threads at the same time. This is true with our current
42 // single-flag approach, but may need adjustment if additional flags are added.
43 class GPU_EXPORT GpuProcessActivityFlags : public ActivityFlagsBase {
44 public:
45 class ScopedSetFlag {
46 public:
47 ScopedSetFlag(GpuProcessActivityFlags* activity_flags, Flag flag)
48 : activity_flags_(activity_flags), flag_(flag) {
49 activity_flags_->SetFlag(flag_);
50 }
51 ~ScopedSetFlag() { activity_flags_->UnsetFlag(flag_); }
52
53 private:
54 GpuProcessActivityFlags* activity_flags_;
55 Flag flag_;
56 };
57
58 GpuProcessActivityFlags();
59 GpuProcessActivityFlags(GpuProcessActivityFlags&& other);
60 GpuProcessActivityFlags(mojo::ScopedSharedBufferHandle handle);
61
62 private:
63 void SetFlag(Flag flag);
64 void UnsetFlag(Flag flag);
65 };
66
67 // Provides read-only access to activity flags. Creating a new
68 // GpuProcessHostActivityFlags will initialize a new mojo shared buffer. The
69 // handle to this buffer should be passed to the GPU process via CloneHandle.
70 // The GPU process will then populate flags, which can be read via this class.
71 class GPU_EXPORT GpuProcessHostActivityFlags : public ActivityFlagsBase {
72 public:
73 GpuProcessHostActivityFlags();
74
75 bool IsFlagSet(Flag flag);
76 mojo::ScopedSharedBufferHandle CloneHandle() { return handle().Clone(); }
77 };
78
79 } // namespace gpu
80
81 #endif // GPU_COMMAND_BUFFER_COMMON_ACTIVITY_FLAGS_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/DEPS ('k') | gpu/command_buffer/common/activity_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698