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