1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2012 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include "mtypes.h" 25bf215546Sopenharmony_ci#include "context.h" 26bf215546Sopenharmony_ci#include "glformats.h" 27bf215546Sopenharmony_ci#include "macros.h" 28bf215546Sopenharmony_ci#include "enums.h" 29bf215546Sopenharmony_ci#include "fbobject.h" 30bf215546Sopenharmony_ci#include "formatquery.h" 31bf215546Sopenharmony_ci#include "teximage.h" 32bf215546Sopenharmony_ci#include "texparam.h" 33bf215546Sopenharmony_ci#include "texobj.h" 34bf215546Sopenharmony_ci#include "get.h" 35bf215546Sopenharmony_ci#include "genmipmap.h" 36bf215546Sopenharmony_ci#include "shaderimage.h" 37bf215546Sopenharmony_ci#include "texcompress.h" 38bf215546Sopenharmony_ci#include "textureview.h" 39bf215546Sopenharmony_ci#include "api_exec_decl.h" 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_ci#include "state_tracker/st_format.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_cistatic bool 44bf215546Sopenharmony_ci_is_renderable(struct gl_context *ctx, GLenum internalformat) 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci /* Section 4.4.4 on page 212 of the GLES 3.0.4 spec says: 47bf215546Sopenharmony_ci * 48bf215546Sopenharmony_ci * "An internal format is color-renderable if it is one of the 49bf215546Sopenharmony_ci * formats from table 3.13 noted as color-renderable or if it 50bf215546Sopenharmony_ci * is unsized format RGBA or RGB." 51bf215546Sopenharmony_ci * 52bf215546Sopenharmony_ci * Therefore, we must accept GL_RGB and GL_RGBA here. 53bf215546Sopenharmony_ci */ 54bf215546Sopenharmony_ci if (internalformat != GL_RGB && internalformat != GL_RGBA && 55bf215546Sopenharmony_ci _mesa_base_fbo_format(ctx, internalformat) == 0) 56bf215546Sopenharmony_ci return false; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci return true; 59bf215546Sopenharmony_ci} 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci/* Handles the cases where either ARB_internalformat_query or 62bf215546Sopenharmony_ci * ARB_internalformat_query2 have to return an error. 63bf215546Sopenharmony_ci */ 64bf215546Sopenharmony_cistatic bool 65bf215546Sopenharmony_ci_legal_parameters(struct gl_context *ctx, GLenum target, GLenum internalformat, 66bf215546Sopenharmony_ci GLenum pname, GLsizei bufSize, GLint *params) 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci{ 69bf215546Sopenharmony_ci bool query2 = _mesa_has_ARB_internalformat_query2(ctx); 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 72bf215546Sopenharmony_ci * 73bf215546Sopenharmony_ci * "The INVALID_ENUM error is generated if the <target> parameter to 74bf215546Sopenharmony_ci * GetInternalformati*v is not one of the targets listed in Table 6.xx. 75bf215546Sopenharmony_ci */ 76bf215546Sopenharmony_ci switch(target){ 77bf215546Sopenharmony_ci case GL_TEXTURE_1D: 78bf215546Sopenharmony_ci case GL_TEXTURE_1D_ARRAY: 79bf215546Sopenharmony_ci case GL_TEXTURE_2D: 80bf215546Sopenharmony_ci case GL_TEXTURE_2D_ARRAY: 81bf215546Sopenharmony_ci case GL_TEXTURE_3D: 82bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 83bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP_ARRAY: 84bf215546Sopenharmony_ci case GL_TEXTURE_RECTANGLE: 85bf215546Sopenharmony_ci case GL_TEXTURE_BUFFER: 86bf215546Sopenharmony_ci if (!query2) { 87bf215546Sopenharmony_ci /* The ARB_internalformat_query spec says: 88bf215546Sopenharmony_ci * 89bf215546Sopenharmony_ci * "If the <target> parameter to GetInternalformativ is not one of 90bf215546Sopenharmony_ci * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY 91bf215546Sopenharmony_ci * or RENDERBUFFER then an INVALID_ENUM error is generated. 92bf215546Sopenharmony_ci */ 93bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 94bf215546Sopenharmony_ci "glGetInternalformativ(target=%s)", 95bf215546Sopenharmony_ci _mesa_enum_to_string(target)); 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci return false; 98bf215546Sopenharmony_ci } 99bf215546Sopenharmony_ci break; 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci case GL_RENDERBUFFER: 102bf215546Sopenharmony_ci break; 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE: 105bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 106bf215546Sopenharmony_ci /* The non-existence of ARB_texture_multisample is treated in 107bf215546Sopenharmony_ci * ARB_internalformat_query implementation like an error. 108bf215546Sopenharmony_ci */ 109bf215546Sopenharmony_ci if (!query2 && 110bf215546Sopenharmony_ci !(_mesa_has_ARB_texture_multisample(ctx) || _mesa_is_gles31(ctx))) { 111bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 112bf215546Sopenharmony_ci "glGetInternalformativ(target=%s)", 113bf215546Sopenharmony_ci _mesa_enum_to_string(target)); 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci return false; 116bf215546Sopenharmony_ci } 117bf215546Sopenharmony_ci break; 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci default: 120bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 121bf215546Sopenharmony_ci "glGetInternalformativ(target=%s)", 122bf215546Sopenharmony_ci _mesa_enum_to_string(target)); 123bf215546Sopenharmony_ci return false; 124bf215546Sopenharmony_ci } 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 128bf215546Sopenharmony_ci * 129bf215546Sopenharmony_ci * "The INVALID_ENUM error is generated if the <pname> parameter is 130bf215546Sopenharmony_ci * not one of the listed possibilities. 131bf215546Sopenharmony_ci */ 132bf215546Sopenharmony_ci switch(pname){ 133bf215546Sopenharmony_ci case GL_SAMPLES: 134bf215546Sopenharmony_ci case GL_NUM_SAMPLE_COUNTS: 135bf215546Sopenharmony_ci break; 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_ci case GL_TEXTURE_REDUCTION_MODE_ARB: 138bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_filter_minmax(ctx)) { 139bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 140bf215546Sopenharmony_ci "glGetInternalformativ(pname=%s)", 141bf215546Sopenharmony_ci _mesa_enum_to_string(pname)); 142bf215546Sopenharmony_ci return false; 143bf215546Sopenharmony_ci } 144bf215546Sopenharmony_ci break; 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_ci case GL_NUM_VIRTUAL_PAGE_SIZES_ARB: 147bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_X_ARB: 148bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_Y_ARB: 149bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_Z_ARB: 150bf215546Sopenharmony_ci if (!_mesa_has_ARB_sparse_texture(ctx)) { 151bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 152bf215546Sopenharmony_ci "glGetInternalformativ(pname=%s)", 153bf215546Sopenharmony_ci _mesa_enum_to_string(pname)); 154bf215546Sopenharmony_ci return false; 155bf215546Sopenharmony_ci } 156bf215546Sopenharmony_ci break; 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci case GL_SRGB_DECODE_ARB: 159bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 160bf215546Sopenharmony_ci * 161bf215546Sopenharmony_ci * "If ARB_texture_sRGB_decode or EXT_texture_sRGB_decode or 162bf215546Sopenharmony_ci * equivalent functionality is not supported, queries for the 163bf215546Sopenharmony_ci * SRGB_DECODE_ARB <pname> set the INVALID_ENUM error. 164bf215546Sopenharmony_ci */ 165bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_sRGB_decode(ctx)) { 166bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 167bf215546Sopenharmony_ci "glGetInternalformativ(pname=%s)", 168bf215546Sopenharmony_ci _mesa_enum_to_string(pname)); 169bf215546Sopenharmony_ci return false; 170bf215546Sopenharmony_ci } 171bf215546Sopenharmony_ci FALLTHROUGH; 172bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SUPPORTED: 173bf215546Sopenharmony_ci case GL_INTERNALFORMAT_PREFERRED: 174bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_SIZE: 175bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_SIZE: 176bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_SIZE: 177bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_SIZE: 178bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_SIZE: 179bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_SIZE: 180bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SHARED_SIZE: 181bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_TYPE: 182bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_TYPE: 183bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_TYPE: 184bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_TYPE: 185bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_TYPE: 186bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_TYPE: 187bf215546Sopenharmony_ci case GL_MAX_WIDTH: 188bf215546Sopenharmony_ci case GL_MAX_HEIGHT: 189bf215546Sopenharmony_ci case GL_MAX_DEPTH: 190bf215546Sopenharmony_ci case GL_MAX_LAYERS: 191bf215546Sopenharmony_ci case GL_MAX_COMBINED_DIMENSIONS: 192bf215546Sopenharmony_ci case GL_COLOR_COMPONENTS: 193bf215546Sopenharmony_ci case GL_DEPTH_COMPONENTS: 194bf215546Sopenharmony_ci case GL_STENCIL_COMPONENTS: 195bf215546Sopenharmony_ci case GL_COLOR_RENDERABLE: 196bf215546Sopenharmony_ci case GL_DEPTH_RENDERABLE: 197bf215546Sopenharmony_ci case GL_STENCIL_RENDERABLE: 198bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE: 199bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 200bf215546Sopenharmony_ci case GL_FRAMEBUFFER_BLEND: 201bf215546Sopenharmony_ci case GL_READ_PIXELS: 202bf215546Sopenharmony_ci case GL_READ_PIXELS_FORMAT: 203bf215546Sopenharmony_ci case GL_READ_PIXELS_TYPE: 204bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_FORMAT: 205bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_TYPE: 206bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_FORMAT: 207bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_TYPE: 208bf215546Sopenharmony_ci case GL_MIPMAP: 209bf215546Sopenharmony_ci case GL_MANUAL_GENERATE_MIPMAP: 210bf215546Sopenharmony_ci case GL_AUTO_GENERATE_MIPMAP: 211bf215546Sopenharmony_ci case GL_COLOR_ENCODING: 212bf215546Sopenharmony_ci case GL_SRGB_READ: 213bf215546Sopenharmony_ci case GL_SRGB_WRITE: 214bf215546Sopenharmony_ci case GL_FILTER: 215bf215546Sopenharmony_ci case GL_VERTEX_TEXTURE: 216bf215546Sopenharmony_ci case GL_TESS_CONTROL_TEXTURE: 217bf215546Sopenharmony_ci case GL_TESS_EVALUATION_TEXTURE: 218bf215546Sopenharmony_ci case GL_GEOMETRY_TEXTURE: 219bf215546Sopenharmony_ci case GL_FRAGMENT_TEXTURE: 220bf215546Sopenharmony_ci case GL_COMPUTE_TEXTURE: 221bf215546Sopenharmony_ci case GL_TEXTURE_SHADOW: 222bf215546Sopenharmony_ci case GL_TEXTURE_GATHER: 223bf215546Sopenharmony_ci case GL_TEXTURE_GATHER_SHADOW: 224bf215546Sopenharmony_ci case GL_SHADER_IMAGE_LOAD: 225bf215546Sopenharmony_ci case GL_SHADER_IMAGE_STORE: 226bf215546Sopenharmony_ci case GL_SHADER_IMAGE_ATOMIC: 227bf215546Sopenharmony_ci case GL_IMAGE_TEXEL_SIZE: 228bf215546Sopenharmony_ci case GL_IMAGE_COMPATIBILITY_CLASS: 229bf215546Sopenharmony_ci case GL_IMAGE_PIXEL_FORMAT: 230bf215546Sopenharmony_ci case GL_IMAGE_PIXEL_TYPE: 231bf215546Sopenharmony_ci case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: 232bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 233bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 234bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 235bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 236bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED: 237bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH: 238bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT: 239bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_SIZE: 240bf215546Sopenharmony_ci case GL_CLEAR_BUFFER: 241bf215546Sopenharmony_ci case GL_TEXTURE_VIEW: 242bf215546Sopenharmony_ci case GL_VIEW_COMPATIBILITY_CLASS: 243bf215546Sopenharmony_ci case GL_NUM_TILING_TYPES_EXT: 244bf215546Sopenharmony_ci case GL_TILING_TYPES_EXT: 245bf215546Sopenharmony_ci /* The ARB_internalformat_query spec says: 246bf215546Sopenharmony_ci * 247bf215546Sopenharmony_ci * "If the <pname> parameter to GetInternalformativ is not SAMPLES 248bf215546Sopenharmony_ci * or NUM_SAMPLE_COUNTS, then an INVALID_ENUM error is generated." 249bf215546Sopenharmony_ci */ 250bf215546Sopenharmony_ci if (!query2) { 251bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 252bf215546Sopenharmony_ci "glGetInternalformativ(pname=%s)", 253bf215546Sopenharmony_ci _mesa_enum_to_string(pname)); 254bf215546Sopenharmony_ci 255bf215546Sopenharmony_ci return false; 256bf215546Sopenharmony_ci } 257bf215546Sopenharmony_ci break; 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_ci default: 260bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 261bf215546Sopenharmony_ci "glGetInternalformativ(pname=%s)", 262bf215546Sopenharmony_ci _mesa_enum_to_string(pname)); 263bf215546Sopenharmony_ci return false; 264bf215546Sopenharmony_ci } 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_ci /* The ARB_internalformat_query spec says: 267bf215546Sopenharmony_ci * 268bf215546Sopenharmony_ci * "If the <bufSize> parameter to GetInternalformativ is negative, then 269bf215546Sopenharmony_ci * an INVALID_VALUE error is generated." 270bf215546Sopenharmony_ci * 271bf215546Sopenharmony_ci * Nothing is said in ARB_internalformat_query2 but we assume the same. 272bf215546Sopenharmony_ci */ 273bf215546Sopenharmony_ci if (bufSize < 0) { 274bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_VALUE, 275bf215546Sopenharmony_ci "glGetInternalformativ(target=%s)", 276bf215546Sopenharmony_ci _mesa_enum_to_string(target)); 277bf215546Sopenharmony_ci return false; 278bf215546Sopenharmony_ci } 279bf215546Sopenharmony_ci 280bf215546Sopenharmony_ci /* The ARB_internalformat_query spec says: 281bf215546Sopenharmony_ci * 282bf215546Sopenharmony_ci * "If the <internalformat> parameter to GetInternalformativ is not 283bf215546Sopenharmony_ci * color-, depth- or stencil-renderable, then an INVALID_ENUM error is 284bf215546Sopenharmony_ci * generated." 285bf215546Sopenharmony_ci */ 286bf215546Sopenharmony_ci if (!query2 && !_is_renderable(ctx, internalformat)) { 287bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_ENUM, 288bf215546Sopenharmony_ci "glGetInternalformativ(internalformat=%s)", 289bf215546Sopenharmony_ci _mesa_enum_to_string(internalformat)); 290bf215546Sopenharmony_ci return false; 291bf215546Sopenharmony_ci } 292bf215546Sopenharmony_ci 293bf215546Sopenharmony_ci return true; 294bf215546Sopenharmony_ci} 295bf215546Sopenharmony_ci 296bf215546Sopenharmony_ci/* Sets the appropriate "unsupported" response as defined by the 297bf215546Sopenharmony_ci * ARB_internalformat_query2 spec for each each <pname>. 298bf215546Sopenharmony_ci */ 299bf215546Sopenharmony_cistatic void 300bf215546Sopenharmony_ci_set_default_response(GLenum pname, GLint buffer[16]) 301bf215546Sopenharmony_ci{ 302bf215546Sopenharmony_ci /* The ARB_internalformat_query2 defines which is the reponse best 303bf215546Sopenharmony_ci * representing "not supported" or "not applicable" for each <pname>. 304bf215546Sopenharmony_ci * 305bf215546Sopenharmony_ci * " In general: 306bf215546Sopenharmony_ci * - size- or count-based queries will return zero, 307bf215546Sopenharmony_ci * - support-, format- or type-based queries will return NONE, 308bf215546Sopenharmony_ci * - boolean-based queries will return FALSE, and 309bf215546Sopenharmony_ci * - list-based queries return no entries." 310bf215546Sopenharmony_ci */ 311bf215546Sopenharmony_ci switch(pname) { 312bf215546Sopenharmony_ci case GL_SAMPLES: 313bf215546Sopenharmony_ci case GL_TILING_TYPES_EXT: 314bf215546Sopenharmony_ci break; 315bf215546Sopenharmony_ci 316bf215546Sopenharmony_ci case GL_MAX_COMBINED_DIMENSIONS: 317bf215546Sopenharmony_ci /* This value can be a 64-bit value. As the default is the 32-bit query, 318bf215546Sopenharmony_ci * we pack 2 32-bit integers. So we need to clean both */ 319bf215546Sopenharmony_ci buffer[0] = 0; 320bf215546Sopenharmony_ci buffer[1] = 0; 321bf215546Sopenharmony_ci break; 322bf215546Sopenharmony_ci 323bf215546Sopenharmony_ci case GL_NUM_SAMPLE_COUNTS: 324bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_SIZE: 325bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_SIZE: 326bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_SIZE: 327bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_SIZE: 328bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_SIZE: 329bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_SIZE: 330bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SHARED_SIZE: 331bf215546Sopenharmony_ci case GL_MAX_WIDTH: 332bf215546Sopenharmony_ci case GL_MAX_HEIGHT: 333bf215546Sopenharmony_ci case GL_MAX_DEPTH: 334bf215546Sopenharmony_ci case GL_MAX_LAYERS: 335bf215546Sopenharmony_ci case GL_IMAGE_TEXEL_SIZE: 336bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH: 337bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT: 338bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_SIZE: 339bf215546Sopenharmony_ci case GL_NUM_TILING_TYPES_EXT: 340bf215546Sopenharmony_ci case GL_NUM_VIRTUAL_PAGE_SIZES_ARB: 341bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_X_ARB: 342bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_Y_ARB: 343bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_Z_ARB: 344bf215546Sopenharmony_ci buffer[0] = 0; 345bf215546Sopenharmony_ci break; 346bf215546Sopenharmony_ci 347bf215546Sopenharmony_ci case GL_INTERNALFORMAT_PREFERRED: 348bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_TYPE: 349bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_TYPE: 350bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_TYPE: 351bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_TYPE: 352bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_TYPE: 353bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_TYPE: 354bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE: 355bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 356bf215546Sopenharmony_ci case GL_FRAMEBUFFER_BLEND: 357bf215546Sopenharmony_ci case GL_READ_PIXELS: 358bf215546Sopenharmony_ci case GL_READ_PIXELS_FORMAT: 359bf215546Sopenharmony_ci case GL_READ_PIXELS_TYPE: 360bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_FORMAT: 361bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_TYPE: 362bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_FORMAT: 363bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_TYPE: 364bf215546Sopenharmony_ci case GL_MANUAL_GENERATE_MIPMAP: 365bf215546Sopenharmony_ci case GL_AUTO_GENERATE_MIPMAP: 366bf215546Sopenharmony_ci case GL_COLOR_ENCODING: 367bf215546Sopenharmony_ci case GL_SRGB_READ: 368bf215546Sopenharmony_ci case GL_SRGB_WRITE: 369bf215546Sopenharmony_ci case GL_SRGB_DECODE_ARB: 370bf215546Sopenharmony_ci case GL_FILTER: 371bf215546Sopenharmony_ci case GL_VERTEX_TEXTURE: 372bf215546Sopenharmony_ci case GL_TESS_CONTROL_TEXTURE: 373bf215546Sopenharmony_ci case GL_TESS_EVALUATION_TEXTURE: 374bf215546Sopenharmony_ci case GL_GEOMETRY_TEXTURE: 375bf215546Sopenharmony_ci case GL_FRAGMENT_TEXTURE: 376bf215546Sopenharmony_ci case GL_COMPUTE_TEXTURE: 377bf215546Sopenharmony_ci case GL_TEXTURE_SHADOW: 378bf215546Sopenharmony_ci case GL_TEXTURE_GATHER: 379bf215546Sopenharmony_ci case GL_TEXTURE_GATHER_SHADOW: 380bf215546Sopenharmony_ci case GL_SHADER_IMAGE_LOAD: 381bf215546Sopenharmony_ci case GL_SHADER_IMAGE_STORE: 382bf215546Sopenharmony_ci case GL_SHADER_IMAGE_ATOMIC: 383bf215546Sopenharmony_ci case GL_IMAGE_COMPATIBILITY_CLASS: 384bf215546Sopenharmony_ci case GL_IMAGE_PIXEL_FORMAT: 385bf215546Sopenharmony_ci case GL_IMAGE_PIXEL_TYPE: 386bf215546Sopenharmony_ci case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: 387bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 388bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 389bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 390bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 391bf215546Sopenharmony_ci case GL_CLEAR_BUFFER: 392bf215546Sopenharmony_ci case GL_TEXTURE_VIEW: 393bf215546Sopenharmony_ci case GL_VIEW_COMPATIBILITY_CLASS: 394bf215546Sopenharmony_ci buffer[0] = GL_NONE; 395bf215546Sopenharmony_ci break; 396bf215546Sopenharmony_ci 397bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SUPPORTED: 398bf215546Sopenharmony_ci case GL_COLOR_COMPONENTS: 399bf215546Sopenharmony_ci case GL_DEPTH_COMPONENTS: 400bf215546Sopenharmony_ci case GL_STENCIL_COMPONENTS: 401bf215546Sopenharmony_ci case GL_COLOR_RENDERABLE: 402bf215546Sopenharmony_ci case GL_DEPTH_RENDERABLE: 403bf215546Sopenharmony_ci case GL_STENCIL_RENDERABLE: 404bf215546Sopenharmony_ci case GL_MIPMAP: 405bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED: 406bf215546Sopenharmony_ci case GL_TEXTURE_REDUCTION_MODE_ARB: 407bf215546Sopenharmony_ci buffer[0] = GL_FALSE; 408bf215546Sopenharmony_ci break; 409bf215546Sopenharmony_ci 410bf215546Sopenharmony_ci default: 411bf215546Sopenharmony_ci unreachable("invalid 'pname'"); 412bf215546Sopenharmony_ci } 413bf215546Sopenharmony_ci} 414bf215546Sopenharmony_ci 415bf215546Sopenharmony_cistatic bool 416bf215546Sopenharmony_ci_is_target_supported(struct gl_context *ctx, GLenum target) 417bf215546Sopenharmony_ci{ 418bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 419bf215546Sopenharmony_ci * 420bf215546Sopenharmony_ci * "if a particular type of <target> is not supported by the 421bf215546Sopenharmony_ci * implementation the "unsupported" answer should be given. 422bf215546Sopenharmony_ci * This is not an error." 423bf215546Sopenharmony_ci * 424bf215546Sopenharmony_ci * Note that legality of targets has already been verified. 425bf215546Sopenharmony_ci */ 426bf215546Sopenharmony_ci switch(target){ 427bf215546Sopenharmony_ci case GL_TEXTURE_1D: 428bf215546Sopenharmony_ci case GL_TEXTURE_2D: 429bf215546Sopenharmony_ci case GL_TEXTURE_3D: 430bf215546Sopenharmony_ci break; 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_ci case GL_TEXTURE_1D_ARRAY: 433bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_array(ctx)) 434bf215546Sopenharmony_ci return false; 435bf215546Sopenharmony_ci break; 436bf215546Sopenharmony_ci 437bf215546Sopenharmony_ci case GL_TEXTURE_2D_ARRAY: 438bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_array(ctx)) 439bf215546Sopenharmony_ci return false; 440bf215546Sopenharmony_ci break; 441bf215546Sopenharmony_ci 442bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 443bf215546Sopenharmony_ci if (!_mesa_is_desktop_gl(ctx)) 444bf215546Sopenharmony_ci return false; 445bf215546Sopenharmony_ci break; 446bf215546Sopenharmony_ci 447bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP_ARRAY: 448bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_cube_map_array(ctx)) 449bf215546Sopenharmony_ci return false; 450bf215546Sopenharmony_ci break; 451bf215546Sopenharmony_ci 452bf215546Sopenharmony_ci case GL_TEXTURE_RECTANGLE: 453bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_rectangle(ctx)) 454bf215546Sopenharmony_ci return false; 455bf215546Sopenharmony_ci break; 456bf215546Sopenharmony_ci 457bf215546Sopenharmony_ci case GL_TEXTURE_BUFFER: 458bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_buffer_object(ctx)) 459bf215546Sopenharmony_ci return false; 460bf215546Sopenharmony_ci break; 461bf215546Sopenharmony_ci 462bf215546Sopenharmony_ci case GL_RENDERBUFFER: 463bf215546Sopenharmony_ci if (!(_mesa_has_ARB_framebuffer_object(ctx) || 464bf215546Sopenharmony_ci _mesa_is_gles3(ctx))) 465bf215546Sopenharmony_ci return false; 466bf215546Sopenharmony_ci break; 467bf215546Sopenharmony_ci 468bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE: 469bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 470bf215546Sopenharmony_ci if (!(_mesa_has_ARB_texture_multisample(ctx) || 471bf215546Sopenharmony_ci _mesa_is_gles31(ctx))) 472bf215546Sopenharmony_ci return false; 473bf215546Sopenharmony_ci break; 474bf215546Sopenharmony_ci 475bf215546Sopenharmony_ci default: 476bf215546Sopenharmony_ci unreachable("invalid target"); 477bf215546Sopenharmony_ci } 478bf215546Sopenharmony_ci 479bf215546Sopenharmony_ci return true; 480bf215546Sopenharmony_ci} 481bf215546Sopenharmony_ci 482bf215546Sopenharmony_cistatic bool 483bf215546Sopenharmony_ci_is_resource_supported(struct gl_context *ctx, GLenum target, 484bf215546Sopenharmony_ci GLenum internalformat, GLenum pname) 485bf215546Sopenharmony_ci{ 486bf215546Sopenharmony_ci /* From the ARB_internalformat_query2 spec: 487bf215546Sopenharmony_ci * 488bf215546Sopenharmony_ci * In the following descriptions, the term /resource/ is used to generically 489bf215546Sopenharmony_ci * refer to an object of the appropriate type that has been created with 490bf215546Sopenharmony_ci * <internalformat> and <target>. If the particular <target> and 491bf215546Sopenharmony_ci * <internalformat> combination do not make sense, ... the "unsupported" 492bf215546Sopenharmony_ci * answer should be given. This is not an error. 493bf215546Sopenharmony_ci */ 494bf215546Sopenharmony_ci 495bf215546Sopenharmony_ci /* In the ARB_internalformat_query2 spec wording, some <pnames> do not care 496bf215546Sopenharmony_ci * about the /resource/ being supported or not, we return 'true' for those. 497bf215546Sopenharmony_ci */ 498bf215546Sopenharmony_ci switch (pname) { 499bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SUPPORTED: 500bf215546Sopenharmony_ci case GL_INTERNALFORMAT_PREFERRED: 501bf215546Sopenharmony_ci case GL_COLOR_COMPONENTS: 502bf215546Sopenharmony_ci case GL_DEPTH_COMPONENTS: 503bf215546Sopenharmony_ci case GL_STENCIL_COMPONENTS: 504bf215546Sopenharmony_ci case GL_COLOR_RENDERABLE: 505bf215546Sopenharmony_ci case GL_DEPTH_RENDERABLE: 506bf215546Sopenharmony_ci case GL_STENCIL_RENDERABLE: 507bf215546Sopenharmony_ci return true; 508bf215546Sopenharmony_ci default: 509bf215546Sopenharmony_ci break; 510bf215546Sopenharmony_ci } 511bf215546Sopenharmony_ci 512bf215546Sopenharmony_ci switch(target){ 513bf215546Sopenharmony_ci case GL_TEXTURE_1D: 514bf215546Sopenharmony_ci case GL_TEXTURE_1D_ARRAY: 515bf215546Sopenharmony_ci case GL_TEXTURE_2D: 516bf215546Sopenharmony_ci case GL_TEXTURE_2D_ARRAY: 517bf215546Sopenharmony_ci case GL_TEXTURE_3D: 518bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 519bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP_ARRAY: 520bf215546Sopenharmony_ci case GL_TEXTURE_RECTANGLE: 521bf215546Sopenharmony_ci /* Based on what Mesa does for glTexImage1D/2D/3D and 522bf215546Sopenharmony_ci * glCompressedTexImage1D/2D/3D functions. 523bf215546Sopenharmony_ci */ 524bf215546Sopenharmony_ci if (_mesa_base_tex_format(ctx, internalformat) < 0) 525bf215546Sopenharmony_ci return false; 526bf215546Sopenharmony_ci 527bf215546Sopenharmony_ci /* additional checks for depth textures */ 528bf215546Sopenharmony_ci if (!_mesa_legal_texture_base_format_for_target(ctx, target, internalformat)) 529bf215546Sopenharmony_ci return false; 530bf215546Sopenharmony_ci 531bf215546Sopenharmony_ci /* additional checks for compressed textures */ 532bf215546Sopenharmony_ci if (_mesa_is_compressed_format(ctx, internalformat) && 533bf215546Sopenharmony_ci !_mesa_target_can_be_compressed(ctx, target, internalformat, NULL)) 534bf215546Sopenharmony_ci return false; 535bf215546Sopenharmony_ci 536bf215546Sopenharmony_ci break; 537bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE: 538bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 539bf215546Sopenharmony_ci /* Based on what Mesa does for glTexImage2D/3DMultisample, 540bf215546Sopenharmony_ci * glTexStorage2D/3DMultisample and 541bf215546Sopenharmony_ci * glTextureStorage2D/3DMultisample functions. 542bf215546Sopenharmony_ci */ 543bf215546Sopenharmony_ci if (!_mesa_is_renderable_texture_format(ctx, internalformat)) 544bf215546Sopenharmony_ci return false; 545bf215546Sopenharmony_ci 546bf215546Sopenharmony_ci break; 547bf215546Sopenharmony_ci case GL_TEXTURE_BUFFER: 548bf215546Sopenharmony_ci /* Based on what Mesa does for the glTexBuffer function. */ 549bf215546Sopenharmony_ci if (_mesa_validate_texbuffer_format(ctx, internalformat) == 550bf215546Sopenharmony_ci MESA_FORMAT_NONE) 551bf215546Sopenharmony_ci return false; 552bf215546Sopenharmony_ci 553bf215546Sopenharmony_ci break; 554bf215546Sopenharmony_ci case GL_RENDERBUFFER: 555bf215546Sopenharmony_ci /* Based on what Mesa does for glRenderbufferStorage(Multisample) and 556bf215546Sopenharmony_ci * glNamedRenderbufferStorage functions. 557bf215546Sopenharmony_ci */ 558bf215546Sopenharmony_ci if (!_mesa_base_fbo_format(ctx, internalformat)) 559bf215546Sopenharmony_ci return false; 560bf215546Sopenharmony_ci 561bf215546Sopenharmony_ci break; 562bf215546Sopenharmony_ci default: 563bf215546Sopenharmony_ci unreachable("bad target"); 564bf215546Sopenharmony_ci } 565bf215546Sopenharmony_ci 566bf215546Sopenharmony_ci return true; 567bf215546Sopenharmony_ci} 568bf215546Sopenharmony_ci 569bf215546Sopenharmony_cistatic bool 570bf215546Sopenharmony_ci_is_internalformat_supported(struct gl_context *ctx, GLenum target, 571bf215546Sopenharmony_ci GLenum internalformat) 572bf215546Sopenharmony_ci{ 573bf215546Sopenharmony_ci /* From the ARB_internalformat_query2 specification: 574bf215546Sopenharmony_ci * 575bf215546Sopenharmony_ci * "- INTERNALFORMAT_SUPPORTED: If <internalformat> is an internal format 576bf215546Sopenharmony_ci * that is supported by the implementation in at least some subset of 577bf215546Sopenharmony_ci * possible operations, TRUE is written to <params>. If <internalformat> 578bf215546Sopenharmony_ci * if not a valid token for any internal format usage, FALSE is returned. 579bf215546Sopenharmony_ci * 580bf215546Sopenharmony_ci * <internalformats> that must be supported (in GL 4.2 or later) include 581bf215546Sopenharmony_ci * the following: 582bf215546Sopenharmony_ci * - "sized internal formats" from Table 3.12, 3.13, and 3.15, 583bf215546Sopenharmony_ci * - any specific "compressed internal format" from Table 3.14, 584bf215546Sopenharmony_ci * - any "image unit format" from Table 3.21. 585bf215546Sopenharmony_ci * - any generic "compressed internal format" from Table 3.14, if the 586bf215546Sopenharmony_ci * implementation accepts it for any texture specification commands, and 587bf215546Sopenharmony_ci * - unsized or base internal format, if the implementation accepts 588bf215546Sopenharmony_ci * it for texture or image specification. 589bf215546Sopenharmony_ci * 590bf215546Sopenharmony_ci * But also: 591bf215546Sopenharmony_ci * "If the particualar <target> and <internalformat> combination do not make 592bf215546Sopenharmony_ci * sense, or if a particular type of <target> is not supported by the 593bf215546Sopenharmony_ci * implementation the "unsupported" answer should be given. This is not an 594bf215546Sopenharmony_ci * error. 595bf215546Sopenharmony_ci */ 596bf215546Sopenharmony_ci GLint buffer[1]; 597bf215546Sopenharmony_ci 598bf215546Sopenharmony_ci if (target == GL_RENDERBUFFER) { 599bf215546Sopenharmony_ci if (_mesa_base_fbo_format(ctx, internalformat) == 0) { 600bf215546Sopenharmony_ci return false; 601bf215546Sopenharmony_ci } 602bf215546Sopenharmony_ci } else if (target == GL_TEXTURE_BUFFER) { 603bf215546Sopenharmony_ci if (_mesa_validate_texbuffer_format(ctx, internalformat) == 604bf215546Sopenharmony_ci MESA_FORMAT_NONE) { 605bf215546Sopenharmony_ci return false; 606bf215546Sopenharmony_ci } 607bf215546Sopenharmony_ci } else { 608bf215546Sopenharmony_ci if (_mesa_base_tex_format(ctx, internalformat) < 0) { 609bf215546Sopenharmony_ci return false; 610bf215546Sopenharmony_ci } 611bf215546Sopenharmony_ci } 612bf215546Sopenharmony_ci 613bf215546Sopenharmony_ci /* Let the driver have the final word */ 614bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, 615bf215546Sopenharmony_ci GL_INTERNALFORMAT_SUPPORTED, buffer); 616bf215546Sopenharmony_ci 617bf215546Sopenharmony_ci return (buffer[0] == GL_TRUE); 618bf215546Sopenharmony_ci} 619bf215546Sopenharmony_ci 620bf215546Sopenharmony_cistatic bool 621bf215546Sopenharmony_ci_legal_target_for_framebuffer_texture_layer(struct gl_context *ctx, 622bf215546Sopenharmony_ci GLenum target) 623bf215546Sopenharmony_ci{ 624bf215546Sopenharmony_ci switch (target) { 625bf215546Sopenharmony_ci case GL_TEXTURE_3D: 626bf215546Sopenharmony_ci case GL_TEXTURE_1D_ARRAY: 627bf215546Sopenharmony_ci case GL_TEXTURE_2D_ARRAY: 628bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP_ARRAY: 629bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 630bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 631bf215546Sopenharmony_ci return true; 632bf215546Sopenharmony_ci default: 633bf215546Sopenharmony_ci return false; 634bf215546Sopenharmony_ci } 635bf215546Sopenharmony_ci} 636bf215546Sopenharmony_ci 637bf215546Sopenharmony_cistatic GLenum 638bf215546Sopenharmony_ci_mesa_generic_type_for_internal_format(GLenum internalFormat) 639bf215546Sopenharmony_ci{ 640bf215546Sopenharmony_ci if (_mesa_is_enum_format_unsigned_int(internalFormat)) 641bf215546Sopenharmony_ci return GL_UNSIGNED_BYTE; 642bf215546Sopenharmony_ci else if (_mesa_is_enum_format_signed_int(internalFormat)) 643bf215546Sopenharmony_ci return GL_BYTE; 644bf215546Sopenharmony_ci else 645bf215546Sopenharmony_ci return GL_FLOAT; 646bf215546Sopenharmony_ci} 647bf215546Sopenharmony_ci 648bf215546Sopenharmony_ci/* default implementation of QueryInternalFormat driverfunc, for 649bf215546Sopenharmony_ci * drivers not implementing ARB_internalformat_query2. 650bf215546Sopenharmony_ci */ 651bf215546Sopenharmony_civoid 652bf215546Sopenharmony_ci_mesa_query_internal_format_default(struct gl_context *ctx, GLenum target, 653bf215546Sopenharmony_ci GLenum internalFormat, GLenum pname, 654bf215546Sopenharmony_ci GLint *params) 655bf215546Sopenharmony_ci{ 656bf215546Sopenharmony_ci (void) target; 657bf215546Sopenharmony_ci 658bf215546Sopenharmony_ci switch (pname) { 659bf215546Sopenharmony_ci case GL_SAMPLES: 660bf215546Sopenharmony_ci case GL_NUM_SAMPLE_COUNTS: 661bf215546Sopenharmony_ci params[0] = 1; 662bf215546Sopenharmony_ci break; 663bf215546Sopenharmony_ci 664bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SUPPORTED: 665bf215546Sopenharmony_ci params[0] = GL_TRUE; 666bf215546Sopenharmony_ci break; 667bf215546Sopenharmony_ci 668bf215546Sopenharmony_ci case GL_INTERNALFORMAT_PREFERRED: 669bf215546Sopenharmony_ci params[0] = internalFormat; 670bf215546Sopenharmony_ci break; 671bf215546Sopenharmony_ci 672bf215546Sopenharmony_ci case GL_READ_PIXELS_FORMAT: { 673bf215546Sopenharmony_ci GLenum base_format = _mesa_base_tex_format(ctx, internalFormat); 674bf215546Sopenharmony_ci switch (base_format) { 675bf215546Sopenharmony_ci case GL_STENCIL_INDEX: 676bf215546Sopenharmony_ci case GL_DEPTH_COMPONENT: 677bf215546Sopenharmony_ci case GL_DEPTH_STENCIL: 678bf215546Sopenharmony_ci case GL_RED: 679bf215546Sopenharmony_ci case GL_RGB: 680bf215546Sopenharmony_ci case GL_BGR: 681bf215546Sopenharmony_ci case GL_RGBA: 682bf215546Sopenharmony_ci case GL_BGRA: 683bf215546Sopenharmony_ci params[0] = base_format; 684bf215546Sopenharmony_ci break; 685bf215546Sopenharmony_ci default: 686bf215546Sopenharmony_ci params[0] = GL_NONE; 687bf215546Sopenharmony_ci break; 688bf215546Sopenharmony_ci } 689bf215546Sopenharmony_ci break; 690bf215546Sopenharmony_ci } 691bf215546Sopenharmony_ci 692bf215546Sopenharmony_ci case GL_READ_PIXELS_TYPE: 693bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_TYPE: 694bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_TYPE: { 695bf215546Sopenharmony_ci GLenum base_format = _mesa_base_tex_format(ctx, internalFormat); 696bf215546Sopenharmony_ci if (base_format > 0) 697bf215546Sopenharmony_ci params[0] = _mesa_generic_type_for_internal_format(internalFormat); 698bf215546Sopenharmony_ci else 699bf215546Sopenharmony_ci params[0] = GL_NONE; 700bf215546Sopenharmony_ci break; 701bf215546Sopenharmony_ci } 702bf215546Sopenharmony_ci 703bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_FORMAT: 704bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_FORMAT: { 705bf215546Sopenharmony_ci GLenum format = GL_NONE; 706bf215546Sopenharmony_ci GLenum base_format = _mesa_base_tex_format(ctx, internalFormat); 707bf215546Sopenharmony_ci if (base_format > 0) { 708bf215546Sopenharmony_ci if (_mesa_is_enum_format_integer(internalFormat)) 709bf215546Sopenharmony_ci format = _mesa_base_format_to_integer_format(base_format); 710bf215546Sopenharmony_ci else 711bf215546Sopenharmony_ci format = base_format; 712bf215546Sopenharmony_ci } 713bf215546Sopenharmony_ci 714bf215546Sopenharmony_ci params[0] = format; 715bf215546Sopenharmony_ci break; 716bf215546Sopenharmony_ci } 717bf215546Sopenharmony_ci 718bf215546Sopenharmony_ci case GL_MANUAL_GENERATE_MIPMAP: 719bf215546Sopenharmony_ci case GL_AUTO_GENERATE_MIPMAP: 720bf215546Sopenharmony_ci case GL_SRGB_READ: 721bf215546Sopenharmony_ci case GL_SRGB_WRITE: 722bf215546Sopenharmony_ci case GL_SRGB_DECODE_ARB: 723bf215546Sopenharmony_ci case GL_VERTEX_TEXTURE: 724bf215546Sopenharmony_ci case GL_TESS_CONTROL_TEXTURE: 725bf215546Sopenharmony_ci case GL_TESS_EVALUATION_TEXTURE: 726bf215546Sopenharmony_ci case GL_GEOMETRY_TEXTURE: 727bf215546Sopenharmony_ci case GL_FRAGMENT_TEXTURE: 728bf215546Sopenharmony_ci case GL_COMPUTE_TEXTURE: 729bf215546Sopenharmony_ci case GL_SHADER_IMAGE_LOAD: 730bf215546Sopenharmony_ci case GL_SHADER_IMAGE_STORE: 731bf215546Sopenharmony_ci case GL_SHADER_IMAGE_ATOMIC: 732bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 733bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 734bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 735bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 736bf215546Sopenharmony_ci case GL_CLEAR_BUFFER: 737bf215546Sopenharmony_ci case GL_TEXTURE_VIEW: 738bf215546Sopenharmony_ci case GL_TEXTURE_SHADOW: 739bf215546Sopenharmony_ci case GL_TEXTURE_GATHER: 740bf215546Sopenharmony_ci case GL_TEXTURE_GATHER_SHADOW: 741bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE: 742bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 743bf215546Sopenharmony_ci case GL_FRAMEBUFFER_BLEND: 744bf215546Sopenharmony_ci case GL_FILTER: 745bf215546Sopenharmony_ci /* 746bf215546Sopenharmony_ci * TODO seems a tad optimistic just saying yes to everything here. 747bf215546Sopenharmony_ci * Even for combinations which make no sense... 748bf215546Sopenharmony_ci * And things like TESS_CONTROL_TEXTURE should definitely default to 749bf215546Sopenharmony_ci * NONE if the driver doesn't even support tessellation... 750bf215546Sopenharmony_ci */ 751bf215546Sopenharmony_ci params[0] = GL_FULL_SUPPORT; 752bf215546Sopenharmony_ci break; 753bf215546Sopenharmony_ci case GL_NUM_TILING_TYPES_EXT: 754bf215546Sopenharmony_ci params[0] = 2; 755bf215546Sopenharmony_ci break; 756bf215546Sopenharmony_ci case GL_TILING_TYPES_EXT: 757bf215546Sopenharmony_ci params[0] = GL_OPTIMAL_TILING_EXT; 758bf215546Sopenharmony_ci params[1] = GL_LINEAR_TILING_EXT; 759bf215546Sopenharmony_ci break; 760bf215546Sopenharmony_ci 761bf215546Sopenharmony_ci default: 762bf215546Sopenharmony_ci _set_default_response(pname, params); 763bf215546Sopenharmony_ci break; 764bf215546Sopenharmony_ci } 765bf215546Sopenharmony_ci} 766bf215546Sopenharmony_ci 767bf215546Sopenharmony_ci/* 768bf215546Sopenharmony_ci * For MAX_WIDTH/MAX_HEIGHT/MAX_DEPTH it returns the equivalent GetInteger 769bf215546Sopenharmony_ci * pname for a Getinternalformat pname/target combination. target/pname 770bf215546Sopenharmony_ci * combinations that would return 0 due dimension number or unsupported status 771bf215546Sopenharmony_ci * should be already filtered out 772bf215546Sopenharmony_ci * 773bf215546Sopenharmony_ci * Note that this means that the returned value would be independent of the 774bf215546Sopenharmony_ci * internalformat. This possibility is already mentioned at the Issue 7 of the 775bf215546Sopenharmony_ci * arb_internalformat_query2 spec. 776bf215546Sopenharmony_ci */ 777bf215546Sopenharmony_cistatic GLenum 778bf215546Sopenharmony_ci_equivalent_size_pname(GLenum target, 779bf215546Sopenharmony_ci GLenum pname) 780bf215546Sopenharmony_ci{ 781bf215546Sopenharmony_ci switch (target) { 782bf215546Sopenharmony_ci case GL_TEXTURE_1D: 783bf215546Sopenharmony_ci case GL_TEXTURE_2D: 784bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE: 785bf215546Sopenharmony_ci return GL_MAX_TEXTURE_SIZE; 786bf215546Sopenharmony_ci case GL_TEXTURE_3D: 787bf215546Sopenharmony_ci return GL_MAX_3D_TEXTURE_SIZE; 788bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 789bf215546Sopenharmony_ci return GL_MAX_CUBE_MAP_TEXTURE_SIZE; 790bf215546Sopenharmony_ci case GL_TEXTURE_RECTANGLE: 791bf215546Sopenharmony_ci return GL_MAX_RECTANGLE_TEXTURE_SIZE; 792bf215546Sopenharmony_ci case GL_RENDERBUFFER: 793bf215546Sopenharmony_ci return GL_MAX_RENDERBUFFER_SIZE; 794bf215546Sopenharmony_ci case GL_TEXTURE_1D_ARRAY: 795bf215546Sopenharmony_ci if (pname == GL_MAX_HEIGHT) 796bf215546Sopenharmony_ci return GL_MAX_ARRAY_TEXTURE_LAYERS; 797bf215546Sopenharmony_ci else 798bf215546Sopenharmony_ci return GL_MAX_TEXTURE_SIZE; 799bf215546Sopenharmony_ci case GL_TEXTURE_2D_ARRAY: 800bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 801bf215546Sopenharmony_ci if (pname == GL_MAX_DEPTH) 802bf215546Sopenharmony_ci return GL_MAX_ARRAY_TEXTURE_LAYERS; 803bf215546Sopenharmony_ci else 804bf215546Sopenharmony_ci return GL_MAX_TEXTURE_SIZE; 805bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP_ARRAY: 806bf215546Sopenharmony_ci if (pname == GL_MAX_DEPTH) 807bf215546Sopenharmony_ci return GL_MAX_ARRAY_TEXTURE_LAYERS; 808bf215546Sopenharmony_ci else 809bf215546Sopenharmony_ci return GL_MAX_CUBE_MAP_TEXTURE_SIZE; 810bf215546Sopenharmony_ci case GL_TEXTURE_BUFFER: 811bf215546Sopenharmony_ci return GL_MAX_TEXTURE_BUFFER_SIZE; 812bf215546Sopenharmony_ci default: 813bf215546Sopenharmony_ci return 0; 814bf215546Sopenharmony_ci } 815bf215546Sopenharmony_ci} 816bf215546Sopenharmony_ci 817bf215546Sopenharmony_ci/* 818bf215546Sopenharmony_ci * Returns the dimensions associated to a target. GL_TEXTURE_BUFFER and 819bf215546Sopenharmony_ci * GL_RENDERBUFFER have associated a dimension, but they are not textures 820bf215546Sopenharmony_ci * per-se, so we can't just call _mesa_get_texture_dimension directly. 821bf215546Sopenharmony_ci */ 822bf215546Sopenharmony_cistatic GLint 823bf215546Sopenharmony_ci_get_target_dimensions(GLenum target) 824bf215546Sopenharmony_ci{ 825bf215546Sopenharmony_ci switch(target) { 826bf215546Sopenharmony_ci case GL_TEXTURE_BUFFER: 827bf215546Sopenharmony_ci return 1; 828bf215546Sopenharmony_ci case GL_RENDERBUFFER: 829bf215546Sopenharmony_ci return 2; 830bf215546Sopenharmony_ci default: 831bf215546Sopenharmony_ci return _mesa_get_texture_dimensions(target); 832bf215546Sopenharmony_ci } 833bf215546Sopenharmony_ci} 834bf215546Sopenharmony_ci 835bf215546Sopenharmony_ci/* 836bf215546Sopenharmony_ci * Returns the minimum amount of dimensions associated to a pname. So for 837bf215546Sopenharmony_ci * example, if querying GL_MAX_HEIGHT, it is assumed that your target would 838bf215546Sopenharmony_ci * have as minimum 2 dimensions. 839bf215546Sopenharmony_ci * 840bf215546Sopenharmony_ci * Useful to handle sentences like this from query2 spec: 841bf215546Sopenharmony_ci * 842bf215546Sopenharmony_ci * "MAX_HEIGHT: 843bf215546Sopenharmony_ci * <skip> 844bf215546Sopenharmony_ci * If the resource does not have at least two dimensions 845bf215546Sopenharmony_ci * <skip>." 846bf215546Sopenharmony_ci */ 847bf215546Sopenharmony_cistatic GLint 848bf215546Sopenharmony_ci_get_min_dimensions(GLenum pname) 849bf215546Sopenharmony_ci{ 850bf215546Sopenharmony_ci switch(pname) { 851bf215546Sopenharmony_ci case GL_MAX_WIDTH: 852bf215546Sopenharmony_ci return 1; 853bf215546Sopenharmony_ci case GL_MAX_HEIGHT: 854bf215546Sopenharmony_ci return 2; 855bf215546Sopenharmony_ci case GL_MAX_DEPTH: 856bf215546Sopenharmony_ci return 3; 857bf215546Sopenharmony_ci default: 858bf215546Sopenharmony_ci return 0; 859bf215546Sopenharmony_ci } 860bf215546Sopenharmony_ci} 861bf215546Sopenharmony_ci 862bf215546Sopenharmony_ci/* 863bf215546Sopenharmony_ci * Similar to teximage.c:check_multisample_target, but independent of the 864bf215546Sopenharmony_ci * dimensions. 865bf215546Sopenharmony_ci */ 866bf215546Sopenharmony_cibool 867bf215546Sopenharmony_ci_mesa_is_multisample_target(GLenum target) 868bf215546Sopenharmony_ci{ 869bf215546Sopenharmony_ci switch(target) { 870bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE: 871bf215546Sopenharmony_ci case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 872bf215546Sopenharmony_ci return true; 873bf215546Sopenharmony_ci default: 874bf215546Sopenharmony_ci return false; 875bf215546Sopenharmony_ci } 876bf215546Sopenharmony_ci 877bf215546Sopenharmony_ci} 878bf215546Sopenharmony_ci 879bf215546Sopenharmony_civoid GLAPIENTRY 880bf215546Sopenharmony_ci_mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, 881bf215546Sopenharmony_ci GLsizei bufSize, GLint *params) 882bf215546Sopenharmony_ci{ 883bf215546Sopenharmony_ci GLint buffer[16]; 884bf215546Sopenharmony_ci GET_CURRENT_CONTEXT(ctx); 885bf215546Sopenharmony_ci 886bf215546Sopenharmony_ci ASSERT_OUTSIDE_BEGIN_END(ctx); 887bf215546Sopenharmony_ci 888bf215546Sopenharmony_ci /* ARB_internalformat_query is also mandatory for ARB_internalformat_query2 */ 889bf215546Sopenharmony_ci if (!(_mesa_has_ARB_internalformat_query(ctx) || 890bf215546Sopenharmony_ci _mesa_is_gles3(ctx))) { 891bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInternalformativ"); 892bf215546Sopenharmony_ci return; 893bf215546Sopenharmony_ci } 894bf215546Sopenharmony_ci 895bf215546Sopenharmony_ci if (!_legal_parameters(ctx, target, internalformat, pname, bufSize, params)) 896bf215546Sopenharmony_ci return; 897bf215546Sopenharmony_ci 898bf215546Sopenharmony_ci /* initialize the contents of the temporary buffer */ 899bf215546Sopenharmony_ci memcpy(buffer, params, MIN2(bufSize, 16) * sizeof(GLint)); 900bf215546Sopenharmony_ci 901bf215546Sopenharmony_ci /* Use the 'unsupported' response defined by the spec for every pname 902bf215546Sopenharmony_ci * as the default answer. 903bf215546Sopenharmony_ci */ 904bf215546Sopenharmony_ci _set_default_response(pname, buffer); 905bf215546Sopenharmony_ci 906bf215546Sopenharmony_ci if (!_is_target_supported(ctx, target) || 907bf215546Sopenharmony_ci !_is_internalformat_supported(ctx, target, internalformat) || 908bf215546Sopenharmony_ci !_is_resource_supported(ctx, target, internalformat, pname)) 909bf215546Sopenharmony_ci goto end; 910bf215546Sopenharmony_ci 911bf215546Sopenharmony_ci switch (pname) { 912bf215546Sopenharmony_ci case GL_SAMPLES: 913bf215546Sopenharmony_ci FALLTHROUGH; 914bf215546Sopenharmony_ci case GL_NUM_SAMPLE_COUNTS: 915bf215546Sopenharmony_ci /* The ARB_internalformat_query2 sets the response as 'unsupported' for 916bf215546Sopenharmony_ci * SAMPLES and NUM_SAMPLE_COUNTS: 917bf215546Sopenharmony_ci * 918bf215546Sopenharmony_ci * "If <internalformat> is not color-renderable, depth-renderable, or 919bf215546Sopenharmony_ci * stencil-renderable (as defined in section 4.4.4), or if <target> 920bf215546Sopenharmony_ci * does not support multiple samples (ie other than 921bf215546Sopenharmony_ci * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY, 922bf215546Sopenharmony_ci * or RENDERBUFFER)." 923bf215546Sopenharmony_ci */ 924bf215546Sopenharmony_ci if ((target != GL_RENDERBUFFER && 925bf215546Sopenharmony_ci target != GL_TEXTURE_2D_MULTISAMPLE && 926bf215546Sopenharmony_ci target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY) || 927bf215546Sopenharmony_ci !_is_renderable(ctx, internalformat)) 928bf215546Sopenharmony_ci goto end; 929bf215546Sopenharmony_ci 930bf215546Sopenharmony_ci /* The GL ES 3.0 specification, section 6.1.15 page 236 says: 931bf215546Sopenharmony_ci * 932bf215546Sopenharmony_ci * "Since multisampling is not supported for signed and unsigned 933bf215546Sopenharmony_ci * integer internal formats, the value of NUM_SAMPLE_COUNTS will be 934bf215546Sopenharmony_ci * zero for such formats. 935bf215546Sopenharmony_ci * 936bf215546Sopenharmony_ci * Since OpenGL ES 3.1 adds support for multisampled integer formats, we 937bf215546Sopenharmony_ci * have to check the version for 30 exactly. 938bf215546Sopenharmony_ci */ 939bf215546Sopenharmony_ci if (pname == GL_NUM_SAMPLE_COUNTS && ctx->API == API_OPENGLES2 && 940bf215546Sopenharmony_ci ctx->Version == 30 && _mesa_is_enum_format_integer(internalformat)) { 941bf215546Sopenharmony_ci goto end; 942bf215546Sopenharmony_ci } 943bf215546Sopenharmony_ci 944bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 945bf215546Sopenharmony_ci buffer); 946bf215546Sopenharmony_ci break; 947bf215546Sopenharmony_ci 948bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SUPPORTED: 949bf215546Sopenharmony_ci /* Having a supported <internalformat> is implemented as a prerequisite 950bf215546Sopenharmony_ci * for all the <pnames>. Thus, if we reach this point, the internalformat is 951bf215546Sopenharmony_ci * supported. 952bf215546Sopenharmony_ci */ 953bf215546Sopenharmony_ci buffer[0] = GL_TRUE; 954bf215546Sopenharmony_ci break; 955bf215546Sopenharmony_ci 956bf215546Sopenharmony_ci case GL_INTERNALFORMAT_PREFERRED: 957bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 958bf215546Sopenharmony_ci * 959bf215546Sopenharmony_ci * "- INTERNALFORMAT_PREFERRED: The implementation-preferred internal 960bf215546Sopenharmony_ci * format for representing resources of the specified <internalformat> is 961bf215546Sopenharmony_ci * returned in <params>. 962bf215546Sopenharmony_ci * 963bf215546Sopenharmony_ci * Therefore, we let the driver answer. Note that if we reach this 964bf215546Sopenharmony_ci * point, it means that the internalformat is supported, so the driver 965bf215546Sopenharmony_ci * is called just to try to get a preferred format. If not supported, 966bf215546Sopenharmony_ci * GL_NONE was already returned and the driver is not called. 967bf215546Sopenharmony_ci */ 968bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 969bf215546Sopenharmony_ci buffer); 970bf215546Sopenharmony_ci break; 971bf215546Sopenharmony_ci 972bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_SIZE: 973bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_SIZE: 974bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_SIZE: 975bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_SIZE: 976bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_SIZE: 977bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_SIZE: 978bf215546Sopenharmony_ci case GL_INTERNALFORMAT_SHARED_SIZE: 979bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_TYPE: 980bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_TYPE: 981bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_TYPE: 982bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_TYPE: 983bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_TYPE: 984bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_TYPE: { 985bf215546Sopenharmony_ci GLint baseformat; 986bf215546Sopenharmony_ci mesa_format texformat; 987bf215546Sopenharmony_ci 988bf215546Sopenharmony_ci if (target != GL_RENDERBUFFER) { 989bf215546Sopenharmony_ci baseformat = _mesa_base_tex_format(ctx, internalformat); 990bf215546Sopenharmony_ci } else { 991bf215546Sopenharmony_ci baseformat = _mesa_base_fbo_format(ctx, internalformat); 992bf215546Sopenharmony_ci } 993bf215546Sopenharmony_ci 994bf215546Sopenharmony_ci /* Let the driver choose the texture format. 995bf215546Sopenharmony_ci * 996bf215546Sopenharmony_ci * Disclaimer: I am considering that drivers use for renderbuffers the 997bf215546Sopenharmony_ci * same format-choice logic as for textures. 998bf215546Sopenharmony_ci */ 999bf215546Sopenharmony_ci texformat = st_ChooseTextureFormat(ctx, target, internalformat, 1000bf215546Sopenharmony_ci GL_NONE /*format */, GL_NONE /* type */); 1001bf215546Sopenharmony_ci 1002bf215546Sopenharmony_ci if (texformat == MESA_FORMAT_NONE || baseformat <= 0) 1003bf215546Sopenharmony_ci goto end; 1004bf215546Sopenharmony_ci 1005bf215546Sopenharmony_ci /* Implementation based on what Mesa does for glGetTexLevelParameteriv 1006bf215546Sopenharmony_ci * and glGetRenderbufferParameteriv functions. 1007bf215546Sopenharmony_ci */ 1008bf215546Sopenharmony_ci if (pname == GL_INTERNALFORMAT_SHARED_SIZE) { 1009bf215546Sopenharmony_ci if (texformat == MESA_FORMAT_R9G9B9E5_FLOAT) { 1010bf215546Sopenharmony_ci buffer[0] = 5; 1011bf215546Sopenharmony_ci } 1012bf215546Sopenharmony_ci goto end; 1013bf215546Sopenharmony_ci } 1014bf215546Sopenharmony_ci 1015bf215546Sopenharmony_ci if (!_mesa_base_format_has_channel(baseformat, pname)) 1016bf215546Sopenharmony_ci goto end; 1017bf215546Sopenharmony_ci 1018bf215546Sopenharmony_ci switch (pname) { 1019bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_SIZE: 1020bf215546Sopenharmony_ci if (!_mesa_is_desktop_gl(ctx) && 1021bf215546Sopenharmony_ci target != GL_RENDERBUFFER && 1022bf215546Sopenharmony_ci target != GL_TEXTURE_BUFFER) 1023bf215546Sopenharmony_ci goto end; 1024bf215546Sopenharmony_ci FALLTHROUGH; 1025bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_SIZE: 1026bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_SIZE: 1027bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_SIZE: 1028bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_SIZE: 1029bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_SIZE: 1030bf215546Sopenharmony_ci buffer[0] = _mesa_get_format_bits(texformat, pname); 1031bf215546Sopenharmony_ci break; 1032bf215546Sopenharmony_ci 1033bf215546Sopenharmony_ci case GL_INTERNALFORMAT_DEPTH_TYPE: 1034bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_float(ctx)) 1035bf215546Sopenharmony_ci goto end; 1036bf215546Sopenharmony_ci FALLTHROUGH; 1037bf215546Sopenharmony_ci case GL_INTERNALFORMAT_RED_TYPE: 1038bf215546Sopenharmony_ci case GL_INTERNALFORMAT_GREEN_TYPE: 1039bf215546Sopenharmony_ci case GL_INTERNALFORMAT_BLUE_TYPE: 1040bf215546Sopenharmony_ci case GL_INTERNALFORMAT_ALPHA_TYPE: 1041bf215546Sopenharmony_ci case GL_INTERNALFORMAT_STENCIL_TYPE: 1042bf215546Sopenharmony_ci buffer[0] = _mesa_get_format_datatype(texformat); 1043bf215546Sopenharmony_ci break; 1044bf215546Sopenharmony_ci 1045bf215546Sopenharmony_ci default: 1046bf215546Sopenharmony_ci break; 1047bf215546Sopenharmony_ci 1048bf215546Sopenharmony_ci } 1049bf215546Sopenharmony_ci break; 1050bf215546Sopenharmony_ci } 1051bf215546Sopenharmony_ci 1052bf215546Sopenharmony_ci /* For WIDTH/HEIGHT/DEPTH/LAYERS there is no reason to think that the 1053bf215546Sopenharmony_ci * returned values should be different to the values returned by 1054bf215546Sopenharmony_ci * GetInteger with MAX_TEXTURE_SIZE, MAX_3D_TEXTURE_SIZE, etc.*/ 1055bf215546Sopenharmony_ci case GL_MAX_WIDTH: 1056bf215546Sopenharmony_ci case GL_MAX_HEIGHT: 1057bf215546Sopenharmony_ci case GL_MAX_DEPTH: { 1058bf215546Sopenharmony_ci GLenum get_pname; 1059bf215546Sopenharmony_ci GLint dimensions; 1060bf215546Sopenharmony_ci GLint min_dimensions; 1061bf215546Sopenharmony_ci 1062bf215546Sopenharmony_ci /* From query2:MAX_HEIGHT spec (as example): 1063bf215546Sopenharmony_ci * 1064bf215546Sopenharmony_ci * "If the resource does not have at least two dimensions, or if the 1065bf215546Sopenharmony_ci * resource is unsupported, zero is returned." 1066bf215546Sopenharmony_ci */ 1067bf215546Sopenharmony_ci dimensions = _get_target_dimensions(target); 1068bf215546Sopenharmony_ci min_dimensions = _get_min_dimensions(pname); 1069bf215546Sopenharmony_ci if (dimensions < min_dimensions) 1070bf215546Sopenharmony_ci goto end; 1071bf215546Sopenharmony_ci 1072bf215546Sopenharmony_ci get_pname = _equivalent_size_pname(target, pname); 1073bf215546Sopenharmony_ci if (get_pname == 0) 1074bf215546Sopenharmony_ci goto end; 1075bf215546Sopenharmony_ci 1076bf215546Sopenharmony_ci _mesa_GetIntegerv(get_pname, buffer); 1077bf215546Sopenharmony_ci break; 1078bf215546Sopenharmony_ci } 1079bf215546Sopenharmony_ci 1080bf215546Sopenharmony_ci case GL_MAX_LAYERS: 1081bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_array(ctx)) 1082bf215546Sopenharmony_ci goto end; 1083bf215546Sopenharmony_ci 1084bf215546Sopenharmony_ci if (!_mesa_is_array_texture(target)) 1085bf215546Sopenharmony_ci goto end; 1086bf215546Sopenharmony_ci 1087bf215546Sopenharmony_ci _mesa_GetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, buffer); 1088bf215546Sopenharmony_ci break; 1089bf215546Sopenharmony_ci 1090bf215546Sopenharmony_ci case GL_MAX_COMBINED_DIMENSIONS:{ 1091bf215546Sopenharmony_ci GLint64 combined_value = 1; 1092bf215546Sopenharmony_ci GLenum max_dimensions_pnames[] = { 1093bf215546Sopenharmony_ci GL_MAX_WIDTH, 1094bf215546Sopenharmony_ci GL_MAX_HEIGHT, 1095bf215546Sopenharmony_ci GL_MAX_DEPTH, 1096bf215546Sopenharmony_ci GL_SAMPLES 1097bf215546Sopenharmony_ci }; 1098bf215546Sopenharmony_ci unsigned i; 1099bf215546Sopenharmony_ci GLint current_value; 1100bf215546Sopenharmony_ci 1101bf215546Sopenharmony_ci /* Combining the dimensions. Note that for array targets, this would 1102bf215546Sopenharmony_ci * automatically include the value of MAX_LAYERS, as that value is 1103bf215546Sopenharmony_ci * returned as MAX_HEIGHT or MAX_DEPTH */ 1104bf215546Sopenharmony_ci for (i = 0; i < 4; i++) { 1105bf215546Sopenharmony_ci if (max_dimensions_pnames[i] == GL_SAMPLES && 1106bf215546Sopenharmony_ci !_mesa_is_multisample_target(target)) 1107bf215546Sopenharmony_ci continue; 1108bf215546Sopenharmony_ci 1109bf215546Sopenharmony_ci _mesa_GetInternalformativ(target, internalformat, 1110bf215546Sopenharmony_ci max_dimensions_pnames[i], 1111bf215546Sopenharmony_ci 1, ¤t_value); 1112bf215546Sopenharmony_ci 1113bf215546Sopenharmony_ci if (current_value != 0) 1114bf215546Sopenharmony_ci combined_value *= current_value; 1115bf215546Sopenharmony_ci } 1116bf215546Sopenharmony_ci 1117bf215546Sopenharmony_ci if (_mesa_is_cube_map_texture(target)) 1118bf215546Sopenharmony_ci combined_value *= 6; 1119bf215546Sopenharmony_ci 1120bf215546Sopenharmony_ci /* We pack the 64-bit value on two 32-bit values. Calling the 32-bit 1121bf215546Sopenharmony_ci * query, this would work as far as the value can be hold on a 32-bit 1122bf215546Sopenharmony_ci * signed integer. For the 64-bit query, the wrapper around the 32-bit 1123bf215546Sopenharmony_ci * query will unpack the value */ 1124bf215546Sopenharmony_ci memcpy(buffer, &combined_value, sizeof(GLint64)); 1125bf215546Sopenharmony_ci break; 1126bf215546Sopenharmony_ci } 1127bf215546Sopenharmony_ci 1128bf215546Sopenharmony_ci case GL_COLOR_COMPONENTS: 1129bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 1130bf215546Sopenharmony_ci * 1131bf215546Sopenharmony_ci * "- COLOR_COMPONENTS: If the internal format contains any color 1132bf215546Sopenharmony_ci * components (R, G, B, or A), TRUE is returned in <params>. 1133bf215546Sopenharmony_ci * If the internal format is unsupported or contains no color 1134bf215546Sopenharmony_ci * components, FALSE is returned." 1135bf215546Sopenharmony_ci */ 1136bf215546Sopenharmony_ci if (_mesa_is_color_format(internalformat)) 1137bf215546Sopenharmony_ci buffer[0] = GL_TRUE; 1138bf215546Sopenharmony_ci break; 1139bf215546Sopenharmony_ci 1140bf215546Sopenharmony_ci case GL_DEPTH_COMPONENTS: 1141bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 1142bf215546Sopenharmony_ci * 1143bf215546Sopenharmony_ci * "- DEPTH_COMPONENTS: If the internal format contains a depth 1144bf215546Sopenharmony_ci * component (D), TRUE is returned in <params>. If the internal format 1145bf215546Sopenharmony_ci * is unsupported or contains no depth component, FALSE is returned." 1146bf215546Sopenharmony_ci */ 1147bf215546Sopenharmony_ci if (_mesa_is_depth_format(internalformat) || 1148bf215546Sopenharmony_ci _mesa_is_depthstencil_format(internalformat)) 1149bf215546Sopenharmony_ci buffer[0] = GL_TRUE; 1150bf215546Sopenharmony_ci break; 1151bf215546Sopenharmony_ci 1152bf215546Sopenharmony_ci case GL_STENCIL_COMPONENTS: 1153bf215546Sopenharmony_ci /* The ARB_internalformat_query2 spec says: 1154bf215546Sopenharmony_ci * 1155bf215546Sopenharmony_ci * "- STENCIL_COMPONENTS: If the internal format contains a stencil 1156bf215546Sopenharmony_ci * component (S), TRUE is returned in <params>. If the internal format 1157bf215546Sopenharmony_ci * is unsupported or contains no stencil component, FALSE is returned. 1158bf215546Sopenharmony_ci */ 1159bf215546Sopenharmony_ci if (_mesa_is_stencil_format(internalformat) || 1160bf215546Sopenharmony_ci _mesa_is_depthstencil_format(internalformat)) 1161bf215546Sopenharmony_ci buffer[0] = GL_TRUE; 1162bf215546Sopenharmony_ci break; 1163bf215546Sopenharmony_ci 1164bf215546Sopenharmony_ci case GL_COLOR_RENDERABLE: 1165bf215546Sopenharmony_ci case GL_DEPTH_RENDERABLE: 1166bf215546Sopenharmony_ci case GL_STENCIL_RENDERABLE: 1167bf215546Sopenharmony_ci if (!_is_renderable(ctx, internalformat)) 1168bf215546Sopenharmony_ci goto end; 1169bf215546Sopenharmony_ci 1170bf215546Sopenharmony_ci if (pname == GL_COLOR_RENDERABLE) { 1171bf215546Sopenharmony_ci if (!_mesa_is_color_format(internalformat)) 1172bf215546Sopenharmony_ci goto end; 1173bf215546Sopenharmony_ci } else { 1174bf215546Sopenharmony_ci GLenum baseFormat = _mesa_base_fbo_format(ctx, internalformat); 1175bf215546Sopenharmony_ci if (baseFormat != GL_DEPTH_STENCIL && 1176bf215546Sopenharmony_ci ((pname == GL_DEPTH_RENDERABLE && baseFormat != GL_DEPTH_COMPONENT) || 1177bf215546Sopenharmony_ci (pname == GL_STENCIL_RENDERABLE && baseFormat != GL_STENCIL_INDEX))) 1178bf215546Sopenharmony_ci goto end; 1179bf215546Sopenharmony_ci } 1180bf215546Sopenharmony_ci 1181bf215546Sopenharmony_ci buffer[0] = GL_TRUE; 1182bf215546Sopenharmony_ci break; 1183bf215546Sopenharmony_ci 1184bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 1185bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_array(ctx) || 1186bf215546Sopenharmony_ci _legal_target_for_framebuffer_texture_layer(ctx, target)) 1187bf215546Sopenharmony_ci goto end; 1188bf215546Sopenharmony_ci FALLTHROUGH; 1189bf215546Sopenharmony_ci case GL_FRAMEBUFFER_RENDERABLE: 1190bf215546Sopenharmony_ci case GL_FRAMEBUFFER_BLEND: 1191bf215546Sopenharmony_ci if (!_mesa_has_ARB_framebuffer_object(ctx)) 1192bf215546Sopenharmony_ci goto end; 1193bf215546Sopenharmony_ci 1194bf215546Sopenharmony_ci if (target == GL_TEXTURE_BUFFER || 1195bf215546Sopenharmony_ci !_is_renderable(ctx, internalformat)) 1196bf215546Sopenharmony_ci goto end; 1197bf215546Sopenharmony_ci 1198bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1199bf215546Sopenharmony_ci buffer); 1200bf215546Sopenharmony_ci break; 1201bf215546Sopenharmony_ci 1202bf215546Sopenharmony_ci case GL_READ_PIXELS: 1203bf215546Sopenharmony_ci case GL_READ_PIXELS_FORMAT: 1204bf215546Sopenharmony_ci case GL_READ_PIXELS_TYPE: 1205bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1206bf215546Sopenharmony_ci buffer); 1207bf215546Sopenharmony_ci break; 1208bf215546Sopenharmony_ci 1209bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_FORMAT: 1210bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_FORMAT: 1211bf215546Sopenharmony_ci case GL_TEXTURE_IMAGE_TYPE: 1212bf215546Sopenharmony_ci case GL_GET_TEXTURE_IMAGE_TYPE: 1213bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1214bf215546Sopenharmony_ci buffer); 1215bf215546Sopenharmony_ci break; 1216bf215546Sopenharmony_ci 1217bf215546Sopenharmony_ci case GL_MIPMAP: 1218bf215546Sopenharmony_ci case GL_MANUAL_GENERATE_MIPMAP: 1219bf215546Sopenharmony_ci case GL_AUTO_GENERATE_MIPMAP: 1220bf215546Sopenharmony_ci if (!_mesa_is_valid_generate_texture_mipmap_target(ctx, target) || 1221bf215546Sopenharmony_ci !_mesa_is_valid_generate_texture_mipmap_internalformat(ctx, 1222bf215546Sopenharmony_ci internalformat)) { 1223bf215546Sopenharmony_ci goto end; 1224bf215546Sopenharmony_ci } 1225bf215546Sopenharmony_ci 1226bf215546Sopenharmony_ci if (pname == GL_MIPMAP) { 1227bf215546Sopenharmony_ci buffer[0] = GL_TRUE; 1228bf215546Sopenharmony_ci goto end; 1229bf215546Sopenharmony_ci } 1230bf215546Sopenharmony_ci else if (pname == GL_MANUAL_GENERATE_MIPMAP) { 1231bf215546Sopenharmony_ci if (!_mesa_has_ARB_framebuffer_object(ctx)) 1232bf215546Sopenharmony_ci goto end; 1233bf215546Sopenharmony_ci } 1234bf215546Sopenharmony_ci else { 1235bf215546Sopenharmony_ci /* From ARB_internalformat_query2: 1236bf215546Sopenharmony_ci * "Dependencies on OpenGL 3.2 (Core Profile) 1237bf215546Sopenharmony_ci * In core profiles for OpenGL 3.2 and later versions, queries 1238bf215546Sopenharmony_ci * for the AUTO_GENERATE_MIPMAP <pname> return the appropriate 1239bf215546Sopenharmony_ci * unsupported response." 1240bf215546Sopenharmony_ci */ 1241bf215546Sopenharmony_ci if (_mesa_is_desktop_gl(ctx) && ctx->Version >= 32) 1242bf215546Sopenharmony_ci goto end; 1243bf215546Sopenharmony_ci } 1244bf215546Sopenharmony_ci 1245bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1246bf215546Sopenharmony_ci buffer); 1247bf215546Sopenharmony_ci break; 1248bf215546Sopenharmony_ci 1249bf215546Sopenharmony_ci case GL_COLOR_ENCODING: 1250bf215546Sopenharmony_ci if (!_mesa_is_color_format(internalformat)) 1251bf215546Sopenharmony_ci goto end; 1252bf215546Sopenharmony_ci 1253bf215546Sopenharmony_ci if (_mesa_is_srgb_format(internalformat)) 1254bf215546Sopenharmony_ci buffer[0] = GL_SRGB; 1255bf215546Sopenharmony_ci else 1256bf215546Sopenharmony_ci buffer[0] = GL_LINEAR; 1257bf215546Sopenharmony_ci break; 1258bf215546Sopenharmony_ci 1259bf215546Sopenharmony_ci case GL_SRGB_READ: 1260bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_sRGB(ctx) || 1261bf215546Sopenharmony_ci !_mesa_is_srgb_format(internalformat)) { 1262bf215546Sopenharmony_ci goto end; 1263bf215546Sopenharmony_ci } 1264bf215546Sopenharmony_ci 1265bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1266bf215546Sopenharmony_ci buffer); 1267bf215546Sopenharmony_ci break; 1268bf215546Sopenharmony_ci 1269bf215546Sopenharmony_ci case GL_SRGB_WRITE: 1270bf215546Sopenharmony_ci if (!ctx->Extensions.EXT_sRGB || 1271bf215546Sopenharmony_ci !_mesa_is_color_format(internalformat)) { 1272bf215546Sopenharmony_ci goto end; 1273bf215546Sopenharmony_ci } 1274bf215546Sopenharmony_ci 1275bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1276bf215546Sopenharmony_ci buffer); 1277bf215546Sopenharmony_ci break; 1278bf215546Sopenharmony_ci 1279bf215546Sopenharmony_ci case GL_SRGB_DECODE_ARB: 1280bf215546Sopenharmony_ci /* Presence of EXT_texture_sRGB_decode was already verified */ 1281bf215546Sopenharmony_ci if (!_mesa_has_EXT_texture_sRGB(ctx) || 1282bf215546Sopenharmony_ci target == GL_RENDERBUFFER || 1283bf215546Sopenharmony_ci !_mesa_is_srgb_format(internalformat)) { 1284bf215546Sopenharmony_ci goto end; 1285bf215546Sopenharmony_ci } 1286bf215546Sopenharmony_ci 1287bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1288bf215546Sopenharmony_ci buffer); 1289bf215546Sopenharmony_ci break; 1290bf215546Sopenharmony_ci 1291bf215546Sopenharmony_ci case GL_FILTER: 1292bf215546Sopenharmony_ci /* If it doesn't allow to set sampler parameters then it would not allow 1293bf215546Sopenharmony_ci * to set a filter different to GL_NEAREST. In practice, this method 1294bf215546Sopenharmony_ci * only filters out MULTISAMPLE/MULTISAMPLE_ARRAY */ 1295bf215546Sopenharmony_ci if (!_mesa_target_allows_setting_sampler_parameters(target)) 1296bf215546Sopenharmony_ci goto end; 1297bf215546Sopenharmony_ci 1298bf215546Sopenharmony_ci if (_mesa_is_enum_format_integer(internalformat)) 1299bf215546Sopenharmony_ci goto end; 1300bf215546Sopenharmony_ci 1301bf215546Sopenharmony_ci if (target == GL_TEXTURE_BUFFER) 1302bf215546Sopenharmony_ci goto end; 1303bf215546Sopenharmony_ci 1304bf215546Sopenharmony_ci /* At this point we know that multi-texel filtering is supported. We 1305bf215546Sopenharmony_ci * need to call the driver to know if it is CAVEAT_SUPPORT or 1306bf215546Sopenharmony_ci * FULL_SUPPORT. 1307bf215546Sopenharmony_ci */ 1308bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1309bf215546Sopenharmony_ci buffer); 1310bf215546Sopenharmony_ci break; 1311bf215546Sopenharmony_ci 1312bf215546Sopenharmony_ci case GL_VERTEX_TEXTURE: 1313bf215546Sopenharmony_ci case GL_TESS_CONTROL_TEXTURE: 1314bf215546Sopenharmony_ci case GL_TESS_EVALUATION_TEXTURE: 1315bf215546Sopenharmony_ci case GL_GEOMETRY_TEXTURE: 1316bf215546Sopenharmony_ci case GL_FRAGMENT_TEXTURE: 1317bf215546Sopenharmony_ci case GL_COMPUTE_TEXTURE: 1318bf215546Sopenharmony_ci if (target == GL_RENDERBUFFER) 1319bf215546Sopenharmony_ci goto end; 1320bf215546Sopenharmony_ci 1321bf215546Sopenharmony_ci if ((pname == GL_TESS_CONTROL_TEXTURE || 1322bf215546Sopenharmony_ci pname == GL_TESS_EVALUATION_TEXTURE) && 1323bf215546Sopenharmony_ci !_mesa_has_tessellation(ctx)) 1324bf215546Sopenharmony_ci goto end; 1325bf215546Sopenharmony_ci 1326bf215546Sopenharmony_ci if (pname == GL_GEOMETRY_TEXTURE && !_mesa_has_geometry_shaders(ctx)) 1327bf215546Sopenharmony_ci goto end; 1328bf215546Sopenharmony_ci 1329bf215546Sopenharmony_ci if (pname == GL_COMPUTE_TEXTURE && !_mesa_has_compute_shaders(ctx)) 1330bf215546Sopenharmony_ci goto end; 1331bf215546Sopenharmony_ci 1332bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1333bf215546Sopenharmony_ci buffer); 1334bf215546Sopenharmony_ci break; 1335bf215546Sopenharmony_ci 1336bf215546Sopenharmony_ci case GL_TEXTURE_GATHER: 1337bf215546Sopenharmony_ci case GL_TEXTURE_GATHER_SHADOW: 1338bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_gather(ctx)) 1339bf215546Sopenharmony_ci goto end; 1340bf215546Sopenharmony_ci 1341bf215546Sopenharmony_ci FALLTHROUGH; 1342bf215546Sopenharmony_ci case GL_TEXTURE_SHADOW: 1343bf215546Sopenharmony_ci /* Only depth or depth-stencil image formats make sense in shadow 1344bf215546Sopenharmony_ci samplers */ 1345bf215546Sopenharmony_ci if (pname != GL_TEXTURE_GATHER && 1346bf215546Sopenharmony_ci !_mesa_is_depth_format(internalformat) && 1347bf215546Sopenharmony_ci !_mesa_is_depthstencil_format(internalformat)) 1348bf215546Sopenharmony_ci goto end; 1349bf215546Sopenharmony_ci 1350bf215546Sopenharmony_ci /* Validate the target for shadow and gather operations */ 1351bf215546Sopenharmony_ci switch (target) { 1352bf215546Sopenharmony_ci case GL_TEXTURE_2D: 1353bf215546Sopenharmony_ci case GL_TEXTURE_2D_ARRAY: 1354bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 1355bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP_ARRAY: 1356bf215546Sopenharmony_ci case GL_TEXTURE_RECTANGLE: 1357bf215546Sopenharmony_ci break; 1358bf215546Sopenharmony_ci 1359bf215546Sopenharmony_ci case GL_TEXTURE_1D: 1360bf215546Sopenharmony_ci case GL_TEXTURE_1D_ARRAY: 1361bf215546Sopenharmony_ci /* 1D and 1DArray textures are not admitted in gather operations */ 1362bf215546Sopenharmony_ci if (pname != GL_TEXTURE_SHADOW) 1363bf215546Sopenharmony_ci goto end; 1364bf215546Sopenharmony_ci break; 1365bf215546Sopenharmony_ci 1366bf215546Sopenharmony_ci default: 1367bf215546Sopenharmony_ci goto end; 1368bf215546Sopenharmony_ci } 1369bf215546Sopenharmony_ci 1370bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1371bf215546Sopenharmony_ci buffer); 1372bf215546Sopenharmony_ci break; 1373bf215546Sopenharmony_ci 1374bf215546Sopenharmony_ci case GL_SHADER_IMAGE_LOAD: 1375bf215546Sopenharmony_ci case GL_SHADER_IMAGE_STORE: 1376bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx)) 1377bf215546Sopenharmony_ci goto end; 1378bf215546Sopenharmony_ci 1379bf215546Sopenharmony_ci /* We call to _mesa_is_shader_image_format_supported 1380bf215546Sopenharmony_ci * using "internalformat" as parameter, because the 1381bf215546Sopenharmony_ci * the ARB_internalformat_query2 spec says: 1382bf215546Sopenharmony_ci * "In this case the <internalformat> is the value of the <format> 1383bf215546Sopenharmony_ci * parameter that is passed to BindImageTexture." 1384bf215546Sopenharmony_ci */ 1385bf215546Sopenharmony_ci if (target == GL_RENDERBUFFER || 1386bf215546Sopenharmony_ci !_mesa_is_shader_image_format_supported(ctx, internalformat)) 1387bf215546Sopenharmony_ci goto end; 1388bf215546Sopenharmony_ci 1389bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1390bf215546Sopenharmony_ci buffer); 1391bf215546Sopenharmony_ci break; 1392bf215546Sopenharmony_ci 1393bf215546Sopenharmony_ci case GL_SHADER_IMAGE_ATOMIC: 1394bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx)) 1395bf215546Sopenharmony_ci goto end; 1396bf215546Sopenharmony_ci 1397bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1398bf215546Sopenharmony_ci buffer); 1399bf215546Sopenharmony_ci break; 1400bf215546Sopenharmony_ci 1401bf215546Sopenharmony_ci case GL_IMAGE_TEXEL_SIZE: { 1402bf215546Sopenharmony_ci mesa_format image_format; 1403bf215546Sopenharmony_ci 1404bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1405bf215546Sopenharmony_ci target == GL_RENDERBUFFER) 1406bf215546Sopenharmony_ci goto end; 1407bf215546Sopenharmony_ci 1408bf215546Sopenharmony_ci image_format = _mesa_get_shader_image_format(internalformat); 1409bf215546Sopenharmony_ci if (image_format == MESA_FORMAT_NONE) 1410bf215546Sopenharmony_ci goto end; 1411bf215546Sopenharmony_ci 1412bf215546Sopenharmony_ci /* We return bits */ 1413bf215546Sopenharmony_ci buffer[0] = (_mesa_get_format_bytes(image_format) * 8); 1414bf215546Sopenharmony_ci break; 1415bf215546Sopenharmony_ci } 1416bf215546Sopenharmony_ci 1417bf215546Sopenharmony_ci case GL_IMAGE_COMPATIBILITY_CLASS: 1418bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1419bf215546Sopenharmony_ci target == GL_RENDERBUFFER) 1420bf215546Sopenharmony_ci goto end; 1421bf215546Sopenharmony_ci 1422bf215546Sopenharmony_ci buffer[0] = _mesa_get_image_format_class(internalformat); 1423bf215546Sopenharmony_ci break; 1424bf215546Sopenharmony_ci 1425bf215546Sopenharmony_ci case GL_IMAGE_PIXEL_FORMAT: { 1426bf215546Sopenharmony_ci GLint base_format; 1427bf215546Sopenharmony_ci 1428bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1429bf215546Sopenharmony_ci target == GL_RENDERBUFFER || 1430bf215546Sopenharmony_ci !_mesa_is_shader_image_format_supported(ctx, internalformat)) 1431bf215546Sopenharmony_ci goto end; 1432bf215546Sopenharmony_ci 1433bf215546Sopenharmony_ci base_format = _mesa_base_tex_format(ctx, internalformat); 1434bf215546Sopenharmony_ci if (base_format == -1) 1435bf215546Sopenharmony_ci goto end; 1436bf215546Sopenharmony_ci 1437bf215546Sopenharmony_ci if (_mesa_is_enum_format_integer(internalformat)) 1438bf215546Sopenharmony_ci buffer[0] = _mesa_base_format_to_integer_format(base_format); 1439bf215546Sopenharmony_ci else 1440bf215546Sopenharmony_ci buffer[0] = base_format; 1441bf215546Sopenharmony_ci break; 1442bf215546Sopenharmony_ci } 1443bf215546Sopenharmony_ci 1444bf215546Sopenharmony_ci case GL_IMAGE_PIXEL_TYPE: { 1445bf215546Sopenharmony_ci mesa_format image_format; 1446bf215546Sopenharmony_ci GLenum datatype; 1447bf215546Sopenharmony_ci GLuint comps; 1448bf215546Sopenharmony_ci 1449bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1450bf215546Sopenharmony_ci target == GL_RENDERBUFFER) 1451bf215546Sopenharmony_ci goto end; 1452bf215546Sopenharmony_ci 1453bf215546Sopenharmony_ci image_format = _mesa_get_shader_image_format(internalformat); 1454bf215546Sopenharmony_ci if (image_format == MESA_FORMAT_NONE) 1455bf215546Sopenharmony_ci goto end; 1456bf215546Sopenharmony_ci 1457bf215546Sopenharmony_ci _mesa_uncompressed_format_to_type_and_comps(image_format, &datatype, 1458bf215546Sopenharmony_ci &comps); 1459bf215546Sopenharmony_ci if (!datatype) 1460bf215546Sopenharmony_ci goto end; 1461bf215546Sopenharmony_ci 1462bf215546Sopenharmony_ci buffer[0] = datatype; 1463bf215546Sopenharmony_ci break; 1464bf215546Sopenharmony_ci } 1465bf215546Sopenharmony_ci 1466bf215546Sopenharmony_ci case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: { 1467bf215546Sopenharmony_ci if (!_mesa_has_ARB_shader_image_load_store(ctx)) 1468bf215546Sopenharmony_ci goto end; 1469bf215546Sopenharmony_ci 1470bf215546Sopenharmony_ci /* As pointed by the spec quote below, this pname query should return 1471bf215546Sopenharmony_ci * the same value that GetTexParameter. So if the target is not valid 1472bf215546Sopenharmony_ci * for GetTexParameter we return the unsupported value. The check below 1473bf215546Sopenharmony_ci * is the same target check used by GetTexParameter. 1474bf215546Sopenharmony_ci */ 1475bf215546Sopenharmony_ci int targetIndex = _mesa_tex_target_to_index(ctx, target); 1476bf215546Sopenharmony_ci if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX) 1477bf215546Sopenharmony_ci goto end; 1478bf215546Sopenharmony_ci 1479bf215546Sopenharmony_ci /* From spec: "Equivalent to calling GetTexParameter with <value> set 1480bf215546Sopenharmony_ci * to IMAGE_FORMAT_COMPATIBILITY_TYPE." 1481bf215546Sopenharmony_ci * 1482bf215546Sopenharmony_ci * GetTexParameter just returns 1483bf215546Sopenharmony_ci * tex_obj->ImageFormatCompatibilityType. We create a fake tex_obj 1484bf215546Sopenharmony_ci * just with the purpose of getting the value. 1485bf215546Sopenharmony_ci */ 1486bf215546Sopenharmony_ci struct gl_texture_object *tex_obj = _mesa_new_texture_object(ctx, 0, target); 1487bf215546Sopenharmony_ci buffer[0] = tex_obj->Attrib.ImageFormatCompatibilityType; 1488bf215546Sopenharmony_ci _mesa_delete_texture_object(ctx, tex_obj); 1489bf215546Sopenharmony_ci 1490bf215546Sopenharmony_ci break; 1491bf215546Sopenharmony_ci } 1492bf215546Sopenharmony_ci 1493bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 1494bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 1495bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 1496bf215546Sopenharmony_ci case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 1497bf215546Sopenharmony_ci if (target == GL_RENDERBUFFER) 1498bf215546Sopenharmony_ci goto end; 1499bf215546Sopenharmony_ci 1500bf215546Sopenharmony_ci if (!_mesa_is_depthstencil_format(internalformat)) { 1501bf215546Sopenharmony_ci if (((pname == GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST || 1502bf215546Sopenharmony_ci pname == GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE) && 1503bf215546Sopenharmony_ci !_mesa_is_depth_format(internalformat)) || 1504bf215546Sopenharmony_ci ((pname == GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST || 1505bf215546Sopenharmony_ci pname == GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE) && 1506bf215546Sopenharmony_ci !_mesa_is_stencil_format(internalformat))) 1507bf215546Sopenharmony_ci goto end; 1508bf215546Sopenharmony_ci } 1509bf215546Sopenharmony_ci 1510bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1511bf215546Sopenharmony_ci buffer); 1512bf215546Sopenharmony_ci break; 1513bf215546Sopenharmony_ci 1514bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED: 1515bf215546Sopenharmony_ci buffer[0] = _mesa_is_compressed_format(ctx, internalformat); 1516bf215546Sopenharmony_ci break; 1517bf215546Sopenharmony_ci 1518bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH: 1519bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT: 1520bf215546Sopenharmony_ci case GL_TEXTURE_COMPRESSED_BLOCK_SIZE: { 1521bf215546Sopenharmony_ci mesa_format mesaformat; 1522bf215546Sopenharmony_ci GLint block_size; 1523bf215546Sopenharmony_ci 1524bf215546Sopenharmony_ci mesaformat = _mesa_glenum_to_compressed_format(internalformat); 1525bf215546Sopenharmony_ci if (mesaformat == MESA_FORMAT_NONE) 1526bf215546Sopenharmony_ci goto end; 1527bf215546Sopenharmony_ci 1528bf215546Sopenharmony_ci block_size = _mesa_get_format_bytes(mesaformat); 1529bf215546Sopenharmony_ci assert(block_size > 0); 1530bf215546Sopenharmony_ci 1531bf215546Sopenharmony_ci if (pname == GL_TEXTURE_COMPRESSED_BLOCK_SIZE) { 1532bf215546Sopenharmony_ci buffer[0] = block_size; 1533bf215546Sopenharmony_ci } else { 1534bf215546Sopenharmony_ci GLuint bwidth, bheight; 1535bf215546Sopenharmony_ci 1536bf215546Sopenharmony_ci /* Returns the width and height in pixels. We return bytes */ 1537bf215546Sopenharmony_ci _mesa_get_format_block_size(mesaformat, &bwidth, &bheight); 1538bf215546Sopenharmony_ci assert(bwidth > 0 && bheight > 0); 1539bf215546Sopenharmony_ci 1540bf215546Sopenharmony_ci if (pname == GL_TEXTURE_COMPRESSED_BLOCK_WIDTH) 1541bf215546Sopenharmony_ci buffer[0] = block_size / bheight; 1542bf215546Sopenharmony_ci else 1543bf215546Sopenharmony_ci buffer[0] = block_size / bwidth; 1544bf215546Sopenharmony_ci } 1545bf215546Sopenharmony_ci break; 1546bf215546Sopenharmony_ci } 1547bf215546Sopenharmony_ci 1548bf215546Sopenharmony_ci case GL_CLEAR_BUFFER: 1549bf215546Sopenharmony_ci if (target != GL_TEXTURE_BUFFER) 1550bf215546Sopenharmony_ci goto end; 1551bf215546Sopenharmony_ci 1552bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1553bf215546Sopenharmony_ci buffer); 1554bf215546Sopenharmony_ci break; 1555bf215546Sopenharmony_ci 1556bf215546Sopenharmony_ci case GL_TEXTURE_VIEW: 1557bf215546Sopenharmony_ci case GL_VIEW_COMPATIBILITY_CLASS: 1558bf215546Sopenharmony_ci if (!_mesa_has_ARB_texture_view(ctx) || 1559bf215546Sopenharmony_ci target == GL_TEXTURE_BUFFER || 1560bf215546Sopenharmony_ci target == GL_RENDERBUFFER) 1561bf215546Sopenharmony_ci goto end; 1562bf215546Sopenharmony_ci 1563bf215546Sopenharmony_ci if (pname == GL_TEXTURE_VIEW) { 1564bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1565bf215546Sopenharmony_ci buffer); 1566bf215546Sopenharmony_ci } else { 1567bf215546Sopenharmony_ci GLenum view_class = _mesa_texture_view_lookup_view_class(ctx, 1568bf215546Sopenharmony_ci internalformat); 1569bf215546Sopenharmony_ci if (view_class == GL_FALSE) 1570bf215546Sopenharmony_ci goto end; 1571bf215546Sopenharmony_ci 1572bf215546Sopenharmony_ci buffer[0] = view_class; 1573bf215546Sopenharmony_ci } 1574bf215546Sopenharmony_ci break; 1575bf215546Sopenharmony_ci 1576bf215546Sopenharmony_ci case GL_NUM_TILING_TYPES_EXT: 1577bf215546Sopenharmony_ci case GL_TILING_TYPES_EXT: 1578bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1579bf215546Sopenharmony_ci buffer); 1580bf215546Sopenharmony_ci break; 1581bf215546Sopenharmony_ci 1582bf215546Sopenharmony_ci case GL_TEXTURE_REDUCTION_MODE_ARB: 1583bf215546Sopenharmony_ci if (ctx->Extensions.EXT_texture_filter_minmax) 1584bf215546Sopenharmony_ci buffer[0] = (GLint)1; 1585bf215546Sopenharmony_ci else if (ctx->Extensions.ARB_texture_filter_minmax) 1586bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, 1587bf215546Sopenharmony_ci buffer); 1588bf215546Sopenharmony_ci else 1589bf215546Sopenharmony_ci buffer[0] = (GLint)0; 1590bf215546Sopenharmony_ci break; 1591bf215546Sopenharmony_ci 1592bf215546Sopenharmony_ci case GL_NUM_VIRTUAL_PAGE_SIZES_ARB: 1593bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_X_ARB: 1594bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_Y_ARB: 1595bf215546Sopenharmony_ci case GL_VIRTUAL_PAGE_SIZE_Z_ARB: 1596bf215546Sopenharmony_ci st_QueryInternalFormat(ctx, target, internalformat, pname, buffer); 1597bf215546Sopenharmony_ci break; 1598bf215546Sopenharmony_ci 1599bf215546Sopenharmony_ci default: 1600bf215546Sopenharmony_ci unreachable("bad param"); 1601bf215546Sopenharmony_ci } 1602bf215546Sopenharmony_ci 1603bf215546Sopenharmony_ci end: 1604bf215546Sopenharmony_ci if (bufSize != 0 && params == NULL) { 1605bf215546Sopenharmony_ci /* Emit a warning to aid application debugging, but go ahead and do the 1606bf215546Sopenharmony_ci * memcpy (and probably crash) anyway. 1607bf215546Sopenharmony_ci */ 1608bf215546Sopenharmony_ci _mesa_warning(ctx, 1609bf215546Sopenharmony_ci "glGetInternalformativ(bufSize = %d, but params = NULL)", 1610bf215546Sopenharmony_ci bufSize); 1611bf215546Sopenharmony_ci } 1612bf215546Sopenharmony_ci 1613bf215546Sopenharmony_ci /* Copy the data from the temporary buffer to the buffer supplied by the 1614bf215546Sopenharmony_ci * application. Clamp the size of the copy to the size supplied by the 1615bf215546Sopenharmony_ci * application. 1616bf215546Sopenharmony_ci */ 1617bf215546Sopenharmony_ci memcpy(params, buffer, MIN2(bufSize, 16) * sizeof(GLint)); 1618bf215546Sopenharmony_ci 1619bf215546Sopenharmony_ci return; 1620bf215546Sopenharmony_ci} 1621bf215546Sopenharmony_ci 1622bf215546Sopenharmony_civoid GLAPIENTRY 1623bf215546Sopenharmony_ci_mesa_GetInternalformati64v(GLenum target, GLenum internalformat, 1624bf215546Sopenharmony_ci GLenum pname, GLsizei bufSize, GLint64 *params) 1625bf215546Sopenharmony_ci{ 1626bf215546Sopenharmony_ci GLint params32[16]; 1627bf215546Sopenharmony_ci unsigned i; 1628bf215546Sopenharmony_ci GLsizei realSize = MIN2(bufSize, 16); 1629bf215546Sopenharmony_ci GLsizei callSize; 1630bf215546Sopenharmony_ci 1631bf215546Sopenharmony_ci GET_CURRENT_CONTEXT(ctx); 1632bf215546Sopenharmony_ci 1633bf215546Sopenharmony_ci ASSERT_OUTSIDE_BEGIN_END(ctx); 1634bf215546Sopenharmony_ci 1635bf215546Sopenharmony_ci if (!_mesa_has_ARB_internalformat_query2(ctx)) { 1636bf215546Sopenharmony_ci _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInternalformati64v"); 1637bf215546Sopenharmony_ci return; 1638bf215546Sopenharmony_ci } 1639bf215546Sopenharmony_ci 1640bf215546Sopenharmony_ci /* For SAMPLES there are cases where params needs to remain unmodified. As 1641bf215546Sopenharmony_ci * no pname can return a negative value, we fill params32 with negative 1642bf215546Sopenharmony_ci * values as reference values, that can be used to know what copy-back to 1643bf215546Sopenharmony_ci * params */ 1644bf215546Sopenharmony_ci for (i = 0; i < realSize; i++) 1645bf215546Sopenharmony_ci params32[i] = -1; 1646bf215546Sopenharmony_ci 1647bf215546Sopenharmony_ci /* For GL_MAX_COMBINED_DIMENSIONS we need to get back 2 32-bit integers, 1648bf215546Sopenharmony_ci * and at the same time we only need 2. So for that pname, we call the 1649bf215546Sopenharmony_ci * 32-bit query with bufSize 2, except on the case of bufSize 0, that is 1650bf215546Sopenharmony_ci * basically like asking to not get the value, but that is a caller 1651bf215546Sopenharmony_ci * problem. */ 1652bf215546Sopenharmony_ci if (pname == GL_MAX_COMBINED_DIMENSIONS && bufSize > 0) 1653bf215546Sopenharmony_ci callSize = 2; 1654bf215546Sopenharmony_ci else 1655bf215546Sopenharmony_ci callSize = bufSize; 1656bf215546Sopenharmony_ci 1657bf215546Sopenharmony_ci _mesa_GetInternalformativ(target, internalformat, pname, callSize, params32); 1658bf215546Sopenharmony_ci 1659bf215546Sopenharmony_ci if (pname == GL_MAX_COMBINED_DIMENSIONS) { 1660bf215546Sopenharmony_ci memcpy(params, params32, sizeof(GLint64)); 1661bf215546Sopenharmony_ci } else { 1662bf215546Sopenharmony_ci for (i = 0; i < realSize; i++) { 1663bf215546Sopenharmony_ci /* We only copy back the values that changed */ 1664bf215546Sopenharmony_ci if (params32[i] < 0) 1665bf215546Sopenharmony_ci break; 1666bf215546Sopenharmony_ci params[i] = (GLint64) params32[i]; 1667bf215546Sopenharmony_ci } 1668bf215546Sopenharmony_ci } 1669bf215546Sopenharmony_ci} 1670