blob: 14e6f6b712f80a19bf902fd1f0d84d38fa772509 [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);
Jamie Madill231c7f52017-04-26 13:45:37 -040067 mCaps = GenerateMinimumCaps(maxClientVersion);
Geoff Lang1e031b22017-02-10 15:01:28 -050068
Jamie Madill231c7f52017-04-26 13:45:37 -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
Jamie Madillc564c072017-06-01 12:45:42 -040095gl::Error ContextNULL::drawArrays(const gl::Context *context,
96 GLenum mode,
97 GLint first,
98 GLsizei count)
Geoff Langd08f3b32016-09-23 15:56:30 -040099{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400100 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400101}
102
Jamie Madillc564c072017-06-01 12:45:42 -0400103gl::Error ContextNULL::drawArraysInstanced(const gl::Context *context,
104 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400105 GLint first,
106 GLsizei count,
107 GLsizei instanceCount)
108{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400109 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400110}
111
Jamie Madillc564c072017-06-01 12:45:42 -0400112gl::Error ContextNULL::drawElements(const gl::Context *context,
113 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400114 GLsizei count,
115 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400116 const void *indices,
Geoff Langd08f3b32016-09-23 15:56:30 -0400117 const gl::IndexRange &indexRange)
118{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400119 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400120}
121
Jamie Madillc564c072017-06-01 12:45:42 -0400122gl::Error ContextNULL::drawElementsInstanced(const gl::Context *context,
123 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400124 GLsizei count,
125 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400126 const void *indices,
Geoff Langd08f3b32016-09-23 15:56:30 -0400127 GLsizei instances,
128 const gl::IndexRange &indexRange)
129{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400130 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400131}
132
Jamie Madillc564c072017-06-01 12:45:42 -0400133gl::Error ContextNULL::drawRangeElements(const gl::Context *context,
134 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400135 GLuint start,
136 GLuint end,
137 GLsizei count,
138 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400139 const void *indices,
Geoff Langd08f3b32016-09-23 15:56:30 -0400140 const gl::IndexRange &indexRange)
141{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400142 return gl::NoError();
143}
144
Jamie Madillc564c072017-06-01 12:45:42 -0400145gl::Error ContextNULL::drawArraysIndirect(const gl::Context *context,
146 GLenum mode,
147 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800148{
149 return gl::NoError();
150}
151
Jamie Madillc564c072017-06-01 12:45:42 -0400152gl::Error ContextNULL::drawElementsIndirect(const gl::Context *context,
153 GLenum mode,
154 GLenum type,
155 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800156{
157 return gl::NoError();
158}
159
Geoff Lang76cdbd52016-09-23 16:51:04 -0400160void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask)
161{
162}
163
164void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask)
165{
166}
167
168void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode)
169{
170}
171
172void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode)
173{
174}
175
176void ContextNULL::stencilThenCoverFillPath(const gl::Path *path,
177 GLenum fillMode,
178 GLuint mask,
179 GLenum coverMode)
180{
181}
182
183void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path,
184 GLint reference,
185 GLuint mask,
186 GLenum coverMode)
187{
188}
189
190void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths,
191 GLenum coverMode,
192 GLenum transformType,
193 const GLfloat *transformValues)
194{
195}
196
197void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths,
198 GLenum coverMode,
199 GLenum transformType,
200 const GLfloat *transformValues)
201{
202}
203
204void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths,
205 GLenum fillMode,
206 GLuint mask,
207 GLenum transformType,
208 const GLfloat *transformValues)
209{
210}
211
212void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths,
213 GLint reference,
214 GLuint mask,
215 GLenum transformType,
216 const GLfloat *transformValues)
217{
218}
219
220void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths,
221 GLenum coverMode,
222 GLenum fillMode,
223 GLuint mask,
224 GLenum transformType,
225 const GLfloat *transformValues)
226{
227}
228
229void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths,
230 GLenum coverMode,
231 GLint reference,
232 GLuint mask,
233 GLenum transformType,
234 const GLfloat *transformValues)
235{
236}
237
238GLenum ContextNULL::getResetStatus()
239{
240 return GL_NO_ERROR;
241}
242
243std::string ContextNULL::getVendorString() const
244{
245 return "NULL";
246}
247
248std::string ContextNULL::getRendererDescription() const
249{
250 return "NULL";
251}
252
253void ContextNULL::insertEventMarker(GLsizei length, const char *marker)
254{
255}
256
257void ContextNULL::pushGroupMarker(GLsizei length, const char *marker)
258{
259}
260
261void ContextNULL::popGroupMarker()
262{
263}
264
Jamie Madillfe548342017-06-19 11:13:24 -0400265void ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400266{
267}
268
269GLint ContextNULL::getGPUDisjoint()
270{
271 return 0;
272}
273
274GLint64 ContextNULL::getTimestamp()
275{
276 return 0;
277}
278
Jamie Madill4928b7c2017-06-20 12:57:39 -0400279void ContextNULL::onMakeCurrent(const gl::Context *context)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400280{
281}
282
283const gl::Caps &ContextNULL::getNativeCaps() const
284{
285 return mCaps;
286}
287
288const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const
289{
290 return mTextureCaps;
291}
292
293const gl::Extensions &ContextNULL::getNativeExtensions() const
294{
295 return mExtensions;
296}
297
298const gl::Limitations &ContextNULL::getNativeLimitations() const
299{
300 return mLimitations;
Geoff Langd08f3b32016-09-23 15:56:30 -0400301}
302
303CompilerImpl *ContextNULL::createCompiler()
304{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400305 return new CompilerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400306}
307
308ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data)
309{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400310 return new ShaderNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400311}
312
313ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data)
314{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400315 return new ProgramNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400316}
317
318FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data)
319{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400320 return new FramebufferNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400321}
322
323TextureImpl *ContextNULL::createTexture(const gl::TextureState &state)
324{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400325 return new TextureNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400326}
327
328RenderbufferImpl *ContextNULL::createRenderbuffer()
329{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400330 return new RenderbufferNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400331}
332
Jamie Madill8f775602016-11-03 16:45:34 -0400333BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400334{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500335 return new BufferNULL(state, mAllocationTracker);
Geoff Langd08f3b32016-09-23 15:56:30 -0400336}
337
338VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data)
339{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400340 return new VertexArrayNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400341}
342
343QueryImpl *ContextNULL::createQuery(GLenum type)
344{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400345 return new QueryNULL(type);
Geoff Langd08f3b32016-09-23 15:56:30 -0400346}
347
348FenceNVImpl *ContextNULL::createFenceNV()
349{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400350 return new FenceNVNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400351}
352
353FenceSyncImpl *ContextNULL::createFenceSync()
354{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400355 return new FenceSyncNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400356}
357
358TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state)
359{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400360 return new TransformFeedbackNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400361}
362
363SamplerImpl *ContextNULL::createSampler()
364{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400365 return new SamplerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400366}
367
368std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range)
369{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400370 std::vector<PathImpl *> result(range);
371 for (GLsizei idx = 0; idx < range; idx++)
372 {
373 result[idx] = new PathNULL();
374 }
375 return result;
Geoff Langd08f3b32016-09-23 15:56:30 -0400376}
377
Jamie Madillfe548342017-06-19 11:13:24 -0400378gl::Error ContextNULL::dispatchCompute(const gl::Context *context,
379 GLuint numGroupsX,
380 GLuint numGroupsY,
381 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800382{
383 return gl::NoError();
384}
385
Geoff Langd08f3b32016-09-23 15:56:30 -0400386} // namespace rx