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

Side by Side Diff: src/gpu/gl/GrGLCreateNullInterface.cpp

Issue 2089013003: Revert of Support GL_SAMPLES queries in null contexts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | tools/gpu/gl/debug/DebugGLTestContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrNonAtomicRef.h"
10 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLInterface.h"
11 #include "GrGLTestInterface.h" 10 #include "GrGLTestInterface.h"
12 #include "SkMutex.h" 11 #include "SkMutex.h"
13 #include "SkTDArray.h" 12 #include "SkTDArray.h"
14 #include <type_traits>
15 13
16 // added to suppress 'no previous prototype' warning and because this code is du plicated in 14 // added to suppress 'no previous prototype' warning and because this code is du plicated in
17 // SkNullGLContext.cpp 15 // SkNullGLContext.cpp
18 namespace { 16 namespace {
19 17
20 class GLObject : public GrNonAtomicRef<GLObject> { 18 class BufferObj {
21 public: 19 public:
22 GLObject(GrGLuint id) : fID(id) {} 20 BufferObj(GrGLuint id) : fID(id), fDataPtr(nullptr), fSize(0), fMapped(false ) {}
23 GrGLuint id() const { return fID; } 21 ~BufferObj() { delete[] fDataPtr; }
24
25 private:
26 GrGLuint fID;
27 };
28
29 // This class maintains a sparsely populated array of object pointers.
30 template<typename T> class TGLObjectManager {
31 static_assert(std::is_convertible<T*, GLObject*>::value, "T must be a subclas s of GLObject");
32
33 public:
34 TGLObjectManager() : fFreeListHead(kFreeListEnd) {
35 *fGLObjects.append() = nullptr; // 0 is not a valid GL object id.
36 }
37
38 ~TGLObjectManager() {
39 // nullptr out the entries that are really free list links rather than p trs before deleting.
40 intptr_t curr = fFreeListHead;
41 while (kFreeListEnd != curr) {
42 intptr_t next = reinterpret_cast<intptr_t>(fGLObjects[SkToS32(curr)] );
43 fGLObjects[SkToS32(curr)] = nullptr;
44 curr = next;
45 }
46
47 fGLObjects.safeUnrefAll();
48 }
49
50 T* lookUp(GrGLuint id) {
51 T* object = fGLObjects[id];
52 SkASSERT(object && object->id() == id);
53 return object;
54 }
55
56 T* create() {
57 GrGLuint id;
58 T* object;
59
60 if (kFreeListEnd == fFreeListHead) {
61 // no free slots - create a new one
62 id = fGLObjects.count();
63 object = new T(id);
64 *fGLObjects.append() = object;
65 } else {
66 // grab the head of the free list and advance the head to the next f ree slot.
67 id = static_cast<GrGLuint>(fFreeListHead);
68 fFreeListHead = reinterpret_cast<intptr_t>(fGLObjects[id]);
69
70 object = new T(id);
71 fGLObjects[id] = object;
72 }
73
74 return object;
75 }
76
77 void free(T* object) {
78 SkASSERT(object);
79 SkASSERT(fGLObjects.count() > 0);
80
81 GrGLuint id = object->id();
82 object->unref();
83
84 fGLObjects[id] = reinterpret_cast<T*>(fFreeListHead);
85 fFreeListHead = id;
86 }
87
88 private:
89 static const intptr_t kFreeListEnd = -1;
90 // Index of the first entry of fGLObjects in the free list. Free slots in fG LObjects are indices
91 // to the next free slot. The last free slot has a value of kFreeListEnd.
92 intptr_t fFreeListHead;
93 SkTDArray<T*> fGLObjects;
94 };
95
96 class Buffer : public GLObject {
97 public:
98 Buffer(GrGLuint id) : INHERITED(id), fDataPtr(nullptr), fSize(0), fMapped(fa lse) {}
99 ~Buffer() { delete[] fDataPtr; }
100 22
101 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) { 23 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
102 if (fDataPtr) { 24 if (fDataPtr) {
103 SkASSERT(0 != fSize); 25 SkASSERT(0 != fSize);
104 delete[] fDataPtr; 26 delete[] fDataPtr;
105 } 27 }
106 28
107 fSize = size; 29 fSize = size;
108 fDataPtr = new char[size]; 30 fDataPtr = new char[size];
109 } 31 }
110 32
33 GrGLuint id() const { return fID; }
111 GrGLchar* dataPtr() { return fDataPtr; } 34 GrGLchar* dataPtr() { return fDataPtr; }
112 GrGLsizeiptr size() const { return fSize; } 35 GrGLsizeiptr size() const { return fSize; }
113 36
114 void setMapped(bool mapped) { fMapped = mapped; } 37 void setMapped(bool mapped) { fMapped = mapped; }
115 bool mapped() const { return fMapped; } 38 bool mapped() const { return fMapped; }
116 39
117 private: 40 private:
41 GrGLuint fID;
118 GrGLchar* fDataPtr; 42 GrGLchar* fDataPtr;
119 GrGLsizeiptr fSize; // size in bytes 43 GrGLsizeiptr fSize; // size in bytes
120 bool fMapped; 44 bool fMapped;
121
122 typedef GLObject INHERITED;
123 }; 45 };
124 46
125 class FramebufferAttachment : public GLObject { 47 // This class maintains a sparsely populated array of buffer pointers.
48 class BufferManager {
126 public: 49 public:
127 FramebufferAttachment(int id) : INHERITED(id), fNumSamples(1) {} 50 BufferManager() : fFreeListHead(kFreeListEnd) {
128 int numSamples() const { return fNumSamples; } 51 *fBuffers.append() = nullptr; // 0 is not a valid GL buffer id.
129
130 protected:
131 int fNumSamples;
132
133 typedef GLObject INHERITED;
134 };
135
136 class Renderbuffer : public FramebufferAttachment {
137 public:
138 Renderbuffer(int id) : INHERITED(id) {}
139 void setNumSamples(int numSamples) { fNumSamples = numSamples; }
140
141 private:
142 typedef FramebufferAttachment INHERITED;
143 };
144
145 class Texture : public FramebufferAttachment {
146 public:
147 Texture(int id) : INHERITED(id) {}
148
149 private:
150 typedef FramebufferAttachment INHERITED;
151 };
152
153 class Framebuffer : public GLObject {
154 public:
155 Framebuffer(int id) : INHERITED(id) {}
156
157 void setAttachment(GrGLenum attachmentPoint, const FramebufferAttachment* at tachment) {
158 switch (attachmentPoint) {
159 default:
160 SK_ABORT("Invalid framebuffer attachment.");
161 break;
162 case GR_GL_STENCIL_ATTACHMENT:
163 fAttachments[(int)AttachmentPoint::kStencil].reset(SkRef(attachm ent));
164 break;
165 case GR_GL_DEPTH_ATTACHMENT:
166 fAttachments[(int)AttachmentPoint::kDepth].reset(SkRef(attachmen t));
167 break;
168 case GR_GL_COLOR_ATTACHMENT0:
169 fAttachments[(int)AttachmentPoint::kColor].reset(SkRef(attachmen t));
170 break;
171 }
172 } 52 }
173 53
174 void notifyAttachmentDeleteWhileBound(const FramebufferAttachment* deleted) { 54 ~BufferManager() {
175 for (auto& attachment : fAttachments) { 55 // nullptr out the entries that are really free list links rather than p trs before deleting.
176 if (attachment == deleted) { 56 intptr_t curr = fFreeListHead;
177 attachment.reset(nullptr); 57 while (kFreeListEnd != curr) {
178 } 58 intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]);
59 fBuffers[SkToS32(curr)] = nullptr;
60 curr = next;
179 } 61 }
62
63 fBuffers.deleteAll();
180 } 64 }
181 65
182 int numSamples() const { 66 BufferObj* lookUp(GrGLuint id) {
183 int numSamples = 0; 67 BufferObj* buffer = fBuffers[id];
184 for (auto& attachment : fAttachments) { 68 SkASSERT(buffer && buffer->id() == id);
185 if (!attachment) { 69 return buffer;
186 continue; 70 }
187 } 71
188 if (numSamples) { 72 BufferObj* create() {
189 GrAlwaysAssert(attachment->numSamples() == numSamples); 73 GrGLuint id;
190 continue; 74 BufferObj* buffer;
191 } 75
192 numSamples = attachment->numSamples(); 76 if (kFreeListEnd == fFreeListHead) {
77 // no free slots - create a new one
78 id = fBuffers.count();
79 buffer = new BufferObj(id);
80 *fBuffers.append() = buffer;
81 } else {
82 // grab the head of the free list and advance the head to the next f ree slot.
83 id = static_cast<GrGLuint>(fFreeListHead);
84 fFreeListHead = reinterpret_cast<intptr_t>(fBuffers[id]);
85
86 buffer = new BufferObj(id);
87 fBuffers[id] = buffer;
193 } 88 }
194 GrAlwaysAssert(numSamples); 89
195 return numSamples; 90 return buffer;
91 }
92
93 void free(BufferObj* buffer) {
94 SkASSERT(buffer);
95 SkASSERT(fBuffers.count() > 0);
96
97 GrGLuint id = buffer->id();
98 delete buffer;
99
100 fBuffers[id] = reinterpret_cast<BufferObj*>(fFreeListHead);
101 fFreeListHead = id;
196 } 102 }
197 103
198 private: 104 private:
199 enum AttachmentPoint { 105 static const intptr_t kFreeListEnd = -1;
200 kStencil, 106 // Index of the first entry of fBuffers in the free list. Free slots in fBuf fers are indices to
201 kDepth, 107 // the next free slot. The last free slot has a value of kFreeListEnd.
202 kColor 108 intptr_t fFreeListHead;
203 }; 109 SkTDArray<BufferObj*> fBuffers;
204 constexpr int static kNumAttachmentPoints = 1 + (int)AttachmentPoint::kColor ;
205
206 SkAutoTUnref<const FramebufferAttachment> fAttachments[kNumAttachmentPoints] ;
207
208 typedef GLObject INHERITED;
209 }; 110 };
210 111
211 /** Null interface implementation */ 112 /** Null interface implementation */
212 class NullInterface : public GrGLTestInterface { 113 class NullInterface : public GrGLTestInterface {
213 public: 114 public:
214 NullInterface(bool enableNVPR) 115 NullInterface(bool enableNVPR)
215 : fCurrDrawFramebuffer(0) 116 : fCurrProgramID(0)
216 , fCurrReadFramebuffer(0)
217 , fCurrRenderbuffer(0)
218 , fCurrProgramID(0)
219 , fCurrShaderID(0) 117 , fCurrShaderID(0)
220 , fCurrGenericID(0) 118 , fCurrGenericID(0)
221 , fCurrUniformLocation(0) 119 , fCurrUniformLocation(0)
222 , fCurrPathID(0) { 120 , fCurrPathID(0) {
223 memset(fBoundBuffers, 0, sizeof(fBoundBuffers)); 121 memset(fBoundBuffers, 0, sizeof(fBoundBuffers));
224 fExtensions.push_back("GL_ARB_framebuffer_object"); 122 fExtensions.push_back("GL_ARB_framebuffer_object");
225 fExtensions.push_back("GL_ARB_blend_func_extended"); 123 fExtensions.push_back("GL_ARB_blend_func_extended");
226 fExtensions.push_back("GL_ARB_timer_query"); 124 fExtensions.push_back("GL_ARB_timer_query");
227 fExtensions.push_back("GL_ARB_draw_buffers"); 125 fExtensions.push_back("GL_ARB_draw_buffers");
228 fExtensions.push_back("GL_ARB_occlusion_query"); 126 fExtensions.push_back("GL_ARB_occlusion_query");
229 fExtensions.push_back("GL_EXT_stencil_wrap"); 127 fExtensions.push_back("GL_EXT_stencil_wrap");
230 if (enableNVPR) { 128 if (enableNVPR) {
231 fExtensions.push_back("GL_NV_path_rendering"); 129 fExtensions.push_back("GL_NV_path_rendering");
232 fExtensions.push_back("GL_ARB_program_interface_query"); 130 fExtensions.push_back("GL_ARB_program_interface_query");
233 } 131 }
234 fExtensions.push_back(nullptr); 132 fExtensions.push_back(nullptr);
235 133
236 this->init(kGL_GrGLStandard); 134 this->init(kGL_GrGLStandard);
237 } 135 }
238 136
239 GrGLenum checkFramebufferStatus(GrGLenum target) override { 137 GrGLenum checkFramebufferStatus(GrGLenum target) override {
240 return GR_GL_FRAMEBUFFER_COMPLETE; 138 return GR_GL_FRAMEBUFFER_COMPLETE;
241 } 139 }
242 140
243 GrGLvoid genBuffers(GrGLsizei n, GrGLuint* ids) override { 141 GrGLvoid genBuffers(GrGLsizei n, GrGLuint* ids) override {
244 for (int i = 0; i < n; ++i) { 142 for (int i = 0; i < n; ++i) {
245 Buffer* buffer = fBufferManager.create(); 143 BufferObj* buffer = fBufferManager.create();
246 ids[i] = buffer->id(); 144 ids[i] = buffer->id();
247 } 145 }
248 } 146 }
249 147
250 GrGLvoid bufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data , 148 GrGLvoid bufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data ,
251 GrGLenum usage) override { 149 GrGLenum usage) override {
252 GrGLuint id = fBoundBuffers[GetBufferIndex(target)]; 150 GrGLuint id = fBoundBuffers[GetBufferIndex(target)];
253 if (id > 0) { 151 if (id > 0) {
254 Buffer* buffer = fBufferManager.lookUp(id); 152 BufferObj* buffer = fBufferManager.lookUp(id);
255 buffer->allocate(size, (const GrGLchar*) data); 153 buffer->allocate(size, (const GrGLchar*) data);
256 } 154 }
257 } 155 }
258 156
259 GrGLuint createProgram() override { 157 GrGLuint createProgram() override {
260 return ++fCurrProgramID; 158 return ++fCurrProgramID;
261 } 159 }
262 160
263 GrGLuint createShader(GrGLenum type) override { 161 GrGLuint createShader(GrGLenum type) override {
264 return ++fCurrShaderID; 162 return ++fCurrShaderID;
(...skipping 14 matching lines...) Expand all
279 if (ids[i] == fBoundBuffers[buffIdx]) { 177 if (ids[i] == fBoundBuffers[buffIdx]) {
280 fBoundBuffers[buffIdx] = 0; 178 fBoundBuffers[buffIdx] = 0;
281 break; 179 break;
282 } 180 }
283 } 181 }
284 } 182 }
285 183
286 // Then actually "delete" the buffers. 184 // Then actually "delete" the buffers.
287 for (int i = 0; i < n; ++i) { 185 for (int i = 0; i < n; ++i) {
288 if (ids[i] > 0) { 186 if (ids[i] > 0) {
289 Buffer* buffer = fBufferManager.lookUp(ids[i]); 187 BufferObj* buffer = fBufferManager.lookUp(ids[i]);
290 fBufferManager.free(buffer); 188 fBufferManager.free(buffer);
291 } 189 }
292 } 190 }
293 } 191 }
294 192
295 GrGLvoid genFramebuffers(GrGLsizei n, GrGLuint *framebuffers) override { 193 GrGLvoid genFramebuffers(GrGLsizei n, GrGLuint *framebuffers) override {
296 for (int i = 0; i < n; ++i) { 194 this->genGenericIds(n, framebuffers);
297 Framebuffer* framebuffer = fFramebufferManager.create();
298 framebuffers[i] = framebuffer->id();
299 }
300 }
301
302 GrGLvoid bindFramebuffer(GrGLenum target, GrGLuint framebuffer) override {
303 SkASSERT(GR_GL_FRAMEBUFFER == target || GR_GL_DRAW_FRAMEBUFFER == target ||
304 GR_GL_READ_FRAMEBUFFER == target);
305 if (GR_GL_READ_FRAMEBUFFER != target) {
306 fCurrDrawFramebuffer = framebuffer;
307 }
308 if (GR_GL_DRAW_FRAMEBUFFER != target) {
309 fCurrReadFramebuffer = framebuffer;
310 }
311 }
312
313 GrGLvoid deleteFramebuffers(GrGLsizei n, const GrGLuint* ids) override {
314 for (int i = 0; i < n; ++i) {
315 if (ids[i] == fCurrDrawFramebuffer) {
316 fCurrDrawFramebuffer = 0;
317 }
318 if (ids[i] == fCurrReadFramebuffer) {
319 fCurrReadFramebuffer = 0;
320 }
321
322 if (ids[i] > 0) {
323 Framebuffer* framebuffer = fFramebufferManager.lookUp(ids[i]);
324 fFramebufferManager.free(framebuffer);
325 }
326 }
327 } 195 }
328 196
329 GrGLvoid genQueries(GrGLsizei n, GrGLuint *ids) override { this->genGenericI ds(n, ids); } 197 GrGLvoid genQueries(GrGLsizei n, GrGLuint *ids) override { this->genGenericI ds(n, ids); }
330 198
331 GrGLvoid genRenderbuffers(GrGLsizei n, GrGLuint *renderbuffers) override { 199 GrGLvoid genRenderbuffers(GrGLsizei n, GrGLuint *renderbuffers) override {
332 for (int i = 0; i < n; ++i) { 200 this->genGenericIds(n, renderbuffers);
333 Renderbuffer* renderbuffer = fRenderbufferManager.create();
334 renderbuffers[i] = renderbuffer->id();
335 }
336 }
337
338 GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderbuffer) override {
339 SkASSERT(GR_GL_RENDERBUFFER == target);
340 fCurrRenderbuffer = renderbuffer;
341 }
342
343 GrGLvoid deleteRenderbuffers(GrGLsizei n, const GrGLuint* ids) override {
344 for (int i = 0; i < n; ++i) {
345 if (ids[i] <= 0) {
346 continue;
347 }
348 if (ids[i] == fCurrRenderbuffer) {
349 fCurrRenderbuffer = 0;
350 }
351 Renderbuffer* renderbuffer = fRenderbufferManager.lookUp(ids[i]);
352
353 if (fCurrDrawFramebuffer) {
354 Framebuffer* drawFramebuffer = fFramebufferManager.lookUp(fCurrD rawFramebuffer);
355 drawFramebuffer->notifyAttachmentDeleteWhileBound(renderbuffer);
356 }
357 if (fCurrReadFramebuffer) {
358 Framebuffer* readFramebuffer = fFramebufferManager.lookUp(fCurrR eadFramebuffer);
359 readFramebuffer->notifyAttachmentDeleteWhileBound(renderbuffer);
360 }
361
362 fRenderbufferManager.free(renderbuffer);
363 }
364 }
365
366 GrGLvoid renderbufferStorage(GrGLenum target, GrGLenum internalformat, GrGLs izei width,
367 GrGLsizei height) override {
368 GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
369 GrAlwaysAssert(fCurrRenderbuffer);
370 Renderbuffer* renderbuffer = fRenderbufferManager.lookUp(fCurrRenderbuff er);
371 renderbuffer->setNumSamples(1);
372 }
373
374 GrGLvoid renderbufferStorageMultisample(GrGLenum target, GrGLsizei samples,
375 GrGLenum internalformat, GrGLsizei w idth,
376 GrGLsizei height) override {
377 GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
378 GrAlwaysAssert(samples > 0);
379 GrAlwaysAssert(fCurrRenderbuffer);
380 Renderbuffer* renderbuffer = fRenderbufferManager.lookUp(fCurrRenderbuff er);
381 renderbuffer->setNumSamples(samples);
382 }
383
384 GrGLvoid namedRenderbufferStorage(GrGLuint renderbuffer, GrGLenum GrGLintern alformat,
385 GrGLsizei width, GrGLsizei height) overrid e {
386 SK_ABORT("Not implemented");
387 }
388
389 GrGLvoid namedRenderbufferStorageMultisample(GrGLuint renderbuffer, GrGLsize i samples,
390 GrGLenum GrGLinternalformat, Gr GLsizei width,
391 GrGLsizei height) override {
392 SK_ABORT("Not implemented");
393 }
394
395 GrGLvoid framebufferRenderbuffer(GrGLenum target, GrGLenum attachment,
396 GrGLenum renderbuffertarget,
397 GrGLuint renderBufferID) override {
398 GrGLuint id = this->getBoundFramebufferID(target);
399 GrAlwaysAssert(id);
400 Framebuffer* framebuffer = fFramebufferManager.lookUp(id);
401
402 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
403 GrAlwaysAssert(fCurrRenderbuffer);
404 Renderbuffer* renderbuffer = fRenderbufferManager.lookUp(fCurrRenderbuff er);
405
406 framebuffer->setAttachment(attachment, renderbuffer);
407 }
408
409 GrGLvoid namedFramebufferRenderbuffer(GrGLuint framebuffer, GrGLenum attachm ent,
410 GrGLenum renderbuffertarget,
411 GrGLuint renderbuffer) override {
412 SK_ABORT("Not implemented");
413 } 201 }
414 202
415 GrGLvoid genTextures(GrGLsizei n, GrGLuint *textures) override { 203 GrGLvoid genTextures(GrGLsizei n, GrGLuint *textures) override {
416 for (int i = 0; i < n; ++i) { 204 this->genGenericIds(n, textures);
417 Texture* texture = fTextureManager.create();
418 textures[i] = texture->id();
419 }
420 }
421
422 GrGLvoid deleteTextures(GrGLsizei n, const GrGLuint* ids) override {
423 for (int i = 0; i < n; ++i) {
424 if (ids[i] <= 0) {
425 continue;
426 }
427 Texture* texture = fTextureManager.lookUp(ids[i]);
428
429 if (fCurrDrawFramebuffer) {
430 Framebuffer* drawFramebuffer = fFramebufferManager.lookUp(fCurrD rawFramebuffer);
431 drawFramebuffer->notifyAttachmentDeleteWhileBound(texture);
432 }
433 if (fCurrReadFramebuffer) {
434 Framebuffer* readFramebuffer = fFramebufferManager.lookUp(fCurrR eadFramebuffer);
435 readFramebuffer->notifyAttachmentDeleteWhileBound(texture);
436 }
437
438 fTextureManager.free(texture);
439 }
440 }
441
442 GrGLvoid framebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenum textarget,
443 GrGLuint textureID, GrGLint level) override {
444 GrGLuint id = this->getBoundFramebufferID(target);
445 GrAlwaysAssert(id);
446 Framebuffer* framebuffer = fFramebufferManager.lookUp(id);
447
448 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
449 Texture* texture = fTextureManager.lookUp(textureID);
450
451 framebuffer->setAttachment(attachment, texture);
452 }
453
454 GrGLvoid framebufferTexture2DMultisample(GrGLenum target, GrGLenum attachmen t,
455 GrGLenum textarget, GrGLuint textur e, GrGLint level,
456 GrGLsizei samples) override {
457 SK_ABORT("Not implemented");
458 }
459
460 GrGLvoid namedFramebufferTexture1D(GrGLuint framebuffer, GrGLenum attachment ,
461 GrGLenum textarget, GrGLuint texture,
462 GrGLint level) override {
463 SK_ABORT("Not implemented");
464 }
465
466 GrGLvoid namedFramebufferTexture2D(GrGLuint framebuffer, GrGLenum attachment ,
467 GrGLenum textarget, GrGLuint texture,
468 GrGLint level) override {
469 SK_ABORT("Not implemented");
470 }
471
472 GrGLvoid namedFramebufferTexture3D(GrGLuint framebuffer, GrGLenum attachment ,
473 GrGLenum textarget, GrGLuint texture, GrG Lint level,
474 GrGLint zoffset) override {
475 SK_ABORT("Not implemented");
476 } 205 }
477 206
478 GrGLvoid genVertexArrays(GrGLsizei n, GrGLuint *arrays) override { 207 GrGLvoid genVertexArrays(GrGLsizei n, GrGLuint *arrays) override {
479 this->genGenericIds(n, arrays); 208 this->genGenericIds(n, arrays);
480 } 209 }
481 210
482 GrGLenum getError() override { return GR_GL_NO_ERROR; } 211 GrGLenum getError() override { return GR_GL_NO_ERROR; }
483 212
484 GrGLvoid getIntegerv(GrGLenum pname, GrGLint* params) override { 213 GrGLvoid getIntegerv(GrGLenum pname, GrGLint* params) override {
485 // TODO: remove from Ganesh the #defines for gets we don't use. 214 // TODO: remove from Ganesh the #defines for gets we don't use.
486 // We would like to minimize gets overall due to performance issues 215 // We would like to minimize gets overall due to performance issues
487 switch (pname) { 216 switch (pname) {
488 case GR_GL_CONTEXT_PROFILE_MASK: 217 case GR_GL_CONTEXT_PROFILE_MASK:
489 *params = GR_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; 218 *params = GR_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
490 break; 219 break;
491 case GR_GL_STENCIL_BITS: 220 case GR_GL_STENCIL_BITS:
492 *params = 8; 221 *params = 8;
493 break; 222 break;
494 case GR_GL_SAMPLES: { 223 case GR_GL_SAMPLES:
495 GrAlwaysAssert(fCurrDrawFramebuffer); 224 *params = 1;
496 Framebuffer* framebuffer = fFramebufferManager.lookUp(fCurrDrawF ramebuffer);
497 *params = framebuffer->numSamples();
498 break; 225 break;
499 }
500 case GR_GL_FRAMEBUFFER_BINDING: 226 case GR_GL_FRAMEBUFFER_BINDING:
501 *params = 0; 227 *params = 0;
502 break; 228 break;
503 case GR_GL_VIEWPORT: 229 case GR_GL_VIEWPORT:
504 params[0] = 0; 230 params[0] = 0;
505 params[1] = 0; 231 params[1] = 0;
506 params[2] = 800; 232 params[2] = 800;
507 params[3] = 600; 233 params[3] = 600;
508 break; 234 break;
509 case GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: 235 case GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 369
644 GrGLint getUniformLocation(GrGLuint program, const char* name) override { 370 GrGLint getUniformLocation(GrGLuint program, const char* name) override {
645 return ++fCurrUniformLocation; 371 return ++fCurrUniformLocation;
646 } 372 }
647 373
648 GrGLvoid* mapBufferRange(GrGLenum target, GrGLintptr offset, GrGLsizeiptr le ngth, 374 GrGLvoid* mapBufferRange(GrGLenum target, GrGLintptr offset, GrGLsizeiptr le ngth,
649 GrGLbitfield access) override { 375 GrGLbitfield access) override {
650 GrGLuint id = fBoundBuffers[GetBufferIndex(target)]; 376 GrGLuint id = fBoundBuffers[GetBufferIndex(target)];
651 if (id > 0) { 377 if (id > 0) {
652 // We just ignore the offset and length here. 378 // We just ignore the offset and length here.
653 Buffer* buffer = fBufferManager.lookUp(id); 379 BufferObj* buffer = fBufferManager.lookUp(id);
654 SkASSERT(!buffer->mapped()); 380 SkASSERT(!buffer->mapped());
655 buffer->setMapped(true); 381 buffer->setMapped(true);
656 return buffer->dataPtr(); 382 return buffer->dataPtr();
657 } 383 }
658 return nullptr; 384 return nullptr;
659 } 385 }
660 386
661 GrGLvoid* mapBuffer(GrGLenum target, GrGLenum access) override { 387 GrGLvoid* mapBuffer(GrGLenum target, GrGLenum access) override {
662 GrGLuint id = fBoundBuffers[GetBufferIndex(target)]; 388 GrGLuint id = fBoundBuffers[GetBufferIndex(target)];
663 if (id > 0) { 389 if (id > 0) {
664 Buffer* buffer = fBufferManager.lookUp(id); 390 BufferObj* buffer = fBufferManager.lookUp(id);
665 SkASSERT(!buffer->mapped()); 391 SkASSERT(!buffer->mapped());
666 buffer->setMapped(true); 392 buffer->setMapped(true);
667 return buffer->dataPtr(); 393 return buffer->dataPtr();
668 } 394 }
669 395
670 SkASSERT(false); 396 SkASSERT(false);
671 return nullptr; // no buffer bound to target 397 return nullptr; // no buffer bound to target
672 } 398 }
673 399
674 GrGLboolean unmapBuffer(GrGLenum target) override { 400 GrGLboolean unmapBuffer(GrGLenum target) override {
675 GrGLuint id = fBoundBuffers[GetBufferIndex(target)]; 401 GrGLuint id = fBoundBuffers[GetBufferIndex(target)];
676 if (id > 0) { 402 if (id > 0) {
677 Buffer* buffer = fBufferManager.lookUp(id); 403 BufferObj* buffer = fBufferManager.lookUp(id);
678 SkASSERT(buffer->mapped()); 404 SkASSERT(buffer->mapped());
679 buffer->setMapped(false); 405 buffer->setMapped(false);
680 return GR_GL_TRUE; 406 return GR_GL_TRUE;
681 } 407 }
682 408
683 GrAlwaysAssert(false); 409 GrAlwaysAssert(false);
684 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; 410 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
685 } 411 }
686 412
687 GrGLvoid getBufferParameteriv(GrGLenum target, GrGLenum pname, GrGLint* para ms) override { 413 GrGLvoid getBufferParameteriv(GrGLenum target, GrGLenum pname, GrGLint* para ms) override {
688 switch (pname) { 414 switch (pname) {
689 case GR_GL_BUFFER_MAPPED: { 415 case GR_GL_BUFFER_MAPPED: {
690 *params = GR_GL_FALSE; 416 *params = GR_GL_FALSE;
691 GrGLuint id = fBoundBuffers[GetBufferIndex(target)]; 417 GrGLuint id = fBoundBuffers[GetBufferIndex(target)];
692 if (id > 0) { 418 if (id > 0) {
693 Buffer* buffer = fBufferManager.lookUp(id); 419 BufferObj* buffer = fBufferManager.lookUp(id);
694 if (buffer->mapped()) { 420 if (buffer->mapped()) {
695 *params = GR_GL_TRUE; 421 *params = GR_GL_TRUE;
696 } 422 }
697 } 423 }
698 break; } 424 break; }
699 default: 425 default:
700 SkFAIL("Unexpected pname to GetBufferParamateriv"); 426 SkFAIL("Unexpected pname to GetBufferParamateriv");
701 break; 427 break;
702 } 428 }
703 }; 429 };
(...skipping 11 matching lines...) Expand all
715 case GR_GL_ARRAY_BUFFER: return 0; 441 case GR_GL_ARRAY_BUFFER: return 0;
716 case GR_GL_ELEMENT_ARRAY_BUFFER: return 1; 442 case GR_GL_ELEMENT_ARRAY_BUFFER: return 1;
717 case GR_GL_TEXTURE_BUFFER: return 2; 443 case GR_GL_TEXTURE_BUFFER: return 2;
718 case GR_GL_DRAW_INDIRECT_BUFFER: return 3; 444 case GR_GL_DRAW_INDIRECT_BUFFER: return 3;
719 case GR_GL_PIXEL_PACK_BUFFER: return 4; 445 case GR_GL_PIXEL_PACK_BUFFER: return 4;
720 case GR_GL_PIXEL_UNPACK_BUFFER: return 5; 446 case GR_GL_PIXEL_UNPACK_BUFFER: return 5;
721 } 447 }
722 } 448 }
723 constexpr int static kNumBufferTargets = 6; 449 constexpr int static kNumBufferTargets = 6;
724 450
725 TGLObjectManager<Buffer> fBufferManager; 451 BufferManager fBufferManager;
726 GrGLuint fBoundBuffers[kNumBufferTargets]; 452 GrGLuint fBoundBuffers[kNumBufferTargets];
727 TGLObjectManager<Framebuffer> fFramebufferManager; 453 GrGLuint fCurrProgramID;
728 GrGLuint fCurrDrawFramebuffer; 454 GrGLuint fCurrShaderID;
729 GrGLuint fCurrReadFramebuffer; 455 GrGLuint fCurrGenericID;
730 TGLObjectManager<Renderbuffer> fRenderbufferManager; 456 GrGLuint fCurrUniformLocation;
731 GrGLuint fCurrRenderbuffer; 457 GrGLuint fCurrPathID;
732 TGLObjectManager<Texture> fTextureManager; 458 SkTArray<const char*> fExtensions;
733 GrGLuint fCurrProgramID;
734 GrGLuint fCurrShaderID;
735 GrGLuint fCurrGenericID;
736 GrGLuint fCurrUniformLocation;
737 GrGLuint fCurrPathID;
738 SkTArray<const char*> fExtensions;
739 459
740 // the OpenGLES 2.0 spec says this must be >= 128 460 // the OpenGLES 2.0 spec says this must be >= 128
741 static const GrGLint kDefaultMaxVertexUniformVectors = 128; 461 static const GrGLint kDefaultMaxVertexUniformVectors = 128;
742 462
743 // the OpenGLES 2.0 spec says this must be >=16 463 // the OpenGLES 2.0 spec says this must be >=16
744 static const GrGLint kDefaultMaxFragmentUniformVectors = 16; 464 static const GrGLint kDefaultMaxFragmentUniformVectors = 16;
745 465
746 // the OpenGLES 2.0 spec says this must be >= 8 466 // the OpenGLES 2.0 spec says this must be >= 8
747 static const GrGLint kDefaultMaxVertexAttribs = 8; 467 static const GrGLint kDefaultMaxVertexAttribs = 8;
748 468
749 // the OpenGLES 2.0 spec says this must be >= 8 469 // the OpenGLES 2.0 spec says this must be >= 8
750 static const GrGLint kDefaultMaxVaryingVectors = 8; 470 static const GrGLint kDefaultMaxVaryingVectors = 8;
751 471
752 GrGLuint getBoundFramebufferID(GrGLenum target) {
753 switch (target) {
754 case GR_GL_FRAMEBUFFER:
755 case GR_GL_DRAW_FRAMEBUFFER:
756 return fCurrDrawFramebuffer;
757 case GR_GL_READ_FRAMEBUFFER:
758 return fCurrReadFramebuffer;
759 default:
760 SK_ABORT("Invalid framebuffer target.");
761 return 0;
762 }
763 }
764
765 const GrGLubyte* CombinedExtensionString() { 472 const GrGLubyte* CombinedExtensionString() {
766 static SkString gExtString; 473 static SkString gExtString;
767 static SkMutex gMutex; 474 static SkMutex gMutex;
768 gMutex.acquire(); 475 gMutex.acquire();
769 if (0 == gExtString.size()) { 476 if (0 == gExtString.size()) {
770 int i = 0; 477 int i = 0;
771 while (fExtensions[i]) { 478 while (fExtensions[i]) {
772 if (i > 0) { 479 if (i > 0) {
773 gExtString.append(" "); 480 gExtString.append(" ");
774 } 481 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 break; 533 break;
827 } 534 }
828 } 535 }
829 536
830 typedef GrGLTestInterface INHERITED; 537 typedef GrGLTestInterface INHERITED;
831 }; 538 };
832 539
833 } // anonymous namespace 540 } // anonymous namespace
834 541
835 const GrGLInterface* GrGLCreateNullInterface(bool enableNVPR) { return new NullI nterface(enableNVPR); } 542 const GrGLInterface* GrGLCreateNullInterface(bool enableNVPR) { return new NullI nterface(enableNVPR); }
OLDNEW
« no previous file with comments | « no previous file | tools/gpu/gl/debug/DebugGLTestContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698