blob: 5309fc04e2e422e3d29c8d7f0bfb39f74edcc5c0 [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 Madill231c7f52017-04-26 13:45:37 -040067 mExtensions = gl::Extensions();
Geoff Lang04d06462017-10-02 16:01:13 -040068 mExtensions.fence = true;
Geoff Lang111a99e2017-10-17 10:58:41 -040069 mExtensions.instancedArrays = true;
Geoff Langadaabc32017-10-02 16:23:00 -040070 mExtensions.pixelBufferObject = true;
71 mExtensions.mapBuffer = true;
72 mExtensions.mapBufferRange = true;
Geoff Lang1e031b22017-02-10 15:01:28 -050073 mExtensions.copyTexture = true;
74 mExtensions.copyCompressedTexture = true;
Geoff Lang4751aab2017-10-30 15:14:52 -040075 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 Langd84a00b2017-10-27 17:27:26 -040081 mExtensions.rgb8rgba8 = true;
Geoff Lang86f81162017-10-30 15:10:45 -040082 mExtensions.textureCompressionDXT1 = true;
83 mExtensions.textureCompressionDXT3 = true;
84 mExtensions.textureCompressionDXT5 = true;
85 mExtensions.textureCompressionS3TCsRGB = true;
86 mExtensions.textureCompressionASTCHDR = true;
87 mExtensions.textureCompressionASTCLDR = true;
88 mExtensions.compressedETC1RGB8Texture = true;
89 mExtensions.lossyETCDecode = true;
Jiawei Shao361df072017-11-22 09:33:59 +080090 mExtensions.geometryShader = true;
Geoff Langd84a00b2017-10-27 17:27:26 -040091
Geoff Lang4751aab2017-10-30 15:14:52 -040092 const gl::Version maxClientVersion(3, 1);
93 mCaps = GenerateMinimumCaps(maxClientVersion, mExtensions);
94
Jamie Madill7b62cf92017-11-02 15:20:49 -040095 InitMinimumTextureCapsMap(maxClientVersion, mExtensions, &mTextureCaps);
Geoff Langd08f3b32016-09-23 15:56:30 -040096}
97
98ContextNULL::~ContextNULL()
99{
100}
101
102gl::Error ContextNULL::initialize()
103{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400104 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400105}
106
Jamie Madillafa02a22017-11-23 12:57:38 -0500107gl::Error ContextNULL::flush(const gl::Context *context)
Geoff Langd08f3b32016-09-23 15:56:30 -0400108{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400109 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400110}
111
Jamie Madillafa02a22017-11-23 12:57:38 -0500112gl::Error ContextNULL::finish(const gl::Context *context)
Geoff Langd08f3b32016-09-23 15:56:30 -0400113{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400114 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400115}
116
Jamie Madillc564c072017-06-01 12:45:42 -0400117gl::Error ContextNULL::drawArrays(const gl::Context *context,
118 GLenum mode,
119 GLint first,
120 GLsizei count)
Geoff Langd08f3b32016-09-23 15:56:30 -0400121{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400122 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400123}
124
Jamie Madillc564c072017-06-01 12:45:42 -0400125gl::Error ContextNULL::drawArraysInstanced(const gl::Context *context,
126 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400127 GLint first,
128 GLsizei count,
129 GLsizei instanceCount)
130{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400131 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400132}
133
Jamie Madillc564c072017-06-01 12:45:42 -0400134gl::Error ContextNULL::drawElements(const gl::Context *context,
135 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400136 GLsizei count,
137 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800138 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400139{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400140 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400141}
142
Jamie Madillc564c072017-06-01 12:45:42 -0400143gl::Error ContextNULL::drawElementsInstanced(const gl::Context *context,
144 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400145 GLsizei count,
146 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400147 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800148 GLsizei instances)
Geoff Langd08f3b32016-09-23 15:56:30 -0400149{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400150 return gl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400151}
152
Jamie Madillc564c072017-06-01 12:45:42 -0400153gl::Error ContextNULL::drawRangeElements(const gl::Context *context,
154 GLenum mode,
Geoff Langd08f3b32016-09-23 15:56:30 -0400155 GLuint start,
156 GLuint end,
157 GLsizei count,
158 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800159 const void *indices)
Geoff Langd08f3b32016-09-23 15:56:30 -0400160{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400161 return gl::NoError();
162}
163
Jamie Madillc564c072017-06-01 12:45:42 -0400164gl::Error ContextNULL::drawArraysIndirect(const gl::Context *context,
165 GLenum mode,
166 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800167{
168 return gl::NoError();
169}
170
Jamie Madillc564c072017-06-01 12:45:42 -0400171gl::Error ContextNULL::drawElementsIndirect(const gl::Context *context,
172 GLenum mode,
173 GLenum type,
174 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800175{
176 return gl::NoError();
177}
178
Geoff Lang76cdbd52016-09-23 16:51:04 -0400179void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask)
180{
181}
182
183void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask)
184{
185}
186
187void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode)
188{
189}
190
191void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode)
192{
193}
194
195void ContextNULL::stencilThenCoverFillPath(const gl::Path *path,
196 GLenum fillMode,
197 GLuint mask,
198 GLenum coverMode)
199{
200}
201
202void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path,
203 GLint reference,
204 GLuint mask,
205 GLenum coverMode)
206{
207}
208
209void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths,
210 GLenum coverMode,
211 GLenum transformType,
212 const GLfloat *transformValues)
213{
214}
215
216void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths,
217 GLenum coverMode,
218 GLenum transformType,
219 const GLfloat *transformValues)
220{
221}
222
223void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths,
224 GLenum fillMode,
225 GLuint mask,
226 GLenum transformType,
227 const GLfloat *transformValues)
228{
229}
230
231void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths,
232 GLint reference,
233 GLuint mask,
234 GLenum transformType,
235 const GLfloat *transformValues)
236{
237}
238
239void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths,
240 GLenum coverMode,
241 GLenum fillMode,
242 GLuint mask,
243 GLenum transformType,
244 const GLfloat *transformValues)
245{
246}
247
248void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths,
249 GLenum coverMode,
250 GLint reference,
251 GLuint mask,
252 GLenum transformType,
253 const GLfloat *transformValues)
254{
255}
256
257GLenum ContextNULL::getResetStatus()
258{
259 return GL_NO_ERROR;
260}
261
262std::string ContextNULL::getVendorString() const
263{
264 return "NULL";
265}
266
267std::string ContextNULL::getRendererDescription() const
268{
269 return "NULL";
270}
271
272void ContextNULL::insertEventMarker(GLsizei length, const char *marker)
273{
274}
275
276void ContextNULL::pushGroupMarker(GLsizei length, const char *marker)
277{
278}
279
280void ContextNULL::popGroupMarker()
281{
282}
283
Geoff Lang5d5253a2017-11-22 14:51:12 -0500284void ContextNULL::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
285{
286}
287
288void ContextNULL::popDebugGroup()
289{
290}
291
Jamie Madillfe548342017-06-19 11:13:24 -0400292void ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400293{
294}
295
296GLint ContextNULL::getGPUDisjoint()
297{
298 return 0;
299}
300
301GLint64 ContextNULL::getTimestamp()
302{
303 return 0;
304}
305
Jamie Madill4928b7c2017-06-20 12:57:39 -0400306void ContextNULL::onMakeCurrent(const gl::Context *context)
Geoff Lang76cdbd52016-09-23 16:51:04 -0400307{
308}
309
310const gl::Caps &ContextNULL::getNativeCaps() const
311{
312 return mCaps;
313}
314
315const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const
316{
317 return mTextureCaps;
318}
319
320const gl::Extensions &ContextNULL::getNativeExtensions() const
321{
322 return mExtensions;
323}
324
325const gl::Limitations &ContextNULL::getNativeLimitations() const
326{
327 return mLimitations;
Geoff Langd08f3b32016-09-23 15:56:30 -0400328}
329
330CompilerImpl *ContextNULL::createCompiler()
331{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400332 return new CompilerNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400333}
334
335ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data)
336{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400337 return new ShaderNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400338}
339
340ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data)
341{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400342 return new ProgramNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400343}
344
345FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data)
346{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400347 return new FramebufferNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400348}
349
350TextureImpl *ContextNULL::createTexture(const gl::TextureState &state)
351{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400352 return new TextureNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400353}
354
355RenderbufferImpl *ContextNULL::createRenderbuffer()
356{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400357 return new RenderbufferNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400358}
359
Jamie Madill8f775602016-11-03 16:45:34 -0400360BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400361{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500362 return new BufferNULL(state, mAllocationTracker);
Geoff Langd08f3b32016-09-23 15:56:30 -0400363}
364
365VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data)
366{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400367 return new VertexArrayNULL(data);
Geoff Langd08f3b32016-09-23 15:56:30 -0400368}
369
370QueryImpl *ContextNULL::createQuery(GLenum type)
371{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400372 return new QueryNULL(type);
Geoff Langd08f3b32016-09-23 15:56:30 -0400373}
374
375FenceNVImpl *ContextNULL::createFenceNV()
376{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400377 return new FenceNVNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400378}
379
Jamie Madill70b5bb02017-08-28 13:32:37 -0400380SyncImpl *ContextNULL::createSync()
Geoff Langd08f3b32016-09-23 15:56:30 -0400381{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400382 return new SyncNULL();
Geoff Langd08f3b32016-09-23 15:56:30 -0400383}
384
385TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state)
386{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400387 return new TransformFeedbackNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400388}
389
Jamie Madill06ef36b2017-09-09 23:32:46 -0400390SamplerImpl *ContextNULL::createSampler(const gl::SamplerState &state)
Geoff Langd08f3b32016-09-23 15:56:30 -0400391{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400392 return new SamplerNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400393}
394
Yunchao Hea336b902017-08-02 16:05:21 +0800395ProgramPipelineImpl *ContextNULL::createProgramPipeline(const gl::ProgramPipelineState &state)
396{
397 return new ProgramPipelineNULL(state);
398}
399
Geoff Langd08f3b32016-09-23 15:56:30 -0400400std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range)
401{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400402 std::vector<PathImpl *> result(range);
403 for (GLsizei idx = 0; idx < range; idx++)
404 {
405 result[idx] = new PathNULL();
406 }
407 return result;
Geoff Langd08f3b32016-09-23 15:56:30 -0400408}
409
Jamie Madillfe548342017-06-19 11:13:24 -0400410gl::Error ContextNULL::dispatchCompute(const gl::Context *context,
411 GLuint numGroupsX,
412 GLuint numGroupsY,
413 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800414{
415 return gl::NoError();
416}
417
Qin Jiajia62fcf622017-11-30 16:16:12 +0800418gl::Error ContextNULL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
419{
420 return gl::NoError();
421}
422
Xinghua Cao89c422a2017-11-29 18:24:20 +0800423gl::Error ContextNULL::memoryBarrier(const gl::Context *context, GLbitfield barriers)
424{
425 return gl::NoError();
426}
427
428gl::Error ContextNULL::memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers)
429{
430 return gl::NoError();
431}
432
Geoff Langd08f3b32016-09-23 15:56:30 -0400433} // namespace rx