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); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 67 | mCaps = GenerateMinimumCaps(maxClientVersion); |
Geoff Lang | 1e031b2 | 2017-02-10 15:01:28 -0500 | [diff] [blame] | 68 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -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 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 95 | gl::Error ContextNULL::drawArrays(const gl::Context *context, |
| 96 | GLenum mode, |
| 97 | GLint first, |
| 98 | GLsizei count) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 99 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 100 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 101 | } |
| 102 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 103 | gl::Error ContextNULL::drawArraysInstanced(const gl::Context *context, |
| 104 | GLenum mode, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 105 | GLint first, |
| 106 | GLsizei count, |
| 107 | GLsizei instanceCount) |
| 108 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 109 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 110 | } |
| 111 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 112 | gl::Error ContextNULL::drawElements(const gl::Context *context, |
| 113 | GLenum mode, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 114 | GLsizei count, |
| 115 | GLenum type, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 116 | const void *indices) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 117 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 118 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 119 | } |
| 120 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 121 | gl::Error ContextNULL::drawElementsInstanced(const gl::Context *context, |
| 122 | GLenum mode, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 123 | GLsizei count, |
| 124 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 125 | const void *indices, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 126 | GLsizei instances) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 127 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 128 | return gl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 129 | } |
| 130 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 131 | gl::Error ContextNULL::drawRangeElements(const gl::Context *context, |
| 132 | GLenum mode, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 133 | GLuint start, |
| 134 | GLuint end, |
| 135 | GLsizei count, |
| 136 | GLenum type, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 137 | const void *indices) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 138 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 139 | return gl::NoError(); |
| 140 | } |
| 141 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 142 | gl::Error ContextNULL::drawArraysIndirect(const gl::Context *context, |
| 143 | GLenum mode, |
| 144 | const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 145 | { |
| 146 | return gl::NoError(); |
| 147 | } |
| 148 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 149 | gl::Error ContextNULL::drawElementsIndirect(const gl::Context *context, |
| 150 | GLenum mode, |
| 151 | GLenum type, |
| 152 | const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 153 | { |
| 154 | return gl::NoError(); |
| 155 | } |
| 156 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 157 | void ContextNULL::stencilFillPath(const gl::Path *path, GLenum fillMode, GLuint mask) |
| 158 | { |
| 159 | } |
| 160 | |
| 161 | void ContextNULL::stencilStrokePath(const gl::Path *path, GLint reference, GLuint mask) |
| 162 | { |
| 163 | } |
| 164 | |
| 165 | void ContextNULL::coverFillPath(const gl::Path *path, GLenum coverMode) |
| 166 | { |
| 167 | } |
| 168 | |
| 169 | void ContextNULL::coverStrokePath(const gl::Path *path, GLenum coverMode) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | void ContextNULL::stencilThenCoverFillPath(const gl::Path *path, |
| 174 | GLenum fillMode, |
| 175 | GLuint mask, |
| 176 | GLenum coverMode) |
| 177 | { |
| 178 | } |
| 179 | |
| 180 | void ContextNULL::stencilThenCoverStrokePath(const gl::Path *path, |
| 181 | GLint reference, |
| 182 | GLuint mask, |
| 183 | GLenum coverMode) |
| 184 | { |
| 185 | } |
| 186 | |
| 187 | void ContextNULL::coverFillPathInstanced(const std::vector<gl::Path *> &paths, |
| 188 | GLenum coverMode, |
| 189 | GLenum transformType, |
| 190 | const GLfloat *transformValues) |
| 191 | { |
| 192 | } |
| 193 | |
| 194 | void ContextNULL::coverStrokePathInstanced(const std::vector<gl::Path *> &paths, |
| 195 | GLenum coverMode, |
| 196 | GLenum transformType, |
| 197 | const GLfloat *transformValues) |
| 198 | { |
| 199 | } |
| 200 | |
| 201 | void ContextNULL::stencilFillPathInstanced(const std::vector<gl::Path *> &paths, |
| 202 | GLenum fillMode, |
| 203 | GLuint mask, |
| 204 | GLenum transformType, |
| 205 | const GLfloat *transformValues) |
| 206 | { |
| 207 | } |
| 208 | |
| 209 | void ContextNULL::stencilStrokePathInstanced(const std::vector<gl::Path *> &paths, |
| 210 | GLint reference, |
| 211 | GLuint mask, |
| 212 | GLenum transformType, |
| 213 | const GLfloat *transformValues) |
| 214 | { |
| 215 | } |
| 216 | |
| 217 | void 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 | |
| 226 | void 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 | |
| 235 | GLenum ContextNULL::getResetStatus() |
| 236 | { |
| 237 | return GL_NO_ERROR; |
| 238 | } |
| 239 | |
| 240 | std::string ContextNULL::getVendorString() const |
| 241 | { |
| 242 | return "NULL"; |
| 243 | } |
| 244 | |
| 245 | std::string ContextNULL::getRendererDescription() const |
| 246 | { |
| 247 | return "NULL"; |
| 248 | } |
| 249 | |
| 250 | void ContextNULL::insertEventMarker(GLsizei length, const char *marker) |
| 251 | { |
| 252 | } |
| 253 | |
| 254 | void ContextNULL::pushGroupMarker(GLsizei length, const char *marker) |
| 255 | { |
| 256 | } |
| 257 | |
| 258 | void ContextNULL::popGroupMarker() |
| 259 | { |
| 260 | } |
| 261 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 262 | void ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 263 | { |
| 264 | } |
| 265 | |
| 266 | GLint ContextNULL::getGPUDisjoint() |
| 267 | { |
| 268 | return 0; |
| 269 | } |
| 270 | |
| 271 | GLint64 ContextNULL::getTimestamp() |
| 272 | { |
| 273 | return 0; |
| 274 | } |
| 275 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 276 | void ContextNULL::onMakeCurrent(const gl::Context *context) |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 277 | { |
| 278 | } |
| 279 | |
| 280 | const gl::Caps &ContextNULL::getNativeCaps() const |
| 281 | { |
| 282 | return mCaps; |
| 283 | } |
| 284 | |
| 285 | const gl::TextureCapsMap &ContextNULL::getNativeTextureCaps() const |
| 286 | { |
| 287 | return mTextureCaps; |
| 288 | } |
| 289 | |
| 290 | const gl::Extensions &ContextNULL::getNativeExtensions() const |
| 291 | { |
| 292 | return mExtensions; |
| 293 | } |
| 294 | |
| 295 | const gl::Limitations &ContextNULL::getNativeLimitations() const |
| 296 | { |
| 297 | return mLimitations; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | CompilerImpl *ContextNULL::createCompiler() |
| 301 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 302 | return new CompilerNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data) |
| 306 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 307 | return new ShaderNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data) |
| 311 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 312 | return new ProgramNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data) |
| 316 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 317 | return new FramebufferNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | TextureImpl *ContextNULL::createTexture(const gl::TextureState &state) |
| 321 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 322 | return new TextureNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | RenderbufferImpl *ContextNULL::createRenderbuffer() |
| 326 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 327 | return new RenderbufferNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 328 | } |
| 329 | |
Jamie Madill | 8f77560 | 2016-11-03 16:45:34 -0400 | [diff] [blame] | 330 | BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 331 | { |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame] | 332 | return new BufferNULL(state, mAllocationTracker); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data) |
| 336 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 337 | return new VertexArrayNULL(data); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | QueryImpl *ContextNULL::createQuery(GLenum type) |
| 341 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 342 | return new QueryNULL(type); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | FenceNVImpl *ContextNULL::createFenceNV() |
| 346 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 347 | return new FenceNVNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | FenceSyncImpl *ContextNULL::createFenceSync() |
| 351 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 352 | return new FenceSyncNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state) |
| 356 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 357 | return new TransformFeedbackNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | SamplerImpl *ContextNULL::createSampler() |
| 361 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 362 | return new SamplerNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range) |
| 366 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 367 | std::vector<PathImpl *> result(range); |
| 368 | for (GLsizei idx = 0; idx < range; idx++) |
| 369 | { |
| 370 | result[idx] = new PathNULL(); |
| 371 | } |
| 372 | return result; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 373 | } |
| 374 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 375 | gl::Error ContextNULL::dispatchCompute(const gl::Context *context, |
| 376 | GLuint numGroupsX, |
| 377 | GLuint numGroupsY, |
| 378 | GLuint numGroupsZ) |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 379 | { |
| 380 | return gl::NoError(); |
| 381 | } |
| 382 | |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 383 | } // namespace rx |