Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 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 | |
| 7 | // RendererGL.cpp: Implements the class methods for RendererGL. |
| 8 | |
| 9 | #include "libANGLE/renderer/gl/RendererGL.h" |
| 10 | |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 11 | #include <EGL/eglext.h> |
| 12 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 13 | #include "common/debug.h" |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 14 | #include "libANGLE/AttributeMap.h" |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 15 | #include "libANGLE/Context.h" |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 16 | #include "libANGLE/ContextState.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 17 | #include "libANGLE/Path.h" |
Geoff Lang | 4ad1709 | 2015-03-10 16:47:44 -0400 | [diff] [blame] | 18 | #include "libANGLE/Surface.h" |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 19 | #include "libANGLE/renderer/gl/BlitGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 20 | #include "libANGLE/renderer/gl/BufferGL.h" |
Martin Radev | 5e424fa | 2017-08-09 16:25:36 +0300 | [diff] [blame] | 21 | #include "libANGLE/renderer/gl/ClearMultiviewGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 22 | #include "libANGLE/renderer/gl/CompilerGL.h" |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 23 | #include "libANGLE/renderer/gl/ContextGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 24 | #include "libANGLE/renderer/gl/FenceNVGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 25 | #include "libANGLE/renderer/gl/FramebufferGL.h" |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 26 | #include "libANGLE/renderer/gl/FunctionsGL.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 27 | #include "libANGLE/renderer/gl/PathGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 28 | #include "libANGLE/renderer/gl/ProgramGL.h" |
| 29 | #include "libANGLE/renderer/gl/QueryGL.h" |
| 30 | #include "libANGLE/renderer/gl/RenderbufferGL.h" |
Geoff Lang | 0af0b81 | 2015-09-23 13:56:25 -0400 | [diff] [blame] | 31 | #include "libANGLE/renderer/gl/SamplerGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 32 | #include "libANGLE/renderer/gl/ShaderGL.h" |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 33 | #include "libANGLE/renderer/gl/StateManagerGL.h" |
Geoff Lang | 4ad1709 | 2015-03-10 16:47:44 -0400 | [diff] [blame] | 34 | #include "libANGLE/renderer/gl/SurfaceGL.h" |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 35 | #include "libANGLE/renderer/gl/SyncGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 36 | #include "libANGLE/renderer/gl/TextureGL.h" |
| 37 | #include "libANGLE/renderer/gl/TransformFeedbackGL.h" |
| 38 | #include "libANGLE/renderer/gl/VertexArrayGL.h" |
Geoff Lang | ddc7446 | 2015-02-25 11:48:09 -0500 | [diff] [blame] | 39 | #include "libANGLE/renderer/gl/renderergl_utils.h" |
Jamie Madill | 222c517 | 2017-07-19 16:15:42 -0400 | [diff] [blame] | 40 | #include "libANGLE/renderer/renderer_utils.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 41 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 42 | namespace |
| 43 | { |
| 44 | |
| 45 | std::vector<GLuint> GatherPaths(const std::vector<gl::Path *> &paths) |
| 46 | { |
| 47 | std::vector<GLuint> ret; |
| 48 | ret.reserve(paths.size()); |
| 49 | |
| 50 | for (const auto *p : paths) |
| 51 | { |
| 52 | const auto *pathObj = rx::GetImplAs<rx::PathGL>(p); |
| 53 | ret.push_back(pathObj->getPathID()); |
| 54 | } |
| 55 | return ret; |
| 56 | } |
| 57 | |
| 58 | } // namespace |
| 59 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 60 | static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source, |
| 61 | GLenum type, |
| 62 | GLuint id, |
| 63 | GLenum severity, |
| 64 | GLsizei length, |
| 65 | const GLchar *message, |
| 66 | const void *userParam) |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 67 | { |
Geoff Lang | 7c37ca1 | 2017-09-26 16:56:32 -0400 | [diff] [blame] | 68 | ASSERT(userParam != nullptr); |
| 69 | rx::RendererGL *renderer = static_cast<rx::RendererGL *>(const_cast<void *>(userParam)); |
| 70 | renderer->onDebugMessage(source, type, id, severity, length, message); |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 71 | } |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 72 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 73 | namespace rx |
| 74 | { |
| 75 | |
Geoff Lang | 5da6690 | 2018-06-05 12:24:06 -0400 | [diff] [blame] | 76 | RendererGL::RendererGL(std::unique_ptr<FunctionsGL> functions, const egl::AttributeMap &attribMap) |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 77 | : mMaxSupportedESVersion(0, 0), |
Geoff Lang | 5da6690 | 2018-06-05 12:24:06 -0400 | [diff] [blame] | 78 | mFunctions(std::move(functions)), |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 79 | mStateManager(nullptr), |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 80 | mBlitter(nullptr), |
Martin Radev | 5e424fa | 2017-08-09 16:25:36 +0300 | [diff] [blame] | 81 | mMultiviewClearer(nullptr), |
Jamie Madill | 222c517 | 2017-07-19 16:15:42 -0400 | [diff] [blame] | 82 | mUseDebugOutput(false), |
Martin Radev | 318f9aa | 2017-05-17 17:47:28 +0300 | [diff] [blame] | 83 | mCapsInitialized(false), |
| 84 | mMultiviewImplementationType(MultiviewImplementationTypeGL::UNSPECIFIED) |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 85 | { |
| 86 | ASSERT(mFunctions); |
Geoff Lang | 5da6690 | 2018-06-05 12:24:06 -0400 | [diff] [blame] | 87 | nativegl_gl::GenerateWorkarounds(mFunctions.get(), &mWorkarounds); |
| 88 | mStateManager = new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions()); |
| 89 | mBlitter = new BlitGL(mFunctions.get(), mWorkarounds, mStateManager); |
| 90 | mMultiviewClearer = new ClearMultiviewGL(mFunctions.get(), mStateManager); |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 91 | |
Jamie Madill | 222c517 | 2017-07-19 16:15:42 -0400 | [diff] [blame] | 92 | bool hasDebugOutput = mFunctions->isAtLeastGL(gl::Version(4, 3)) || |
| 93 | mFunctions->hasGLExtension("GL_KHR_debug") || |
| 94 | mFunctions->isAtLeastGLES(gl::Version(3, 2)) || |
| 95 | mFunctions->hasGLESExtension("GL_KHR_debug"); |
| 96 | |
| 97 | mUseDebugOutput = hasDebugOutput && ShouldUseDebugLayers(attribMap); |
| 98 | |
| 99 | if (mUseDebugOutput) |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 100 | { |
Corentin Wallez | 930fefc | 2016-09-14 15:54:18 -0400 | [diff] [blame] | 101 | mFunctions->enable(GL_DEBUG_OUTPUT); |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 102 | mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 103 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, |
| 104 | nullptr, GL_TRUE); |
| 105 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, |
| 106 | nullptr, GL_TRUE); |
| 107 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, 0, |
| 108 | nullptr, GL_FALSE); |
| 109 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, |
| 110 | 0, nullptr, GL_FALSE); |
Geoff Lang | 7c37ca1 | 2017-09-26 16:56:32 -0400 | [diff] [blame] | 111 | mFunctions->debugMessageCallback(&LogGLDebugMessage, this); |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 112 | } |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 113 | |
Corentin Wallez | 8314465 | 2016-08-31 17:03:30 -0400 | [diff] [blame] | 114 | if (mWorkarounds.initializeCurrentVertexAttributes) |
| 115 | { |
| 116 | GLint maxVertexAttribs = 0; |
| 117 | mFunctions->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); |
| 118 | |
| 119 | for (GLint i = 0; i < maxVertexAttribs; ++i) |
| 120 | { |
| 121 | mFunctions->vertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 1.0f); |
| 122 | } |
| 123 | } |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 124 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 125 | |
| 126 | RendererGL::~RendererGL() |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 127 | { |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 128 | SafeDelete(mBlitter); |
Martin Radev | 5e424fa | 2017-08-09 16:25:36 +0300 | [diff] [blame] | 129 | SafeDelete(mMultiviewClearer); |
Geoff Lang | bf8a72f | 2015-11-03 16:34:45 -0500 | [diff] [blame] | 130 | SafeDelete(mStateManager); |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 131 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 132 | |
| 133 | gl::Error RendererGL::flush() |
| 134 | { |
Geoff Lang | 2c91914 | 2015-04-01 14:44:13 -0400 | [diff] [blame] | 135 | mFunctions->flush(); |
He Yunchao | acd1898 | 2017-01-04 10:46:42 +0800 | [diff] [blame] | 136 | return gl::NoError(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | gl::Error RendererGL::finish() |
| 140 | { |
Jamie Madill | 222c517 | 2017-07-19 16:15:42 -0400 | [diff] [blame] | 141 | if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mUseDebugOutput) |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 142 | { |
| 143 | mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
| 144 | } |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 145 | |
Geoff Lang | 2c91914 | 2015-04-01 14:44:13 -0400 | [diff] [blame] | 146 | mFunctions->finish(); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 147 | |
Jamie Madill | 222c517 | 2017-07-19 16:15:42 -0400 | [diff] [blame] | 148 | if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mUseDebugOutput) |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 149 | { |
| 150 | mFunctions->disable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
| 151 | } |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 152 | |
He Yunchao | acd1898 | 2017-01-04 10:46:42 +0800 | [diff] [blame] | 153 | return gl::NoError(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 154 | } |
| 155 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 156 | gl::Error RendererGL::drawArrays(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 157 | gl::PrimitiveMode mode, |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 158 | GLint first, |
| 159 | GLsizei count) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 160 | { |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 161 | const gl::Program *program = context->getGLState().getProgram(); |
| 162 | const bool usesMultiview = program->usesMultiview(); |
| 163 | const GLsizei instanceCount = usesMultiview ? program->getNumViews() : 0; |
Geoff Lang | 7c82bc4 | 2015-03-09 16:18:08 -0400 | [diff] [blame] | 164 | |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 165 | ANGLE_TRY(mStateManager->setDrawArraysState(context, first, count, instanceCount)); |
Jamie Madill | 6d94f06 | 2017-10-21 22:19:40 -0400 | [diff] [blame] | 166 | if (!usesMultiview) |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 167 | { |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 168 | mFunctions->drawArrays(ToGLenum(mode), first, count); |
Jamie Madill | 6d94f06 | 2017-10-21 22:19:40 -0400 | [diff] [blame] | 169 | } |
| 170 | else |
| 171 | { |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 172 | mFunctions->drawArraysInstanced(ToGLenum(mode), first, count, instanceCount); |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 173 | } |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 174 | return gl::NoError(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 175 | } |
| 176 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 177 | gl::Error RendererGL::drawArraysInstanced(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 178 | gl::PrimitiveMode mode, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 179 | GLint first, |
| 180 | GLsizei count, |
| 181 | GLsizei instanceCount) |
| 182 | { |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 183 | GLsizei adjustedInstanceCount = instanceCount; |
| 184 | const gl::Program *program = context->getGLState().getProgram(); |
| 185 | if (program->usesMultiview()) |
Geoff Lang | 3cf12ce | 2015-08-27 14:40:48 -0400 | [diff] [blame] | 186 | { |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 187 | adjustedInstanceCount *= program->getNumViews(); |
Geoff Lang | 3cf12ce | 2015-08-27 14:40:48 -0400 | [diff] [blame] | 188 | } |
| 189 | |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 190 | ANGLE_TRY(mStateManager->setDrawArraysState(context, first, count, adjustedInstanceCount)); |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 191 | mFunctions->drawArraysInstanced(ToGLenum(mode), first, count, adjustedInstanceCount); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 192 | return gl::NoError(); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 193 | } |
| 194 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 195 | gl::Error RendererGL::drawElements(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 196 | gl::PrimitiveMode mode, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 197 | GLsizei count, |
| 198 | GLenum type, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 199 | const void *indices) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 200 | { |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 201 | const gl::Program *program = context->getGLState().getProgram(); |
| 202 | const bool usesMultiview = program->usesMultiview(); |
| 203 | const GLsizei instanceCount = usesMultiview ? program->getNumViews() : 0; |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 204 | const void *drawIndexPtr = nullptr; |
Geoff Lang | 7c82bc4 | 2015-03-09 16:18:08 -0400 | [diff] [blame] | 205 | |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 206 | ANGLE_TRY(mStateManager->setDrawElementsState(context, count, type, indices, instanceCount, |
| 207 | &drawIndexPtr)); |
Jamie Madill | 6d94f06 | 2017-10-21 22:19:40 -0400 | [diff] [blame] | 208 | if (!usesMultiview) |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 209 | { |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 210 | mFunctions->drawElements(ToGLenum(mode), count, type, drawIndexPtr); |
Jamie Madill | 6d94f06 | 2017-10-21 22:19:40 -0400 | [diff] [blame] | 211 | } |
| 212 | else |
| 213 | { |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 214 | mFunctions->drawElementsInstanced(ToGLenum(mode), count, type, drawIndexPtr, instanceCount); |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 215 | } |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 216 | return gl::NoError(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 217 | } |
| 218 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 219 | gl::Error RendererGL::drawElementsInstanced(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 220 | gl::PrimitiveMode mode, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 221 | GLsizei count, |
| 222 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 223 | const void *indices, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 224 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 225 | { |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 226 | GLsizei adjustedInstanceCount = instances; |
| 227 | const gl::Program *program = context->getGLState().getProgram(); |
| 228 | if (program->usesMultiview()) |
| 229 | { |
| 230 | adjustedInstanceCount *= program->getNumViews(); |
| 231 | } |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 232 | const void *drawIndexPointer = nullptr; |
Geoff Lang | 3cf12ce | 2015-08-27 14:40:48 -0400 | [diff] [blame] | 233 | |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 234 | ANGLE_TRY(mStateManager->setDrawElementsState(context, count, type, indices, |
| 235 | adjustedInstanceCount, &drawIndexPointer)); |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 236 | mFunctions->drawElementsInstanced(ToGLenum(mode), count, type, drawIndexPointer, |
| 237 | adjustedInstanceCount); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 238 | return gl::NoError(); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 239 | } |
| 240 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 241 | gl::Error RendererGL::drawRangeElements(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 242 | gl::PrimitiveMode mode, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 243 | GLuint start, |
| 244 | GLuint end, |
| 245 | GLsizei count, |
| 246 | GLenum type, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 247 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 248 | { |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 249 | const gl::Program *program = context->getGLState().getProgram(); |
| 250 | const bool usesMultiview = program->usesMultiview(); |
| 251 | const GLsizei instanceCount = usesMultiview ? program->getNumViews() : 0; |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 252 | const void *drawIndexPointer = nullptr; |
Geoff Lang | 4750223 | 2015-08-25 16:26:10 -0400 | [diff] [blame] | 253 | |
Martin Radev | 8f276e2 | 2017-05-30 12:05:52 +0300 | [diff] [blame] | 254 | ANGLE_TRY(mStateManager->setDrawElementsState(context, count, type, indices, instanceCount, |
| 255 | &drawIndexPointer)); |
Jamie Madill | 6d94f06 | 2017-10-21 22:19:40 -0400 | [diff] [blame] | 256 | if (!usesMultiview) |
Geoff Lang | 4750223 | 2015-08-25 16:26:10 -0400 | [diff] [blame] | 257 | { |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 258 | mFunctions->drawRangeElements(ToGLenum(mode), start, end, count, type, drawIndexPointer); |
Jamie Madill | 6d94f06 | 2017-10-21 22:19:40 -0400 | [diff] [blame] | 259 | } |
| 260 | else |
| 261 | { |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 262 | mFunctions->drawElementsInstanced(ToGLenum(mode), count, type, drawIndexPointer, |
| 263 | instanceCount); |
Geoff Lang | 4750223 | 2015-08-25 16:26:10 -0400 | [diff] [blame] | 264 | } |
He Yunchao | acd1898 | 2017-01-04 10:46:42 +0800 | [diff] [blame] | 265 | return gl::NoError(); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 266 | } |
| 267 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 268 | gl::Error RendererGL::drawArraysIndirect(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 269 | gl::PrimitiveMode mode, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 270 | const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 271 | { |
Jiajia Qin | 4747414 | 2017-12-29 13:41:00 +0800 | [diff] [blame] | 272 | ANGLE_TRY(mStateManager->setDrawIndirectState(context)); |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 273 | mFunctions->drawArraysIndirect(ToGLenum(mode), indirect); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 274 | return gl::NoError(); |
| 275 | } |
| 276 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 277 | gl::Error RendererGL::drawElementsIndirect(const gl::Context *context, |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 278 | gl::PrimitiveMode mode, |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 279 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 280 | const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 281 | { |
Jiajia Qin | 4747414 | 2017-12-29 13:41:00 +0800 | [diff] [blame] | 282 | ANGLE_TRY(mStateManager->setDrawIndirectState(context)); |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 283 | mFunctions->drawElementsIndirect(ToGLenum(mode), type, indirect); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 284 | return gl::NoError(); |
| 285 | } |
| 286 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 287 | void RendererGL::stencilFillPath(const gl::ContextState &state, |
| 288 | const gl::Path *path, |
| 289 | GLenum fillMode, |
| 290 | GLuint mask) |
| 291 | { |
| 292 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 293 | |
| 294 | mFunctions->stencilFillPathNV(pathObj->getPathID(), fillMode, mask); |
| 295 | |
| 296 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 297 | } |
| 298 | |
| 299 | void RendererGL::stencilStrokePath(const gl::ContextState &state, |
| 300 | const gl::Path *path, |
| 301 | GLint reference, |
| 302 | GLuint mask) |
| 303 | { |
| 304 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 305 | |
| 306 | mFunctions->stencilStrokePathNV(pathObj->getPathID(), reference, mask); |
| 307 | |
| 308 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 309 | } |
| 310 | |
| 311 | void RendererGL::coverFillPath(const gl::ContextState &state, |
| 312 | const gl::Path *path, |
| 313 | GLenum coverMode) |
| 314 | { |
| 315 | |
| 316 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 317 | mFunctions->coverFillPathNV(pathObj->getPathID(), coverMode); |
| 318 | |
| 319 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 320 | } |
| 321 | |
| 322 | void RendererGL::coverStrokePath(const gl::ContextState &state, |
| 323 | const gl::Path *path, |
| 324 | GLenum coverMode) |
| 325 | { |
| 326 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 327 | mFunctions->coverStrokePathNV(pathObj->getPathID(), coverMode); |
| 328 | |
| 329 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 330 | } |
| 331 | |
| 332 | void RendererGL::stencilThenCoverFillPath(const gl::ContextState &state, |
| 333 | const gl::Path *path, |
| 334 | GLenum fillMode, |
| 335 | GLuint mask, |
| 336 | GLenum coverMode) |
| 337 | { |
| 338 | |
| 339 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 340 | mFunctions->stencilThenCoverFillPathNV(pathObj->getPathID(), fillMode, mask, coverMode); |
| 341 | |
| 342 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 343 | } |
| 344 | |
| 345 | void RendererGL::stencilThenCoverStrokePath(const gl::ContextState &state, |
| 346 | const gl::Path *path, |
| 347 | GLint reference, |
| 348 | GLuint mask, |
| 349 | GLenum coverMode) |
| 350 | { |
| 351 | |
| 352 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 353 | mFunctions->stencilThenCoverStrokePathNV(pathObj->getPathID(), reference, mask, coverMode); |
| 354 | |
| 355 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 356 | } |
| 357 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 358 | void RendererGL::coverFillPathInstanced(const gl::ContextState &state, |
| 359 | const std::vector<gl::Path *> &paths, |
| 360 | GLenum coverMode, |
| 361 | GLenum transformType, |
| 362 | const GLfloat *transformValues) |
| 363 | { |
| 364 | const auto &pathObjs = GatherPaths(paths); |
| 365 | |
| 366 | mFunctions->coverFillPathInstancedNV(static_cast<GLsizei>(pathObjs.size()), GL_UNSIGNED_INT, |
| 367 | &pathObjs[0], 0, coverMode, transformType, |
| 368 | transformValues); |
| 369 | |
| 370 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 371 | } |
| 372 | void RendererGL::coverStrokePathInstanced(const gl::ContextState &state, |
| 373 | const std::vector<gl::Path *> &paths, |
| 374 | GLenum coverMode, |
| 375 | GLenum transformType, |
| 376 | const GLfloat *transformValues) |
| 377 | { |
| 378 | const auto &pathObjs = GatherPaths(paths); |
| 379 | |
| 380 | mFunctions->coverStrokePathInstancedNV(static_cast<GLsizei>(pathObjs.size()), GL_UNSIGNED_INT, |
| 381 | &pathObjs[0], 0, coverMode, transformType, |
| 382 | transformValues); |
| 383 | |
| 384 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 385 | } |
| 386 | void RendererGL::stencilFillPathInstanced(const gl::ContextState &state, |
| 387 | const std::vector<gl::Path *> &paths, |
| 388 | GLenum fillMode, |
| 389 | GLuint mask, |
| 390 | GLenum transformType, |
| 391 | const GLfloat *transformValues) |
| 392 | { |
| 393 | const auto &pathObjs = GatherPaths(paths); |
| 394 | |
| 395 | mFunctions->stencilFillPathInstancedNV(static_cast<GLsizei>(pathObjs.size()), GL_UNSIGNED_INT, |
| 396 | &pathObjs[0], 0, fillMode, mask, transformType, |
| 397 | transformValues); |
| 398 | |
| 399 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 400 | } |
| 401 | void RendererGL::stencilStrokePathInstanced(const gl::ContextState &state, |
| 402 | const std::vector<gl::Path *> &paths, |
| 403 | GLint reference, |
| 404 | GLuint mask, |
| 405 | GLenum transformType, |
| 406 | const GLfloat *transformValues) |
| 407 | { |
| 408 | const auto &pathObjs = GatherPaths(paths); |
| 409 | |
| 410 | mFunctions->stencilStrokePathInstancedNV(static_cast<GLsizei>(pathObjs.size()), GL_UNSIGNED_INT, |
| 411 | &pathObjs[0], 0, reference, mask, transformType, |
| 412 | transformValues); |
| 413 | |
| 414 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 415 | } |
| 416 | |
| 417 | void RendererGL::stencilThenCoverFillPathInstanced(const gl::ContextState &state, |
| 418 | const std::vector<gl::Path *> &paths, |
| 419 | GLenum coverMode, |
| 420 | GLenum fillMode, |
| 421 | GLuint mask, |
| 422 | GLenum transformType, |
| 423 | const GLfloat *transformValues) |
| 424 | { |
| 425 | const auto &pathObjs = GatherPaths(paths); |
| 426 | |
| 427 | mFunctions->stencilThenCoverFillPathInstancedNV( |
| 428 | static_cast<GLsizei>(pathObjs.size()), GL_UNSIGNED_INT, &pathObjs[0], 0, fillMode, mask, |
| 429 | coverMode, transformType, transformValues); |
| 430 | |
| 431 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 432 | } |
| 433 | void RendererGL::stencilThenCoverStrokePathInstanced(const gl::ContextState &state, |
| 434 | const std::vector<gl::Path *> &paths, |
| 435 | GLenum coverMode, |
| 436 | GLint reference, |
| 437 | GLuint mask, |
| 438 | GLenum transformType, |
| 439 | const GLfloat *transformValues) |
| 440 | { |
| 441 | const auto &pathObjs = GatherPaths(paths); |
| 442 | |
| 443 | mFunctions->stencilThenCoverStrokePathInstancedNV( |
| 444 | static_cast<GLsizei>(pathObjs.size()), GL_UNSIGNED_INT, &pathObjs[0], 0, reference, mask, |
| 445 | coverMode, transformType, transformValues); |
| 446 | |
| 447 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 448 | } |
| 449 | |
Corentin Wallez | b920e36 | 2016-08-03 18:19:41 -0400 | [diff] [blame] | 450 | GLenum RendererGL::getResetStatus() |
| 451 | { |
| 452 | return mFunctions->getGraphicsResetStatus(); |
| 453 | } |
| 454 | |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 455 | void RendererGL::insertEventMarker(GLsizei length, const char *marker) |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 456 | { |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 459 | void RendererGL::pushGroupMarker(GLsizei length, const char *marker) |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 460 | { |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | void RendererGL::popGroupMarker() |
| 464 | { |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | void RendererGL::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) |
| 468 | { |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | void RendererGL::popDebugGroup() |
| 472 | { |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 475 | std::string RendererGL::getVendorString() const |
| 476 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 477 | return std::string(reinterpret_cast<const char *>(mFunctions->getString(GL_VENDOR))); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | std::string RendererGL::getRendererDescription() const |
| 481 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 482 | std::string nativeVendorString( |
| 483 | reinterpret_cast<const char *>(mFunctions->getString(GL_VENDOR))); |
| 484 | std::string nativeRendererString( |
| 485 | reinterpret_cast<const char *>(mFunctions->getString(GL_RENDERER))); |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 486 | |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 487 | std::ostringstream rendererString; |
| 488 | rendererString << nativeVendorString << " " << nativeRendererString << " OpenGL"; |
Geoff Lang | 08dcfed | 2015-05-25 13:38:42 -0400 | [diff] [blame] | 489 | if (mFunctions->standard == STANDARD_GL_ES) |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 490 | { |
| 491 | rendererString << " ES"; |
| 492 | } |
Geoff Lang | 08dcfed | 2015-05-25 13:38:42 -0400 | [diff] [blame] | 493 | rendererString << " " << mFunctions->version.major << "." << mFunctions->version.minor; |
Geoff Lang | 8b0f0b3 | 2015-07-20 15:59:28 -0400 | [diff] [blame] | 494 | if (mFunctions->standard == STANDARD_GL_DESKTOP) |
| 495 | { |
| 496 | // Some drivers (NVIDIA) use a profile mask of 0 when in compatibility profile. |
| 497 | if ((mFunctions->profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0 || |
| 498 | (mFunctions->isAtLeastGL(gl::Version(3, 2)) && mFunctions->profile == 0)) |
| 499 | { |
| 500 | rendererString << " compatibility"; |
| 501 | } |
| 502 | else if ((mFunctions->profile & GL_CONTEXT_CORE_PROFILE_BIT) != 0) |
| 503 | { |
| 504 | rendererString << " core"; |
| 505 | } |
| 506 | } |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 507 | |
| 508 | return rendererString.str(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 509 | } |
| 510 | |
Geoff Lang | 862c0ba | 2015-05-25 15:31:16 -0400 | [diff] [blame] | 511 | const gl::Version &RendererGL::getMaxSupportedESVersion() const |
| 512 | { |
| 513 | // Force generation of caps |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 514 | getNativeCaps(); |
Geoff Lang | 862c0ba | 2015-05-25 15:31:16 -0400 | [diff] [blame] | 515 | |
| 516 | return mMaxSupportedESVersion; |
| 517 | } |
| 518 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 519 | void RendererGL::generateCaps(gl::Caps *outCaps, |
| 520 | gl::TextureCapsMap *outTextureCaps, |
Austin Kinross | 02df796 | 2015-07-01 10:03:42 -0700 | [diff] [blame] | 521 | gl::Extensions *outExtensions, |
| 522 | gl::Limitations * /* outLimitations */) const |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 523 | { |
Geoff Lang | 5da6690 | 2018-06-05 12:24:06 -0400 | [diff] [blame] | 524 | nativegl_gl::GenerateCaps(mFunctions.get(), mWorkarounds, outCaps, outTextureCaps, |
| 525 | outExtensions, &mMaxSupportedESVersion, |
| 526 | &mMultiviewImplementationType); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 527 | } |
| 528 | |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 529 | GLint RendererGL::getGPUDisjoint() |
| 530 | { |
| 531 | // TODO(ewell): On GLES backends we should find a way to reliably query disjoint events |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | GLint64 RendererGL::getTimestamp() |
| 536 | { |
| 537 | GLint64 result = 0; |
| 538 | mFunctions->getInteger64v(GL_TIMESTAMP, &result); |
| 539 | return result; |
| 540 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 541 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 542 | void RendererGL::ensureCapsInitialized() const |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 543 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 544 | if (!mCapsInitialized) |
| 545 | { |
| 546 | generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations); |
| 547 | mCapsInitialized = true; |
| 548 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 549 | } |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 550 | |
| 551 | const gl::Caps &RendererGL::getNativeCaps() const |
| 552 | { |
| 553 | ensureCapsInitialized(); |
| 554 | return mNativeCaps; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 555 | } |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 556 | |
| 557 | const gl::TextureCapsMap &RendererGL::getNativeTextureCaps() const |
| 558 | { |
| 559 | ensureCapsInitialized(); |
| 560 | return mNativeTextureCaps; |
| 561 | } |
| 562 | |
| 563 | const gl::Extensions &RendererGL::getNativeExtensions() const |
| 564 | { |
| 565 | ensureCapsInitialized(); |
| 566 | return mNativeExtensions; |
| 567 | } |
| 568 | |
| 569 | const gl::Limitations &RendererGL::getNativeLimitations() const |
| 570 | { |
| 571 | ensureCapsInitialized(); |
| 572 | return mNativeLimitations; |
| 573 | } |
| 574 | |
Martin Radev | 318f9aa | 2017-05-17 17:47:28 +0300 | [diff] [blame] | 575 | MultiviewImplementationTypeGL RendererGL::getMultiviewImplementationType() const |
| 576 | { |
| 577 | ensureCapsInitialized(); |
| 578 | return mMultiviewImplementationType; |
| 579 | } |
| 580 | |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 581 | void RendererGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const |
| 582 | { |
| 583 | ensureCapsInitialized(); |
Geoff Lang | 5da6690 | 2018-06-05 12:24:06 -0400 | [diff] [blame] | 584 | nativegl_gl::ApplyWorkarounds(mFunctions.get(), workarounds); |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 585 | } |
| 586 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 587 | gl::Error RendererGL::dispatchCompute(const gl::Context *context, |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 588 | GLuint numGroupsX, |
| 589 | GLuint numGroupsY, |
| 590 | GLuint numGroupsZ) |
| 591 | { |
Jiajia Qin | 5b6b9c6 | 2017-12-25 16:10:51 +0800 | [diff] [blame] | 592 | ANGLE_TRY(mStateManager->setDispatchComputeState(context)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 593 | mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ); |
| 594 | return gl::NoError(); |
| 595 | } |
| 596 | |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 597 | gl::Error RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) |
| 598 | { |
Jiajia Qin | 5b6b9c6 | 2017-12-25 16:10:51 +0800 | [diff] [blame] | 599 | ANGLE_TRY(mStateManager->setDispatchComputeState(context)); |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 600 | mFunctions->dispatchComputeIndirect(indirect); |
| 601 | return gl::NoError(); |
| 602 | } |
| 603 | |
Xinghua Cao | 89c422a | 2017-11-29 18:24:20 +0800 | [diff] [blame] | 604 | gl::Error RendererGL::memoryBarrier(GLbitfield barriers) |
| 605 | { |
| 606 | mFunctions->memoryBarrier(barriers); |
| 607 | return gl::NoError(); |
| 608 | } |
| 609 | gl::Error RendererGL::memoryBarrierByRegion(GLbitfield barriers) |
| 610 | { |
| 611 | mFunctions->memoryBarrierByRegion(barriers); |
| 612 | return gl::NoError(); |
| 613 | } |
| 614 | |
Geoff Lang | 7c37ca1 | 2017-09-26 16:56:32 -0400 | [diff] [blame] | 615 | void RendererGL::onDebugMessage(GLenum source, |
| 616 | GLenum type, |
| 617 | GLuint id, |
| 618 | GLenum severity, |
| 619 | GLsizei length, |
| 620 | const GLchar *message) |
| 621 | { |
| 622 | constexpr size_t kMaxDebugMessagesPerNonErrorType = 5; |
| 623 | const std::string formattedMessage = |
| 624 | nativegl::FormatDebugMessage(source, type, id, severity, length, message); |
| 625 | if (type == GL_DEBUG_TYPE_ERROR) |
| 626 | { |
| 627 | ERR() << std::endl << formattedMessage; |
| 628 | } |
| 629 | else if (mDebugMessageCounts[id] < kMaxDebugMessagesPerNonErrorType) |
| 630 | { |
| 631 | // TODO(ynovikov): filter into WARN and INFO if INFO is ever implemented |
| 632 | WARN() << std::endl << formattedMessage; |
| 633 | } |
| 634 | |
| 635 | mDebugMessageCounts[id]++; |
| 636 | } |
| 637 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 638 | } // namespace rx |