blob: 5021986d458bca3f2f178e5c8c8a32104fd0092c [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
Jamie Madill493f9572018-05-24 19:52:15 -040067 mExtensions = gl::Extensions();
68 mExtensions.fence = true;
69 mExtensions.instancedArrays = true;
70 mExtensions.pixelBufferObject = true;
71 mExtensions.mapBuffer = true;
72 mExtensions.mapBufferRange = true;
73 mExtensions.copyTexture = true;
74 mExtensions.copyCompressedTexture = true;
75 mExtensions.textureRectangle = true;
Geoff Lang73dcc602017-11-08 16:41:52 -050076 mExtensions.textureUsage = true;
77 mExtensions.vertexArrayObject = true;
78 mExtensions.debugMarker = true;
79 mExtensions.translatedShaderSource = true;
Geoff Lang1e031b22017-02-10 15:01:28 -050080
Geoff Langd54d3042017-11-07 14:56:07 -050081 mExtensions.textureStorage = true;
Jamie Madill493f9572018-05-24 19:52:15 -040082 mExtensions.rgb8rgba8 = true;
Geoff Lang86f81162017-10-30 15:10:45 -040083 mExtensions.textureCompressionDXT1 = true;
84 mExtensions.textureCompressionDXT3 = true;
85 mExtensions.textureCompressionDXT5 = true;
86 mExtensions.textureCompressionS3TCsRGB = true;
87 mExtensions.textureCompressionASTCHDR = true;
88 mExtensions.textureCompressionASTCLDR = true;
89 mExtensions.compressedETC1RGB8Texture = true;
90 mExtensions.lossyETCDecode = true;
Jiawei Shao361df072017-11-22 09:33:59 +080091 mExtensions.geometryShader = true;
Geoff Langd84a00b2017-10-27 17:27:26 -040092
Geoff Lang025aafd2017-10-30 15:16:37 -040093 mExtensions.eglImage = true;
94 mExtensions.eglImageExternal = true;
95 mExtensions.eglImageExternalEssl3 = true;
96 mExtensions.eglStreamConsumerExternal = true;
97
Geoff Lang4751aab2017-10-30 15:14:52 -040098 const gl::Version maxClientVersion(3, 1);
99 mCaps = GenerateMinimumCaps(maxClientVersion, mExtensions);
100
Jamie Madill7b62cf92017-11-02 15:20:49 -0400101 InitMinimumTextureCapsMap(maxClientVersion, mExtensions, &mTextureCaps);
Geoff Langd08f3b32016-09-23 15:56:30 -0400102}
103
104ContextNULL::~ContextNULL()
105{
106}
107
108gl::Error ContextNULL::initialize()
109{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400110 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400111}
112
Jamie Madillafa02a22017-11-23 12:57:38 -0500113gl::Error ContextNULL::flush(const gl::Context *context)
Geoff Langd08f3b32016-09-23 15:56:30 -0400114{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400115 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400116}
117
Jamie Madillafa02a22017-11-23 12:57:38 -0500118gl::Error ContextNULL::finish(const gl::Context *context)
Geoff Langd08f3b32016-09-23 15:56:30 -0400119{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400120 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400121}
122
Jamie Madillc564c072017-06-01 12:45:42 -0400123gl::Error ContextNULL::drawArrays(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400124 gl::PrimitiveMode mode,
Jamie Madillc564c072017-06-01 12:45:42 -0400125 GLint first,
126 GLsizei count)
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::drawArraysInstanced(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400132 gl::PrimitiveMode mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400133 GLint first,
134 GLsizei count,
135 GLsizei instanceCount)
136{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400137 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400138}
139
Jamie Madillc564c072017-06-01 12:45:42 -0400140gl::Error ContextNULL::drawElements(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400141 gl::PrimitiveMode mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400142 GLsizei count,
143 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800144 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400145{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400146 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400147}
148
Jamie Madillc564c072017-06-01 12:45:42 -0400149gl::Error ContextNULL::drawElementsInstanced(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400150 gl::PrimitiveMode mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400151 GLsizei count,
152 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400153 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800154 GLsizei instances)
Geoff Langd08f3b32016-09-23 15:56:30 -0400155{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400156 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400157}
158
Jamie Madillc564c072017-06-01 12:45:42 -0400159gl::Error ContextNULL::drawRangeElements(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400160 gl::PrimitiveMode mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400161 GLuint start,
162 GLuint end,
163 GLsizei count,
164 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800165 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400166{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400167 return gl::NoError();
168}
169
Jamie Madillc564c072017-06-01 12:45:42 -0400170gl::Error ContextNULL::drawArraysIndirect(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400171 gl::PrimitiveMode mode,
Jamie Madillc564c072017-06-01 12:45:42 -0400172 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800173{
174 return gl::NoError();
175}
176
Jamie Madillc564c072017-06-01 12:45:42 -0400177gl::Error ContextNULL::drawElementsIndirect(const gl::Context *context,
Jamie Madill493f9572018-05-24 19:52:15 -0400178 gl::PrimitiveMode mode,
Jamie Madillc564c072017-06-01 12:45:42 -0400179 GLenum type,
180 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800181{
182 return gl::NoError();
183}
184
Geoff Lang76cdbd52016-09-23 16:51:04 -0400185void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask)
186{
187}
188
189void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask)
190{
191}
192
193void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode)
194{
195}
196
197void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode)
198{
199}
200
201void ContextNULL::stencilThenCoverFillPath(const gl::Path *path,
202 GLenum fillMode,
203 GLuint mask,
204 GLenum coverMode)
205{
206}
207
208void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path,
209 GLint reference,
210 GLuint mask,
211 GLenum coverMode)
212{
213}
214
215void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths,
216 GLenum coverMode,
217 GLenum transformType,
218 const GLfloat *transformValues)
219{
220}
221
222void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths,
223 GLenum coverMode,
224 GLenum transformType,
225 const GLfloat *transformValues)
226{
227}
228
229void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths,
230 GLenum fillMode,
231 GLuint mask,
232 GLenum transformType,
233 const GLfloat *transformValues)
234{
235}
236
237void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths,
238 GLint reference,
239 GLuint mask,
240 GLenum transformType,
241 const GLfloat *transformValues)
242{
243}
244
245void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths,
246 GLenum coverMode,
247 GLenum fillMode,
248 GLuint mask,
249 GLenum transformType,
250 const GLfloat *transformValues)
251{
252}
253
254void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths,
255 GLenum coverMode,
256 GLint reference,
257 GLuint mask,
258 GLenum transformType,
259 const GLfloat *transformValues)
260{
261}
262
263GLenum ContextNULL::getResetStatus()
264{
265 return GL_NO_ERROR;
266}
267
268std::string ContextNULL::getVendorString() const
269{
270 return "NULL";
271}
272
273std::string ContextNULL::getRendererDescription() const
274{
275 return "NULL";
276}
277
278void ContextNULL::insertEventMarker(GLsizei length, const char *marker)
279{
280}
281
282void ContextNULL::pushGroupMarker(GLsizei length, const char *marker)
283{
284}
285
286void ContextNULL::popGroupMarker()
287{
288}
289
Geoff Lang5d5253a2017-11-22 14:51:12 -0500290void ContextNULL::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
291{
292}
293
294void ContextNULL::popDebugGroup()
295{
296}
297
Jamie Madill189ad872018-07-09 13:32:37 -0400298gl::Error ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400299{
Jamie Madill189ad872018-07-09 13:32:37 -0400300 return gl::NoError();
Geoff Lang76cdbd52016-09-23 16:51:04 -0400301}
302
303GLint ContextNULL::getGPUDisjoint()
304{
305 return 0;
306}
307
308GLint64 ContextNULL::getTimestamp()
309{
310 return 0;
311}
312
Luc Ferron5396f2a2018-07-12 08:24:23 -0400313gl::Error ContextNULL::onMakeCurrent(const gl::Context *context)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400314{
Luc Ferron5396f2a2018-07-12 08:24:23 -0400315 return gl::NoError();
Geoff Lang76cdbd52016-09-23 16:51:04 -0400316}
317
Jiawei Shaod0a7d102018-05-07 12:40:20 +0800318gl::Caps ContextNULL::getNativeCaps() const
Geoff Lang76cdbd52016-09-23 16:51:04 -0400319{
320 return mCaps;
321}
322
323const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const
324{
325 return mTextureCaps;
326}
327
328const gl::Extensions &ContextNULL::getNativeExtensions() const
329{
330 return mExtensions;
331}
332
333const gl::Limitations &ContextNULL::getNativeLimitations() const
334{
335 return mLimitations;
Geoff Langd08f3b32016-09-23 15:56:30 -0400336}
337
338CompilerImpl *ContextNULL::createCompiler()
339{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400340 return new CompilerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400341}
342
343ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data)
344{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400345 return new ShaderNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400346}
347
348ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data)
349{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400350 return new ProgramNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400351}
352
353FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data)
354{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400355 return new FramebufferNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400356}
357
358TextureImpl *ContextNULL::createTexture(const gl::TextureState &state)
359{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400360 return new TextureNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400361}
362
Jamie Madille703c602018-02-20 10:21:48 -0500363RenderbufferImpl *ContextNULL::createRenderbuffer(const gl::RenderbufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400364{
Jamie Madille703c602018-02-20 10:21:48 -0500365 return new RenderbufferNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400366}
367
Jamie Madill8f775602016-11-03 16:45:34 -0400368BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400369{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500370 return new BufferNULL(state, mAllocationTracker);
Geoff Langd08f3b32016-09-23 15:56:30 -0400371}
372
373VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data)
374{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400375 return new VertexArrayNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400376}
377
Corentin Wallezad3ae902018-03-09 13:40:42 -0500378QueryImpl *ContextNULL::createQuery(gl::QueryType type)
Geoff Langd08f3b32016-09-23 15:56:30 -0400379{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400380 return new QueryNULL(type);
Geoff Langd08f3b32016-09-23 15:56:30 -0400381}
382
383FenceNVImpl *ContextNULL::createFenceNV()
384{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400385 return new FenceNVNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400386}
387
Jamie Madill70b5bb02017-08-28 13:32:37 -0400388SyncImpl *ContextNULL::createSync()
Geoff Langd08f3b32016-09-23 15:56:30 -0400389{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400390 return new SyncNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400391}
392
393TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state)
394{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400395 return new TransformFeedbackNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400396}
397
Jamie Madill06ef36b2017-09-09 23:32:46 -0400398SamplerImpl *ContextNULL::createSampler(const gl::SamplerState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400399{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400400 return new SamplerNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400401}
402
Yunchao Hea336b902017-08-02 16:05:21 +0800403ProgramPipelineImpl *ContextNULL::createProgramPipeline(const gl::ProgramPipelineState &state)
404{
405 return new ProgramPipelineNULL(state);
406}
407
Geoff Langd08f3b32016-09-23 15:56:30 -0400408std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range)
409{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400410 std::vector<PathImpl *> result(range);
411 for (GLsizei idx = 0; idx < range; idx++)
412 {
413 result[idx] = new PathNULL();
414 }
415 return result;
Geoff Langd08f3b32016-09-23 15:56:30 -0400416}
417
Jamie Madillfe548342017-06-19 11:13:24 -0400418gl::Error ContextNULL::dispatchCompute(const gl::Context *context,
419 GLuint numGroupsX,
420 GLuint numGroupsY,
421 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800422{
423 return gl::NoError();
424}
425
Qin Jiajia62fcf622017-11-30 16:16:12 +0800426gl::Error ContextNULL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
427{
428 return gl::NoError();
429}
430
Xinghua Cao89c422a2017-11-29 18:24:20 +0800431gl::Error ContextNULL::memoryBarrier(const gl::Context *context, GLbitfield barriers)
432{
433 return gl::NoError();
434}
435
436gl::Error ContextNULL::memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers)
437{
438 return gl::NoError();
439}
440
Geoff Langd08f3b32016-09-23 15:56:30 -0400441} // namespace rx