blob: 4d39cd9a6b7fd34f3cf71cf2f563ce0bae90a0f5 [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"
Geoff Lang76cdbd52016-09-23 16:51:04 -040018#include "libANGLE/renderer/null/FramebufferNULL.h"
19#include "libANGLE/renderer/null/ImageNULL.h"
20#include "libANGLE/renderer/null/PathNULL.h"
21#include "libANGLE/renderer/null/ProgramNULL.h"
22#include "libANGLE/renderer/null/QueryNULL.h"
23#include "libANGLE/renderer/null/RenderbufferNULL.h"
24#include "libANGLE/renderer/null/SamplerNULL.h"
25#include "libANGLE/renderer/null/ShaderNULL.h"
Jamie Madill70b5bb02017-08-28 13:32:37 -040026#include "libANGLE/renderer/null/SyncNULL.h"
Geoff Lang76cdbd52016-09-23 16:51:04 -040027#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,
Qin Jiajia1da00652017-06-20 17:16:25 +0800116 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400117{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400118 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400119}
120
Jamie Madillc564c072017-06-01 12:45:42 -0400121gl::Error ContextNULL::drawElementsInstanced(const gl::Context *context,
122 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400123 GLsizei count,
124 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400125 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800126 GLsizei instances)
Geoff Langd08f3b32016-09-23 15:56:30 -0400127{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400128 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400129}
130
Jamie Madillc564c072017-06-01 12:45:42 -0400131gl::Error ContextNULL::drawRangeElements(const gl::Context *context,
132 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400133 GLuint start,
134 GLuint end,
135 GLsizei count,
136 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800137 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400138{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400139 return gl::NoError();
140}
141
Jamie Madillc564c072017-06-01 12:45:42 -0400142gl::Error ContextNULL::drawArraysIndirect(const gl::Context *context,
143 GLenum mode,
144 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800145{
146 return gl::NoError();
147}
148
Jamie Madillc564c072017-06-01 12:45:42 -0400149gl::Error ContextNULL::drawElementsIndirect(const gl::Context *context,
150 GLenum mode,
151 GLenum type,
152 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800153{
154 return gl::NoError();
155}
156
Geoff Lang76cdbd52016-09-23 16:51:04 -0400157void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask)
158{
159}
160
161void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask)
162{
163}
164
165void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode)
166{
167}
168
169void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode)
170{
171}
172
173void ContextNULL::stencilThenCoverFillPath(const gl::Path *path,
174 GLenum fillMode,
175 GLuint mask,
176 GLenum coverMode)
177{
178}
179
180void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path,
181 GLint reference,
182 GLuint mask,
183 GLenum coverMode)
184{
185}
186
187void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths,
188 GLenum coverMode,
189 GLenum transformType,
190 const GLfloat *transformValues)
191{
192}
193
194void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths,
195 GLenum coverMode,
196 GLenum transformType,
197 const GLfloat *transformValues)
198{
199}
200
201void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths,
202 GLenum fillMode,
203 GLuint mask,
204 GLenum transformType,
205 const GLfloat *transformValues)
206{
207}
208
209void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths,
210 GLint reference,
211 GLuint mask,
212 GLenum transformType,
213 const GLfloat *transformValues)
214{
215}
216
217void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths,
218 GLenum coverMode,
219 GLenum fillMode,
220 GLuint mask,
221 GLenum transformType,
222 const GLfloat *transformValues)
223{
224}
225
226void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths,
227 GLenum coverMode,
228 GLint reference,
229 GLuint mask,
230 GLenum transformType,
231 const GLfloat *transformValues)
232{
233}
234
235GLenum ContextNULL::getResetStatus()
236{
237 return GL_NO_ERROR;
238}
239
240std::string ContextNULL::getVendorString() const
241{
242 return "NULL";
243}
244
245std::string ContextNULL::getRendererDescription() const
246{
247 return "NULL";
248}
249
250void ContextNULL::insertEventMarker(GLsizei length, const char *marker)
251{
252}
253
254void ContextNULL::pushGroupMarker(GLsizei length, const char *marker)
255{
256}
257
258void ContextNULL::popGroupMarker()
259{
260}
261
Jamie Madillfe548342017-06-19 11:13:24 -0400262void ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400263{
264}
265
266GLint ContextNULL::getGPUDisjoint()
267{
268 return 0;
269}
270
271GLint64 ContextNULL::getTimestamp()
272{
273 return 0;
274}
275
Jamie Madill4928b7c2017-06-20 12:57:39 -0400276void ContextNULL::onMakeCurrent(const gl::Context *context)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400277{
278}
279
280const gl::Caps &ContextNULL::getNativeCaps() const
281{
282 return mCaps;
283}
284
285const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const
286{
287 return mTextureCaps;
288}
289
290const gl::Extensions &ContextNULL::getNativeExtensions() const
291{
292 return mExtensions;
293}
294
295const gl::Limitations &ContextNULL::getNativeLimitations() const
296{
297 return mLimitations;
Geoff Langd08f3b32016-09-23 15:56:30 -0400298}
299
300CompilerImpl *ContextNULL::createCompiler()
301{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400302 return new CompilerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400303}
304
305ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data)
306{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400307 return new ShaderNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400308}
309
310ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data)
311{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400312 return new ProgramNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400313}
314
315FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data)
316{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400317 return new FramebufferNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400318}
319
320TextureImpl *ContextNULL::createTexture(const gl::TextureState &state)
321{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400322 return new TextureNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400323}
324
325RenderbufferImpl *ContextNULL::createRenderbuffer()
326{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400327 return new RenderbufferNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400328}
329
Jamie Madill8f775602016-11-03 16:45:34 -0400330BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400331{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500332 return new BufferNULL(state, mAllocationTracker);
Geoff Langd08f3b32016-09-23 15:56:30 -0400333}
334
335VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data)
336{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400337 return new VertexArrayNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400338}
339
340QueryImpl *ContextNULL::createQuery(GLenum type)
341{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400342 return new QueryNULL(type);
Geoff Langd08f3b32016-09-23 15:56:30 -0400343}
344
345FenceNVImpl *ContextNULL::createFenceNV()
346{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400347 return new FenceNVNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400348}
349
Jamie Madill70b5bb02017-08-28 13:32:37 -0400350SyncImpl *ContextNULL::createSync()
Geoff Langd08f3b32016-09-23 15:56:30 -0400351{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400352 return new SyncNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400353}
354
355TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state)
356{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400357 return new TransformFeedbackNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400358}
359
Jamie Madill06ef36b2017-09-09 23:32:46 -0400360SamplerImpl *ContextNULL::createSampler(const gl::SamplerState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400361{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400362 return new SamplerNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400363}
364
365std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range)
366{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400367 std::vector<PathImpl *> result(range);
368 for (GLsizei idx = 0; idx < range; idx++)
369 {
370 result[idx] = new PathNULL();
371 }
372 return result;
Geoff Langd08f3b32016-09-23 15:56:30 -0400373}
374
Jamie Madillfe548342017-06-19 11:13:24 -0400375gl::Error ContextNULL::dispatchCompute(const gl::Context *context,
376 GLuint numGroupsX,
377 GLuint numGroupsY,
378 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800379{
380 return gl::NoError();
381}
382
Geoff Langd08f3b32016-09-23 15:56:30 -0400383} // namespace rx