blob: 6fcf819765ff1568d115cfe390c18e941cb1fc05 [file] [log] [blame]
Geoff Langd08f3b32016-09-23 15:56:30 -04001//
2// Copyright 2016 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6// ContextNULL.cpp:
7// Implements the class methods for ContextNULL.
8//
9
10#include "libANGLE/renderer/null/ContextNULL.h"
11
12#include "common/debug.h"
13
Geoff Lang76cdbd52016-09-23 16:51:04 -040014#include "libANGLE/renderer/null/BufferNULL.h"
15#include "libANGLE/renderer/null/CompilerNULL.h"
16#include "libANGLE/renderer/null/DisplayNULL.h"
17#include "libANGLE/renderer/null/FenceNVNULL.h"
18#include "libANGLE/renderer/null/FenceSyncNULL.h"
19#include "libANGLE/renderer/null/FramebufferNULL.h"
20#include "libANGLE/renderer/null/ImageNULL.h"
21#include "libANGLE/renderer/null/PathNULL.h"
22#include "libANGLE/renderer/null/ProgramNULL.h"
23#include "libANGLE/renderer/null/QueryNULL.h"
24#include "libANGLE/renderer/null/RenderbufferNULL.h"
25#include "libANGLE/renderer/null/SamplerNULL.h"
26#include "libANGLE/renderer/null/ShaderNULL.h"
27#include "libANGLE/renderer/null/TextureNULL.h"
28#include "libANGLE/renderer/null/TransformFeedbackNULL.h"
29#include "libANGLE/renderer/null/VertexArrayNULL.h"
30
Geoff Langd08f3b32016-09-23 15:56:30 -040031namespace rx
32{
33
Geoff Lang1b60d8d2017-02-10 14:56:55 -050034AllocationTrackerNULL::AllocationTrackerNULL(size_t maxTotalAllocationSize)
35 : mAllocatedBytes(0), mMaxBytes(maxTotalAllocationSize)
Geoff Langd08f3b32016-09-23 15:56:30 -040036{
Geoff Lang1b60d8d2017-02-10 14:56:55 -050037}
38
39AllocationTrackerNULL::~AllocationTrackerNULL()
40{
41 // ASSERT that all objects with the NULL renderer clean up after themselves
42 ASSERT(mAllocatedBytes == 0);
43}
44
45bool AllocationTrackerNULL::updateMemoryAllocation(size_t oldSize, size_t newSize)
46{
47 ASSERT(mAllocatedBytes >= oldSize);
48
49 size_t sizeAfterRelease = mAllocatedBytes - oldSize;
50 size_t sizeAfterReallocate = sizeAfterRelease + newSize;
51 if (sizeAfterReallocate < sizeAfterRelease || sizeAfterReallocate > mMaxBytes)
52 {
53 // Overflow or allocation would be too large
54 return false;
55 }
56
57 mAllocatedBytes = sizeAfterReallocate;
58 return true;
59}
60
61ContextNULL::ContextNULL(const gl::ContextState &state, AllocationTrackerNULL *allocationTracker)
62 : ContextImpl(state), mAllocationTracker(allocationTracker)
63{
64 ASSERT(mAllocationTracker != nullptr);
65
Geoff Lang76cdbd52016-09-23 16:51:04 -040066 const gl::Version maxClientVersion(3, 1);
67 mCaps = GenerateMinimumCaps(maxClientVersion);
Geoff Lang1e031b22017-02-10 15:01:28 -050068
Geoff Lang76cdbd52016-09-23 16:51:04 -040069 mExtensions = gl::Extensions();
Geoff Lang1e031b22017-02-10 15:01:28 -050070 mExtensions.copyTexture = true;
71 mExtensions.copyCompressedTexture = true;
72
Geoff Lang76cdbd52016-09-23 16:51:04 -040073 mTextureCaps = GenerateMinimumTextureCapsMap(maxClientVersion, mExtensions);
Geoff Langd08f3b32016-09-23 15:56:30 -040074}
75
76ContextNULL::~ContextNULL()
77{
78}
79
80gl::Error ContextNULL::initialize()
81{
Geoff Lang76cdbd52016-09-23 16:51:04 -040082 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040083}
84
85gl::Error ContextNULL::flush()
86{
Geoff Lang76cdbd52016-09-23 16:51:04 -040087 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040088}
89
90gl::Error ContextNULL::finish()
91{
Geoff Lang76cdbd52016-09-23 16:51:04 -040092 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040093}
94
95gl::Error ContextNULL::drawArrays(GLenum mode, GLint first, GLsizei count)
96{
Geoff Lang76cdbd52016-09-23 16:51:04 -040097 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040098}
99
100gl::Error ContextNULL::drawArraysInstanced(GLenum mode,
101 GLint first,
102 GLsizei count,
103 GLsizei instanceCount)
104{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400105 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400106}
107
108gl::Error ContextNULL::drawElements(GLenum mode,
109 GLsizei count,
110 GLenum type,
111 const GLvoid *indices,
112 const gl::IndexRange &indexRange)
113{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400114 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400115}
116
117gl::Error ContextNULL::drawElementsInstanced(GLenum mode,
118 GLsizei count,
119 GLenum type,
120 const GLvoid *indices,
121 GLsizei instances,
122 const gl::IndexRange &indexRange)
123{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400124 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400125}
126
127gl::Error ContextNULL::drawRangeElements(GLenum mode,
128 GLuint start,
129 GLuint end,
130 GLsizei count,
131 GLenum type,
132 const GLvoid *indices,
133 const gl::IndexRange &indexRange)
134{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400135 return gl::NoError();
136}
137
Jiajia Qind9671222016-11-29 16:30:31 +0800138gl::Error ContextNULL::drawArraysIndirect(GLenum mode, const GLvoid *indirect)
139{
140 return gl::NoError();
141}
142
143gl::Error ContextNULL::drawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect)
144{
145 return gl::NoError();
146}
147
Geoff Lang76cdbd52016-09-23 16:51:04 -0400148void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask)
149{
150}
151
152void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask)
153{
154}
155
156void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode)
157{
158}
159
160void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode)
161{
162}
163
164void ContextNULL::stencilThenCoverFillPath(const gl::Path *path,
165 GLenum fillMode,
166 GLuint mask,
167 GLenum coverMode)
168{
169}
170
171void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path,
172 GLint reference,
173 GLuint mask,
174 GLenum coverMode)
175{
176}
177
178void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths,
179 GLenum coverMode,
180 GLenum transformType,
181 const GLfloat *transformValues)
182{
183}
184
185void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths,
186 GLenum coverMode,
187 GLenum transformType,
188 const GLfloat *transformValues)
189{
190}
191
192void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths,
193 GLenum fillMode,
194 GLuint mask,
195 GLenum transformType,
196 const GLfloat *transformValues)
197{
198}
199
200void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths,
201 GLint reference,
202 GLuint mask,
203 GLenum transformType,
204 const GLfloat *transformValues)
205{
206}
207
208void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths,
209 GLenum coverMode,
210 GLenum fillMode,
211 GLuint mask,
212 GLenum transformType,
213 const GLfloat *transformValues)
214{
215}
216
217void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths,
218 GLenum coverMode,
219 GLint reference,
220 GLuint mask,
221 GLenum transformType,
222 const GLfloat *transformValues)
223{
224}
225
226GLenum ContextNULL::getResetStatus()
227{
228 return GL_NO_ERROR;
229}
230
231std::string ContextNULL::getVendorString() const
232{
233 return "NULL";
234}
235
236std::string ContextNULL::getRendererDescription() const
237{
238 return "NULL";
239}
240
241void ContextNULL::insertEventMarker(GLsizei length, const char *marker)
242{
243}
244
245void ContextNULL::pushGroupMarker(GLsizei length, const char *marker)
246{
247}
248
249void ContextNULL::popGroupMarker()
250{
251}
252
253void ContextNULL::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits)
254{
255}
256
257GLint ContextNULL::getGPUDisjoint()
258{
259 return 0;
260}
261
262GLint64 ContextNULL::getTimestamp()
263{
264 return 0;
265}
266
267void ContextNULL::onMakeCurrent(const gl::ContextState &data)
268{
269}
270
271const gl::Caps &ContextNULL::getNativeCaps() const
272{
273 return mCaps;
274}
275
276const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const
277{
278 return mTextureCaps;
279}
280
281const gl::Extensions &ContextNULL::getNativeExtensions() const
282{
283 return mExtensions;
284}
285
286const gl::Limitations &ContextNULL::getNativeLimitations() const
287{
288 return mLimitations;
Geoff Langd08f3b32016-09-23 15:56:30 -0400289}
290
291CompilerImpl *ContextNULL::createCompiler()
292{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400293 return new CompilerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400294}
295
296ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data)
297{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400298 return new ShaderNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400299}
300
301ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data)
302{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400303 return new ProgramNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400304}
305
306FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data)
307{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400308 return new FramebufferNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400309}
310
311TextureImpl *ContextNULL::createTexture(const gl::TextureState &state)
312{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400313 return new TextureNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400314}
315
316RenderbufferImpl *ContextNULL::createRenderbuffer()
317{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400318 return new RenderbufferNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400319}
320
Jamie Madill8f775602016-11-03 16:45:34 -0400321BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400322{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500323 return new BufferNULL(state, mAllocationTracker);
Geoff Langd08f3b32016-09-23 15:56:30 -0400324}
325
326VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data)
327{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400328 return new VertexArrayNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400329}
330
331QueryImpl *ContextNULL::createQuery(GLenum type)
332{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400333 return new QueryNULL(type);
Geoff Langd08f3b32016-09-23 15:56:30 -0400334}
335
336FenceNVImpl *ContextNULL::createFenceNV()
337{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400338 return new FenceNVNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400339}
340
341FenceSyncImpl *ContextNULL::createFenceSync()
342{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400343 return new FenceSyncNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400344}
345
346TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state)
347{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400348 return new TransformFeedbackNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400349}
350
351SamplerImpl *ContextNULL::createSampler()
352{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400353 return new SamplerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400354}
355
356std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range)
357{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400358 std::vector<PathImpl *> result(range);
359 for (GLsizei idx = 0; idx < range; idx++)
360 {
361 result[idx] = new PathNULL();
362 }
363 return result;
Geoff Langd08f3b32016-09-23 15:56:30 -0400364}
365
366} // namespace rx