Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 1 | // |
| 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 Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 14 | #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 Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 31 | namespace rx |
| 32 | { |
| 33 | |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame] | 34 | AllocationTrackerNULL::AllocationTrackerNULL(size_t maxTotalAllocationSize) |
| 35 | : mAllocatedBytes(0), mMaxBytes(maxTotalAllocationSize) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 36 | { |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | AllocationTrackerNULL::~AllocationTrackerNULL() |
| 40 | { |
| 41 | // ASSERT that all objects with the NULL renderer clean up after themselves |
| 42 | ASSERT(mAllocatedBytes == 0); |
| 43 | } |
| 44 | |
| 45 | bool 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 | |
| 61 | ContextNULL::ContextNULL(const gl::ContextState &state, AllocationTrackerNULL *allocationTracker) |
| 62 | : ContextImpl(state), mAllocationTracker(allocationTracker) |
| 63 | { |
| 64 | ASSERT(mAllocationTracker != nullptr); |
| 65 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 66 | const gl::Version maxClientVersion(3, 1); |
| 67 | mCaps = GenerateMinimumCaps(maxClientVersion); |
Geoff Lang | 1e031b2 | 2017-02-10 15:01:28 -0500 | [diff] [blame] | 68 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 69 | mExtensions = gl::Extensions(); |
Geoff Lang | 1e031b2 | 2017-02-10 15:01:28 -0500 | [diff] [blame] | 70 | mExtensions.copyTexture = true; |
| 71 | mExtensions.copyCompressedTexture = true; |
| 72 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 73 | mTextureCaps = GenerateMinimumTextureCapsMap(maxClientVersion, mExtensions); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | ContextNULL::~ContextNULL() |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | gl::Error ContextNULL::initialize() |
| 81 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 82 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | gl::Error ContextNULL::flush() |
| 86 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 87 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | gl::Error ContextNULL::finish() |
| 91 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 92 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | gl::Error ContextNULL::drawArrays(GLenum mode, GLint first, GLsizei count) |
| 96 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 97 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | gl::Error ContextNULL::drawArraysInstanced(GLenum mode, |
| 101 | GLint first, |
| 102 | GLsizei count, |
| 103 | GLsizei instanceCount) |
| 104 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 105 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | gl::Error ContextNULL::drawElements(GLenum mode, |
| 109 | GLsizei count, |
| 110 | GLenum type, |
| 111 | const GLvoid *indices, |
| 112 | const gl::IndexRange &indexRange) |
| 113 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 114 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | gl::Error ContextNULL::drawElementsInstanced(GLenum mode, |
| 118 | GLsizei count, |
| 119 | GLenum type, |
| 120 | const GLvoid *indices, |
| 121 | GLsizei instances, |
| 122 | const gl::IndexRange &indexRange) |
| 123 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 124 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | gl::Error ContextNULL::drawRangeElements(GLenum mode, |
| 128 | GLuint start, |
| 129 | GLuint end, |
| 130 | GLsizei count, |
| 131 | GLenum type, |
| 132 | const GLvoid *indices, |
| 133 | const gl::IndexRange &indexRange) |
| 134 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 135 | return gl::NoError(); |
| 136 | } |
| 137 | |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 138 | gl::Error ContextNULL::drawArraysIndirect(GLenum mode, const GLvoid *indirect) |
| 139 | { |
| 140 | return gl::NoError(); |
| 141 | } |
| 142 | |
| 143 | gl::Error ContextNULL::drawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect) |
| 144 | { |
| 145 | return gl::NoError(); |
| 146 | } |
| 147 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 148 | void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask) |
| 149 | { |
| 150 | } |
| 151 | |
| 152 | void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask) |
| 153 | { |
| 154 | } |
| 155 | |
| 156 | void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode) |
| 157 | { |
| 158 | } |
| 159 | |
| 160 | void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode) |
| 161 | { |
| 162 | } |
| 163 | |
| 164 | void ContextNULL::stencilThenCoverFillPath(const gl::Path *path, |
| 165 | GLenum fillMode, |
| 166 | GLuint mask, |
| 167 | GLenum coverMode) |
| 168 | { |
| 169 | } |
| 170 | |
| 171 | void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path, |
| 172 | GLint reference, |
| 173 | GLuint mask, |
| 174 | GLenum coverMode) |
| 175 | { |
| 176 | } |
| 177 | |
| 178 | void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths, |
| 179 | GLenum coverMode, |
| 180 | GLenum transformType, |
| 181 | const GLfloat *transformValues) |
| 182 | { |
| 183 | } |
| 184 | |
| 185 | void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths, |
| 186 | GLenum coverMode, |
| 187 | GLenum transformType, |
| 188 | const GLfloat *transformValues) |
| 189 | { |
| 190 | } |
| 191 | |
| 192 | void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths, |
| 193 | GLenum fillMode, |
| 194 | GLuint mask, |
| 195 | GLenum transformType, |
| 196 | const GLfloat *transformValues) |
| 197 | { |
| 198 | } |
| 199 | |
| 200 | void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths, |
| 201 | GLint reference, |
| 202 | GLuint mask, |
| 203 | GLenum transformType, |
| 204 | const GLfloat *transformValues) |
| 205 | { |
| 206 | } |
| 207 | |
| 208 | void ContextNULL::stencilThenCoverFillPathInstanced(const std::vector<gl::Path *> &paths, |
| 209 | GLenum coverMode, |
| 210 | GLenum fillMode, |
| 211 | GLuint mask, |
| 212 | GLenum transformType, |
| 213 | const GLfloat *transformValues) |
| 214 | { |
| 215 | } |
| 216 | |
| 217 | void ContextNULL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *> &paths, |
| 218 | GLenum coverMode, |
| 219 | GLint reference, |
| 220 | GLuint mask, |
| 221 | GLenum transformType, |
| 222 | const GLfloat *transformValues) |
| 223 | { |
| 224 | } |
| 225 | |
| 226 | GLenum ContextNULL::getResetStatus() |
| 227 | { |
| 228 | return GL_NO_ERROR; |
| 229 | } |
| 230 | |
| 231 | std::string ContextNULL::getVendorString() const |
| 232 | { |
| 233 | return "NULL"; |
| 234 | } |
| 235 | |
| 236 | std::string ContextNULL::getRendererDescription() const |
| 237 | { |
| 238 | return "NULL"; |
| 239 | } |
| 240 | |
| 241 | void ContextNULL::insertEventMarker(GLsizei length, const char *marker) |
| 242 | { |
| 243 | } |
| 244 | |
| 245 | void ContextNULL::pushGroupMarker(GLsizei length, const char *marker) |
| 246 | { |
| 247 | } |
| 248 | |
| 249 | void ContextNULL::popGroupMarker() |
| 250 | { |
| 251 | } |
| 252 | |
Frank Henigman | 5a53d54 | 2017-02-16 21:24:10 -0500 | [diff] [blame^] | 253 | void ContextNULL::syncState(const gl::State::DirtyBits &dirtyBits) |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 254 | { |
| 255 | } |
| 256 | |
| 257 | GLint ContextNULL::getGPUDisjoint() |
| 258 | { |
| 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | GLint64 ContextNULL::getTimestamp() |
| 263 | { |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | void ContextNULL::onMakeCurrent(const gl::ContextState &data) |
| 268 | { |
| 269 | } |
| 270 | |
| 271 | const gl::Caps &ContextNULL::getNativeCaps() const |
| 272 | { |
| 273 | return mCaps; |
| 274 | } |
| 275 | |
| 276 | const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const |
| 277 | { |
| 278 | return mTextureCaps; |
| 279 | } |
| 280 | |
| 281 | const gl::Extensions &ContextNULL::getNativeExtensions() const |
| 282 | { |
| 283 | return mExtensions; |
| 284 | } |
| 285 | |
| 286 | const gl::Limitations &ContextNULL::getNativeLimitations() const |
| 287 | { |
| 288 | return mLimitations; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | CompilerImpl *ContextNULL::createCompiler() |
| 292 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 293 | return new CompilerNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data) |
| 297 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 298 | return new ShaderNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data) |
| 302 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 303 | return new ProgramNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data) |
| 307 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 308 | return new FramebufferNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | TextureImpl *ContextNULL::createTexture(const gl::TextureState &state) |
| 312 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 313 | return new TextureNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | RenderbufferImpl *ContextNULL::createRenderbuffer() |
| 317 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 318 | return new RenderbufferNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 319 | } |
| 320 | |
Jamie Madill | 8f77560 | 2016-11-03 16:45:34 -0400 | [diff] [blame] | 321 | BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 322 | { |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame] | 323 | return new BufferNULL(state, mAllocationTracker); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data) |
| 327 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 328 | return new VertexArrayNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | QueryImpl *ContextNULL::createQuery(GLenum type) |
| 332 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 333 | return new QueryNULL(type); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | FenceNVImpl *ContextNULL::createFenceNV() |
| 337 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 338 | return new FenceNVNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | FenceSyncImpl *ContextNULL::createFenceSync() |
| 342 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 343 | return new FenceSyncNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state) |
| 347 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 348 | return new TransformFeedbackNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | SamplerImpl *ContextNULL::createSampler() |
| 352 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 353 | return new SamplerNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range) |
| 357 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 358 | std::vector<PathImpl *> result(range); |
| 359 | for (GLsizei idx = 0; idx < range; idx++) |
| 360 | { |
| 361 | result[idx] = new PathNULL(); |
| 362 | } |
| 363 | return result; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | } // namespace rx |