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" |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 15 | #include "libANGLE/ContextState.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame^] | 16 | #include "libANGLE/Path.h" |
Geoff Lang | 4ad1709 | 2015-03-10 16:47:44 -0400 | [diff] [blame] | 17 | #include "libANGLE/Surface.h" |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 18 | #include "libANGLE/renderer/gl/BlitGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 19 | #include "libANGLE/renderer/gl/BufferGL.h" |
| 20 | #include "libANGLE/renderer/gl/CompilerGL.h" |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 21 | #include "libANGLE/renderer/gl/ContextGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 22 | #include "libANGLE/renderer/gl/FenceNVGL.h" |
| 23 | #include "libANGLE/renderer/gl/FenceSyncGL.h" |
| 24 | #include "libANGLE/renderer/gl/FramebufferGL.h" |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 25 | #include "libANGLE/renderer/gl/FunctionsGL.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame^] | 26 | #include "libANGLE/renderer/gl/PathGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 27 | #include "libANGLE/renderer/gl/ProgramGL.h" |
| 28 | #include "libANGLE/renderer/gl/QueryGL.h" |
| 29 | #include "libANGLE/renderer/gl/RenderbufferGL.h" |
Geoff Lang | 0af0b81 | 2015-09-23 13:56:25 -0400 | [diff] [blame] | 30 | #include "libANGLE/renderer/gl/SamplerGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 31 | #include "libANGLE/renderer/gl/ShaderGL.h" |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 32 | #include "libANGLE/renderer/gl/StateManagerGL.h" |
Geoff Lang | 4ad1709 | 2015-03-10 16:47:44 -0400 | [diff] [blame] | 33 | #include "libANGLE/renderer/gl/SurfaceGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 34 | #include "libANGLE/renderer/gl/TextureGL.h" |
| 35 | #include "libANGLE/renderer/gl/TransformFeedbackGL.h" |
| 36 | #include "libANGLE/renderer/gl/VertexArrayGL.h" |
Geoff Lang | ddc7446 | 2015-02-25 11:48:09 -0500 | [diff] [blame] | 37 | #include "libANGLE/renderer/gl/renderergl_utils.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 38 | |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 39 | #ifndef NDEBUG |
| 40 | static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, |
| 41 | const GLchar *message, const void *userParam) |
| 42 | { |
| 43 | std::string sourceText; |
| 44 | switch (source) |
| 45 | { |
| 46 | case GL_DEBUG_SOURCE_API: sourceText = "OpenGL"; break; |
| 47 | case GL_DEBUG_SOURCE_WINDOW_SYSTEM: sourceText = "Windows"; break; |
| 48 | case GL_DEBUG_SOURCE_SHADER_COMPILER: sourceText = "Shader Compiler"; break; |
| 49 | case GL_DEBUG_SOURCE_THIRD_PARTY: sourceText = "Third Party"; break; |
| 50 | case GL_DEBUG_SOURCE_APPLICATION: sourceText = "Application"; break; |
| 51 | case GL_DEBUG_SOURCE_OTHER: sourceText = "Other"; break; |
| 52 | default: sourceText = "UNKNOWN"; break; |
| 53 | } |
| 54 | |
| 55 | std::string typeText; |
| 56 | switch (type) |
| 57 | { |
| 58 | case GL_DEBUG_TYPE_ERROR: typeText = "Error"; break; |
| 59 | case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: typeText = "Deprecated behavior"; break; |
| 60 | case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: typeText = "Undefined behavior"; break; |
| 61 | case GL_DEBUG_TYPE_PORTABILITY: typeText = "Portability"; break; |
| 62 | case GL_DEBUG_TYPE_PERFORMANCE: typeText = "Performance"; break; |
| 63 | case GL_DEBUG_TYPE_OTHER: typeText = "Other"; break; |
| 64 | case GL_DEBUG_TYPE_MARKER: typeText = "Marker"; break; |
| 65 | default: typeText = "UNKNOWN"; break; |
| 66 | } |
| 67 | |
| 68 | std::string severityText; |
| 69 | switch (severity) |
| 70 | { |
| 71 | case GL_DEBUG_SEVERITY_HIGH: severityText = "High"; break; |
| 72 | case GL_DEBUG_SEVERITY_MEDIUM: severityText = "Medium"; break; |
| 73 | case GL_DEBUG_SEVERITY_LOW: severityText = "Low"; break; |
| 74 | case GL_DEBUG_SEVERITY_NOTIFICATION: severityText = "Notification"; break; |
| 75 | default: severityText = "UNKNOWN"; break; |
| 76 | } |
| 77 | |
| 78 | ERR("\n\tSource: %s\n\tType: %s\n\tID: %d\n\tSeverity: %s\n\tMessage: %s", sourceText.c_str(), typeText.c_str(), id, |
| 79 | severityText.c_str(), message); |
| 80 | } |
| 81 | #endif |
| 82 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 83 | namespace rx |
| 84 | { |
| 85 | |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 86 | RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &attribMap) |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 87 | : mMaxSupportedESVersion(0, 0), |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 88 | mFunctions(functions), |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 89 | mStateManager(nullptr), |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 90 | mBlitter(nullptr), |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 91 | mHasDebugOutput(false), |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 92 | mSkipDrawCalls(false), |
| 93 | mCapsInitialized(false) |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 94 | { |
| 95 | ASSERT(mFunctions); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 96 | mStateManager = new StateManagerGL(mFunctions, getNativeCaps()); |
Geoff Lang | cab7e1d | 2015-07-27 11:20:41 -0400 | [diff] [blame] | 97 | nativegl_gl::GenerateWorkarounds(mFunctions, &mWorkarounds); |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 98 | mBlitter = new BlitGL(functions, mWorkarounds, mStateManager); |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 99 | |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 100 | mHasDebugOutput = mFunctions->isAtLeastGL(gl::Version(4, 3)) || |
| 101 | mFunctions->hasGLExtension("GL_KHR_debug") || |
| 102 | mFunctions->isAtLeastGLES(gl::Version(3, 2)) || |
| 103 | mFunctions->hasGLESExtension("GL_KHR_debug"); |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 104 | #ifndef NDEBUG |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 105 | if (mHasDebugOutput) |
Geoff Lang | b80360f | 2015-05-04 15:01:31 -0400 | [diff] [blame] | 106 | { |
| 107 | mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
| 108 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, GL_TRUE); |
| 109 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, GL_TRUE); |
| 110 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, 0, nullptr, GL_FALSE); |
| 111 | mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, GL_FALSE); |
| 112 | mFunctions->debugMessageCallback(&LogGLDebugMessage, nullptr); |
| 113 | } |
| 114 | #endif |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 115 | |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 116 | EGLint deviceType = |
| 117 | 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] | 118 | if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE) |
| 119 | { |
| 120 | mSkipDrawCalls = true; |
| 121 | } |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 122 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 123 | |
| 124 | RendererGL::~RendererGL() |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 125 | { |
Geoff Lang | 53b8aec | 2015-08-24 10:33:25 -0400 | [diff] [blame] | 126 | SafeDelete(mBlitter); |
Geoff Lang | bf8a72f | 2015-11-03 16:34:45 -0500 | [diff] [blame] | 127 | SafeDelete(mStateManager); |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame] | 128 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 129 | |
| 130 | gl::Error RendererGL::flush() |
| 131 | { |
Geoff Lang | 2c91914 | 2015-04-01 14:44:13 -0400 | [diff] [blame] | 132 | mFunctions->flush(); |
| 133 | return gl::Error(GL_NO_ERROR); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | gl::Error RendererGL::finish() |
| 137 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 138 | #ifdef NDEBUG |
| 139 | if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mHasDebugOutput) |
| 140 | { |
| 141 | mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
| 142 | } |
| 143 | #endif |
| 144 | |
Geoff Lang | 2c91914 | 2015-04-01 14:44:13 -0400 | [diff] [blame] | 145 | mFunctions->finish(); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 146 | |
| 147 | #ifdef NDEBUG |
| 148 | if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mHasDebugOutput) |
| 149 | { |
| 150 | mFunctions->disable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
| 151 | } |
| 152 | #endif |
| 153 | |
Geoff Lang | 2c91914 | 2015-04-01 14:44:13 -0400 | [diff] [blame] | 154 | return gl::Error(GL_NO_ERROR); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 155 | } |
| 156 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 157 | gl::Error RendererGL::drawArrays(const gl::ContextState &data, |
| 158 | GLenum mode, |
| 159 | GLint first, |
| 160 | GLsizei count) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 161 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 162 | ANGLE_TRY(mStateManager->setDrawArraysState(data, first, count, 0)); |
Geoff Lang | 7c82bc4 | 2015-03-09 16:18:08 -0400 | [diff] [blame] | 163 | |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 164 | if (!mSkipDrawCalls) |
| 165 | { |
| 166 | mFunctions->drawArrays(mode, first, count); |
| 167 | } |
Geoff Lang | d6e5087 | 2015-02-24 12:42:26 -0500 | [diff] [blame] | 168 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 169 | return gl::NoError(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 170 | } |
| 171 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 172 | gl::Error RendererGL::drawArraysInstanced(const gl::ContextState &data, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 173 | GLenum mode, |
| 174 | GLint first, |
| 175 | GLsizei count, |
| 176 | GLsizei instanceCount) |
| 177 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 178 | ANGLE_TRY(mStateManager->setDrawArraysState(data, first, count, instanceCount)); |
Geoff Lang | 3cf12ce | 2015-08-27 14:40:48 -0400 | [diff] [blame] | 179 | |
| 180 | if (!mSkipDrawCalls) |
| 181 | { |
| 182 | mFunctions->drawArraysInstanced(mode, first, count, instanceCount); |
| 183 | } |
| 184 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 185 | return gl::NoError(); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 186 | } |
| 187 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 188 | gl::Error RendererGL::drawElements(const gl::ContextState &data, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 189 | GLenum mode, |
| 190 | GLsizei count, |
| 191 | GLenum type, |
| 192 | const GLvoid *indices, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 193 | const gl::IndexRange &indexRange) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 194 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 195 | const GLvoid *drawIndexPtr = nullptr; |
| 196 | ANGLE_TRY(mStateManager->setDrawElementsState(data, count, type, indices, 0, &drawIndexPtr)); |
Geoff Lang | 7c82bc4 | 2015-03-09 16:18:08 -0400 | [diff] [blame] | 197 | |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 198 | if (!mSkipDrawCalls) |
| 199 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 200 | mFunctions->drawElements(mode, count, type, drawIndexPtr); |
Jamie Madill | 39fcf26 | 2015-06-08 14:39:07 -0400 | [diff] [blame] | 201 | } |
Geoff Lang | d6e5087 | 2015-02-24 12:42:26 -0500 | [diff] [blame] | 202 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 203 | return gl::NoError(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 204 | } |
| 205 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 206 | gl::Error RendererGL::drawElementsInstanced(const gl::ContextState &data, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 207 | GLenum mode, |
| 208 | GLsizei count, |
| 209 | GLenum type, |
| 210 | const GLvoid *indices, |
| 211 | GLsizei instances, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 212 | const gl::IndexRange &indexRange) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 213 | { |
Geoff Lang | 3cf12ce | 2015-08-27 14:40:48 -0400 | [diff] [blame] | 214 | const GLvoid *drawIndexPointer = nullptr; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 215 | ANGLE_TRY(mStateManager->setDrawElementsState(data, count, type, indices, instances, |
| 216 | &drawIndexPointer)); |
Geoff Lang | 3cf12ce | 2015-08-27 14:40:48 -0400 | [diff] [blame] | 217 | |
| 218 | if (!mSkipDrawCalls) |
| 219 | { |
| 220 | mFunctions->drawElementsInstanced(mode, count, type, drawIndexPointer, instances); |
| 221 | } |
| 222 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 223 | return gl::NoError(); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 224 | } |
| 225 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 226 | gl::Error RendererGL::drawRangeElements(const gl::ContextState &data, |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 227 | GLenum mode, |
| 228 | GLuint start, |
| 229 | GLuint end, |
| 230 | GLsizei count, |
| 231 | GLenum type, |
| 232 | const GLvoid *indices, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 233 | const gl::IndexRange &indexRange) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 234 | { |
Geoff Lang | 4750223 | 2015-08-25 16:26:10 -0400 | [diff] [blame] | 235 | const GLvoid *drawIndexPointer = nullptr; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 236 | ANGLE_TRY( |
| 237 | mStateManager->setDrawElementsState(data, count, type, indices, 0, &drawIndexPointer)); |
Geoff Lang | 4750223 | 2015-08-25 16:26:10 -0400 | [diff] [blame] | 238 | |
| 239 | if (!mSkipDrawCalls) |
| 240 | { |
| 241 | mFunctions->drawRangeElements(mode, start, end, count, type, drawIndexPointer); |
| 242 | } |
| 243 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 244 | return gl::Error(GL_NO_ERROR); |
| 245 | } |
| 246 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame^] | 247 | void RendererGL::stencilFillPath(const gl::ContextState &state, |
| 248 | const gl::Path *path, |
| 249 | GLenum fillMode, |
| 250 | GLuint mask) |
| 251 | { |
| 252 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 253 | |
| 254 | mFunctions->stencilFillPathNV(pathObj->getPathID(), fillMode, mask); |
| 255 | |
| 256 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 257 | } |
| 258 | |
| 259 | void RendererGL::stencilStrokePath(const gl::ContextState &state, |
| 260 | const gl::Path *path, |
| 261 | GLint reference, |
| 262 | GLuint mask) |
| 263 | { |
| 264 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 265 | |
| 266 | mFunctions->stencilStrokePathNV(pathObj->getPathID(), reference, mask); |
| 267 | |
| 268 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 269 | } |
| 270 | |
| 271 | void RendererGL::coverFillPath(const gl::ContextState &state, |
| 272 | const gl::Path *path, |
| 273 | GLenum coverMode) |
| 274 | { |
| 275 | |
| 276 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 277 | mFunctions->coverFillPathNV(pathObj->getPathID(), coverMode); |
| 278 | |
| 279 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 280 | } |
| 281 | |
| 282 | void RendererGL::coverStrokePath(const gl::ContextState &state, |
| 283 | const gl::Path *path, |
| 284 | GLenum coverMode) |
| 285 | { |
| 286 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 287 | mFunctions->coverStrokePathNV(pathObj->getPathID(), coverMode); |
| 288 | |
| 289 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 290 | } |
| 291 | |
| 292 | void RendererGL::stencilThenCoverFillPath(const gl::ContextState &state, |
| 293 | const gl::Path *path, |
| 294 | GLenum fillMode, |
| 295 | GLuint mask, |
| 296 | GLenum coverMode) |
| 297 | { |
| 298 | |
| 299 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 300 | mFunctions->stencilThenCoverFillPathNV(pathObj->getPathID(), fillMode, mask, coverMode); |
| 301 | |
| 302 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 303 | } |
| 304 | |
| 305 | void RendererGL::stencilThenCoverStrokePath(const gl::ContextState &state, |
| 306 | const gl::Path *path, |
| 307 | GLint reference, |
| 308 | GLuint mask, |
| 309 | GLenum coverMode) |
| 310 | { |
| 311 | |
| 312 | const auto *pathObj = GetImplAs<PathGL>(path); |
| 313 | mFunctions->stencilThenCoverStrokePathNV(pathObj->getPathID(), reference, mask, coverMode); |
| 314 | |
| 315 | ASSERT(mFunctions->getError() == GL_NO_ERROR); |
| 316 | } |
| 317 | |
Jamie Madill | 8415b5f | 2016-04-26 13:41:39 -0400 | [diff] [blame] | 318 | ContextImpl *RendererGL::createContext(const gl::ContextState &state) |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 319 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 320 | return new ContextGL(state, this); |
Geoff Lang | 0af0b81 | 2015-09-23 13:56:25 -0400 | [diff] [blame] | 321 | } |
| 322 | |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 323 | void RendererGL::insertEventMarker(GLsizei length, const char *marker) |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 324 | { |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 325 | mFunctions->debugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, |
| 326 | GL_DEBUG_SEVERITY_NOTIFICATION, length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 327 | } |
| 328 | |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 329 | void RendererGL::pushGroupMarker(GLsizei length, const char *marker) |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 330 | { |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 331 | mFunctions->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | void RendererGL::popGroupMarker() |
| 335 | { |
Geoff Lang | f6ade2e | 2015-09-29 11:21:43 -0400 | [diff] [blame] | 336 | mFunctions->popDebugGroup(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 339 | void RendererGL::notifyDeviceLost() |
| 340 | { |
| 341 | UNIMPLEMENTED(); |
| 342 | } |
| 343 | |
| 344 | bool RendererGL::isDeviceLost() const |
| 345 | { |
| 346 | UNIMPLEMENTED(); |
| 347 | return bool(); |
| 348 | } |
| 349 | |
| 350 | bool RendererGL::testDeviceLost() |
| 351 | { |
| 352 | UNIMPLEMENTED(); |
| 353 | return bool(); |
| 354 | } |
| 355 | |
| 356 | bool RendererGL::testDeviceResettable() |
| 357 | { |
| 358 | UNIMPLEMENTED(); |
| 359 | return bool(); |
| 360 | } |
| 361 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 362 | std::string RendererGL::getVendorString() const |
| 363 | { |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 364 | return std::string(reinterpret_cast<const char*>(mFunctions->getString(GL_VENDOR))); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | std::string RendererGL::getRendererDescription() const |
| 368 | { |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 369 | std::string nativeVendorString(reinterpret_cast<const char*>(mFunctions->getString(GL_VENDOR))); |
| 370 | std::string nativeRendererString(reinterpret_cast<const char*>(mFunctions->getString(GL_RENDERER))); |
| 371 | |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 372 | std::ostringstream rendererString; |
| 373 | rendererString << nativeVendorString << " " << nativeRendererString << " OpenGL"; |
Geoff Lang | 08dcfed | 2015-05-25 13:38:42 -0400 | [diff] [blame] | 374 | if (mFunctions->standard == STANDARD_GL_ES) |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 375 | { |
| 376 | rendererString << " ES"; |
| 377 | } |
Geoff Lang | 08dcfed | 2015-05-25 13:38:42 -0400 | [diff] [blame] | 378 | rendererString << " " << mFunctions->version.major << "." << mFunctions->version.minor; |
Geoff Lang | 8b0f0b3 | 2015-07-20 15:59:28 -0400 | [diff] [blame] | 379 | if (mFunctions->standard == STANDARD_GL_DESKTOP) |
| 380 | { |
| 381 | // Some drivers (NVIDIA) use a profile mask of 0 when in compatibility profile. |
| 382 | if ((mFunctions->profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0 || |
| 383 | (mFunctions->isAtLeastGL(gl::Version(3, 2)) && mFunctions->profile == 0)) |
| 384 | { |
| 385 | rendererString << " compatibility"; |
| 386 | } |
| 387 | else if ((mFunctions->profile & GL_CONTEXT_CORE_PROFILE_BIT) != 0) |
| 388 | { |
| 389 | rendererString << " core"; |
| 390 | } |
| 391 | } |
Geoff Lang | e42753b | 2015-04-08 13:46:33 -0400 | [diff] [blame] | 392 | |
| 393 | return rendererString.str(); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 394 | } |
| 395 | |
Geoff Lang | 862c0ba | 2015-05-25 15:31:16 -0400 | [diff] [blame] | 396 | const gl::Version &RendererGL::getMaxSupportedESVersion() const |
| 397 | { |
| 398 | // Force generation of caps |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 399 | getNativeCaps(); |
Geoff Lang | 862c0ba | 2015-05-25 15:31:16 -0400 | [diff] [blame] | 400 | |
| 401 | return mMaxSupportedESVersion; |
| 402 | } |
| 403 | |
Austin Kinross | 02df796 | 2015-07-01 10:03:42 -0700 | [diff] [blame] | 404 | void RendererGL::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, |
| 405 | gl::Extensions *outExtensions, |
| 406 | gl::Limitations * /* outLimitations */) const |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 407 | { |
Geoff Lang | 862c0ba | 2015-05-25 15:31:16 -0400 | [diff] [blame] | 408 | nativegl_gl::GenerateCaps(mFunctions, outCaps, outTextureCaps, outExtensions, &mMaxSupportedESVersion); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 409 | } |
| 410 | |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 411 | GLint RendererGL::getGPUDisjoint() |
| 412 | { |
| 413 | // TODO(ewell): On GLES backends we should find a way to reliably query disjoint events |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | GLint64 RendererGL::getTimestamp() |
| 418 | { |
| 419 | GLint64 result = 0; |
| 420 | mFunctions->getInteger64v(GL_TIMESTAMP, &result); |
| 421 | return result; |
| 422 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 423 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 424 | void RendererGL::ensureCapsInitialized() const |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 425 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 426 | if (!mCapsInitialized) |
| 427 | { |
| 428 | generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations); |
| 429 | mCapsInitialized = true; |
| 430 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 431 | } |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 432 | |
| 433 | const gl::Caps &RendererGL::getNativeCaps() const |
| 434 | { |
| 435 | ensureCapsInitialized(); |
| 436 | return mNativeCaps; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 437 | } |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 438 | |
| 439 | const gl::TextureCapsMap &RendererGL::getNativeTextureCaps() const |
| 440 | { |
| 441 | ensureCapsInitialized(); |
| 442 | return mNativeTextureCaps; |
| 443 | } |
| 444 | |
| 445 | const gl::Extensions &RendererGL::getNativeExtensions() const |
| 446 | { |
| 447 | ensureCapsInitialized(); |
| 448 | return mNativeExtensions; |
| 449 | } |
| 450 | |
| 451 | const gl::Limitations &RendererGL::getNativeLimitations() const |
| 452 | { |
| 453 | ensureCapsInitialized(); |
| 454 | return mNativeLimitations; |
| 455 | } |
| 456 | |
| 457 | } // namespace rx |