15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci IMG_multisampled_render_to_texture 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_IMG_multisampled_render_to_texture 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Georg Kolling, Imagination Technologies (georg.kolling 'at' imgtec.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciStatus 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Complete 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciVersion 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Last Modified Date: March 26, 2010 205bd8deadSopenharmony_ci Revision: 3 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciNumber 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci OpenGL ES Extension #74 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciDependencies 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci OpenGL ES 2.0 or OES_framebuffer_object are required. This 295bd8deadSopenharmony_ci extension is written against the OpenGL ES 2.0 Specification. 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciOverview 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci This extension introduces functionality to perform multisampled 345bd8deadSopenharmony_ci rendering to a color renderable texture, without requiring an 355bd8deadSopenharmony_ci explicit resolve of multisample data. 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci Some GPU architectures - such as tile-based renderers - are 385bd8deadSopenharmony_ci capable of performing multisampled rendering by storing 395bd8deadSopenharmony_ci multisample data in internal high-speed memory and downsampling the 405bd8deadSopenharmony_ci data when writing out to external memory after rendering has 415bd8deadSopenharmony_ci finished. Since per-sample data is never written out to external 425bd8deadSopenharmony_ci memory, this approach saves bandwidth and storage space. In this 435bd8deadSopenharmony_ci case multisample data gets discarded, however this is acceptable 445bd8deadSopenharmony_ci in most cases. 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci The extension provides a new command, FramebufferTexture2DMultisampleIMG, 475bd8deadSopenharmony_ci which attaches a texture level to a framebuffer and enables 485bd8deadSopenharmony_ci multisampled rendering to that texture level. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci When the texture level is used as a source or destination for any 515bd8deadSopenharmony_ci operation other than drawing to it, an implicit resolve of 525bd8deadSopenharmony_ci multisampled color data is performed. After such a resolve, the 535bd8deadSopenharmony_ci multisampled color data is discarded. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci In order to allow the use of multisampled depth and stencil buffers 565bd8deadSopenharmony_ci when performing multisampled rendering to a texture, the extension 575bd8deadSopenharmony_ci also adds the command RenderbufferStorageMultisampleIMG. 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ciIP Status 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci No known IP claims. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ciNew Procedures and Functions 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci void RenderbufferStorageMultisampleIMG( 665bd8deadSopenharmony_ci enum target, sizei samples, 675bd8deadSopenharmony_ci enum internalformat, 685bd8deadSopenharmony_ci sizei width, sizei height); 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci void FramebufferTexture2DMultisampleIMG( 715bd8deadSopenharmony_ci enum target, enum attachment, 725bd8deadSopenharmony_ci enum textarget, uint texture, 735bd8deadSopenharmony_ci int level, sizei samples); 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ciNew Tokens 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetRenderbufferParameteriv: 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci RENDERBUFFER_SAMPLES_IMG 0x9133 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci Returned by CheckFramebufferStatus: 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, 865bd8deadSopenharmony_ci GetFloatv, and GetDoublev: 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci MAX_SAMPLES_IMG 0x9135 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetFramebufferAttachmentParameteriv: 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci TEXTURE_SAMPLES_IMG 0x9136 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ciAdditions to Section 4.4.3 of the OpenGL ES 2.0 Specification 965bd8deadSopenharmony_ci(Renderbuffer Objects) 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci Replace the paragraph describing the command RenderbufferStorage 995bd8deadSopenharmony_ci with the following: 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci The command 1025bd8deadSopenharmony_ci void RenderbufferStorageMultisampleIMG( enum target, 1035bd8deadSopenharmony_ci sizei samples, enum internalformat, sizei width, 1045bd8deadSopenharmony_ci sizei height ); 1055bd8deadSopenharmony_ci establishes the data storage, format, dimensions, and number of 1065bd8deadSopenharmony_ci samples of a renderbuffer object's image. target must be RENDERBUFFER. 1075bd8deadSopenharmony_ci internalformat must be one of the color-renderable, depth-renderable, 1085bd8deadSopenharmony_ci or stencil-renderable formats described in table 4.5. width and height 1095bd8deadSopenharmony_ci are the dimensions in pixels of the renderbuffer. If either width or 1105bd8deadSopenharmony_ci height is greater than the value of MAX_RENDERBUFFER_SIZE, or if 1115bd8deadSopenharmony_ci samples is greater than the value of MAX_SAMPLES_IMG, then the error 1125bd8deadSopenharmony_ci INVALID_VALUE is generated. If OpenGL ES is unable to create a data 1135bd8deadSopenharmony_ci store of the requested size, the error OUT_OF_MEMORY is generated. 1145bd8deadSopenharmony_ci Upon success, RenderbufferStorageMultisampleIMG deletes any existing 1155bd8deadSopenharmony_ci data store for the renderbuffer image and the contents of the data 1165bd8deadSopenharmony_ci store after calling RenderbufferStorageMultisampleIMG are undefined. 1175bd8deadSopenharmony_ci RENDERBUFFER_WIDTH is set to width, RENDERBUFFER_HEIGHT is set to 1185bd8deadSopenharmony_ci height, and RENDERBUFFER_INTERNAL_FORMAT is set to internalformat. 1195bd8deadSopenharmony_ci If samples is zero, then RENDERBUFFER_SAMPLES_IMG is set to zero. 1205bd8deadSopenharmony_ci Otherwise samples represents a request for a desired minimum number 1215bd8deadSopenharmony_ci of samples. Since different implementations may support different 1225bd8deadSopenharmony_ci sample counts for multisampled rendering, the actual number of samples 1235bd8deadSopenharmony_ci allocated for the renderbuffer image is implementation-dependent. 1245bd8deadSopenharmony_ci However, the resulting value for RENDERBUFFER_SAMPLES_IMG is 1255bd8deadSopenharmony_ci guaranteed to be greater than or equal to samples and no more than the 1265bd8deadSopenharmony_ci next larger sample count supported by the implementation. 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci An OpenGL ES implementation may vary its allocation of internal 1295bd8deadSopenharmony_ci component resolution based on any RenderbufferStorageMultisampleIMG 1305bd8deadSopenharmony_ci parameter (except target), but the allocation and chosen internal format 1315bd8deadSopenharmony_ci must not be a function of any other state and cannot be changed once 1325bd8deadSopenharmony_ci they are established. 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci The command 1355bd8deadSopenharmony_ci void RenderbufferStorage( enum target, enum internalformat, 1365bd8deadSopenharmony_ci sizei width, sizei height ); 1375bd8deadSopenharmony_ci is equivalent to calling RenderbufferStorageMultisampleIMG with 1385bd8deadSopenharmony_ci samples equal to zero. 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci Add the following after the paragraph describing FramebufferTexture2D: 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci The command 1435bd8deadSopenharmony_ci void FramebufferTexture2DMultisampleIMG( enum target, 1445bd8deadSopenharmony_ci enum attachment, enum textarget, uint texture, 1455bd8deadSopenharmony_ci int level, sizei samples ); 1465bd8deadSopenharmony_ci enables multisampled rendering into the images of a texture object. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci target, textarget, texture, and level correspond to the same 1495bd8deadSopenharmony_ci parameters for FramebufferTexture2D and have the same restrictions. 1505bd8deadSopenharmony_ci attachment must be COLOR_ATTACHMENT0. If samples is greater than the 1515bd8deadSopenharmony_ci value of MAX_SAMPLES_IMG, then the error INVALID_VALUE is generated. 1525bd8deadSopenharmony_ci If samples is zero, then TEXTURE_SAMPLES_IMG is set to zero, and 1535bd8deadSopenharmony_ci FramebufferTexture2DMultisampleIMG behaves like FramebufferTexture2D. 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci Otherwise samples represents a request for a desired minimum number 1565bd8deadSopenharmony_ci of samples. Since different implementations may support different 1575bd8deadSopenharmony_ci sample counts for multisampled rendering, the actual number of samples 1585bd8deadSopenharmony_ci allocated for the image is implementation-dependent. However, the 1595bd8deadSopenharmony_ci resulting value for TEXTURE_SAMPLES_IMG is guaranteed to be greater 1605bd8deadSopenharmony_ci than or equal to samples and no more than the next larger sample count 1615bd8deadSopenharmony_ci supported by the implementation. 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci The implementation allocates an implicit multisample buffer with 1645bd8deadSopenharmony_ci TEXTURE_SAMPLES_IMG samples and the same internalformat, width, and 1655bd8deadSopenharmony_ci height as the specified texture level. This buffer is used as the 1665bd8deadSopenharmony_ci target for rendering instead of the specified texture level. The 1675bd8deadSopenharmony_ci buffer is associated with the attachment and gets deleted 1685bd8deadSopenharmony_ci after the attachment is broken. 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci When the texture level is used as a source or destination for any 1715bd8deadSopenharmony_ci operation, or when the attachment is broken, an implicit resolve 1725bd8deadSopenharmony_ci of multisample data from the multisample buffer to the texture level 1735bd8deadSopenharmony_ci is performed. After such a resolve, the contents of the multisample 1745bd8deadSopenharmony_ci buffer become undefined. 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci The operations which cause a resolve include: 1775bd8deadSopenharmony_ci - Drawing with the texture bound to an active texture unit 1785bd8deadSopenharmony_ci - ReadPixels or CopyTex[Sub]Image* while the texture is 1795bd8deadSopenharmony_ci attached to the framebuffer 1805bd8deadSopenharmony_ci - CopyTex[Sub]Image*, Tex[Sub]Image*, 1815bd8deadSopenharmony_ci CompressedTex[Sub]Image* with the specified level as 1825bd8deadSopenharmony_ci destination 1835bd8deadSopenharmony_ci - GenerateMipmap 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ciAdditions to section 4.4.5 of the OpenGL ES 2.0 Specification 1865bd8deadSopenharmony_ci(Framebuffer Completeness) 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci Add the following bullet point after 1895bd8deadSopenharmony_ci * All attached images have the same width and height. 1905bd8deadSopenharmony_ci FRAMEBUFFER_INCOMPLETE_DIMENSIONS 1915bd8deadSopenharmony_ci on page 116: 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci * The value of RENDERBUFFER_SAMPLES_IMG is the same for all 1945bd8deadSopenharmony_ci attached renderbuffers; the value of TEXTURE_SAMPLES_IMG 1955bd8deadSopenharmony_ci is the same for all texture attachments; and, if the attached 1965bd8deadSopenharmony_ci images are a mix of renderbuffers and textures, the value of 1975bd8deadSopenharmony_ci RENDERBUFFER_SAMPLES_IMG matches the value of TEXTURE_- 1985bd8deadSopenharmony_ci SAMPLES_IMG. 1995bd8deadSopenharmony_ci FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ciDependencies on GL and ES profiles, versions, and other extensions 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci None 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ciErrors 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ci The error OUT_OF_MEMORY is generated when 2085bd8deadSopenharmony_ci RenderbufferStorageMultisampleIMG cannot create storage of the 2095bd8deadSopenharmony_ci specified size. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci If RenderbufferStorageMultisampleEXT is called with a value of 2125bd8deadSopenharmony_ci <samples> that is greater than MAX_SAMPLES_IMG, then the error 2135bd8deadSopenharmony_ci INVALID_VALUE is generated. 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci The error INVALID_ENUM is generated if FramebufferTexture2DMultisampleIMG 2165bd8deadSopenharmony_ci is called with a <target> that is not FRAMEBUFFER. 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci The error INVALID_ENUM is generated if FramebufferTexture2DMultisampleIMG 2195bd8deadSopenharmony_ci is called with an <attachment> that is not COLOR_ATTACHMENT0. 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci The error INVALID_ENUM is generated if FramebufferTexture2DMultisampleIMG 2225bd8deadSopenharmony_ci is called with a <textarget> that is not TEXTURE_2D, 2235bd8deadSopenharmony_ci TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, 2245bd8deadSopenharmony_ci TEXTURE_CUBE_MAP_POSITIVE_Z, TEXTURE_CUBE_MAP_NEGATIVE_X, 2255bd8deadSopenharmony_ci TEXTURE_CUBE_MAP_NEGATIVE_Y, or TEXTURE_CUBE_MAP_NEGATIVE_Z. 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ciNew State 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci Changes to table 6.22, p. 154 (Renderbuffer State) 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci Initial 2325bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 2335bd8deadSopenharmony_ci --------- ---- ---------------- ------- ------------ ----- 2345bd8deadSopenharmony_ci RENDERBUFFER_SAMPLES_IMG Z+ GetRenderbuffer- 0 Renderbuffer 4.4.3 2355bd8deadSopenharmony_ci Parameteriv samples 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci Changes to table 6.23, p. 155 (Framebuffer State) 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci Initial 2405bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 2415bd8deadSopenharmony_ci --------- ------ --------------------- ------- --------------- ---- 2425bd8deadSopenharmony_ci TEXTURE_SAMPLES_IMG n * Z+ GetFramebuffer- 0 Framebuffer 4.4 2435bd8deadSopenharmony_ci AttachmentParameteriv texture samples 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ciNew Implementation Dependent State 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ci Changes to table 6.17, p. 149 (Implementation Dependent Values) 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci Minimum 2505bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 2515bd8deadSopenharmony_ci --------- ---- ----------- ------- ----------- ---- 2525bd8deadSopenharmony_ci MAX_SAMPLES_IMG Z+ GetIntegerv 2 Max. # of 4.4 2535bd8deadSopenharmony_ci samples. 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ciSample Code 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci GLsizei width = ...; 2585bd8deadSopenharmony_ci GLsizei height = ...; 2595bd8deadSopenharmony_ci GLint samples; 2605bd8deadSopenharmony_ci glGetIntegerv(GL_MAX_SAMPLES_IMG, &samples); 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ci /* Create multisampled depth renderbuffer */ 2635bd8deadSopenharmony_ci GLuint depthbuffer; 2645bd8deadSopenharmony_ci glGenRenderbuffers(1, &depthbuffer); 2655bd8deadSopenharmony_ci glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer); 2665bd8deadSopenharmony_ci glRenderbufferStorageMultisampleIMG(GL_RENDERBUFFER, samples, 2675bd8deadSopenharmony_ci GL_DEPTH_COMPONENT16, width, height); 2685bd8deadSopenharmony_ci glBindRenderbuffer(GL_RENDERBUFFER, 0); 2695bd8deadSopenharmony_ci 2705bd8deadSopenharmony_ci /* Create RGBA texture with single mipmap level */ 2715bd8deadSopenharmony_ci GLuint texture; 2725bd8deadSopenharmony_ci glGenTextures(1, &texture); 2735bd8deadSopenharmony_ci glBindTexture(GL_TEXTURE_2D, texture); 2745bd8deadSopenharmony_ci glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, 2755bd8deadSopenharmony_ci GL_UNSIGNED_SHORT_4_4_4_4, NULL); 2765bd8deadSopenharmony_ci glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 2775bd8deadSopenharmony_ci glBindTexture(GL_TEXTURE_2D, 0); 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci /* Create framebuffer object, attach texture and depth renderbuffer */ 2805bd8deadSopenharmony_ci GLuint framebuffer; 2815bd8deadSopenharmony_ci glGenFramebuffers(1, &framebuffer); 2825bd8deadSopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); 2835bd8deadSopenharmony_ci glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 2845bd8deadSopenharmony_ci GL_RENDERBUFFER, depthbuffer); 2855bd8deadSopenharmony_ci glFramebufferTexture2DMultisampleIMG(GL_FRAMEBUFFER, 2865bd8deadSopenharmony_ci GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0, samples); 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ci /* handle unsupported cases */ 2895bd8deadSopenharmony_ci if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != 2905bd8deadSopenharmony_ci GL_FRAMEBUFFER_COMPLETE) 2915bd8deadSopenharmony_ci { 2925bd8deadSopenharmony_ci ... 2935bd8deadSopenharmony_ci } 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci /* draw to the texture */ 2965bd8deadSopenharmony_ci glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 2975bd8deadSopenharmony_ci ... 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci /* Discard the depth renderbuffer contents if possible */ 3005bd8deadSopenharmony_ci if (extension_supported("GL_EXT_discard_framebuffer")) 3015bd8deadSopenharmony_ci { 3025bd8deadSopenharmony_ci GLenum discard_attachments[] = { GL_DEPTH_EXT }; 3035bd8deadSopenharmony_ci glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, 3045bd8deadSopenharmony_ci discard_attachments); 3055bd8deadSopenharmony_ci } 3065bd8deadSopenharmony_ci 3075bd8deadSopenharmony_ci /* Draw to the default framebuffer using the antialiased texture */ 3085bd8deadSopenharmony_ci /* Color data is implicitly resolved before the texture gets used */ 3095bd8deadSopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, 0); 3105bd8deadSopenharmony_ci glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | 3115bd8deadSopenharmony_ci GL_STENCIL_BUFFER_BIT); 3125bd8deadSopenharmony_ci glBindTexture(GL_TEXTURE_2D, texture); 3135bd8deadSopenharmony_ci ... 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ciConformance Tests 3165bd8deadSopenharmony_ci 3175bd8deadSopenharmony_ci No conformance test has been defined yet 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ciIssues 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci 3225bd8deadSopenharmony_ciRevision History 3235bd8deadSopenharmony_ci 3245bd8deadSopenharmony_ci Revision 3, 2010/03/26 3255bd8deadSopenharmony_ci - Set enums to undefined 3265bd8deadSopenharmony_ci 3275bd8deadSopenharmony_ci Revision 2, 2010/03/24 3285bd8deadSopenharmony_ci - Removed error condition for glReadPixels and glCopyTexImage2D 3295bd8deadSopenharmony_ci 3305bd8deadSopenharmony_ci Revision 1, 2010/01/05 3315bd8deadSopenharmony_ci - First draft of extension 332