1/* 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef Extensions3D_h 27#define Extensions3D_h 28 29#include "GraphicsTypes3D.h" 30 31#include <wtf/text/WTFString.h> 32 33namespace WebCore { 34 35// This is a base class containing only pure virtual functions. 36// Implementations must provide a subclass. 37// 38// The supported extensions are defined below and in subclasses, 39// possibly platform-specific ones. 40// 41// Calling any extension function not supported by the current context 42// must be a no-op; in particular, it may not have side effects. In 43// this situation, if the function has a return value, 0 is returned. 44class Extensions3D { 45public: 46 virtual ~Extensions3D() {} 47 48 // Supported extensions: 49 // GL_EXT_texture_format_BGRA8888 50 // GL_EXT_read_format_bgra 51 // GL_ARB_robustness 52 // GL_ARB_texture_non_power_of_two / GL_OES_texture_npot 53 // GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil 54 // GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample 55 // GL_IMG_multisampled_render_to_texture 56 // GL_OES_texture_float 57 // GL_OES_texture_float_linear 58 // GL_OES_texture_half_float 59 // GL_OES_texture_half_float_linear 60 // GL_OES_standard_derivatives 61 // GL_OES_rgb8_rgba8 62 // GL_OES_vertex_array_object 63 // GL_OES_element_index_uint 64 // GL_ANGLE_translated_shader_source 65 // GL_ARB_texture_rectangle (only the subset required to 66 // implement IOSurface binding; it's recommended to support 67 // this only on Mac OS X to limit the amount of code dependent 68 // on this extension) 69 // GL_EXT_texture_compression_dxt1 70 // GL_EXT_texture_compression_s3tc 71 // GL_OES_compressed_ETC1_RGB8_texture 72 // GL_IMG_texture_compression_pvrtc 73 // EXT_texture_filter_anisotropic 74 // GL_EXT_debug_marker 75 // GL_ARB_draw_buffers / GL_EXT_draw_buffers 76 // GL_ANGLE_instanced_arrays 77 78 // Takes full name of extension; for example, 79 // "GL_EXT_texture_format_BGRA8888". 80 virtual bool supports(const String&) = 0; 81 82 // Certain OpenGL and WebGL implementations may support enabling 83 // extensions lazily. This method may only be called with 84 // extension names for which supports returns true. 85 virtual void ensureEnabled(const String&) = 0; 86 87 // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA8888". 88 // Checks to see whether the given extension is actually enabled (see ensureEnabled). 89 // Has no other side-effects. 90 virtual bool isEnabled(const String&) = 0; 91 92 enum ExtensionsEnumType { 93 // GL_EXT_texture_format_BGRA8888 enums 94 BGRA_EXT = 0x80E1, 95 96 // GL_ARB_robustness enums 97 GUILTY_CONTEXT_RESET_ARB = 0x8253, 98 INNOCENT_CONTEXT_RESET_ARB = 0x8254, 99 UNKNOWN_CONTEXT_RESET_ARB = 0x8255, 100 101 // GL_EXT/OES_packed_depth_stencil enums 102 DEPTH24_STENCIL8 = 0x88F0, 103 104 // GL_ANGLE_framebuffer_blit names 105 READ_FRAMEBUFFER = 0x8CA8, 106 DRAW_FRAMEBUFFER = 0x8CA9, 107 DRAW_FRAMEBUFFER_BINDING = 0x8CA6, 108 READ_FRAMEBUFFER_BINDING = 0x8CAA, 109 110 // GL_ANGLE_framebuffer_multisample names 111 RENDERBUFFER_SAMPLES = 0x8CAB, 112 FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56, 113 MAX_SAMPLES = 0x8D57, 114 115 // GL_IMG_multisampled_render_to_texture 116 RENDERBUFFER_SAMPLES_IMG = 0x9133, 117 FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134, 118 MAX_SAMPLES_IMG = 0x9135, 119 TEXTURE_SAMPLES_IMG = 0x9136, 120 121 // GL_OES_standard_derivatives names 122 FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B, 123 124 // GL_OES_rgb8_rgba8 names 125 RGB8_OES = 0x8051, 126 RGBA8_OES = 0x8058, 127 128 // GL_OES_vertex_array_object names 129 VERTEX_ARRAY_BINDING_OES = 0x85B5, 130 131 // GL_ANGLE_translated_shader_source 132 TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0, 133 134 // GL_ARB_texture_rectangle 135 TEXTURE_RECTANGLE_ARB = 0x84F5, 136 TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6, 137 138 // GL_EXT_texture_compression_dxt1 139 // GL_EXT_texture_compression_s3tc 140 COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0, 141 COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1, 142 COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2, 143 COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3, 144 145 // GL_OES_compressed_ETC1_RGB8_texture 146 ETC1_RGB8_OES = 0x8D64, 147 148 // GL_IMG_texture_compression_pvrtc 149 COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00, 150 COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01, 151 COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02, 152 COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03, 153 154 // GL_AMD_compressed_ATC_texture 155 COMPRESSED_ATC_RGB_AMD = 0x8C92, 156 COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93, 157 COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE, 158 159 // GL_EXT_texture_filter_anisotropic 160 TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE, 161 MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF, 162 163 // GL_ARB_draw_buffers / GL_EXT_draw_buffers 164 MAX_DRAW_BUFFERS_EXT = 0x8824, 165 DRAW_BUFFER0_EXT = 0x8825, 166 DRAW_BUFFER1_EXT = 0x8826, 167 DRAW_BUFFER2_EXT = 0x8827, 168 DRAW_BUFFER3_EXT = 0x8828, 169 DRAW_BUFFER4_EXT = 0x8829, 170 DRAW_BUFFER5_EXT = 0x882A, 171 DRAW_BUFFER6_EXT = 0x882B, 172 DRAW_BUFFER7_EXT = 0x882C, 173 DRAW_BUFFER8_EXT = 0x882D, 174 DRAW_BUFFER9_EXT = 0x882E, 175 DRAW_BUFFER10_EXT = 0x882F, 176 DRAW_BUFFER11_EXT = 0x8830, 177 DRAW_BUFFER12_EXT = 0x8831, 178 DRAW_BUFFER13_EXT = 0x8832, 179 DRAW_BUFFER14_EXT = 0x8833, 180 DRAW_BUFFER15_EXT = 0x8834, 181 MAX_COLOR_ATTACHMENTS_EXT = 0x8CDF, 182 COLOR_ATTACHMENT0_EXT = 0x8CE0, 183 COLOR_ATTACHMENT1_EXT = 0x8CE1, 184 COLOR_ATTACHMENT2_EXT = 0x8CE2, 185 COLOR_ATTACHMENT3_EXT = 0x8CE3, 186 COLOR_ATTACHMENT4_EXT = 0x8CE4, 187 COLOR_ATTACHMENT5_EXT = 0x8CE5, 188 COLOR_ATTACHMENT6_EXT = 0x8CE6, 189 COLOR_ATTACHMENT7_EXT = 0x8CE7, 190 COLOR_ATTACHMENT8_EXT = 0x8CE8, 191 COLOR_ATTACHMENT9_EXT = 0x8CE9, 192 COLOR_ATTACHMENT10_EXT = 0x8CEA, 193 COLOR_ATTACHMENT11_EXT = 0x8CEB, 194 COLOR_ATTACHMENT12_EXT = 0x8CEC, 195 COLOR_ATTACHMENT13_EXT = 0x8CED, 196 COLOR_ATTACHMENT14_EXT = 0x8CEE, 197 COLOR_ATTACHMENT15_EXT = 0x8CEF 198 }; 199 200 // GL_ARB_robustness 201 // Note: This method's behavior differs from the GL_ARB_robustness 202 // specification in the following way: 203 // The implementation must not reset the error state during this call. 204 // If getGraphicsResetStatusARB returns an error, it should continue 205 // returning the same error. Restoring the GraphicsContext3D is handled 206 // externally. 207 virtual int getGraphicsResetStatusARB() = 0; 208 209 // GL_ANGLE_framebuffer_blit 210 virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) = 0; 211 212 // GL_ANGLE_framebuffer_multisample 213 virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0; 214 215 // GL_OES_vertex_array_object 216 virtual Platform3DObject createVertexArrayOES() = 0; 217 virtual void deleteVertexArrayOES(Platform3DObject) = 0; 218 virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0; 219 virtual void bindVertexArrayOES(Platform3DObject) = 0; 220 221 // GL_ANGLE_translated_shader_source 222 virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0; 223 224 // EXT Robustness - uses getGraphicsResetStatusARB 225 virtual void readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data) = 0; 226 virtual void getnUniformfvEXT(GC3Duint program, int location, GC3Dsizei bufSize, float *params) = 0; 227 virtual void getnUniformivEXT(GC3Duint program, int location, GC3Dsizei bufSize, int *params) = 0; 228 229 // GL_EXT_debug_marker 230 virtual void insertEventMarkerEXT(const String&) = 0; 231 virtual void pushGroupMarkerEXT(const String&) = 0; 232 virtual void popGroupMarkerEXT(void) = 0; 233 234 // GL_ARB_draw_buffers / GL_EXT_draw_buffers 235 virtual void drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) = 0; 236 237 // GL_ANGLE_instanced_arrays 238 virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) = 0; 239 virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount) = 0; 240 virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) = 0; 241 242 virtual bool isNVIDIA() = 0; 243 virtual bool isAMD() = 0; 244 virtual bool isIntel() = 0; 245 virtual bool isImagination() = 0; 246 virtual String vendor() = 0; 247 248 // If this method returns false then the system *definitely* does not support multisampling. 249 // It does not necessarily say the system does support it - callers must attempt to construct 250 // multisampled renderbuffers and check framebuffer completeness. 251 // Ports should implement this to return false on configurations where it is known 252 // that multisampling is not available. 253 virtual bool maySupportMultisampling() = 0; 254 255 // Some configurations have bugs regarding built-in functions in their OpenGL drivers 256 // that must be avoided. Ports should implement these flags on such configurations. 257 virtual bool requiresBuiltInFunctionEmulation() = 0; 258 virtual bool requiresRestrictedMaximumTextureSize() = 0; 259 260}; 261 262} // namespace WebCore 263 264#endif // Extensions3D_h 265