1*8975f5c5SAndroid Build Coastguard WorkerName 2*8975f5c5SAndroid Build Coastguard Worker 3*8975f5c5SAndroid Build Coastguard Worker ANGLE_texture_usage 4*8975f5c5SAndroid Build Coastguard Worker 5*8975f5c5SAndroid Build Coastguard WorkerName Strings 6*8975f5c5SAndroid Build Coastguard Worker 7*8975f5c5SAndroid Build Coastguard Worker GL_ANGLE_texture_usage 8*8975f5c5SAndroid Build Coastguard Worker 9*8975f5c5SAndroid Build Coastguard WorkerContributors 10*8975f5c5SAndroid Build Coastguard Worker 11*8975f5c5SAndroid Build Coastguard Worker Nicolas Capens, TransGaming 12*8975f5c5SAndroid Build Coastguard Worker Daniel Koch, TransGaming 13*8975f5c5SAndroid Build Coastguard Worker 14*8975f5c5SAndroid Build Coastguard WorkerContact 15*8975f5c5SAndroid Build Coastguard Worker 16*8975f5c5SAndroid Build Coastguard Worker Daniel Koch, TransGaming (daniel 'at' transgaming.com) 17*8975f5c5SAndroid Build Coastguard Worker 18*8975f5c5SAndroid Build Coastguard WorkerStatus 19*8975f5c5SAndroid Build Coastguard Worker 20*8975f5c5SAndroid Build Coastguard Worker Complete 21*8975f5c5SAndroid Build Coastguard Worker 22*8975f5c5SAndroid Build Coastguard WorkerVersion 23*8975f5c5SAndroid Build Coastguard Worker 24*8975f5c5SAndroid Build Coastguard Worker Last Modified Date: November 10, 2011 25*8975f5c5SAndroid Build Coastguard Worker Version: 2 26*8975f5c5SAndroid Build Coastguard Worker 27*8975f5c5SAndroid Build Coastguard WorkerNumber 28*8975f5c5SAndroid Build Coastguard Worker 29*8975f5c5SAndroid Build Coastguard Worker OpenGL ES Extension #112 30*8975f5c5SAndroid Build Coastguard Worker 31*8975f5c5SAndroid Build Coastguard WorkerDependencies 32*8975f5c5SAndroid Build Coastguard Worker 33*8975f5c5SAndroid Build Coastguard Worker This extension is written against the OpenGL ES 2.0 Specification. 34*8975f5c5SAndroid Build Coastguard Worker 35*8975f5c5SAndroid Build Coastguard WorkerOverview 36*8975f5c5SAndroid Build Coastguard Worker 37*8975f5c5SAndroid Build Coastguard Worker In some implementations it is advantageous to know the expected 38*8975f5c5SAndroid Build Coastguard Worker usage of a texture before the backing storage for it is allocated. 39*8975f5c5SAndroid Build Coastguard Worker This can help to inform the implementation's choice of format 40*8975f5c5SAndroid Build Coastguard Worker and type of memory used for the allocation. If the usage is not 41*8975f5c5SAndroid Build Coastguard Worker known in advance, the implementation essentially has to make a 42*8975f5c5SAndroid Build Coastguard Worker guess as to how it will be used. If it is later proven wrong, 43*8975f5c5SAndroid Build Coastguard Worker it may need to perform costly re-allocations and/or reformatting 44*8975f5c5SAndroid Build Coastguard Worker of the texture data, resulting in reduced performance. 45*8975f5c5SAndroid Build Coastguard Worker 46*8975f5c5SAndroid Build Coastguard Worker This extension adds a texture usage flag that is specified via 47*8975f5c5SAndroid Build Coastguard Worker the TEXTURE_USAGE_ANGLE TexParameter. This can be used to 48*8975f5c5SAndroid Build Coastguard Worker indicate that the application knows that this texture will be 49*8975f5c5SAndroid Build Coastguard Worker used for rendering. 50*8975f5c5SAndroid Build Coastguard Worker 51*8975f5c5SAndroid Build Coastguard WorkerIP Status 52*8975f5c5SAndroid Build Coastguard Worker 53*8975f5c5SAndroid Build Coastguard Worker No known IP claims. 54*8975f5c5SAndroid Build Coastguard Worker 55*8975f5c5SAndroid Build Coastguard WorkerNew Procedures and Functions 56*8975f5c5SAndroid Build Coastguard Worker 57*8975f5c5SAndroid Build Coastguard Worker None 58*8975f5c5SAndroid Build Coastguard Worker 59*8975f5c5SAndroid Build Coastguard WorkerNew Tokens 60*8975f5c5SAndroid Build Coastguard Worker 61*8975f5c5SAndroid Build Coastguard Worker Accepted as a value for <pname> for the TexParameter{if} and 62*8975f5c5SAndroid Build Coastguard Worker TexParameter{if}v commands and for the <value> parameter of 63*8975f5c5SAndroid Build Coastguard Worker GetTexParameter{if}v: 64*8975f5c5SAndroid Build Coastguard Worker 65*8975f5c5SAndroid Build Coastguard Worker TEXTURE_USAGE_ANGLE 0x93A2 66*8975f5c5SAndroid Build Coastguard Worker 67*8975f5c5SAndroid Build Coastguard Worker Accepted as a value to <param> for the TexParameter{if} and 68*8975f5c5SAndroid Build Coastguard Worker to <params> for the TexParameter{if}v commands with a <pname> of 69*8975f5c5SAndroid Build Coastguard Worker TEXTURE_USAGE_ANGLE; returned as possible values for <data> when 70*8975f5c5SAndroid Build Coastguard Worker GetTexParameter{if}v is queried with a <value> of TEXTURE_USAGE_ANGLE: 71*8975f5c5SAndroid Build Coastguard Worker 72*8975f5c5SAndroid Build Coastguard Worker NONE 0x0000 73*8975f5c5SAndroid Build Coastguard Worker FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 74*8975f5c5SAndroid Build Coastguard Worker 75*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL ES Operation) 76*8975f5c5SAndroid Build Coastguard Worker 77*8975f5c5SAndroid Build Coastguard Worker None 78*8975f5c5SAndroid Build Coastguard Worker 79*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization) 80*8975f5c5SAndroid Build Coastguard Worker 81*8975f5c5SAndroid Build Coastguard Worker Add a new row to Table 3.10 (Texture parameters and their values): 82*8975f5c5SAndroid Build Coastguard Worker 83*8975f5c5SAndroid Build Coastguard Worker Name | Type | Legal Values 84*8975f5c5SAndroid Build Coastguard Worker ------------------------------------------------------------ 85*8975f5c5SAndroid Build Coastguard Worker TEXTURE_USAGE_ANGLE | enum | NONE, FRAMEBUFFER_ATTACHMENT_ANGLE 86*8975f5c5SAndroid Build Coastguard Worker 87*8975f5c5SAndroid Build Coastguard Worker Add a new section 3.7.x (Texture Usage) before section 3.7.12 and 88*8975f5c5SAndroid Build Coastguard Worker renumber the subsequent sections: 89*8975f5c5SAndroid Build Coastguard Worker 90*8975f5c5SAndroid Build Coastguard Worker "3.7.x Texture Usage 91*8975f5c5SAndroid Build Coastguard Worker 92*8975f5c5SAndroid Build Coastguard Worker Texture usage can be specified via the TEXTURE_USAGE_ANGLE value 93*8975f5c5SAndroid Build Coastguard Worker for the <pname> argument to TexParameter{if}[v]. In order to take effect, 94*8975f5c5SAndroid Build Coastguard Worker the texture usage must be specified before the texture contents are 95*8975f5c5SAndroid Build Coastguard Worker defined either via TexImage2D or TexStorage2DEXT. 96*8975f5c5SAndroid Build Coastguard Worker 97*8975f5c5SAndroid Build Coastguard Worker The usage values can impact the layout and type of memory used for the 98*8975f5c5SAndroid Build Coastguard Worker texture data. Specifying incorrect usage values may result in reduced 99*8975f5c5SAndroid Build Coastguard Worker functionality and/or significantly degraded performance. 100*8975f5c5SAndroid Build Coastguard Worker 101*8975f5c5SAndroid Build Coastguard Worker Possible values for <params> when <pname> is TEXTURE_USAGE_ANGLE are: 102*8975f5c5SAndroid Build Coastguard Worker 103*8975f5c5SAndroid Build Coastguard Worker NONE - the default. No particular usage has been specified and it is 104*8975f5c5SAndroid Build Coastguard Worker up to the implementation to determine the usage of the texture. 105*8975f5c5SAndroid Build Coastguard Worker Leaving the usage unspecified means that the implementation may 106*8975f5c5SAndroid Build Coastguard Worker have to reallocate the texture data as the texture is used in 107*8975f5c5SAndroid Build Coastguard Worker various ways. 108*8975f5c5SAndroid Build Coastguard Worker 109*8975f5c5SAndroid Build Coastguard Worker FRAMEBUFFER_ATTACHMENT_ANGLE - this texture will be attached to a 110*8975f5c5SAndroid Build Coastguard Worker framebuffer object and used as a desination for rendering or blits." 111*8975f5c5SAndroid Build Coastguard Worker 112*8975f5c5SAndroid Build Coastguard Worker Modify section 3.7.12 (Texture State) and place the last 3 sentences 113*8975f5c5SAndroid Build Coastguard Worker with the following: 114*8975f5c5SAndroid Build Coastguard Worker 115*8975f5c5SAndroid Build Coastguard Worker "Next, there are the three sets of texture properties; each consists of 116*8975f5c5SAndroid Build Coastguard Worker the selected minification and magnification filters, the wrap modes for 117*8975f5c5SAndroid Build Coastguard Worker <s> and <t>, and the usage flags. In the initial state, the value assigned 118*8975f5c5SAndroid Build Coastguard Worker to TEXTURE_MIN_FILTER is NEAREST_MIPMAP_LINEAR, and the value for 119*8975f5c5SAndroid Build Coastguard Worker TEXTURE_MAG_FILTER is LINEAR. <s> and <t> wrap modes are both set to 120*8975f5c5SAndroid Build Coastguard Worker REPEAT. The initial value for TEXTURE_USAGE_ANGLE is NONE." 121*8975f5c5SAndroid Build Coastguard Worker 122*8975f5c5SAndroid Build Coastguard Worker 123*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment 124*8975f5c5SAndroid Build Coastguard WorkerOperations and the Framebuffer) 125*8975f5c5SAndroid Build Coastguard Worker 126*8975f5c5SAndroid Build Coastguard Worker None 127*8975f5c5SAndroid Build Coastguard Worker 128*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 5 of the OpenGL ES 2.0 Specification (Special 129*8975f5c5SAndroid Build Coastguard WorkerFunctions): 130*8975f5c5SAndroid Build Coastguard Worker 131*8975f5c5SAndroid Build Coastguard Worker None 132*8975f5c5SAndroid Build Coastguard Worker 133*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and 134*8975f5c5SAndroid Build Coastguard WorkerState Requests) 135*8975f5c5SAndroid Build Coastguard Worker 136*8975f5c5SAndroid Build Coastguard Worker None 137*8975f5c5SAndroid Build Coastguard Worker 138*8975f5c5SAndroid Build Coastguard WorkerDependencies on EXT_texture_storage 139*8975f5c5SAndroid Build Coastguard Worker 140*8975f5c5SAndroid Build Coastguard Worker If EXT_texture_storage is not supported, omit any references to 141*8975f5c5SAndroid Build Coastguard Worker TexStorage2DEXT. 142*8975f5c5SAndroid Build Coastguard Worker 143*8975f5c5SAndroid Build Coastguard WorkerErrors 144*8975f5c5SAndroid Build Coastguard Worker 145*8975f5c5SAndroid Build Coastguard Worker If TexParameter{if} or TexParamter{if}v is called with a <pname> 146*8975f5c5SAndroid Build Coastguard Worker of TEXTURE_USAGE_ANGLE and the value of <param> or <params> is not 147*8975f5c5SAndroid Build Coastguard Worker NONE or FRAMEBUFFER_ATTACHMENT_ANGLE the error INVALID_VALUE is 148*8975f5c5SAndroid Build Coastguard Worker generated. 149*8975f5c5SAndroid Build Coastguard Worker 150*8975f5c5SAndroid Build Coastguard WorkerUsage Example 151*8975f5c5SAndroid Build Coastguard Worker 152*8975f5c5SAndroid Build Coastguard Worker /* create and bind texture */ 153*8975f5c5SAndroid Build Coastguard Worker glGenTextures(1, &texture); 154*8975f5c5SAndroid Build Coastguard Worker glActiveTexture(GL_TEXTURE0); 155*8975f5c5SAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, texture); 156*8975f5c5SAndroid Build Coastguard Worker 157*8975f5c5SAndroid Build Coastguard Worker /* specify texture parameters */ 158*8975f5c5SAndroid Build Coastguard Worker glTexParameteri(GL_TEXTURE_2D, GL_*, ...); /* as before */ 159*8975f5c5SAndroid Build Coastguard Worker 160*8975f5c5SAndroid Build Coastguard Worker /* specify that we'll be rendering to the texture */ 161*8975f5c5SAndroid Build Coastguard Worker glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE); 162*8975f5c5SAndroid Build Coastguard Worker 163*8975f5c5SAndroid Build Coastguard Worker glTexStorage2DEXT(GL_TEXTURE_2D, levels, ...); // Allocation 164*8975f5c5SAndroid Build Coastguard Worker for(int level = 0; level < levels; ++level) 165*8975f5c5SAndroid Build Coastguard Worker glTexSubImage2D(GL_TEXTURE_2D, level, ...); // Initialisation 166*8975f5c5SAndroid Build Coastguard Worker 167*8975f5c5SAndroid Build Coastguard WorkerIssues 168*8975f5c5SAndroid Build Coastguard Worker 169*8975f5c5SAndroid Build Coastguard Worker 1. Should there be a dynamic usage value? 170*8975f5c5SAndroid Build Coastguard Worker 171*8975f5c5SAndroid Build Coastguard Worker DISCUSSION: We could accept a dynamic flag to indicate that a texture will 172*8975f5c5SAndroid Build Coastguard Worker be updated frequently. We could map this to D3D9 dynamic textures. This would 173*8975f5c5SAndroid Build Coastguard Worker allow us to avoid creating temporary surfaces when updating the texture. 174*8975f5c5SAndroid Build Coastguard Worker However renderable textures cannot be dynamic in D3D9, which eliminates the 175*8975f5c5SAndroid Build Coastguard Worker primary use case for this. Furthermore, the memory usage of dynamic textures 176*8975f5c5SAndroid Build Coastguard Worker typically increases threefold when you lock it. 177*8975f5c5SAndroid Build Coastguard Worker 178*8975f5c5SAndroid Build Coastguard Worker 2. Should the texture usage be an enum or a bitfield? 179*8975f5c5SAndroid Build Coastguard Worker 180*8975f5c5SAndroid Build Coastguard Worker UNRESOLVED. Using a bitfield would allow combination of values to be specified. 181*8975f5c5SAndroid Build Coastguard Worker On the other hand, if combinations are really required, additional <pnames> 182*8975f5c5SAndroid Build Coastguard Worker could be added as necessary. Querying a bitfield via the GetTexParameter command 183*8975f5c5SAndroid Build Coastguard Worker feels a bit odd. 184*8975f5c5SAndroid Build Coastguard Worker 185*8975f5c5SAndroid Build Coastguard Worker 3. What should happen if TEXTURE_USAGE_ANGLE is set/changed after the texture 186*8975f5c5SAndroid Build Coastguard Worker contents have been specified? 187*8975f5c5SAndroid Build Coastguard Worker 188*8975f5c5SAndroid Build Coastguard Worker RESOLVED: It will have no effect. However, if the texture is redefined (for 189*8975f5c5SAndroid Build Coastguard Worker example by TexImage2D) the new allocation will use the updated usage. 190*8975f5c5SAndroid Build Coastguard Worker GetTexParameter is used to query the value of the TEXTURE_USAGE_ANGLE 191*8975f5c5SAndroid Build Coastguard Worker state that was last set by TexParameter for the currently bound texture, or 192*8975f5c5SAndroid Build Coastguard Worker the default value if it has never been set. There is no way to determine the 193*8975f5c5SAndroid Build Coastguard Worker usage that was in effect at the time the texture was defined. 194*8975f5c5SAndroid Build Coastguard Worker 195*8975f5c5SAndroid Build Coastguard WorkerRevision History 196*8975f5c5SAndroid Build Coastguard Worker 197*8975f5c5SAndroid Build Coastguard Worker Rev. Date Author Changes 198*8975f5c5SAndroid Build Coastguard Worker ---- ----------- --------- ---------------------------------------- 199*8975f5c5SAndroid Build Coastguard Worker 1 10 Nov 2011 dgkoch Initial revision 200*8975f5c5SAndroid Build Coastguard Worker 2 10 Nov 2011 dgkoch Add overview 201*8975f5c5SAndroid Build Coastguard Worker 202*8975f5c5SAndroid Build Coastguard Worker 203