blob: c0a40350cbf0a7b56cf88621734d46caa9dac4da [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"
Yunchao Hea336b902017-08-02 16:05:21 +080022#include "libANGLE/renderer/null/ProgramPipelineNULL.h"
Geoff Lang76cdbd52016-09-23 16:51:04 -040023#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"
Jamie Madill70b5bb02017-08-28 13:32:37 -040027#include "libANGLE/renderer/null/SyncNULL.h"
Geoff Lang76cdbd52016-09-23 16:51:04 -040028#include "libANGLE/renderer/null/TextureNULL.h"
29#include "libANGLE/renderer/null/TransformFeedbackNULL.h"
30#include "libANGLE/renderer/null/VertexArrayNULL.h"
31
Geoff Langd08f3b32016-09-23 15:56:30 -040032namespace rx
33{
34
Geoff Lang1b60d8d2017-02-10 14:56:55 -050035AllocationTrackerNULL::AllocationTrackerNULL(size_t maxTotalAllocationSize)
36 : mAllocatedBytes(0), mMaxBytes(maxTotalAllocationSize)
Geoff Langd08f3b32016-09-23 15:56:30 -040037{
Geoff Lang1b60d8d2017-02-10 14:56:55 -050038}
39
40AllocationTrackerNULL::~AllocationTrackerNULL()
41{
42 // ASSERT that all objects with the NULL renderer clean up after themselves
43 ASSERT(mAllocatedBytes == 0);
44}
45
46bool AllocationTrackerNULL::updateMemoryAllocation(size_t oldSize, size_t newSize)
47{
48 ASSERT(mAllocatedBytes >= oldSize);
49
50 size_t sizeAfterRelease = mAllocatedBytes - oldSize;
51 size_t sizeAfterReallocate = sizeAfterRelease + newSize;
52 if (sizeAfterReallocate < sizeAfterRelease || sizeAfterReallocate > mMaxBytes)
53 {
54 // Overflow or allocation would be too large
55 return false;
56 }
57
58 mAllocatedBytes = sizeAfterReallocate;
59 return true;
60}
61
62ContextNULL::ContextNULL(const gl::ContextState &state, AllocationTrackerNULL *allocationTracker)
63 : ContextImpl(state), mAllocationTracker(allocationTracker)
64{
65 ASSERT(mAllocationTracker != nullptr);
66
Geoff Lang76cdbd52016-09-23 16:51:04 -040067 const gl::Version maxClientVersion(3, 1);
Jamie Madill231c7f52017-04-26 13:45:37 -040068 mCaps = GenerateMinimumCaps(maxClientVersion);
Geoff Lang1e031b22017-02-10 15:01:28 -050069
Jamie Madill231c7f52017-04-26 13:45:37 -040070 mExtensions = gl::Extensions();
Geoff Lang04d06462017-10-02 16:01:13 -040071 mExtensions.fence = true;
Geoff Lang111a99e2017-10-17 10:58:41 -040072 mExtensions.instancedArrays = true;
Geoff Langadaabc32017-10-02 16:23:00 -040073 mExtensions.pixelBufferObject = true;
74 mExtensions.mapBuffer = true;
75 mExtensions.mapBufferRange = true;
Geoff Lang1e031b22017-02-10 15:01:28 -050076 mExtensions.copyTexture = true;
77 mExtensions.copyCompressedTexture = true;
78
Geoff Lang76cdbd52016-09-23 16:51:04 -040079 mTextureCaps = GenerateMinimumTextureCapsMap(maxClientVersion, mExtensions);
Geoff Langd08f3b32016-09-23 15:56:30 -040080}
81
82ContextNULL::~ContextNULL()
83{
84}
85
86gl::Error ContextNULL::initialize()
87{
Geoff Lang76cdbd52016-09-23 16:51:04 -040088 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040089}
90
91gl::Error ContextNULL::flush()
92{
Geoff Lang76cdbd52016-09-23 16:51:04 -040093 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040094}
95
96gl::Error ContextNULL::finish()
97{
Geoff Lang76cdbd52016-09-23 16:51:04 -040098 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040099}
100
Jamie Madillc564c072017-06-01 12:45:42 -0400101gl::Error ContextNULL::drawArrays(const gl::Context *context,
102 GLenum mode,
103 GLint first,
104 GLsizei count)
Geoff Langd08f3b32016-09-23 15:56:30 -0400105{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400106 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400107}
108
Jamie Madillc564c072017-06-01 12:45:42 -0400109gl::Error ContextNULL::drawArraysInstanced(const gl::Context *context,
110 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400111 GLint first,
112 GLsizei count,
113 GLsizei instanceCount)
114{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400115 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400116}
117
Jamie Madillc564c072017-06-01 12:45:42 -0400118gl::Error ContextNULL::drawElements(const gl::Context *context,
119 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400120 GLsizei count,
121 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800122 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400123{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400124 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400125}
126
Jamie Madillc564c072017-06-01 12:45:42 -0400127gl::Error ContextNULL::drawElementsInstanced(const gl::Context *context,
128 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400129 GLsizei count,
130 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400131 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800132 GLsizei instances)
Geoff Langd08f3b32016-09-23 15:56:30 -0400133{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400134 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400135}
136
Jamie Madillc564c072017-06-01 12:45:42 -0400137gl::Error ContextNULL::drawRangeElements(const gl::Context *context,
138 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400139 GLuint start,
140 GLuint end,
141 GLsizei count,
142 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800143 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400144{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400145 return gl::NoError();
146}
147
Jamie Madillc564c072017-06-01 12:45:42 -0400148gl::Error ContextNULL::drawArraysIndirect(const gl::Context *context,
149 GLenum mode,
150 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800151{
152 return gl::NoError();
153}
154
Jamie Madillc564c072017-06-01 12:45:42 -0400155gl::Error ContextNULL::drawElementsIndirect(const gl::Context *context,
156 GLenum mode,
157 GLenum type,
158 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800159{
160 return gl::NoError();
161}
162
Geoff Lang76cdbd52016-09-23 16:51:04 -0400163void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask)
164{
165}
166
167void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask)
168{
169}
170
171void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode)
172{
173}
174
175void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode)
176{
177}
178
179void ContextNULL::stencilThenCoverFillPath(const gl::Path *path,
180 GLenum fillMode,
181 GLuint mask,
182 GLenum coverMode)
183{
184}
185
186void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path,
187 GLint reference,
188 GLuint mask,
189 GLenum coverMode)
190{
191}
192
193void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths,
194 GLenum coverMode,
195 GLenum transformType,
196 const GLfloat *transformValues)
197{
198}
199
200void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths,
201 GLenum coverMode,
202 GLenum transformType,
203 const GLfloat *transformValues)
204{
205}
206
207void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths,
208 GLenum fillMode,
209 GLuint mask,
210 GLenum transformType,
211 const GLfloat *transformValues)
212{
213}
214
215void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths,
216 GLint reference,
217 GLuint mask,
218 GLenum transformType,
219 const GLfloat *transformValues)
220{
221}
222
223void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths,
224 GLenum coverMode,
225 GLenum fillMode,
226 GLuint mask,
227 GLenum transformType,
228 const GLfloat *transformValues)
229{
230}
231
232void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths,
233 GLenum coverMode,
234 GLint reference,
235 GLuint mask,
236 GLenum transformType,
237 const GLfloat *transformValues)
238{
239}
240
241GLenum ContextNULL::getResetStatus()
242{
243 return GL_NO_ERROR;
244}
245
246std::string ContextNULL::getVendorString() const
247{
248 return "NULL";
249}
250
251std::string ContextNULL::getRendererDescription() const
252{
253 return "NULL";
254}
255
256void ContextNULL::insertEventMarker(GLsizei length, const char *marker)
257{
258}
259
260void ContextNULL::pushGroupMarker(GLsizei length, const char *marker)
261{
262}
263
264void ContextNULL::popGroupMarker()
265{
266}
267
Jamie Madillfe548342017-06-19 11:13:24 -0400268void ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400269{
270}
271
272GLint ContextNULL::getGPUDisjoint()
273{
274 return 0;
275}
276
277GLint64 ContextNULL::getTimestamp()
278{
279 return 0;
280}
281
Jamie Madill4928b7c2017-06-20 12:57:39 -0400282void ContextNULL::onMakeCurrent(const gl::Context *context)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400283{
284}
285
286const gl::Caps &ContextNULL::getNativeCaps() const
287{
288 return mCaps;
289}
290
291const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const
292{
293 return mTextureCaps;
294}
295
296const gl::Extensions &ContextNULL::getNativeExtensions() const
297{
298 return mExtensions;
299}
300
301const gl::Limitations &ContextNULL::getNativeLimitations() const
302{
303 return mLimitations;
Geoff Langd08f3b32016-09-23 15:56:30 -0400304}
305
306CompilerImpl *ContextNULL::createCompiler()
307{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400308 return new CompilerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400309}
310
311ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data)
312{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400313 return new ShaderNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400314}
315
316ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data)
317{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400318 return new ProgramNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400319}
320
321FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data)
322{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400323 return new FramebufferNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400324}
325
326TextureImpl *ContextNULL::createTexture(const gl::TextureState &state)
327{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400328 return new TextureNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400329}
330
331RenderbufferImpl *ContextNULL::createRenderbuffer()
332{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400333 return new RenderbufferNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400334}
335
Jamie Madill8f775602016-11-03 16:45:34 -0400336BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400337{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500338 return new BufferNULL(state, mAllocationTracker);
Geoff Langd08f3b32016-09-23 15:56:30 -0400339}
340
341VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data)
342{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400343 return new VertexArrayNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400344}
345
346QueryImpl *ContextNULL::createQuery(GLenum type)
347{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400348 return new QueryNULL(type);
Geoff Langd08f3b32016-09-23 15:56:30 -0400349}
350
351FenceNVImpl *ContextNULL::createFenceNV()
352{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400353 return new FenceNVNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400354}
355
Jamie Madill70b5bb02017-08-28 13:32:37 -0400356SyncImpl *ContextNULL::createSync()
Geoff Langd08f3b32016-09-23 15:56:30 -0400357{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400358 return new SyncNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400359}
360
361TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state)
362{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400363 return new TransformFeedbackNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400364}
365
Jamie Madill06ef36b2017-09-09 23:32:46 -0400366SamplerImpl *ContextNULL::createSampler(const gl::SamplerState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400367{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400368 return new SamplerNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400369}
370
Yunchao Hea336b902017-08-02 16:05:21 +0800371ProgramPipelineImpl *ContextNULL::createProgramPipeline(const gl::ProgramPipelineState &state)
372{
373 return new ProgramPipelineNULL(state);
374}
375
Geoff Langd08f3b32016-09-23 15:56:30 -0400376std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range)
377{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400378 std::vector<PathImpl *> result(range);
379 for (GLsizei idx = 0; idx < range; idx++)
380 {
381 result[idx] = new PathNULL();
382 }
383 return result;
Geoff Langd08f3b32016-09-23 15:56:30 -0400384}
385
Jamie Madillfe548342017-06-19 11:13:24 -0400386gl::Error ContextNULL::dispatchCompute(const gl::Context *context,
387 GLuint numGroupsX,
388 GLuint numGroupsY,
389 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800390{
391 return gl::NoError();
392}
393
Geoff Langd08f3b32016-09-23 15:56:30 -0400394} // namespace rx