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 | |
| 11 | #include "common/debug.h" |
Geoff Lang | c415283 | 2015-02-20 09:57:29 -0500 | [diff] [blame] | 12 | #include "libANGLE/Data.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 13 | #include "libANGLE/renderer/gl/BufferGL.h" |
| 14 | #include "libANGLE/renderer/gl/CompilerGL.h" |
| 15 | #include "libANGLE/renderer/gl/DefaultAttachmentGL.h" |
| 16 | #include "libANGLE/renderer/gl/FenceNVGL.h" |
| 17 | #include "libANGLE/renderer/gl/FenceSyncGL.h" |
| 18 | #include "libANGLE/renderer/gl/FramebufferGL.h" |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 19 | #include "libANGLE/renderer/gl/FunctionsGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 20 | #include "libANGLE/renderer/gl/ProgramGL.h" |
| 21 | #include "libANGLE/renderer/gl/QueryGL.h" |
| 22 | #include "libANGLE/renderer/gl/RenderbufferGL.h" |
| 23 | #include "libANGLE/renderer/gl/ShaderGL.h" |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame^] | 24 | #include "libANGLE/renderer/gl/StateManagerGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 25 | #include "libANGLE/renderer/gl/TextureGL.h" |
| 26 | #include "libANGLE/renderer/gl/TransformFeedbackGL.h" |
| 27 | #include "libANGLE/renderer/gl/VertexArrayGL.h" |
| 28 | |
| 29 | namespace rx |
| 30 | { |
| 31 | |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 32 | RendererGL::RendererGL(const FunctionsGL *functions) |
| 33 | : Renderer(), |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame^] | 34 | mFunctions(functions), |
| 35 | mStateManager(nullptr) |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 36 | { |
| 37 | ASSERT(mFunctions); |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame^] | 38 | mStateManager = new StateManagerGL(mFunctions); |
Geoff Lang | 56cf9af | 2015-02-17 10:16:49 -0500 | [diff] [blame] | 39 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 40 | |
| 41 | RendererGL::~RendererGL() |
Geoff Lang | 94463d5 | 2015-02-18 13:09:37 -0500 | [diff] [blame^] | 42 | { |
| 43 | SafeDelete(mStateManager); |
| 44 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 45 | |
| 46 | gl::Error RendererGL::flush() |
| 47 | { |
| 48 | UNIMPLEMENTED(); |
| 49 | return gl::Error(GL_INVALID_OPERATION); |
| 50 | } |
| 51 | |
| 52 | gl::Error RendererGL::finish() |
| 53 | { |
| 54 | UNIMPLEMENTED(); |
| 55 | return gl::Error(GL_INVALID_OPERATION); |
| 56 | } |
| 57 | |
| 58 | gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode, |
| 59 | GLint first, GLsizei count, GLsizei instances) |
| 60 | { |
| 61 | UNIMPLEMENTED(); |
| 62 | return gl::Error(GL_INVALID_OPERATION); |
| 63 | } |
| 64 | |
| 65 | gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type, |
| 66 | const GLvoid *indices, GLsizei instances, |
| 67 | const RangeUI &indexRange) |
| 68 | { |
| 69 | UNIMPLEMENTED(); |
| 70 | return gl::Error(GL_INVALID_OPERATION); |
| 71 | } |
| 72 | |
| 73 | CompilerImpl *RendererGL::createCompiler(const gl::Data &data) |
| 74 | { |
Geoff Lang | c415283 | 2015-02-20 09:57:29 -0500 | [diff] [blame] | 75 | return new CompilerGL(data); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | ShaderImpl *RendererGL::createShader(GLenum type) |
| 79 | { |
Geoff Lang | 295ed4c | 2015-02-20 09:58:25 -0500 | [diff] [blame] | 80 | return new ShaderGL(type, mFunctions); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | ProgramImpl *RendererGL::createProgram() |
| 84 | { |
| 85 | return new ProgramGL(); |
| 86 | } |
| 87 | |
| 88 | DefaultAttachmentImpl *RendererGL::createDefaultAttachment(GLenum type, egl::Surface *surface) |
| 89 | { |
| 90 | return new DefaultAttachmentGL(); |
| 91 | } |
| 92 | |
| 93 | FramebufferImpl *RendererGL::createFramebuffer() |
| 94 | { |
| 95 | return new FramebufferGL(); |
| 96 | } |
| 97 | |
| 98 | TextureImpl *RendererGL::createTexture(GLenum target) |
| 99 | { |
| 100 | return new TextureGL(); |
| 101 | } |
| 102 | |
| 103 | RenderbufferImpl *RendererGL::createRenderbuffer() |
| 104 | { |
| 105 | return new RenderbufferGL(); |
| 106 | } |
| 107 | |
| 108 | BufferImpl *RendererGL::createBuffer() |
| 109 | { |
| 110 | return new BufferGL(); |
| 111 | } |
| 112 | |
| 113 | VertexArrayImpl *RendererGL::createVertexArray() |
| 114 | { |
| 115 | return new VertexArrayGL(); |
| 116 | } |
| 117 | |
| 118 | QueryImpl *RendererGL::createQuery(GLenum type) |
| 119 | { |
| 120 | return new QueryGL(type); |
| 121 | } |
| 122 | |
| 123 | FenceNVImpl *RendererGL::createFenceNV() |
| 124 | { |
| 125 | return new FenceNVGL(); |
| 126 | } |
| 127 | |
| 128 | FenceSyncImpl *RendererGL::createFenceSync() |
| 129 | { |
| 130 | return new FenceSyncGL(); |
| 131 | } |
| 132 | |
| 133 | TransformFeedbackImpl *RendererGL::createTransformFeedback() |
| 134 | { |
| 135 | return new TransformFeedbackGL(); |
| 136 | } |
| 137 | |
| 138 | void RendererGL::notifyDeviceLost() |
| 139 | { |
| 140 | UNIMPLEMENTED(); |
| 141 | } |
| 142 | |
| 143 | bool RendererGL::isDeviceLost() const |
| 144 | { |
| 145 | UNIMPLEMENTED(); |
| 146 | return bool(); |
| 147 | } |
| 148 | |
| 149 | bool RendererGL::testDeviceLost() |
| 150 | { |
| 151 | UNIMPLEMENTED(); |
| 152 | return bool(); |
| 153 | } |
| 154 | |
| 155 | bool RendererGL::testDeviceResettable() |
| 156 | { |
| 157 | UNIMPLEMENTED(); |
| 158 | return bool(); |
| 159 | } |
| 160 | |
| 161 | VendorID RendererGL::getVendorId() const |
| 162 | { |
| 163 | UNIMPLEMENTED(); |
| 164 | return VendorID(); |
| 165 | } |
| 166 | |
| 167 | std::string RendererGL::getVendorString() const |
| 168 | { |
| 169 | UNIMPLEMENTED(); |
| 170 | return std::string(); |
| 171 | } |
| 172 | |
| 173 | std::string RendererGL::getRendererDescription() const |
| 174 | { |
| 175 | UNIMPLEMENTED(); |
| 176 | return std::string(); |
| 177 | } |
| 178 | |
| 179 | void RendererGL::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, gl::Extensions *outExtensions) const |
| 180 | { |
| 181 | // Set some minimum GLES2 caps, TODO: query for real GL caps |
| 182 | outCaps->maxElementIndex = static_cast<GLint64>(std::numeric_limits<unsigned int>::max()); |
| 183 | outCaps->max3DTextureSize = 0; |
| 184 | outCaps->max2DTextureSize = 1024; |
| 185 | outCaps->maxCubeMapTextureSize = outCaps->max2DTextureSize; |
| 186 | outCaps->maxArrayTextureLayers = 1; |
| 187 | outCaps->maxLODBias = 0.0f; |
| 188 | outCaps->maxRenderbufferSize = outCaps->max2DTextureSize; |
| 189 | outCaps->maxDrawBuffers = 1; |
| 190 | outCaps->maxColorAttachments = 1; |
| 191 | outCaps->maxViewportWidth = outCaps->max2DTextureSize; |
| 192 | outCaps->maxViewportHeight = outCaps->maxViewportWidth; |
| 193 | outCaps->minAliasedPointSize = 1.0f; |
| 194 | outCaps->maxAliasedPointSize = 1.0f; |
| 195 | outCaps->minAliasedLineWidth = 1.0f; |
| 196 | outCaps->maxAliasedLineWidth = 1.0f; |
| 197 | outCaps->maxElementsIndices = 0; |
| 198 | outCaps->maxElementsVertices = 0; |
| 199 | outCaps->maxServerWaitTimeout = 0; |
| 200 | outCaps->maxVertexAttributes = 16; |
| 201 | outCaps->maxVertexUniformVectors = 256; |
| 202 | outCaps->maxVertexUniformVectors = outCaps->maxVertexUniformVectors * 4; |
| 203 | outCaps->maxVertexUniformBlocks = 0; |
| 204 | outCaps->maxVertexOutputComponents = 16; |
| 205 | outCaps->maxVertexTextureImageUnits = outCaps->maxTextureImageUnits; |
| 206 | outCaps->maxFragmentUniformVectors = 256; |
| 207 | outCaps->maxFragmentUniformComponents = outCaps->maxFragmentUniformVectors * 4; |
| 208 | outCaps->maxFragmentUniformBlocks = 0; |
| 209 | outCaps->maxFragmentInputComponents = outCaps->maxVertexOutputComponents; |
| 210 | outCaps->maxTextureImageUnits = 16; |
| 211 | outCaps->minProgramTexelOffset = 0; |
| 212 | outCaps->maxProgramTexelOffset = 0; |
| 213 | outCaps->maxUniformBufferBindings = 0; |
| 214 | outCaps->maxUniformBlockSize = 0; |
| 215 | outCaps->uniformBufferOffsetAlignment = 0; |
| 216 | outCaps->maxCombinedUniformBlocks = 0; |
| 217 | outCaps->maxCombinedVertexUniformComponents = 0; |
| 218 | outCaps->maxCombinedFragmentUniformComponents = 0; |
| 219 | outCaps->maxVaryingComponents = 0; |
| 220 | outCaps->maxVaryingVectors = outCaps->maxVertexOutputComponents / 4; |
| 221 | outCaps->maxCombinedTextureImageUnits = outCaps->maxVertexTextureImageUnits + outCaps->maxTextureImageUnits; |
| 222 | outCaps->maxTransformFeedbackInterleavedComponents = 0; |
| 223 | outCaps->maxTransformFeedbackSeparateAttributes = 0; |
| 224 | outCaps->maxTransformFeedbackSeparateComponents = 0; |
| 225 | |
| 226 | gl::TextureCaps supportedTextureFormat; |
| 227 | supportedTextureFormat.texturable = true; |
| 228 | supportedTextureFormat.filterable = true; |
| 229 | supportedTextureFormat.renderable = true; |
| 230 | |
| 231 | outTextureCaps->insert(GL_RGB565, supportedTextureFormat); |
| 232 | outTextureCaps->insert(GL_RGBA4, supportedTextureFormat); |
| 233 | outTextureCaps->insert(GL_RGB5_A1, supportedTextureFormat); |
| 234 | outTextureCaps->insert(GL_RGB8_OES, supportedTextureFormat); |
| 235 | outTextureCaps->insert(GL_RGBA8_OES, supportedTextureFormat); |
| 236 | |
| 237 | outTextureCaps->insert(GL_DEPTH_COMPONENT16, supportedTextureFormat); |
| 238 | outTextureCaps->insert(GL_STENCIL_INDEX8, supportedTextureFormat); |
| 239 | |
| 240 | outExtensions->setTextureExtensionSupport(*outTextureCaps); |
| 241 | outExtensions->textureNPOT = true; |
| 242 | outExtensions->textureStorage = true; |
| 243 | } |
| 244 | |
| 245 | Workarounds RendererGL::generateWorkarounds() const |
| 246 | { |
| 247 | Workarounds workarounds; |
| 248 | return workarounds; |
| 249 | } |
| 250 | |
| 251 | } |