15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_multisampled_render_to_texture 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_multisampled_render_to_texture 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Georg Kolling, Imagination Technologies (georg.kolling 'at' imgtec.com) 125bd8deadSopenharmony_ci Ben Bowman, Imagination Technologies (benji.bowman 'at' imgtec.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContact 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Jan-Harald Fredriksen (jan-harald.fredriksen 'at' arm.com) 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciStatus 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Complete 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciVersion 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Last Modified Date: June 28, 2016 255bd8deadSopenharmony_ci Revision: 7 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciNumber 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL ES Extension #106 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciDependencies 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci OpenGL ES 2.0 or OES_framebuffer_object are required. This 345bd8deadSopenharmony_ci extension is written against the OpenGL ES 2.0 Specification. 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci This extension interacts with OpenGL ES 3.0 and later versions. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ciOverview 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci This extension introduces functionality to perform multisampled 415bd8deadSopenharmony_ci rendering to a color renderable texture, without requiring an 425bd8deadSopenharmony_ci explicit resolve of multisample data. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci Some GPU architectures - such as tile-based renderers - are 455bd8deadSopenharmony_ci capable of performing multisampled rendering by storing 465bd8deadSopenharmony_ci multisample data in internal high-speed memory and downsampling the 475bd8deadSopenharmony_ci data when writing out to external memory after rendering has 485bd8deadSopenharmony_ci finished. Since per-sample data is never written out to external 495bd8deadSopenharmony_ci memory, this approach saves bandwidth and storage space. In this 505bd8deadSopenharmony_ci case multisample data gets discarded, however this is acceptable 515bd8deadSopenharmony_ci in most cases. 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci The extension provides a new command, FramebufferTexture2DMultisampleEXT, 545bd8deadSopenharmony_ci which attaches a texture level to a framebuffer and enables 555bd8deadSopenharmony_ci multisampled rendering to that texture level. 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci When the texture level is flushed or used as a source or destination 585bd8deadSopenharmony_ci for any operation other than drawing to it, an implicit resolve of 595bd8deadSopenharmony_ci multisampled color data may be performed. After such a resolve, the 605bd8deadSopenharmony_ci multisampled color data is discarded. 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci In order to allow the use of multisampled depth and stencil buffers 635bd8deadSopenharmony_ci when performing multisampled rendering to a texture, the extension 645bd8deadSopenharmony_ci also adds the command RenderbufferStorageMultisampleEXT. 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ciIP Status 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ci No known IP claims. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ciNew Procedures and Functions 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci void RenderbufferStorageMultisampleEXT( 735bd8deadSopenharmony_ci enum target, sizei samples, 745bd8deadSopenharmony_ci enum internalformat, 755bd8deadSopenharmony_ci sizei width, sizei height); 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci void FramebufferTexture2DMultisampleEXT( 785bd8deadSopenharmony_ci enum target, enum attachment, 795bd8deadSopenharmony_ci enum textarget, uint texture, 805bd8deadSopenharmony_ci int level, sizei samples); 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ciNew Tokens 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetRenderbufferParameteriv: 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci RENDERBUFFER_SAMPLES_EXT 0x8CAB 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci Returned by CheckFramebufferStatus: 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, 935bd8deadSopenharmony_ci and GetFloatv: 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci MAX_SAMPLES_EXT 0x8D57 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetFramebufferAttachmentParameteriv: 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ciAdditions to Section 4.4.3 of the OpenGL ES 2.0 Specification 1035bd8deadSopenharmony_ci(Renderbuffer Objects) 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci Replace the paragraph describing the command RenderbufferStorage 1065bd8deadSopenharmony_ci with the following: 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci The command 1095bd8deadSopenharmony_ci void RenderbufferStorageMultisampleEXT( enum target, 1105bd8deadSopenharmony_ci sizei samples, enum internalformat, sizei width, 1115bd8deadSopenharmony_ci sizei height ); 1125bd8deadSopenharmony_ci establishes the data storage, format, dimensions, and number of 1135bd8deadSopenharmony_ci samples of a renderbuffer object's image. target must be RENDERBUFFER. 1145bd8deadSopenharmony_ci internalformat must be one of the color-renderable, depth-renderable, 1155bd8deadSopenharmony_ci or stencil-renderable formats described in table 4.5. width and height 1165bd8deadSopenharmony_ci are the dimensions in pixels of the renderbuffer. If either width or 1175bd8deadSopenharmony_ci height is greater than the value of MAX_RENDERBUFFER_SIZE, or if 1185bd8deadSopenharmony_ci samples is greater than the value of MAX_SAMPLES_EXT, then the error 1195bd8deadSopenharmony_ci INVALID_VALUE is generated. If OpenGL ES is unable to create a data 1205bd8deadSopenharmony_ci store of the requested size, the error OUT_OF_MEMORY is generated. 1215bd8deadSopenharmony_ci Upon success, RenderbufferStorageMultisampleEXT deletes any existing 1225bd8deadSopenharmony_ci data store for the renderbuffer image and the contents of the data 1235bd8deadSopenharmony_ci store after calling RenderbufferStorageMultisampleEXT are undefined. 1245bd8deadSopenharmony_ci RENDERBUFFER_WIDTH is set to width, RENDERBUFFER_HEIGHT is set to 1255bd8deadSopenharmony_ci height, and RENDERBUFFER_INTERNAL_FORMAT is set to internalformat. 1265bd8deadSopenharmony_ci If samples is zero, then RENDERBUFFER_SAMPLES_EXT is set to zero. 1275bd8deadSopenharmony_ci Otherwise samples represents a request for a desired minimum number 1285bd8deadSopenharmony_ci of samples. Since different implementations may support different 1295bd8deadSopenharmony_ci sample counts for multisampled rendering, the actual number of samples 1305bd8deadSopenharmony_ci allocated for the renderbuffer image is implementation-dependent. 1315bd8deadSopenharmony_ci However, the resulting value for RENDERBUFFER_SAMPLES_EXT is 1325bd8deadSopenharmony_ci guaranteed to be greater than or equal to samples and no more than the 1335bd8deadSopenharmony_ci next larger sample count supported by the implementation. 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ci When the renderbuffer is used as a source or destination for any 1365bd8deadSopenharmony_ci operation, when the attachment is flushed, or when the attachment is 1375bd8deadSopenharmony_ci broken, an implicit resolve of the multisample data may be performed. 1385bd8deadSopenharmony_ci After such a resolve, the contents of the multisample buffer become 1395bd8deadSopenharmony_ci undefined. The operations that may cause an implicit resolve are the 1405bd8deadSopenharmony_ci same as for FramebufferTexture2DMultisampleEXT. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci An OpenGL ES implementation may vary its allocation of internal 1435bd8deadSopenharmony_ci component resolution based on any RenderbufferStorageMultisampleEXT 1445bd8deadSopenharmony_ci parameter (except target), but the allocation and chosen internal format 1455bd8deadSopenharmony_ci must not be a function of any other state and cannot be changed once 1465bd8deadSopenharmony_ci they are established. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci The command 1495bd8deadSopenharmony_ci void RenderbufferStorage( enum target, enum internalformat, 1505bd8deadSopenharmony_ci sizei width, sizei height ); 1515bd8deadSopenharmony_ci is equivalent to calling RenderbufferStorageMultisampleEXT with 1525bd8deadSopenharmony_ci samples equal to zero. 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci Add the following after the paragraph describing FramebufferTexture2D: 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ci The command 1575bd8deadSopenharmony_ci void FramebufferTexture2DMultisampleEXT( enum target, 1585bd8deadSopenharmony_ci enum attachment, enum textarget, uint texture, 1595bd8deadSopenharmony_ci int level, sizei samples ); 1605bd8deadSopenharmony_ci enables multisampled rendering into the images of a texture object. 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci target, textarget, texture, and level correspond to the same 1635bd8deadSopenharmony_ci parameters for FramebufferTexture2D and have the same restrictions. 1645bd8deadSopenharmony_ci attachment must be COLOR_ATTACHMENT0. If samples is greater than the 1655bd8deadSopenharmony_ci value of MAX_SAMPLES_EXT, then the error INVALID_VALUE is generated. 1665bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if samples is greater than 1675bd8deadSopenharmony_ci the maximum number of samples supported for target and its 1685bd8deadSopenharmony_ci internalformat. If samples is zero, then TEXTURE_SAMPLES_EXT is set 1695bd8deadSopenharmony_ci to zero, and FramebufferTexture2DMultisampleEXT behaves like 1705bd8deadSopenharmony_ci FramebufferTexture2D. 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci Otherwise samples represents a request for a desired minimum number 1735bd8deadSopenharmony_ci of samples. Since different implementations may support different 1745bd8deadSopenharmony_ci sample counts for multisampled rendering, the actual number of samples 1755bd8deadSopenharmony_ci allocated for the image is implementation-dependent. However, the 1765bd8deadSopenharmony_ci resulting value for TEXTURE_SAMPLES_EXT is guaranteed to be greater 1775bd8deadSopenharmony_ci than or equal to samples and no more than the next larger sample count 1785bd8deadSopenharmony_ci supported by the implementation. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci The implementation allocates an implicit multisample buffer with 1815bd8deadSopenharmony_ci TEXTURE_SAMPLES_EXT samples and the same internalformat, width, and 1825bd8deadSopenharmony_ci height as the specified texture level. This buffer is used as the 1835bd8deadSopenharmony_ci target for rendering instead of the specified texture level. The 1845bd8deadSopenharmony_ci buffer is associated with the attachment and gets deleted after the 1855bd8deadSopenharmony_ci attachment is broken. 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci While the implicit multisample buffer is attached, color sample values 1885bd8deadSopenharmony_ci are automatically resolved to a single color in the texture level each 1895bd8deadSopenharmony_ci time a pixel is updated. This has the effect of making the antialiasing 1905bd8deadSopenharmony_ci appear to be automatic at the application level. 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci When the texture level is used as a source or destination for any 1935bd8deadSopenharmony_ci operation, the attachment is flushed, or when the attachment is broken, 1945bd8deadSopenharmony_ci the GL implementation may discard the contents of the implicit multisample 1955bd8deadSopenharmony_ci buffer. If the contents are discarded, the subsequent operations on the 1965bd8deadSopenharmony_ci multisample buffer will behave as if all samples within a pixel have the 1975bd8deadSopenharmony_ci value most recently written to the color buffer for that pixel. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci The operations which may cause the contents of the implicit multisample 2005bd8deadSopenharmony_ci buffer to be discarded include: 2015bd8deadSopenharmony_ci - Drawing with the texture bound to an active texture unit 2025bd8deadSopenharmony_ci - ReadPixels or CopyTex[Sub]Image* while the texture is 2035bd8deadSopenharmony_ci attached to the framebuffer 2045bd8deadSopenharmony_ci - CopyTex[Sub]Image*, Tex[Sub]Image*, 2055bd8deadSopenharmony_ci CompressedTex[Sub]Image* with the specified level as 2065bd8deadSopenharmony_ci destination 2075bd8deadSopenharmony_ci - GenerateMipmap 2085bd8deadSopenharmony_ci - Flush or Finish while the texture is attached to the 2095bd8deadSopenharmony_ci framebuffer 2105bd8deadSopenharmony_ci - BindFramebuffer while the texture is attached to the currently 2115bd8deadSopenharmony_ci bound framebuffer. 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ciAdditions to section 4.4.5 of the OpenGL ES 2.0 Specification 2155bd8deadSopenharmony_ci(Framebuffer Completeness) 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci Add the following bullet point to the list of conditions for 2185bd8deadSopenharmony_ci Framebuffer Attachment Completeness: 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci * The number of texture samples (as set by FramebufferTexture2DMultisampleEXT) 2215bd8deadSopenharmony_ci must be less than or equal to the maximum number of samples supported for 2225bd8deadSopenharmony_ci the internal format of _image_. 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci Add the following bullet point after 2255bd8deadSopenharmony_ci * All attached images have the same width and height. 2265bd8deadSopenharmony_ci FRAMEBUFFER_INCOMPLETE_DIMENSIONS 2275bd8deadSopenharmony_ci on page 116: 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci * The value of RENDERBUFFER_SAMPLES_EXT is the same for all 2305bd8deadSopenharmony_ci attached renderbuffers; the value of TEXTURE_SAMPLES_EXT 2315bd8deadSopenharmony_ci is the same for all texture attachments; and, if the attached 2325bd8deadSopenharmony_ci images are a mix of renderbuffers and textures, the value of 2335bd8deadSopenharmony_ci RENDERBUFFER_SAMPLES_EXT matches the value of TEXTURE_- 2345bd8deadSopenharmony_ci SAMPLES_EXT. 2355bd8deadSopenharmony_ci FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ciDependencies on GL and ES profiles, versions, and other extensions 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci Interactions with OpenGL ES 3.0 and later versions: 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci If OpenGL ES 3.0 or later is not supported, ignore all references 2425bd8deadSopenharmony_ci to DRAW_FRAMEBUFFER and READ_FRAMEBUFFER. 2435bd8deadSopenharmony_ci 2445bd8deadSopenharmony_ci The OpenGL ES 3.1 specification states that: 2455bd8deadSopenharmony_ci "An INVALID_OPERATION error is generated by CopyTexSubImage3D, 2465bd8deadSopenharmony_ci CopyTexImage2D, or CopyTexSubImage2D if 2475bd8deadSopenharmony_ci ... 2485bd8deadSopenharmony_ci * the value of READ_FRAMEBUFFER_BINDING is non-zero, and 2495bd8deadSopenharmony_ci - the read buffer selects an attachment that has no image attached, 2505bd8deadSopenharmony_ci or 2515bd8deadSopenharmony_ci - the value of SAMPLE_BUFFERS for the read framebuffer is one." 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci Similarly, for ReadPixels: 2545bd8deadSopenharmony_ci "An INVALID_OPERATION error is generated if the value of READ_- 2555bd8deadSopenharmony_ci FRAMEBUFFER_BINDING (see section 9) is non-zero, the read framebuffer 2565bd8deadSopenharmony_ci is framebuffer complete, and the value of SAMPLE_BUFFERS for the read 2575bd8deadSopenharmony_ci framebuffer is one." 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci These errors do not apply to textures and renderbuffers that have 2605bd8deadSopenharmony_ci associated multisample data specified by the mechanisms described in 2615bd8deadSopenharmony_ci this extension, i.e., the above operations are allowed even when 2625bd8deadSopenharmony_ci SAMPLE_BUFFERS is non-zero for renderbuffers created via Renderbuffer- 2635bd8deadSopenharmony_ci StorageMultisampleEXT or textures attached via FramebufferTexture2D- 2645bd8deadSopenharmony_ci MultisampleEXT. 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci Also, FBOs cannot combine attachments that have associated multisample 2675bd8deadSopenharmony_ci data specified by the mechanisms described in this extension with 2685bd8deadSopenharmony_ci attachments allocated using the core OpenGL ES 3.1 mechanisms, such as 2695bd8deadSopenharmony_ci TexStorage2DMultisample. Add to section 9.4.2 "Whole Framebuffer 2705bd8deadSopenharmony_ci Completeness": 2715bd8deadSopenharmony_ci "* If the value of RENDERBUFFER_SAMPLES is non-zero, all or none of the 2725bd8deadSopenharmony_ci attached renderbuffers have been allocated using RenderbufferStorage- 2735bd8deadSopenharmony_ci MultisampleEXT; if the value of TEXTURES_SAMPLES is non-zero, all or 2745bd8deadSopenharmony_ci none of the attached textures have been attached using Framebuffer- 2755bd8deadSopenharmony_ci Texture2DMultisampleEXT. 2765bd8deadSopenharmony_ci { GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT }" 2775bd8deadSopenharmony_ci 2785bd8deadSopenharmony_ci Add to the description of FramebufferTexture2DMultisampleEXT (first 2795bd8deadSopenharmony_ci paragraph): 2805bd8deadSopenharmony_ci "The maximum number of samples supported can be determined by calling 2815bd8deadSopenharmony_ci GetInternalformativ with a pname of SAMPLES." 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ciErrors 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci The error OUT_OF_MEMORY is generated when 2865bd8deadSopenharmony_ci RenderbufferStorageMultisampleEXT cannot create storage of the 2875bd8deadSopenharmony_ci specified size. 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ci If RenderbufferStorageMultisampleEXT is called with a value of 2905bd8deadSopenharmony_ci <samples> that is greater than MAX_SAMPLES_EXT, then the error 2915bd8deadSopenharmony_ci INVALID_VALUE is generated. 2925bd8deadSopenharmony_ci 2935bd8deadSopenharmony_ci The error INVALID_ENUM is generated if FramebufferTexture2DMultisampleEXT 2945bd8deadSopenharmony_ci is called with a <target> that is not FRAMEBUFFER, DRAW_FRAMEBUFFER, or 2955bd8deadSopenharmony_ci READ_FRAMEBUFFER. 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ci The error INVALID_ENUM is generated if FramebufferTexture2DMultisampleEXT 2985bd8deadSopenharmony_ci is called with an <attachment> that is not COLOR_ATTACHMENT0. 2995bd8deadSopenharmony_ci 3005bd8deadSopenharmony_ci The error INVALID_ENUM is generated if FramebufferTexture2DMultisampleEXT 3015bd8deadSopenharmony_ci is called with a <textarget> that is not TEXTURE_2D, 3025bd8deadSopenharmony_ci TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, 3035bd8deadSopenharmony_ci TEXTURE_CUBE_MAP_POSITIVE_Z, TEXTURE_CUBE_MAP_NEGATIVE_X, 3045bd8deadSopenharmony_ci TEXTURE_CUBE_MAP_NEGATIVE_Y, or TEXTURE_CUBE_MAP_NEGATIVE_Z. 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci The error INVALID_OPERATION is generated if FramebufferTexture2DMultisampleEXT 3075bd8deadSopenharmony_ci is called with <samples> greater than the maximum number of samples supported 3085bd8deadSopenharmony_ci for <target> and its internalformat. 3095bd8deadSopenharmony_ci 3105bd8deadSopenharmony_ciNew State 3115bd8deadSopenharmony_ci 3125bd8deadSopenharmony_ci Changes to table 6.22, p. 154 (Renderbuffer State) 3135bd8deadSopenharmony_ci 3145bd8deadSopenharmony_ci Initial 3155bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 3165bd8deadSopenharmony_ci --------- ---- ---------------- ------- ------------ ----- 3175bd8deadSopenharmony_ci RENDERBUFFER_SAMPLES_EXT Z+ GetRenderbuffer- 0 Renderbuffer 4.4.3 3185bd8deadSopenharmony_ci Parameteriv samples 3195bd8deadSopenharmony_ci 3205bd8deadSopenharmony_ci Changes to table 6.23, p. 155 (Framebuffer State) 3215bd8deadSopenharmony_ci 3225bd8deadSopenharmony_ci Initial 3235bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 3245bd8deadSopenharmony_ci --------- ------ --------------------- ------- --------------- ---- 3255bd8deadSopenharmony_ci TEXTURE_SAMPLES_EXT n * Z+ GetFramebuffer- 0 Framebuffer 4.4 3265bd8deadSopenharmony_ci AttachmentParameteriv texture samples 3275bd8deadSopenharmony_ci 3285bd8deadSopenharmony_ciNew Implementation Dependent State 3295bd8deadSopenharmony_ci 3305bd8deadSopenharmony_ci Changes to table 6.17, p. 149 (Implementation Dependent Values) 3315bd8deadSopenharmony_ci 3325bd8deadSopenharmony_ci Minimum 3335bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 3345bd8deadSopenharmony_ci --------- ---- ----------- ------- ----------- ---- 3355bd8deadSopenharmony_ci MAX_SAMPLES_EXT Z+ GetIntegerv 2 Max. # of 4.4 3365bd8deadSopenharmony_ci samples. 3375bd8deadSopenharmony_ci 3385bd8deadSopenharmony_ciSample Code 3395bd8deadSopenharmony_ci 3405bd8deadSopenharmony_ci GLsizei width = ...; 3415bd8deadSopenharmony_ci GLsizei height = ...; 3425bd8deadSopenharmony_ci GLint samples; 3435bd8deadSopenharmony_ci glGetIntegerv(GL_MAX_SAMPLES_EXT, &samples); 3445bd8deadSopenharmony_ci 3455bd8deadSopenharmony_ci /* Create multisampled depth renderbuffer */ 3465bd8deadSopenharmony_ci GLuint depthbuffer; 3475bd8deadSopenharmony_ci glGenRenderbuffers(1, &depthbuffer); 3485bd8deadSopenharmony_ci glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer); 3495bd8deadSopenharmony_ci glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, samples, 3505bd8deadSopenharmony_ci GL_DEPTH_COMPONENT16, width, height); 3515bd8deadSopenharmony_ci glBindRenderbuffer(GL_RENDERBUFFER, 0); 3525bd8deadSopenharmony_ci 3535bd8deadSopenharmony_ci /* Create RGBA texture with single mipmap level */ 3545bd8deadSopenharmony_ci GLuint texture; 3555bd8deadSopenharmony_ci glGenTextures(1, &texture); 3565bd8deadSopenharmony_ci glBindTexture(GL_TEXTURE_2D, texture); 3575bd8deadSopenharmony_ci glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, 3585bd8deadSopenharmony_ci GL_UNSIGNED_SHORT_4_4_4_4, NULL); 3595bd8deadSopenharmony_ci glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 3605bd8deadSopenharmony_ci glBindTexture(GL_TEXTURE_2D, 0); 3615bd8deadSopenharmony_ci 3625bd8deadSopenharmony_ci /* Create framebuffer object, attach texture and depth renderbuffer */ 3635bd8deadSopenharmony_ci GLuint framebuffer; 3645bd8deadSopenharmony_ci glGenFramebuffers(1, &framebuffer); 3655bd8deadSopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); 3665bd8deadSopenharmony_ci glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 3675bd8deadSopenharmony_ci GL_RENDERBUFFER, depthbuffer); 3685bd8deadSopenharmony_ci glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, 3695bd8deadSopenharmony_ci GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0, samples); 3705bd8deadSopenharmony_ci 3715bd8deadSopenharmony_ci /* handle unsupported cases */ 3725bd8deadSopenharmony_ci if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != 3735bd8deadSopenharmony_ci GL_FRAMEBUFFER_COMPLETE) 3745bd8deadSopenharmony_ci { 3755bd8deadSopenharmony_ci ... 3765bd8deadSopenharmony_ci } 3775bd8deadSopenharmony_ci 3785bd8deadSopenharmony_ci /* draw to the texture */ 3795bd8deadSopenharmony_ci glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 3805bd8deadSopenharmony_ci ... 3815bd8deadSopenharmony_ci 3825bd8deadSopenharmony_ci /* Discard the depth renderbuffer contents if possible */ 3835bd8deadSopenharmony_ci if (extension_supported("GL_EXT_discard_framebuffer")) 3845bd8deadSopenharmony_ci { 3855bd8deadSopenharmony_ci GLenum discard_attachments[] = { GL_DEPTH_ATTACHMENT }; 3865bd8deadSopenharmony_ci glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, 3875bd8deadSopenharmony_ci discard_attachments); 3885bd8deadSopenharmony_ci } 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci /* Draw to the default framebuffer using the antialiased texture */ 3915bd8deadSopenharmony_ci /* Color data is implicitly resolved before the texture gets used */ 3925bd8deadSopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, 0); 3935bd8deadSopenharmony_ci glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | 3945bd8deadSopenharmony_ci GL_STENCIL_BUFFER_BIT); 3955bd8deadSopenharmony_ci glBindTexture(GL_TEXTURE_2D, texture); 3965bd8deadSopenharmony_ci ... 3975bd8deadSopenharmony_ci 3985bd8deadSopenharmony_ciConformance Tests 3995bd8deadSopenharmony_ci 4005bd8deadSopenharmony_ci No conformance test has been defined yet 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ciIssues 4035bd8deadSopenharmony_ci 4045bd8deadSopenharmony_ci 1. Which operations can cause a resolve? 4055bd8deadSopenharmony_ci The IMG_multisampled_render_to_texture includes this list: 4065bd8deadSopenharmony_ci - Drawing with the texture bound to an active texture unit 4075bd8deadSopenharmony_ci - ReadPixels or CopyTex[Sub]Image* while the texture is 4085bd8deadSopenharmony_ci attached to the framebuffer 4095bd8deadSopenharmony_ci - CopyTex[Sub]Image*, Tex[Sub]Image*, 4105bd8deadSopenharmony_ci CompressedTex[Sub]Image* with the specified level as 4115bd8deadSopenharmony_ci destination 4125bd8deadSopenharmony_ci - GenerateMipmap 4135bd8deadSopenharmony_ci An implementation may also want to resolve the multisample buffer on 4145bd8deadSopenharmony_ci operations such as: 4155bd8deadSopenharmony_ci - Flush and Finish when a multisampled texture or render- 4165bd8deadSopenharmony_ci buffer is attached to the current framebuffer. 4175bd8deadSopenharmony_ci - BindFramebuffer when the currently bound framebuffer has a 4185bd8deadSopenharmony_ci multisampled texture or renderbuffer attachment. 4195bd8deadSopenharmony_ci 4205bd8deadSopenharmony_ci RESOLVED: Allow, but don't require, all of the above to cause a resolve. 4215bd8deadSopenharmony_ci 4225bd8deadSopenharmony_ci 2. Should there be a way for applications to query if the multisample 4235bd8deadSopenharmony_ci buffer has been resolved - and therefore is undefined? 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci This may be useful if the operations that cause the multisample 4265bd8deadSopenharmony_ci buffer to be resolved is allowed to vary between implementations. 4275bd8deadSopenharmony_ci 4285bd8deadSopenharmony_ci RESOLVED: No, for two reasons: 1) This extension aims to be backwards 4295bd8deadSopenharmony_ci compatible with the IMG_multisampled_render_to_texture extension, which 4305bd8deadSopenharmony_ci did not include such a query, and 2) Given the resolution of issue 3 this 4315bd8deadSopenharmony_ci is not very useful as the application cannot control whether multisample 4325bd8deadSopenharmony_ci information is preserved or not. 4335bd8deadSopenharmony_ci 4345bd8deadSopenharmony_ci 3. Should there be a way for applications to preserve the multisample 4355bd8deadSopenharmony_ci buffer after a resolve? 4365bd8deadSopenharmony_ci 4375bd8deadSopenharmony_ci This would be similar in spirit to the EGL_BUFFER_PRESERVED options in 4385bd8deadSopenharmony_ci EGL 1.4. Applications could - at a performance and memory cost - choose 4395bd8deadSopenharmony_ci to make the multisample buffer _not_ undefined after a resolve. 4405bd8deadSopenharmony_ci 4415bd8deadSopenharmony_ci RESOLVED: No. The purpose of this extension is to support multisampled 4425bd8deadSopenharmony_ci rendering in a lightway manner. Preserving the multisample buffer goes 4435bd8deadSopenharmony_ci against this intent. 4445bd8deadSopenharmony_ci 4455bd8deadSopenharmony_ci 4. Should TEXTURE_SAMPLES_EXT rather be called FRAMEBUFFER_ATTACHMENT_- 4465bd8deadSopenharmony_ci TEXTURE_SAMPLES_EXT? 4475bd8deadSopenharmony_ci 4485bd8deadSopenharmony_ci TEXTURE_SAMPLES is used in desktop GL to refer to the number of samples in 4495bd8deadSopenharmony_ci a multisampled texture. This extension does not introduce multisampled 4505bd8deadSopenharmony_ci textures, but rather allows multisampled rendering to non-multisampled 4515bd8deadSopenharmony_ci textures. For the purposes of this extension, the texture sample count 4525bd8deadSopenharmony_ci should be considered framebuffer attachment state rather than texture 4535bd8deadSopenharmony_ci state, thus FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT is a more 4545bd8deadSopenharmony_ci appropriate name. 4555bd8deadSopenharmony_ci 4565bd8deadSopenharmony_ci RESOLVED: Use FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT. 4575bd8deadSopenharmony_ci 4585bd8deadSopenharmony_ci 5. Is CopyTex[Sub]Image2D allowed if the texture has implicit multisamples? 4595bd8deadSopenharmony_ci And is ReadPixels allowed if the texture or renderbuffer has implicit 4605bd8deadSopenharmony_ci multisamples? 4615bd8deadSopenharmony_ci 4625bd8deadSopenharmony_ci RESOLVED: Yes. 4635bd8deadSopenharmony_ci 4645bd8deadSopenharmony_ci This extension is written against OpenGL ES 2.0, which did not have multi- 4655bd8deadSopenharmony_ci sampled textures or renderbuffers. With this extension, an application can 4665bd8deadSopenharmony_ci use FramebufferTexture2DMultisampleEXT to associate multisample data with 4675bd8deadSopenharmony_ci an existing texture, or use RenderbufferStorageMultisampleEXT to allocate 4685bd8deadSopenharmony_ci a renderbuffer with associated multisample data. This does not add any 4695bd8deadSopenharmony_ci restrictions on the usage of such texture and renderbuffers beyond what 4705bd8deadSopenharmony_ci ES 2.0 defines, but any operations (such as CopyTexImage2D and ReadPixels) 4715bd8deadSopenharmony_ci may cause the multisample data to be resolved and lost. That is, the intent 4725bd8deadSopenharmony_ci of this extension is that implementations do not have to allocate multi- 4735bd8deadSopenharmony_ci sample data in system memory, but can store these data in internal high- 4745bd8deadSopenharmony_ci speed memory only, and implicitly downsample whenever those data need to 4755bd8deadSopenharmony_ci by visible is system memory. 4765bd8deadSopenharmony_ci 4775bd8deadSopenharmony_ci 6. What are the interactions with OpenGL ES 3.0 and later? 4785bd8deadSopenharmony_ci 4795bd8deadSopenharmony_ci RESOLVED. 4805bd8deadSopenharmony_ci 4815bd8deadSopenharmony_ci If this extension is supported in OpenGL ES 3.0 or later then 4825bd8deadSopenharmony_ci DRAW_FRAMEBUFFER and READ_FRAMEBUFFER are valid values for the <target> 4835bd8deadSopenharmony_ci parameter to FramebufferTexture2DMultisampleEXT. Since this parameter is 4845bd8deadSopenharmony_ci defined to correspond to - and have the same restrictions as - the <target> 4855bd8deadSopenharmony_ci parameter to FramebufferTexture2D, this also implies that FRAMEBUFFER is 4865bd8deadSopenharmony_ci equivalent to DRAW_FRAMEBUFFER for this command. 4875bd8deadSopenharmony_ci 4885bd8deadSopenharmony_ci Note that this behavior was first described in revision 6 of this extension, 4895bd8deadSopenharmony_ci and was undefined in earlier revisions of this spec. Drivers written against 4905bd8deadSopenharmony_ci these earlier versions may generate errors if DRAW_FRAMEBUFFER and READ_- 4915bd8deadSopenharmony_ci FRAMEBUFFER are used for the <target> parameter to 4925bd8deadSopenharmony_ci FramebufferTexture2DMultisampleEXT. 4935bd8deadSopenharmony_ci 4945bd8deadSopenharmony_ci 7. What is the language about automatic resolves about? 4955bd8deadSopenharmony_ci 4965bd8deadSopenharmony_ci RESOLVED. 4975bd8deadSopenharmony_ci 4985bd8deadSopenharmony_ci The GL specification is written as if the multisample buffer is a separate 4995bd8deadSopenharmony_ci buffer from the color buffer. This is not quite how modern GPUs work, but 5005bd8deadSopenharmony_ci was true for some historic systems. This extension builds on the existing 5015bd8deadSopenharmony_ci specification wording and uses the existing terminology. 5025bd8deadSopenharmony_ci 5035bd8deadSopenharmony_ci In the Multisampling section, the GL specification says that: 5045bd8deadSopenharmony_ci 5055bd8deadSopenharmony_ci "The color sample values are resolved to a single, displayable color. For 5065bd8deadSopenharmony_ci window system-provided framebuffers, this occurs each time a pixel is 5075bd8deadSopenharmony_ci updated, so the antialiasing appears to be automatic at the application 5085bd8deadSopenharmony_ci level." 5095bd8deadSopenharmony_ci 5105bd8deadSopenharmony_ci In practice, most GPUs will only resolve the color sample values once 5115bd8deadSopenharmony_ci (e.g. at the end of a frame), but from the application's point of view that 5125bd8deadSopenharmony_ci does not make any observable difference. 5135bd8deadSopenharmony_ci 5145bd8deadSopenharmony_ci This extension inherits this behavor. The application does not (and cannot) 5155bd8deadSopenharmony_ci do anything to resolve the multisamples - this is always done automatically. 5165bd8deadSopenharmony_ci 5175bd8deadSopenharmony_ci Further, this extension does not change any of the semantics around how 5185bd8deadSopenharmony_ci resources are synchronized. E.g. an attachment will always see the most 5195bd8deadSopenharmony_ci recent change made to the attached texture, whether that was done by 5205bd8deadSopenharmony_ci rendering into an attachment or by a texture update operation. 5215bd8deadSopenharmony_ci 5225bd8deadSopenharmony_ci This implies that the multisample buffer and the color buffer are always 5235bd8deadSopenharmony_ci "in sync". The only behavior that is implementation-defined in this 5245bd8deadSopenharmony_ci extension is when the implicit multisample buffer is discarded. After the 5255bd8deadSopenharmony_ci operations that may (or may not) cause such a discard, an application can 5265bd8deadSopenharmony_ci observe either 1 or n distinct values in the multisample buffer depending 5275bd8deadSopenharmony_ci on whether the discard happened or not. As described in Issue 2, there's 5285bd8deadSopenharmony_ci no way for the application to query whether the discard happened. 5295bd8deadSopenharmony_ci 5305bd8deadSopenharmony_ci 5315bd8deadSopenharmony_ciRevision History 5325bd8deadSopenharmony_ci 5335bd8deadSopenharmony_ci Revision 8, 2018/04/11 5345bd8deadSopenharmony_ci - Clarified wording around implicit resolves, and added Issue 7. 5355bd8deadSopenharmony_ci 5365bd8deadSopenharmony_ci Revision 7, 2016/06/28 5375bd8deadSopenharmony_ci - Clarified that it is an error to call FramebufferTexture2DMultisampleEXT 5385bd8deadSopenharmony_ci with a sample count higher than what is supported for the given internalformat. 5395bd8deadSopenharmony_ci - Added Framebuffer Attachment Completeness rule. 5405bd8deadSopenharmony_ci 5415bd8deadSopenharmony_ci Revision 6, 2016/04/06 5425bd8deadSopenharmony_ci - Updating interactions with OpenGL ES 3.0 and added the related 5435bd8deadSopenharmony_ci Issue 6. 5445bd8deadSopenharmony_ci 5455bd8deadSopenharmony_ci Revision 5, 2015/01/05 5465bd8deadSopenharmony_ci - Clarified that multisampled data is also implictly resolved for render- 5475bd8deadSopenharmony_ci buffers. 5485bd8deadSopenharmony_ci - Clarified interactions with multisampled textures in OpenGL ES 3.x. 5495bd8deadSopenharmony_ci - Added interaction with OpenGL ES 3.1. 5505bd8deadSopenharmony_ci - Added Issue 5. 5515bd8deadSopenharmony_ci 5525bd8deadSopenharmony_ci Revision 4, 2012/07/04 5535bd8deadSopenharmony_ci - Fixing bug where enum names clashed with enums in the GL extension 5545bd8deadSopenharmony_ci EXT_framebuffer_multisample, but with different values defined. 5555bd8deadSopenharmony_ci This causes obvious problems. As a consequence, values have been 5565bd8deadSopenharmony_ci updated for the following enums: 5575bd8deadSopenharmony_ci * RENDERBUFFER_SAMPLES_EXT 5585bd8deadSopenharmony_ci * FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 5595bd8deadSopenharmony_ci * MAX_SAMPLES_EXT 5605bd8deadSopenharmony_ci The values now match the values in EXT_framebuffer_multisample. 5615bd8deadSopenharmony_ci 5625bd8deadSopenharmony_ci Revision 3, 2011/11/21 5635bd8deadSopenharmony_ci - Fixing a bug in Sample Code where GL_DEPTH_EXT was used instead of 5645bd8deadSopenharmony_ci GL_DEPTH_ATTACHMENT. 5655bd8deadSopenharmony_ci 5665bd8deadSopenharmony_ci Revision 2, 2011/10/30 5675bd8deadSopenharmony_ci - Renaming to EXT extension. Resolving issues 1-4. 5685bd8deadSopenharmony_ci 5695bd8deadSopenharmony_ci Revision 1, 2011/10/02 5705bd8deadSopenharmony_ci - First draft of XXX extension (based on IMG extension with the same name) 571