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