Path: blob/main_old/extensions/ANGLE_texture_usage.txt
1693 views
Name12ANGLE_texture_usage34Name Strings56GL_ANGLE_texture_usage78Contributors910Nicolas Capens, TransGaming11Daniel Koch, TransGaming1213Contact1415Daniel Koch, TransGaming (daniel 'at' transgaming.com)1617Status1819Complete2021Version2223Last Modified Date: November 10, 201124Version: 22526Number2728OpenGL ES Extension #1122930Dependencies3132This extension is written against the OpenGL ES 2.0 Specification.3334Overview3536In some implementations it is advantageous to know the expected37usage of a texture before the backing storage for it is allocated.38This can help to inform the implementation's choice of format39and type of memory used for the allocation. If the usage is not40known in advance, the implementation essentially has to make a41guess as to how it will be used. If it is later proven wrong,42it may need to perform costly re-allocations and/or reformatting43of the texture data, resulting in reduced performance.4445This extension adds a texture usage flag that is specified via46the TEXTURE_USAGE_ANGLE TexParameter. This can be used to47indicate that the application knows that this texture will be48used for rendering.4950IP Status5152No known IP claims.5354New Procedures and Functions5556None5758New Tokens5960Accepted as a value for <pname> for the TexParameter{if} and61TexParameter{if}v commands and for the <value> parameter of62GetTexParameter{if}v:6364TEXTURE_USAGE_ANGLE 0x93A26566Accepted as a value to <param> for the TexParameter{if} and67to <params> for the TexParameter{if}v commands with a <pname> of68TEXTURE_USAGE_ANGLE; returned as possible values for <data> when69GetTexParameter{if}v is queried with a <value> of TEXTURE_USAGE_ANGLE:7071NONE 0x000072FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A37374Additions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL ES Operation)7576None7778Additions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)7980Add a new row to Table 3.10 (Texture parameters and their values):8182Name | Type | Legal Values83------------------------------------------------------------84TEXTURE_USAGE_ANGLE | enum | NONE, FRAMEBUFFER_ATTACHMENT_ANGLE8586Add a new section 3.7.x (Texture Usage) before section 3.7.12 and87renumber the subsequent sections:8889"3.7.x Texture Usage9091Texture usage can be specified via the TEXTURE_USAGE_ANGLE value92for the <pname> argument to TexParameter{if}[v]. In order to take effect,93the texture usage must be specified before the texture contents are94defined either via TexImage2D or TexStorage2DEXT.9596The usage values can impact the layout and type of memory used for the97texture data. Specifying incorrect usage values may result in reduced98functionality and/or significantly degraded performance.99100Possible values for <params> when <pname> is TEXTURE_USAGE_ANGLE are:101102NONE - the default. No particular usage has been specified and it is103up to the implementation to determine the usage of the texture.104Leaving the usage unspecified means that the implementation may105have to reallocate the texture data as the texture is used in106various ways.107108FRAMEBUFFER_ATTACHMENT_ANGLE - this texture will be attached to a109framebuffer object and used as a desination for rendering or blits."110111Modify section 3.7.12 (Texture State) and place the last 3 sentences112with the following:113114"Next, there are the three sets of texture properties; each consists of115the selected minification and magnification filters, the wrap modes for116<s> and <t>, and the usage flags. In the initial state, the value assigned117to TEXTURE_MIN_FILTER is NEAREST_MIPMAP_LINEAR, and the value for118TEXTURE_MAG_FILTER is LINEAR. <s> and <t> wrap modes are both set to119REPEAT. The initial value for TEXTURE_USAGE_ANGLE is NONE."120121122Additions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment123Operations and the Framebuffer)124125None126127Additions to Chapter 5 of the OpenGL ES 2.0 Specification (Special128Functions):129130None131132Additions to Chapter 6 of the OpenGL ES 2.0 Specification (State and133State Requests)134135None136137Dependencies on EXT_texture_storage138139If EXT_texture_storage is not supported, omit any references to140TexStorage2DEXT.141142Errors143144If TexParameter{if} or TexParamter{if}v is called with a <pname>145of TEXTURE_USAGE_ANGLE and the value of <param> or <params> is not146NONE or FRAMEBUFFER_ATTACHMENT_ANGLE the error INVALID_VALUE is147generated.148149Usage Example150151/* create and bind texture */152glGenTextures(1, &texture);153glActiveTexture(GL_TEXTURE0);154glBindTexture(GL_TEXTURE_2D, texture);155156/* specify texture parameters */157glTexParameteri(GL_TEXTURE_2D, GL_*, ...); /* as before */158159/* specify that we'll be rendering to the texture */160glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);161162glTexStorage2DEXT(GL_TEXTURE_2D, levels, ...); // Allocation163for(int level = 0; level < levels; ++level)164glTexSubImage2D(GL_TEXTURE_2D, level, ...); // Initialisation165166Issues1671681. Should there be a dynamic usage value?169170DISCUSSION: We could accept a dynamic flag to indicate that a texture will171be updated frequently. We could map this to D3D9 dynamic textures. This would172allow us to avoid creating temporary surfaces when updating the texture.173However renderable textures cannot be dynamic in D3D9, which eliminates the174primary use case for this. Furthermore, the memory usage of dynamic textures175typically increases threefold when you lock it.1761772. Should the texture usage be an enum or a bitfield?178179UNRESOLVED. Using a bitfield would allow combination of values to be specified.180On the other hand, if combinations are really required, additional <pnames>181could be added as necessary. Querying a bitfield via the GetTexParameter command182feels a bit odd.1831843. What should happen if TEXTURE_USAGE_ANGLE is set/changed after the texture185contents have been specified?186187RESOLVED: It will have no effect. However, if the texture is redefined (for188example by TexImage2D) the new allocation will use the updated usage.189GetTexParameter is used to query the value of the TEXTURE_USAGE_ANGLE190state that was last set by TexParameter for the currently bound texture, or191the default value if it has never been set. There is no way to determine the192usage that was in effect at the time the texture was defined.193194Revision History195196Rev. Date Author Changes197---- ----------- --------- ----------------------------------------1981 10 Nov 2011 dgkoch Initial revision1992 10 Nov 2011 dgkoch Add overview200201202203204