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

Side by Side Diff: gpu/command_buffer/service/sampler_manager.h

Issue 1498033003: Implement SamplerManager in the command buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed problem zmo@ pointed out Created 5 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2015 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_SERVICE_SAMPLER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_
7
8 #include <vector>
9 #include "base/basictypes.h"
10 #include "base/containers/hash_tables.h"
11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "gpu/command_buffer/service/feature_info.h"
15 #include "gpu/command_buffer/service/gl_utils.h"
16 #include "gpu/gpu_export.h"
17
18 namespace gpu {
19
20 namespace gles2 {
21
22 class SamplerManager;
23
24 class GPU_EXPORT Sampler : public base::RefCounted<Sampler> {
25 public:
26 Sampler(SamplerManager* manager, GLuint service_id);
27
28 // The service side OpenGL id of the texture.
29 GLuint service_id() const {
30 return service_id_;
31 }
32
33 // Sampler parameters
34 GLenum min_filter() const {
35 return min_filter_;
36 }
37
38 GLenum mag_filter() const {
39 return mag_filter_;
40 }
41
42 GLenum wrap_r() const {
43 return wrap_r_;
44 }
45
46 GLenum wrap_s() const {
47 return wrap_s_;
48 }
49
50 GLenum wrap_t() const {
51 return wrap_t_;
52 }
53
54 GLenum compare_func() const {
55 return compare_func_;
56 }
57
58 GLenum compare_mode() const {
59 return compare_mode_;
60 }
61
62 GLfloat max_lod() const {
63 return max_lod_;
64 }
65
66 GLfloat min_lod() const {
67 return min_lod_;
68 }
69
70 bool IsDeleted() const {
71 return deleted_;
72 }
73
74 protected:
75 virtual ~Sampler();
76
77 SamplerManager* manager() const {
78 return manager_;
79 }
80
81 void MarkAsDeleted() {
82 deleted_ = true;
83 }
84
85 private:
86 friend class SamplerManager;
87 friend class base::RefCounted<Sampler>;
88
89 // Sets a sampler parameter.
90 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
91 GLenum SetParameteri(
92 const FeatureInfo* feature_info, GLenum pname, GLint param);
93 GLenum SetParameterf(
94 const FeatureInfo* feature_info, GLenum pname, GLfloat param);
95
96 // The manager that owns this Sampler.
97 SamplerManager* manager_;
98
99 // The id of the texure
100 GLuint service_id_;
101
102 // Texture parameters.
103 GLenum min_filter_;
104 GLenum mag_filter_;
105 GLenum wrap_r_;
106 GLenum wrap_s_;
107 GLenum wrap_t_;
108 GLenum usage_;
109 GLenum compare_func_;
110 GLenum compare_mode_;
111 GLfloat max_lod_;
112 GLfloat min_lod_;
113 GLint base_level_;
114 GLint max_level_;
115
116 // True if deleted.
117 bool deleted_;
118 };
119
120 // This class keeps track of the samplers and their state.
121 class GPU_EXPORT SamplerManager {
122 public:
123 SamplerManager(FeatureInfo* feature_info);
124 ~SamplerManager();
125
126 // Must call before destruction.
127 void Destroy(bool have_context);
128
129 // Creates a Sampler for the given sampler.
130 Sampler* CreateSampler(GLuint client_id, GLuint service_id);
131
132 // Gets the Sampler info for the given sampler.
133 Sampler* GetSampler(GLuint client_id);
134
135 // Removes a Sampler info for the given sampler.
136 void RemoveSampler(GLuint client_id);
137
138 // Sets a sampler parameter of a Sampler.
139 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
140 void SetParameteri(
141 const char* function_name, ErrorState* error_state,
142 Sampler* sampler, GLenum pname, GLint param);
143 void SetParameterf(
144 const char* function_name, ErrorState* error_state,
145 Sampler* sampler, GLenum pname, GLfloat param);
146
147 private:
148 friend class Sampler;
149
150 scoped_refptr<FeatureInfo> feature_info_;
151
152 // Info for each sampler in the system.
153 typedef base::hash_map<GLuint, scoped_refptr<Sampler> > SamplerMap;
154 SamplerMap samplers_;
155
156 bool have_context_;
157
158 DISALLOW_COPY_AND_ASSIGN(SamplerManager);
159 };
160
161 } // namespace gles2
162 } // namespace gpu
163
164 #endif // GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698