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