11b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick/* 21b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * Copyright © 2012 Intel Corporation 31b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * 41b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * Permission is hereby granted, free of charge, to any person obtaining a 51b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * copy of this software and associated documentation files (the "Software"), 61b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * to deal in the Software without restriction, including without limitation 71b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * the rights to use, copy, modify, merge, publish, distribute, sublicense, 81b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * and/or sell copies of the Software, and to permit persons to whom the 91b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * Software is furnished to do so, subject to the following conditions: 101b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * 111b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * The above copyright notice and this permission notice (including the next 121b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * paragraph) shall be included in all copies or substantial portions of the 131b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * Software. 141b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * 151b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 201b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 211b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * DEALINGS IN THE SOFTWARE. 221b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick */ 231b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 241b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick#include "mtypes.h" 256064810e53aef4c13c943b6dbdd6a647219458e9Brian Paul#include "context.h" 261b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick#include "glformats.h" 271b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick#include "macros.h" 281b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick#include "enums.h" 291b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick#include "fbobject.h" 301b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick#include "formatquery.h" 31806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes#include "teximage.h" 327241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes#include "texparam.h" 33b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro#include "texobj.h" 344e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro#include "get.h" 3587b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes#include "genmipmap.h" 3652c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes#include "shaderimage.h" 37aed633bb97443749f250951553287cde021a1aaaAntia Puentes#include "texcompress.h" 38557939c08faed7766aeee187c168ed4083c67e35Antia Puentes#include "textureview.h" 391b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 40d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentesstatic bool 41d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes_is_renderable(struct gl_context *ctx, GLenum internalformat) 42d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes{ 43d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* Section 4.4.4 on page 212 of the GLES 3.0.4 spec says: 44d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * 45d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * "An internal format is color-renderable if it is one of the 46d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * formats from table 3.13 noted as color-renderable or if it 47d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * is unsized format RGBA or RGB." 48d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * 49d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * Therefore, we must accept GL_RGB and GL_RGBA here. 50d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes */ 51d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes if (internalformat != GL_RGB && internalformat != GL_RGBA && 52d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes _mesa_base_fbo_format(ctx, internalformat) == 0) 53d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes return false; 54d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 55d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes return true; 56d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes} 57d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 58a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes/* Handles the cases where either ARB_internalformat_query or 59a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * ARB_internalformat_query2 have to return an error. 60a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 61a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentesstatic bool 62a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes_legal_parameters(struct gl_context *ctx, GLenum target, GLenum internalformat, 63a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes GLenum pname, GLsizei bufSize, GLint *params) 64a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 65a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes{ 66a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes bool query2 = _mesa_has_ARB_internalformat_query2(ctx); 67a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 68a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query2 spec says: 69a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 70a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "The INVALID_ENUM error is generated if the <target> parameter to 71a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * GetInternalformati*v is not one of the targets listed in Table 6.xx. 72a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 73a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes switch(target){ 74a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_1D: 75a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_1D_ARRAY: 76a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_2D: 77a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_2D_ARRAY: 78a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_3D: 79a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_CUBE_MAP: 80a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_CUBE_MAP_ARRAY: 81a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_RECTANGLE: 82a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_BUFFER: 83a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes if (!query2) { 84a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query spec says: 85a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 86a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "If the <target> parameter to GetInternalformativ is not one of 87a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY 88a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * or RENDERBUFFER then an INVALID_ENUM error is generated. 89a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 90a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 91a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(target=%s)", 92a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(target)); 93a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 94a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 95a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 96a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes break; 97a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 98a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_RENDERBUFFER: 99a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes break; 100a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 101a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_2D_MULTISAMPLE: 102a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 103a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The non-existence of ARB_texture_multisample is treated in 104a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * ARB_internalformat_query implementation like an error. 105a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 106a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes if (!query2 && 107a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes !(_mesa_has_ARB_texture_multisample(ctx) || _mesa_is_gles31(ctx))) { 108a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 109a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(target=%s)", 110a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(target)); 111a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 112a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 113a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 114a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes break; 115a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 116a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes default: 117a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 118a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(target=%s)", 119a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(target)); 120a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 121a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 122a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 123a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 124a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query2 spec says: 125a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 126a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "The INVALID_ENUM error is generated if the <pname> parameter is 127a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * not one of the listed possibilities. 128a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 129a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes switch(pname){ 130a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SAMPLES: 131a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_NUM_SAMPLE_COUNTS: 132a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes break; 133a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 134a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SRGB_DECODE_ARB: 135a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query2 spec says: 136a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 137a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "If ARB_texture_sRGB_decode or EXT_texture_sRGB_decode or 138a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * equivalent functionality is not supported, queries for the 139a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * SRGB_DECODE_ARB <pname> set the INVALID_ENUM error. 140a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 141a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes if (!_mesa_has_EXT_texture_sRGB_decode(ctx)) { 142a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 143a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(pname=%s)", 144a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(pname)); 145a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 146a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 147a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* fallthrough */ 148a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_SUPPORTED: 149a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_PREFERRED: 150a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_RED_SIZE: 151a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_GREEN_SIZE: 152a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_BLUE_SIZE: 153a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_ALPHA_SIZE: 154a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_DEPTH_SIZE: 155a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_STENCIL_SIZE: 156a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_SHARED_SIZE: 157a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_RED_TYPE: 158a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_GREEN_TYPE: 159a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_BLUE_TYPE: 160a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_ALPHA_TYPE: 161a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_DEPTH_TYPE: 162a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_INTERNALFORMAT_STENCIL_TYPE: 163a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MAX_WIDTH: 164a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MAX_HEIGHT: 165a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MAX_DEPTH: 166a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MAX_LAYERS: 167a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MAX_COMBINED_DIMENSIONS: 168a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_COLOR_COMPONENTS: 169a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_DEPTH_COMPONENTS: 170a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_STENCIL_COMPONENTS: 171a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_COLOR_RENDERABLE: 172a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_DEPTH_RENDERABLE: 173a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_STENCIL_RENDERABLE: 174a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_FRAMEBUFFER_RENDERABLE: 175a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 176a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_FRAMEBUFFER_BLEND: 177a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_READ_PIXELS: 178a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_READ_PIXELS_FORMAT: 179a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_READ_PIXELS_TYPE: 180a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_IMAGE_FORMAT: 181a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_IMAGE_TYPE: 182a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_GET_TEXTURE_IMAGE_FORMAT: 183a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_GET_TEXTURE_IMAGE_TYPE: 184a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MIPMAP: 185a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_MANUAL_GENERATE_MIPMAP: 186a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_AUTO_GENERATE_MIPMAP: 187a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_COLOR_ENCODING: 188a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SRGB_READ: 189a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SRGB_WRITE: 190a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_FILTER: 191a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_VERTEX_TEXTURE: 192a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TESS_CONTROL_TEXTURE: 193a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TESS_EVALUATION_TEXTURE: 194a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_GEOMETRY_TEXTURE: 195a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_FRAGMENT_TEXTURE: 196a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_COMPUTE_TEXTURE: 197a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_SHADOW: 198a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_GATHER: 199a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_GATHER_SHADOW: 200a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SHADER_IMAGE_LOAD: 201a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SHADER_IMAGE_STORE: 202a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SHADER_IMAGE_ATOMIC: 203a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_IMAGE_TEXEL_SIZE: 204a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_IMAGE_COMPATIBILITY_CLASS: 205a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_IMAGE_PIXEL_FORMAT: 206a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_IMAGE_PIXEL_TYPE: 207a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: 208a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 209a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 210a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 211a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 212a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_COMPRESSED: 213a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH: 214a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT: 215a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_SIZE: 216a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_CLEAR_BUFFER: 217a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_TEXTURE_VIEW: 218a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes case GL_VIEW_COMPATIBILITY_CLASS: 219a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query spec says: 220a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 221a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "If the <pname> parameter to GetInternalformativ is not SAMPLES 222a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * or NUM_SAMPLE_COUNTS, then an INVALID_ENUM error is generated." 223a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 224a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes if (!query2) { 225a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 226a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(pname=%s)", 227a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(pname)); 228a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 229a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 230a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 231a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes break; 232a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 233a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes default: 234a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 235a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(pname=%s)", 236a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(pname)); 237a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 238a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 239a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 240a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query spec says: 241a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 242a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "If the <bufSize> parameter to GetInternalformativ is negative, then 243a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * an INVALID_VALUE error is generated." 244a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 245a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * Nothing is said in ARB_internalformat_query2 but we assume the same. 246a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 247a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes if (bufSize < 0) { 248a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_VALUE, 249a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(target=%s)", 250a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(target)); 251a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 252a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 253a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 254a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes /* The ARB_internalformat_query spec says: 255a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * 256a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * "If the <internalformat> parameter to GetInternalformativ is not 257a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * color-, depth- or stencil-renderable, then an INVALID_ENUM error is 258a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes * generated." 259a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes */ 260d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes if (!query2 && !_is_renderable(ctx, internalformat)) { 261a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_error(ctx, GL_INVALID_ENUM, 262a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes "glGetInternalformativ(internalformat=%s)", 263a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes _mesa_enum_to_string(internalformat)); 264a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return false; 265a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes } 266a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 267a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes return true; 268a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes} 269a6434f41cc580f75909afbfcd6fa71e23706f96fAntia Puentes 2704af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes/* Sets the appropriate "unsupported" response as defined by the 2714af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * ARB_internalformat_query2 spec for each each <pname>. 2724af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes */ 2734af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentesstatic void 2744af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes_set_default_response(GLenum pname, GLint buffer[16]) 2754af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes{ 2764af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes /* The ARB_internalformat_query2 defines which is the reponse best 2774af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * representing "not supported" or "not applicable" for each <pname>. 2784af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * 2794af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * " In general: 2804af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * - size- or count-based queries will return zero, 2814af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * - support-, format- or type-based queries will return NONE, 2824af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * - boolean-based queries will return FALSE, and 2834af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes * - list-based queries return no entries." 2844af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes */ 2854af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes switch(pname) { 2864af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SAMPLES: 2874af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes break; 2884af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes 2894af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MAX_COMBINED_DIMENSIONS: 290e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro /* This value can be a 64-bit value. As the default is the 32-bit query, 291e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * we pack 2 32-bit integers. So we need to clean both */ 292e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro buffer[0] = 0; 293e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro buffer[1] = 0; 294e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro break; 295e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 2964af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_NUM_SAMPLE_COUNTS: 2974af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_RED_SIZE: 2984af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_GREEN_SIZE: 2994af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_BLUE_SIZE: 3004af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_ALPHA_SIZE: 3014af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_DEPTH_SIZE: 3024af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_STENCIL_SIZE: 3034af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_SHARED_SIZE: 3044af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MAX_WIDTH: 3054af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MAX_HEIGHT: 3064af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MAX_DEPTH: 3074af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MAX_LAYERS: 3084af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_IMAGE_TEXEL_SIZE: 3094af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH: 3104af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT: 3114af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_SIZE: 3124af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes buffer[0] = 0; 3134af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes break; 3144af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes 3154af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_PREFERRED: 3164af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_RED_TYPE: 3174af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_GREEN_TYPE: 3184af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_BLUE_TYPE: 3194af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_ALPHA_TYPE: 3204af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_DEPTH_TYPE: 3214af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_STENCIL_TYPE: 3224af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_FRAMEBUFFER_RENDERABLE: 3234af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 3244af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_FRAMEBUFFER_BLEND: 3254af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_READ_PIXELS: 3264af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_READ_PIXELS_FORMAT: 3274af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_READ_PIXELS_TYPE: 3284af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_IMAGE_FORMAT: 3294af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_IMAGE_TYPE: 3304af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_GET_TEXTURE_IMAGE_FORMAT: 3314af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_GET_TEXTURE_IMAGE_TYPE: 3324af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MANUAL_GENERATE_MIPMAP: 3334af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_AUTO_GENERATE_MIPMAP: 3344af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_COLOR_ENCODING: 3354af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SRGB_READ: 3364af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SRGB_WRITE: 3374af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SRGB_DECODE_ARB: 3384af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_FILTER: 3394af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_VERTEX_TEXTURE: 3404af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TESS_CONTROL_TEXTURE: 3414af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TESS_EVALUATION_TEXTURE: 3424af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_GEOMETRY_TEXTURE: 3434af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_FRAGMENT_TEXTURE: 3444af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_COMPUTE_TEXTURE: 3454af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_SHADOW: 3464af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_GATHER: 3474af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_GATHER_SHADOW: 3484af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SHADER_IMAGE_LOAD: 3494af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SHADER_IMAGE_STORE: 3504af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SHADER_IMAGE_ATOMIC: 3514af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_IMAGE_COMPATIBILITY_CLASS: 3524af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_IMAGE_PIXEL_FORMAT: 3534af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_IMAGE_PIXEL_TYPE: 3544af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: 3554af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 3564af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 3574af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 3584af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 3594af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_CLEAR_BUFFER: 3604af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_VIEW: 3614af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_VIEW_COMPATIBILITY_CLASS: 3624af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes buffer[0] = GL_NONE; 3634af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes break; 3644af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes 3654af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_INTERNALFORMAT_SUPPORTED: 3664af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_COLOR_COMPONENTS: 3674af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_DEPTH_COMPONENTS: 3684af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_STENCIL_COMPONENTS: 3694af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_COLOR_RENDERABLE: 3704af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_DEPTH_RENDERABLE: 3714af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_STENCIL_RENDERABLE: 3724af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_MIPMAP: 3734af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes case GL_TEXTURE_COMPRESSED: 3744af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes buffer[0] = GL_FALSE; 3754af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes break; 3764af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes 3774af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes default: 3784af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes unreachable("invalid 'pname'"); 3794af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes } 3804af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes} 3814af3e5e9f1f80e18b5f9b198f9bd652936170908Antia Puentes 382806bc2bf223c03c488de5549582141824dcbbc40Antia Puentesstatic bool 383806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes_is_target_supported(struct gl_context *ctx, GLenum target) 384806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes{ 385806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes /* The ARB_internalformat_query2 spec says: 386806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes * 387806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes * "if a particular type of <target> is not supported by the 388806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes * implementation the "unsupported" answer should be given. 389806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes * This is not an error." 390c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin * 391c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin * For OpenGL ES, queries can only be used with GL_RENDERBUFFER or MS. 392806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes */ 393806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes switch(target){ 394c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin case GL_TEXTURE_1D: 395806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_2D: 396806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_3D: 397806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes if (!_mesa_is_desktop_gl(ctx)) 398806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 399806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 400806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 401806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_1D_ARRAY: 402806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes if (!_mesa_has_EXT_texture_array(ctx)) 403806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 404806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 405806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 406806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_2D_ARRAY: 407c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin if (!_mesa_has_EXT_texture_array(ctx)) 408806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 409806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 410806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 411806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_CUBE_MAP: 412c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin if (ctx->API != API_OPENGL_CORE && !_mesa_has_ARB_texture_cube_map(ctx)) 413806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 414806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 415806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 416806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_CUBE_MAP_ARRAY: 417806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes if (!_mesa_has_ARB_texture_cube_map_array(ctx)) 418806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 419806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 420806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 421806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_RECTANGLE: 422c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin if (!_mesa_has_ARB_texture_rectangle(ctx)) 423806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 424806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 425806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 426806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_BUFFER: 427806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes if (!_mesa_has_ARB_texture_buffer_object(ctx)) 428806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 429806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 430806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 431806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_RENDERBUFFER: 432806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes if (!(_mesa_has_ARB_framebuffer_object(ctx) || 433806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes _mesa_is_gles3(ctx))) 434806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 435806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 436806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 437806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_2D_MULTISAMPLE: 438806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 439806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes if (!(_mesa_has_ARB_texture_multisample(ctx) || 440806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes _mesa_is_gles31(ctx))) 441806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return false; 442806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes break; 443806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 444806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes default: 445806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes unreachable("invalid target"); 446806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes } 447806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 448806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes return true; 449806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes} 450806bc2bf223c03c488de5549582141824dcbbc40Antia Puentes 4515f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentesstatic bool 4525f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes_is_resource_supported(struct gl_context *ctx, GLenum target, 4535f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes GLenum internalformat, GLenum pname) 4545f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes{ 4555f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* From the ARB_internalformat_query2 spec: 4565f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * 4575f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * In the following descriptions, the term /resource/ is used to generically 4585f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * refer to an object of the appropriate type that has been created with 4595f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * <internalformat> and <target>. If the particular <target> and 4605f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * <internalformat> combination do not make sense, ... the "unsupported" 4615f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * answer should be given. This is not an error. 4625f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes */ 4635f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 4645f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* In the ARB_internalformat_query2 spec wording, some <pnames> do not care 4655f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * about the /resource/ being supported or not, we return 'true' for those. 4665f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes */ 4675f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes switch (pname) { 4685f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_INTERNALFORMAT_SUPPORTED: 4695f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_INTERNALFORMAT_PREFERRED: 4705f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_COLOR_COMPONENTS: 4715f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_DEPTH_COMPONENTS: 4725f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_STENCIL_COMPONENTS: 4735f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_COLOR_RENDERABLE: 4745f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_DEPTH_RENDERABLE: 4755f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_STENCIL_RENDERABLE: 4765f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return true; 4775f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes default: 4785f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes break; 4795f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes } 4805f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 4815f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes switch(target){ 4825f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_1D: 4835f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_1D_ARRAY: 4845f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_2D: 4855f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_2D_ARRAY: 4865f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_3D: 4875f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_CUBE_MAP: 4885f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_CUBE_MAP_ARRAY: 4895f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_RECTANGLE: 4905f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* Based on what Mesa does for glTexImage1D/2D/3D and 4915f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * glCompressedTexImage1D/2D/3D functions. 4925f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes */ 4935f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (_mesa_base_tex_format(ctx, internalformat) < 0) 4945f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return false; 4955f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 4965f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* additional checks for depth textures */ 4975f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (!_mesa_legal_texture_base_format_for_target(ctx, target, internalformat)) 4985f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return false; 4995f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5005f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* additional checks for compressed textures */ 5015f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (_mesa_is_compressed_format(ctx, internalformat) && 5025f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes (!_mesa_target_can_be_compressed(ctx, target, internalformat, NULL) || 5035f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes _mesa_format_no_online_compression(ctx, internalformat))) 5045f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return false; 5055f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5065f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes break; 5075f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_2D_MULTISAMPLE: 5085f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 5095f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* Based on what Mesa does for glTexImage2D/3DMultisample, 5105f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * glTexStorage2D/3DMultisample and 5115f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * glTextureStorage2D/3DMultisample functions. 5125f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes */ 5135f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (!_mesa_is_renderable_texture_format(ctx, internalformat)) 5145f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return false; 5155f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5165f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes break; 5175f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_TEXTURE_BUFFER: 5185f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* Based on what Mesa does for the glTexBuffer function. */ 5195f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (_mesa_validate_texbuffer_format(ctx, internalformat) == 5205f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes MESA_FORMAT_NONE) 5215f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return false; 5225f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5235f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes break; 5245f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes case GL_RENDERBUFFER: 5255f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes /* Based on what Mesa does for glRenderbufferStorage(Multisample) and 5265f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes * glNamedRenderbufferStorage functions. 5275f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes */ 5285f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (!_mesa_base_fbo_format(ctx, internalformat)) 5295f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return false; 5305f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5315f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes break; 5325f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes default: 5335f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes unreachable("bad target"); 5345f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes } 5355f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5365f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes return true; 5375f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes} 5385f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes 5394722abc6300249e5afeff54e1286d2261c26bd28Antia Puentesstatic bool 5404722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes_is_internalformat_supported(struct gl_context *ctx, GLenum target, 5414722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes GLenum internalformat) 5424722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes{ 5434722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes /* From the ARB_internalformat_query2 specification: 5444722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * 5454722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * "- INTERNALFORMAT_SUPPORTED: If <internalformat> is an internal format 5464722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * that is supported by the implementation in at least some subset of 5474722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * possible operations, TRUE is written to <params>. If <internalformat> 5484722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * if not a valid token for any internal format usage, FALSE is returned. 5494722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * 5504722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * <internalformats> that must be supported (in GL 4.2 or later) include 5514722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * the following: 5524722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * - "sized internal formats" from Table 3.12, 3.13, and 3.15, 5534722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * - any specific "compressed internal format" from Table 3.14, 5544722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * - any "image unit format" from Table 3.21. 5554722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * - any generic "compressed internal format" from Table 3.14, if the 5564722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * implementation accepts it for any texture specification commands, and 5574722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * - unsized or base internal format, if the implementation accepts 5584722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * it for texture or image specification. 5594722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes */ 5604722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes GLint buffer[1]; 5614722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes 56260a27ad122128145d28be37e9c0b0bc86a8e5181Giuseppe Bilotta /* At this point an internalformat is valid if it is valid as a texture or 5634722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * as a renderbuffer format. The checks are different because those methods 5644722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes * return different values when passing non supported internalformats */ 5654722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes if (_mesa_base_tex_format(ctx, internalformat) < 0 && 5664722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes _mesa_base_fbo_format(ctx, internalformat) == 0) 5674722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes return false; 5684722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes 5694722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes /* Let the driver have the final word */ 5704722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, 5714722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes GL_INTERNALFORMAT_SUPPORTED, buffer); 5724722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes 5734722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes return (buffer[0] == GL_TRUE); 5744722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes} 5754722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes 576e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentesstatic bool 577e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes_legal_target_for_framebuffer_texture_layer(struct gl_context *ctx, 578e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes GLenum target) 579e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes{ 580e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes switch (target) { 581e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_TEXTURE_3D: 582e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_TEXTURE_1D_ARRAY: 583e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_TEXTURE_2D_ARRAY: 584e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_TEXTURE_CUBE_MAP_ARRAY: 585e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 586e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_TEXTURE_CUBE_MAP: 587e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes return true; 588e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes default: 589e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes return false; 590e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes } 591e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes} 592e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes 593020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitevstatic GLenum 594020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev_mesa_generic_type_for_internal_format(GLenum internalFormat) 595020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev{ 596020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev if (_mesa_is_enum_format_unsigned_int(internalFormat)) 597020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev return GL_UNSIGNED_BYTE; 598020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev else if (_mesa_is_enum_format_signed_int(internalFormat)) 599020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev return GL_BYTE; 600020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev else 601020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev return GL_FLOAT; 602020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev} 603020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev 60445054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev/* default implementation of QueryInternalFormat driverfunc, for 60545054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev * drivers not implementing ARB_internalformat_query2. 60645054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev */ 60745054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitevvoid 60845054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev_mesa_query_internal_format_default(struct gl_context *ctx, GLenum target, 60945054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev GLenum internalFormat, GLenum pname, 61045054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev GLint *params) 61145054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev{ 61245054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev (void) target; 61345054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev 614993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev switch (pname) { 615993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev case GL_SAMPLES: 616993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev case GL_NUM_SAMPLE_COUNTS: 617993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev params[0] = 1; 618993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev break; 61956ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes 62056ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes case GL_INTERNALFORMAT_SUPPORTED: 62156ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes params[0] = GL_TRUE; 62256ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes break; 62356ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes 624eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev case GL_INTERNALFORMAT_PREFERRED: 625eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev params[0] = internalFormat; 626eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev break; 627eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev 628bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_READ_PIXELS_FORMAT: { 629bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev GLenum base_format = _mesa_base_tex_format(ctx, internalFormat); 630bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev switch (base_format) { 631bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_STENCIL_INDEX: 632bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_DEPTH_COMPONENT: 633bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_DEPTH_STENCIL: 634bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_RED: 635bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_RGB: 636bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_BGR: 637bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_RGBA: 638bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_BGRA: 639bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev params[0] = base_format; 640bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev break; 641bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev default: 642bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev params[0] = GL_NONE; 643bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev break; 644bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev } 645bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev break; 646bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev } 647bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev 648ec299602a6a1db209e8e93c0853ccad1eb4ffa72Eduardo Lima Mitev case GL_READ_PIXELS_TYPE: 649ec299602a6a1db209e8e93c0853ccad1eb4ffa72Eduardo Lima Mitev case GL_TEXTURE_IMAGE_TYPE: 650ec299602a6a1db209e8e93c0853ccad1eb4ffa72Eduardo Lima Mitev case GL_GET_TEXTURE_IMAGE_TYPE: { 651020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev GLenum base_format = _mesa_base_tex_format(ctx, internalFormat); 652020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev if (base_format > 0) 653020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev params[0] = _mesa_generic_type_for_internal_format(internalFormat); 654020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev else 655020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev params[0] = GL_NONE; 656020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev break; 657020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev } 658020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev 65923f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev case GL_TEXTURE_IMAGE_FORMAT: 66023f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev case GL_GET_TEXTURE_IMAGE_FORMAT: { 66123f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev GLenum format = GL_NONE; 66223f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev GLenum base_format = _mesa_base_tex_format(ctx, internalFormat); 66323f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev if (base_format > 0) { 66423f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev if (_mesa_is_enum_format_integer(internalFormat)) 66523f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev format = _mesa_base_format_to_integer_format(base_format); 66623f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev else 66723f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev format = base_format; 66823f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev } 66923f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev 67023f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev params[0] = format; 67123f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev break; 67223f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev } 67323f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev 67487b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes case GL_MANUAL_GENERATE_MIPMAP: 67587b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes case GL_AUTO_GENERATE_MIPMAP: 676bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes case GL_SRGB_READ: 677bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes case GL_SRGB_WRITE: 678aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes case GL_SRGB_DECODE_ARB: 679fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes case GL_VERTEX_TEXTURE: 680fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes case GL_TESS_CONTROL_TEXTURE: 681fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes case GL_TESS_EVALUATION_TEXTURE: 682fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes case GL_GEOMETRY_TEXTURE: 683fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes case GL_FRAGMENT_TEXTURE: 684fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes case GL_COMPUTE_TEXTURE: 68552c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes case GL_SHADER_IMAGE_LOAD: 68652c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes case GL_SHADER_IMAGE_STORE: 68752c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes case GL_SHADER_IMAGE_ATOMIC: 688467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 689467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 690467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 691467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 6922066c7be61c2edc07c79ea690ee1aef92665b5ecAntia Puentes case GL_CLEAR_BUFFER: 693557939c08faed7766aeee187c168ed4083c67e35Antia Puentes case GL_TEXTURE_VIEW: 694b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_SHADOW: 695b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_GATHER: 696b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_GATHER_SHADOW: 697e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_FRAMEBUFFER_RENDERABLE: 698e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 699e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_FRAMEBUFFER_BLEND: 7008d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro case GL_FILTER: 70187b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes params[0] = GL_FULL_SUPPORT; 70287b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes break; 70387b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes 704993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev default: 705d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes _set_default_response(pname, params); 706993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev break; 707993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev } 70845054f9702bd07cd293c1f6c1317eae9530cc4daEduardo Lima Mitev} 7094412f3bc13886751f91f265babd78bac28c7ba41Chris Forbes 7104e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro/* 7114e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * For MAX_WIDTH/MAX_HEIGHT/MAX_DEPTH it returns the equivalent GetInteger 7124e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * pname for a Getinternalformat pname/target combination. target/pname 7134e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * combinations that would return 0 due dimension number or unsupported status 7144e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * should be already filtered out 7154e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * 7164e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * Note that this means that the returned value would be independent of the 7174e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * internalformat. This possibility is already mentioned at the Issue 7 of the 7184e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * arb_internalformat_query2 spec. 7194e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro */ 7204e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeirostatic GLenum 7214e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro PiñeiroequivalentSizePname(GLenum target, 7224e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro GLenum pname) 7234e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro{ 7244e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro switch (target) { 7254e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_1D: 7264e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_2D: 7274e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_2D_MULTISAMPLE: 7284e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_TEXTURE_SIZE; 7294e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_3D: 7304e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_3D_TEXTURE_SIZE; 7314e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_CUBE_MAP: 7324e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_CUBE_MAP_TEXTURE_SIZE; 7334e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_RECTANGLE: 7344e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_RECTANGLE_TEXTURE_SIZE; 7354e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_RENDERBUFFER: 7364e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_RENDERBUFFER_SIZE; 7374e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_1D_ARRAY: 7384e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (pname == GL_MAX_HEIGHT) 7394e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_ARRAY_TEXTURE_LAYERS; 7404e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro else 7414e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_TEXTURE_SIZE; 7424e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_2D_ARRAY: 7434e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 7444e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (pname == GL_MAX_DEPTH) 7454e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_ARRAY_TEXTURE_LAYERS; 7464e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro else 7474e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_TEXTURE_SIZE; 7484e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_CUBE_MAP_ARRAY: 7494e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (pname == GL_MAX_DEPTH) 7504e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_ARRAY_TEXTURE_LAYERS; 7514e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro else 7524e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_CUBE_MAP_TEXTURE_SIZE; 7534e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_BUFFER: 7544e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return GL_MAX_TEXTURE_BUFFER_SIZE; 7554e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro default: 7564e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 0; 7574e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro } 7584e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro} 7594e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 7604e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro/* 7614e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * Returns the dimensions associated to a target. GL_TEXTURE_BUFFER and 7624e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * GL_RENDERBUFFER have associated a dimension, but they are not textures 7634e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * per-se, so we can't just call _mesa_get_texture_dimension directly. 7644e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro */ 7654e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeirostatic GLint 7664e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiroget_target_dimensions(GLenum target) 7674e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro{ 7684e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro switch(target) { 7694e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_TEXTURE_BUFFER: 7704e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 1; 7714e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_RENDERBUFFER: 7724e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 2; 7734e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro default: 7744e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return _mesa_get_texture_dimensions(target); 7754e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro } 7764e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro} 7774e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 7784e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro/* 7794e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * Returns the minimum amount of dimensions associated to a pname. So for 7804e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * example, if querying GL_MAX_HEIGHT, it is assumed that your target would 7814e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * have as minimum 2 dimensions. 7824e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * 7834e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * Useful to handle sentences like this from query2 spec: 7844e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * 7854e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * "MAX_HEIGHT: 7864e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * <skip> 7874e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * If the resource does not have at least two dimensions 7884e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * <skip>." 7894e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro */ 7904e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeirostatic GLint 7914e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiroget_min_dimensions(GLenum pname) 7924e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro{ 7934e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro switch(pname) { 7944e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_MAX_WIDTH: 7954e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 1; 7964e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_MAX_HEIGHT: 7974e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 2; 7984e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_MAX_DEPTH: 7994e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 3; 8004e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro default: 8014e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro return 0; 8024e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro } 8034e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro} 8044e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 805e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro/* 806e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * Similar to teximage.c:check_multisample_target, but independent of the 807e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * dimensions. 808e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro */ 809e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeirostatic bool 810e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeirois_multisample_target(GLenum target) 811e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro{ 812e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro switch(target) { 813e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro case GL_TEXTURE_2D_MULTISAMPLE: 814e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: 815e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro return true; 816e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro default: 817e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro return false; 818e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro } 819e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 820e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro} 821e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 8221b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanickvoid GLAPIENTRY 8231b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick_mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, 8241b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick GLsizei bufSize, GLint *params) 8251b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick{ 8261b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick GLint buffer[16]; 8271b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick GET_CURRENT_CONTEXT(ctx); 8281b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 8296064810e53aef4c13c943b6dbdd6a647219458e9Brian Paul ASSERT_OUTSIDE_BEGIN_END(ctx); 8306064810e53aef4c13c943b6dbdd6a647219458e9Brian Paul 831d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* ARB_internalformat_query is also mandatory for ARB_internalformat_query2 */ 832d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes if (!(_mesa_has_ARB_internalformat_query(ctx) || 833d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes _mesa_is_gles3(ctx))) { 8341b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInternalformativ"); 8351b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick return; 8361b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick } 8371b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 838993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev assert(ctx->Driver.QueryInternalFormat != NULL); 839f5e7f12e4a1d2ee98ced36c232842d60181fc01eIan Romanick 840d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes if (!_legal_parameters(ctx, target, internalformat, pname, bufSize, params)) 8411b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick return; 8421b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 843d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* initialize the contents of the temporary buffer */ 844d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes memcpy(buffer, params, MIN2(bufSize, 16) * sizeof(GLint)); 8451b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 846d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* Use the 'unsupported' response defined by the spec for every pname 847d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * as the default answer. 8481b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick */ 849d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes _set_default_response(pname, buffer); 8501b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 8515f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes if (!_is_target_supported(ctx, target) || 8524722abc6300249e5afeff54e1286d2261c26bd28Antia Puentes !_is_internalformat_supported(ctx, target, internalformat) || 8535f6e3a03704c67dd5a271a4e43645355c5199cc7Antia Puentes !_is_resource_supported(ctx, target, internalformat, pname)) 854d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes goto end; 85525ee5c60dcb49e68c80eb5157769ccb655d647faEduardo Lima Mitev 8561b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick switch (pname) { 8571b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick case GL_SAMPLES: 858d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* fall-through */ 859d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_NUM_SAMPLE_COUNTS: 860d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* The ARB_internalformat_query2 sets the response as 'unsupported' for 861d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * SAMPLES and NUM_SAMPLE_COUNTS: 862d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * 863d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * "If <internalformat> is not color-renderable, depth-renderable, or 864d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * stencil-renderable (as defined in section 4.4.4), or if <target> 865d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * does not support multiple samples (ie other than 866d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY, 867d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * or RENDERBUFFER)." 868d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes */ 869d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes if ((target != GL_RENDERBUFFER && 870d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes target != GL_TEXTURE_2D_MULTISAMPLE && 871d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY) || 872d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes !_is_renderable(ctx, internalformat)) 873d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes goto end; 874d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 875d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes /* The GL ES 3.0 specification, section 6.1.15 page 236 says: 876d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * 877d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * "Since multisampling is not supported for signed and unsigned 878d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * integer internal formats, the value of NUM_SAMPLE_COUNTS will be 879d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes * zero for such formats. 8809bdbb9c0e0d0fb73831c590eb9626a3298f55982Alejandro Piñeiro * 8819bdbb9c0e0d0fb73831c590eb9626a3298f55982Alejandro Piñeiro * Since OpenGL ES 3.1 adds support for multisampled integer formats, we 8829bdbb9c0e0d0fb73831c590eb9626a3298f55982Alejandro Piñeiro * have to check the version for 30 exactly. 883d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes */ 884d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes if (pname == GL_NUM_SAMPLE_COUNTS && ctx->API == API_OPENGLES2 && 885d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes ctx->Version == 30 && _mesa_is_enum_format_integer(internalformat)) { 886d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes goto end; 887d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes } 888d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 889993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 890993d7345b7c356d96f3d24865d83ff368bc6fc55Eduardo Lima Mitev buffer); 8911b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick break; 892d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 893d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_SUPPORTED: 89456ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes /* Having a supported <internalformat> is implemented as a prerequisite 89556ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes * for all the <pnames>. Thus, if we reach this point, the internalformat is 89656ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes * supported. 89756ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes */ 89856ec2dfcb1b9e2756d550dfad9008597b1951997Antia Puentes buffer[0] = GL_TRUE; 8991b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick break; 900d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 901d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_PREFERRED: 902eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev /* The ARB_internalformat_query2 spec says: 903eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev * 904eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev * "- INTERNALFORMAT_PREFERRED: The implementation-preferred internal 905eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev * format for representing resources of the specified <internalformat> is 906eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev * returned in <params>. 907eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev * 908b48c42cd1f81bf9a411d19aea2660d75622a1350Alejandro Piñeiro * Therefore, we let the driver answer. Note that if we reach this 909b48c42cd1f81bf9a411d19aea2660d75622a1350Alejandro Piñeiro * point, it means that the internalformat is supported, so the driver 910b48c42cd1f81bf9a411d19aea2660d75622a1350Alejandro Piñeiro * is called just to try to get a preferred format. If not supported, 911b48c42cd1f81bf9a411d19aea2660d75622a1350Alejandro Piñeiro * GL_NONE was already returned and the driver is not called. 912eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev */ 913eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 914eacb2c971ed2aa0a2f51f47d8b1667a5edf97a00Eduardo Lima Mitev buffer); 915d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 916d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 917d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_RED_SIZE: 918d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_GREEN_SIZE: 919d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_BLUE_SIZE: 920d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_ALPHA_SIZE: 921d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_DEPTH_SIZE: 922d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_STENCIL_SIZE: 923d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_SHARED_SIZE: 924d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_RED_TYPE: 925d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_GREEN_TYPE: 926d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_BLUE_TYPE: 927d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_ALPHA_TYPE: 928d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_INTERNALFORMAT_DEPTH_TYPE: 9297241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_STENCIL_TYPE: { 9307241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes GLint baseformat; 9317241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes mesa_format texformat; 932d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 9337241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (target != GL_RENDERBUFFER) { 9347241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (!_mesa_legal_get_tex_level_parameter_target(ctx, target, true)) 9357241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes goto end; 9367241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9377241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes baseformat = _mesa_base_tex_format(ctx, internalformat); 9387241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes } else { 9397241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes baseformat = _mesa_base_fbo_format(ctx, internalformat); 9407241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes } 9417241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9427241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes /* Let the driver choose the texture format. 9437241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes * 9447241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes * Disclaimer: I am considering that drivers use for renderbuffers the 9457241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes * same format-choice logic as for textures. 9467241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes */ 9477241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes texformat = ctx->Driver.ChooseTextureFormat(ctx, target, internalformat, 9487241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes GL_NONE /*format */, GL_NONE /* type */); 9497241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9507241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (texformat == MESA_FORMAT_NONE || baseformat <= 0) 9517241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes goto end; 9527241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9537241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes /* Implementation based on what Mesa does for glGetTexLevelParameteriv 9547241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes * and glGetRenderbufferParameteriv functions. 9557241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes */ 9567241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (pname == GL_INTERNALFORMAT_SHARED_SIZE) { 9577241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (_mesa_has_EXT_texture_shared_exponent(ctx) && 9587241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes target != GL_TEXTURE_BUFFER && 9597241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes target != GL_RENDERBUFFER && 9607241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes texformat == MESA_FORMAT_R9G9B9E5_FLOAT) { 9617241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes buffer[0] = 5; 9627241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes } 9637241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes goto end; 9647241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes } 9657241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9667241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (!_mesa_base_format_has_channel(baseformat, pname)) 9677241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes goto end; 9687241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9697241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes switch (pname) { 9707241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_DEPTH_SIZE: 971c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin if (ctx->API != API_OPENGL_CORE && 972c42acd93d47452eec492400d1f3e7c66dd9bb672Ilia Mirkin !_mesa_has_ARB_depth_texture(ctx) && 9737241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes target != GL_RENDERBUFFER && 9747241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes target != GL_TEXTURE_BUFFER) 9757241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes goto end; 9767241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes /* fallthrough */ 9777241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_RED_SIZE: 9787241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_GREEN_SIZE: 9797241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_BLUE_SIZE: 9807241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_ALPHA_SIZE: 9817241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_STENCIL_SIZE: 9827241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes buffer[0] = _mesa_get_format_bits(texformat, pname); 9837241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes break; 9847241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9857241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_DEPTH_TYPE: 9867241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes if (!_mesa_has_ARB_texture_float(ctx)) 9877241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes goto end; 9887241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes /* fallthrough */ 9897241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_RED_TYPE: 9907241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_GREEN_TYPE: 9917241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_BLUE_TYPE: 9927241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_ALPHA_TYPE: 9937241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes case GL_INTERNALFORMAT_STENCIL_TYPE: 9947241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes buffer[0] = _mesa_get_format_datatype(texformat); 9957241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes break; 9967241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 9977241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes default: 9987241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes break; 9997241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes 10007241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes } 1001d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 10027241e1b5f4b9882425517b3d0131114119a7fdc6Antia Puentes } 1003d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 10044e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro /* For WIDTH/HEIGHT/DEPTH/LAYERS there is no reason to think that the 10054e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * returned values should be different to the values returned by 10064e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * GetInteger with MAX_TEXTURE_SIZE, MAX_3D_TEXTURE_SIZE, etc.*/ 1007d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_MAX_WIDTH: 1008d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_MAX_HEIGHT: 10094e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro case GL_MAX_DEPTH: { 10104e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro GLenum get_pname; 10114e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro GLint dimensions; 10124e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro GLint min_dimensions; 1013d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 10144e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro /* From query2:MAX_HEIGHT spec (as example): 10154e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * 10164e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * "If the resource does not have at least two dimensions, or if the 10174e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro * resource is unsupported, zero is returned." 10184e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro */ 10194e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro dimensions = get_target_dimensions(target); 10204e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro min_dimensions = get_min_dimensions(pname); 10214e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (dimensions < min_dimensions) 10224e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro goto end; 10234e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 10244e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro get_pname = equivalentSizePname(target, pname); 10254e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (get_pname == 0) 10264e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro goto end; 10274e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 10284e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro _mesa_GetIntegerv(get_pname, buffer); 1029d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 10304e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro } 1031d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1032d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_MAX_LAYERS: 10334e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (!_mesa_has_EXT_texture_array(ctx)) 10344e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro goto end; 10354e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 10364e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro if (!_mesa_is_array_texture(target)) 10374e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro goto end; 10384e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro 10394e33278b39f5292b5ca82281f7b364d402ba48b2Alejandro Piñeiro _mesa_GetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, buffer); 1040d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1041d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1042e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro case GL_MAX_COMBINED_DIMENSIONS:{ 1043e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GLint64 combined_value = 1; 1044e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GLenum max_dimensions_pnames[] = { 1045e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GL_MAX_WIDTH, 1046e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GL_MAX_HEIGHT, 1047e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GL_MAX_DEPTH, 1048e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GL_SAMPLES 1049e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro }; 1050e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro unsigned i; 1051e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GLint current_value; 1052e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1053e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro /* Combining the dimensions. Note that for array targets, this would 1054e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * automatically include the value of MAX_LAYERS, as that value is 1055e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * returned as MAX_HEIGHT or MAX_DEPTH */ 1056e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro for (i = 0; i < 4; i++) { 1057e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro if (max_dimensions_pnames[i] == GL_SAMPLES && 1058e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro !is_multisample_target(target)) 1059e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro continue; 1060e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1061e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro _mesa_GetInternalformativ(target, internalformat, 1062e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro max_dimensions_pnames[i], 1063e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1, ¤t_value); 1064e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1065e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro if (current_value != 0) 1066e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro combined_value *= current_value; 1067e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro } 1068e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1069e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro if (_mesa_is_cube_map_texture(target)) 1070e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro combined_value *= 6; 1071e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1072e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro /* We pack the 64-bit value on two 32-bit values. Calling the 32-bit 1073e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * query, this would work as far as the value can be hold on a 32-bit 1074e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * signed integer. For the 64-bit query, the wrapper around the 32-bit 1075e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * query will unpack the value */ 1076e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro memcpy(buffer, &combined_value, sizeof(GLint64)); 1077d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1078e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro } 1079d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1080d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_COLOR_COMPONENTS: 1081c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes /* The ARB_internalformat_query2 spec says: 1082c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * 1083c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * "- COLOR_COMPONENTS: If the internal format contains any color 1084c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * components (R, G, B, or A), TRUE is returned in <params>. 1085c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * If the internal format is unsupported or contains no color 1086c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * components, FALSE is returned." 1087c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes */ 1088c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes if (_mesa_is_color_format(internalformat)) 1089c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes buffer[0] = GL_TRUE; 1090d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1091d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1092d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_DEPTH_COMPONENTS: 1093c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes /* The ARB_internalformat_query2 spec says: 1094c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * 1095c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * "- DEPTH_COMPONENTS: If the internal format contains a depth 1096c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * component (D), TRUE is returned in <params>. If the internal format 1097c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * is unsupported or contains no depth component, FALSE is returned." 1098c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes */ 1099c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes if (_mesa_is_depth_format(internalformat) || 1100c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes _mesa_is_depthstencil_format(internalformat)) 1101c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes buffer[0] = GL_TRUE; 1102d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1103d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1104d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_STENCIL_COMPONENTS: 1105c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes /* The ARB_internalformat_query2 spec says: 1106c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * 1107c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * "- STENCIL_COMPONENTS: If the internal format contains a stencil 1108c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * component (S), TRUE is returned in <params>. If the internal format 1109c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes * is unsupported or contains no stencil component, FALSE is returned. 1110c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes */ 1111c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes if (_mesa_is_stencil_format(internalformat) || 1112c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes _mesa_is_depthstencil_format(internalformat)) 1113c22ceb08bb4340b8f6e13e5b94fb288ce1bfeefaAntia Puentes buffer[0] = GL_TRUE; 1114d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1115d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1116d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_COLOR_RENDERABLE: 1117d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_DEPTH_RENDERABLE: 1118d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_STENCIL_RENDERABLE: 1119df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes if (!_is_renderable(ctx, internalformat)) 1120df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes goto end; 1121df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes 1122df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes if (pname == GL_COLOR_RENDERABLE) { 1123df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes if (!_mesa_is_color_format(internalformat)) 1124df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes goto end; 1125df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes } else { 1126df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes GLenum baseFormat = _mesa_base_fbo_format(ctx, internalformat); 1127df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes if (baseFormat != GL_DEPTH_STENCIL && 1128df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes ((pname == GL_DEPTH_RENDERABLE && baseFormat != GL_DEPTH_COMPONENT) || 1129df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes (pname == GL_STENCIL_RENDERABLE && baseFormat != GL_STENCIL_INDEX))) 1130df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes goto end; 1131df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes } 1132df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes 1133df3a37311d2cb1bf83e6803a8c974b7269d4c3c9Antia Puentes buffer[0] = GL_TRUE; 1134d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1135d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1136e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_FRAMEBUFFER_RENDERABLE_LAYERED: 1137e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes if (!_mesa_has_EXT_texture_array(ctx) || 1138e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes _legal_target_for_framebuffer_texture_layer(ctx, target)) 1139e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes goto end; 1140e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes /* fallthrough */ 1141d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_FRAMEBUFFER_RENDERABLE: 1142e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes case GL_FRAMEBUFFER_BLEND: 1143e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes if (!_mesa_has_ARB_framebuffer_object(ctx)) 1144e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes goto end; 1145d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1146e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes if (target == GL_TEXTURE_BUFFER || 1147e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes !_is_renderable(ctx, internalformat)) 1148e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes goto end; 1149d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1150e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1151e8ab7727e1cb359be565b9d3dace1c0490e452adAntia Puentes buffer); 1152d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1153d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1154d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_READ_PIXELS: 1155bec286f7246bedba9f7f34185f2e1e29befec3abEduardo Lima Mitev case GL_READ_PIXELS_FORMAT: 1156020671f2a3d47ff35e9937b4db3fa09df6f6d488Eduardo Lima Mitev case GL_READ_PIXELS_TYPE: 115709550c16a51e89dbf64b0864d3fb4ddb6accac52Eduardo Lima Mitev ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 115809550c16a51e89dbf64b0864d3fb4ddb6accac52Eduardo Lima Mitev buffer); 1159d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1160d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1161d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_IMAGE_FORMAT: 116223f94146c987c380bcdebb0d787dc71e808afc27Eduardo Lima Mitev case GL_GET_TEXTURE_IMAGE_FORMAT: 1163d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_IMAGE_TYPE: 1164d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_GET_TEXTURE_IMAGE_TYPE: 1165ec299602a6a1db209e8e93c0853ccad1eb4ffa72Eduardo Lima Mitev ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1166ec299602a6a1db209e8e93c0853ccad1eb4ffa72Eduardo Lima Mitev buffer); 1167d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1168d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1169d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_MIPMAP: 1170d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_MANUAL_GENERATE_MIPMAP: 1171d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_AUTO_GENERATE_MIPMAP: 117287b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes if (!_mesa_is_valid_generate_texture_mipmap_target(ctx, target) || 117387b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes !_mesa_is_valid_generate_texture_mipmap_internalformat(ctx, 117487b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes internalformat)) { 117587b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes goto end; 117687b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes } 117787b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes 117887b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes if (pname == GL_MIPMAP) { 117987b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes buffer[0] = GL_TRUE; 118087b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes goto end; 118187b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes } 118287b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes else if (pname == GL_MANUAL_GENERATE_MIPMAP) { 118387b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes if (!_mesa_has_ARB_framebuffer_object(ctx)) 118487b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes goto end; 118587b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes } 118687b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes else { 118787b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes /* From ARB_internalformat_query2: 118887b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes * "Dependencies on OpenGL 3.2 (Core Profile) 118987b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes * In core profiles for OpenGL 3.2 and later versions, queries 119087b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes * for the AUTO_GENERATE_MIPMAP <pname> return the appropriate 119187b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes * unsupported response." 119287b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes */ 119387b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes if (_mesa_is_desktop_gl(ctx) && ctx->Version >= 32) 119487b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes goto end; 119587b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes } 119687b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes 119787b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 119887b2de3998fd26767af437ffe512779dc2e8d404Antia Puentes buffer); 1199d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1200d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1201d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_COLOR_ENCODING: 1202e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes if (!_mesa_is_color_format(internalformat)) 1203e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes goto end; 1204e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes 1205e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes if (_mesa_is_srgb_format(internalformat)) 1206e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes buffer[0] = GL_SRGB; 1207e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes else 1208e88cbb7a51051da66bf142515bc028559f999a64Antia Puentes buffer[0] = GL_LINEAR; 1209d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1210d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1211d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SRGB_READ: 1212bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes if (!_mesa_has_EXT_texture_sRGB(ctx) || 1213bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes !_mesa_is_srgb_format(internalformat)) { 1214bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes goto end; 1215bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes } 1216bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes 1217bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1218bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes buffer); 1219d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1220d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1221d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SRGB_WRITE: 1222bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes if (!_mesa_has_EXT_framebuffer_sRGB(ctx) || 1223bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes !_mesa_is_color_format(internalformat)) { 1224bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes goto end; 1225bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes } 1226bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes 1227bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1228bcb2f9cdb97ab2b866e238780ba68908b10e2e79Antia Puentes buffer); 1229d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1230d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1231d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SRGB_DECODE_ARB: 1232aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes /* Presence of EXT_texture_sRGB_decode was already verified */ 1233aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes if (!_mesa_has_EXT_texture_sRGB(ctx) || 1234aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes target == GL_RENDERBUFFER || 1235aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes !_mesa_is_srgb_format(internalformat)) { 1236aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes goto end; 1237aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes } 1238aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes 1239aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1240aeb759c7d631eb10a69245ba8d7b6a2179a268f5Antia Puentes buffer); 1241d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1242d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1243d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_FILTER: 12448d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro /* If it doesn't allow to set sampler parameters then it would not allow 12458d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro * to set a filter different to GL_NEAREST. In practice, this method 12468d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro * only filters out MULTISAMPLE/MULTISAMPLE_ARRAY */ 12478d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro if (!_mesa_target_allows_setting_sampler_parameters(target)) 12488d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro goto end; 12498d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro 12508d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro if (_mesa_is_enum_format_integer(internalformat)) 12518d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro goto end; 12528d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro 12538d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro if (target == GL_TEXTURE_BUFFER) 12548d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro goto end; 12558d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro 12568d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro /* At this point we know that multi-texel filtering is supported. We 12578d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro * need to call the driver to know if it is CAVEAT_SUPPORT or 12588d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro * FULL_SUPPORT. 12598d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro */ 12608d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 12618d7696f6380c38085029fff0eb00c3c18ea8e017Alejandro Piñeiro buffer); 1262d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1263d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1264d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_VERTEX_TEXTURE: 1265d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TESS_CONTROL_TEXTURE: 1266d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TESS_EVALUATION_TEXTURE: 1267d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_GEOMETRY_TEXTURE: 1268d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_FRAGMENT_TEXTURE: 1269d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_COMPUTE_TEXTURE: 1270fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes if (target == GL_RENDERBUFFER) 1271fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes goto end; 1272fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes 1273fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes if ((pname == GL_TESS_CONTROL_TEXTURE || 1274fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes pname == GL_TESS_EVALUATION_TEXTURE) && 1275fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes !_mesa_has_tessellation(ctx)) 1276fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes goto end; 1277fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes 1278fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes if (pname == GL_GEOMETRY_TEXTURE && !_mesa_has_geometry_shaders(ctx)) 1279fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes goto end; 1280fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes 1281fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes if (pname == GL_COMPUTE_TEXTURE && !_mesa_has_compute_shaders(ctx)) 1282fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes goto end; 1283fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes 1284fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1285fae2b10ff9ec568df328785183e483d4fcbf0f83Antia Puentes buffer); 1286d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1287d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1288b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_GATHER: 1289b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_GATHER_SHADOW: 1290b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes if (!_mesa_has_ARB_texture_gather(ctx)) 1291b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes goto end; 1292b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes 1293b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes /* fallthrough */ 1294d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_SHADOW: 1295b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes /* Only depth or depth-stencil image formats make sense in shadow 1296b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes samplers */ 1297b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes if (pname != GL_TEXTURE_GATHER && 1298b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes !_mesa_is_depth_format(internalformat) && 1299b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes !_mesa_is_depthstencil_format(internalformat)) 1300b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes goto end; 1301d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1302b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes /* Validate the target for shadow and gather operations */ 1303b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes switch (target) { 1304b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_2D: 1305b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_2D_ARRAY: 1306b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_CUBE_MAP: 1307b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_CUBE_MAP_ARRAY: 1308b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_RECTANGLE: 1309b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes break; 1310d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1311b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_1D: 1312b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes case GL_TEXTURE_1D_ARRAY: 1313b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes /* 1D and 1DArray textures are not admitted in gather operations */ 1314b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes if (pname != GL_TEXTURE_SHADOW) 1315b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes goto end; 1316b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes break; 1317b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes 1318b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes default: 1319b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes goto end; 1320b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes } 1321b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes 1322b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1323b4ee9f56fd8e457c91a85bcebb124b088edee76eAntia Puentes buffer); 1324d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1325d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1326d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SHADER_IMAGE_LOAD: 1327d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SHADER_IMAGE_STORE: 132852c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes if (!_mesa_has_ARB_shader_image_load_store(ctx)) 132952c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes goto end; 133052c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes 133152c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes /* We call to _mesa_is_shader_image_format_supported 133252c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes * using "internalformat" as parameter, because the 133352c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes * the ARB_internalformat_query2 spec says: 133452c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes * "In this case the <internalformat> is the value of the <format> 133552c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes * parameter that is passed to BindImageTexture." 133652c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes */ 133752c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes if (target == GL_RENDERBUFFER || 133852c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes !_mesa_is_shader_image_format_supported(ctx, internalformat)) 133952c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes goto end; 134052c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes 134152c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 134252c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes buffer); 1343d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1344d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1345d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SHADER_IMAGE_ATOMIC: 134652c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes if (!_mesa_has_ARB_shader_image_load_store(ctx)) 134752c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes goto end; 134852c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes 134952c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 135052c3692324675535105f2d5bbdf2c4cd26e76580Antia Puentes buffer); 1351d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1352d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1353bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes case GL_IMAGE_TEXEL_SIZE: { 1354bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes mesa_format image_format; 1355bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1356bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1357bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes target == GL_RENDERBUFFER) 1358bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1359bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1360bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes image_format = _mesa_get_shader_image_format(internalformat); 1361bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (image_format == MESA_FORMAT_NONE) 1362bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1363bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1364bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes /* We return bits */ 1365bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes buffer[0] = (_mesa_get_format_bytes(image_format) * 8); 1366d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1367bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes } 1368d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1369d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_IMAGE_COMPATIBILITY_CLASS: 1370bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1371bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes target == GL_RENDERBUFFER) 1372bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1373bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1374bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes buffer[0] = _mesa_get_image_format_class(internalformat); 1375d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1376d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1377bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes case GL_IMAGE_PIXEL_FORMAT: { 1378bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes GLint base_format; 1379bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1380bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1381bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes target == GL_RENDERBUFFER || 1382bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes !_mesa_is_shader_image_format_supported(ctx, internalformat)) 1383bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1384bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1385bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes base_format = _mesa_base_tex_format(ctx, internalformat); 1386bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (base_format == -1) 1387bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1388bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1389bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (_mesa_is_enum_format_integer(internalformat)) 1390bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes buffer[0] = _mesa_base_format_to_integer_format(base_format); 1391bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes else 1392bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes buffer[0] = base_format; 1393d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1394bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes } 1395d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1396bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes case GL_IMAGE_PIXEL_TYPE: { 1397bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes mesa_format image_format; 1398bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes GLenum datatype; 1399bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes GLuint comps; 1400bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1401bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (!_mesa_has_ARB_shader_image_load_store(ctx) || 1402bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes target == GL_RENDERBUFFER) 1403bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1404bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1405bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes image_format = _mesa_get_shader_image_format(internalformat); 1406bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (image_format == MESA_FORMAT_NONE) 1407bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1408bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1409bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes _mesa_uncompressed_format_to_type_and_comps(image_format, &datatype, 1410bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes &comps); 1411bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes if (!datatype) 1412bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes goto end; 1413bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes 1414bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes buffer[0] = datatype; 1415d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1416bd45fb3de4d067c014084affef76095ba74091d9Antia Puentes } 1417d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1418b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: { 1419b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro if (!_mesa_has_ARB_shader_image_load_store(ctx)) 1420b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro goto end; 1421b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro 1422b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro if (!_mesa_legal_get_tex_level_parameter_target(ctx, target, true)) 1423b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro goto end; 1424b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro 1425b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro /* From spec: "Equivalent to calling GetTexParameter with <value> set 1426b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro * to IMAGE_FORMAT_COMPATIBILITY_TYPE." 1427b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro * 1428b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro * GetTexParameter just returns 1429b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro * tex_obj->ImageFormatCompatibilityType. We create a fake tex_obj 1430b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro * just with the purpose of getting the value. 1431b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro */ 1432b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro struct gl_texture_object *tex_obj = _mesa_new_texture_object(ctx, 0, target); 1433b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro buffer[0] = tex_obj->ImageFormatCompatibilityType; 1434b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro _mesa_delete_texture_object(ctx, tex_obj); 1435b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro 1436d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1437b750144b0a5be87b5ed3008f3373b1f96722b9bdAlejandro Piñeiro } 1438d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1439d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: 1440d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: 1441d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: 1442d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: 1443467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes if (target == GL_RENDERBUFFER) 1444467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes goto end; 1445467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes 1446467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes if (!_mesa_is_depthstencil_format(internalformat)) { 1447467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes if (((pname == GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST || 1448467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes pname == GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE) && 1449467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes !_mesa_is_depth_format(internalformat)) || 1450467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes ((pname == GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST || 1451467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes pname == GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE) && 1452467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes !_mesa_is_stencil_format(internalformat))) 1453467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes goto end; 1454467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes } 1455467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes 1456467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1457467f462c75281083f91846f176d6fd4a5d1afbbdAntia Puentes buffer); 1458d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1459d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1460d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_COMPRESSED: 1461aed633bb97443749f250951553287cde021a1aaaAntia Puentes buffer[0] = _mesa_is_compressed_format(ctx, internalformat); 1462d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1463d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1464d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_WIDTH: 1465d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT: 1466aed633bb97443749f250951553287cde021a1aaaAntia Puentes case GL_TEXTURE_COMPRESSED_BLOCK_SIZE: { 1467aed633bb97443749f250951553287cde021a1aaaAntia Puentes mesa_format mesaformat; 1468aed633bb97443749f250951553287cde021a1aaaAntia Puentes GLint block_size; 1469d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1470aed633bb97443749f250951553287cde021a1aaaAntia Puentes mesaformat = _mesa_glenum_to_compressed_format(internalformat); 1471aed633bb97443749f250951553287cde021a1aaaAntia Puentes if (mesaformat == MESA_FORMAT_NONE) 1472aed633bb97443749f250951553287cde021a1aaaAntia Puentes goto end; 1473aed633bb97443749f250951553287cde021a1aaaAntia Puentes 1474aed633bb97443749f250951553287cde021a1aaaAntia Puentes block_size = _mesa_get_format_bytes(mesaformat); 1475aed633bb97443749f250951553287cde021a1aaaAntia Puentes assert(block_size > 0); 1476aed633bb97443749f250951553287cde021a1aaaAntia Puentes 1477aed633bb97443749f250951553287cde021a1aaaAntia Puentes if (pname == GL_TEXTURE_COMPRESSED_BLOCK_SIZE) { 1478aed633bb97443749f250951553287cde021a1aaaAntia Puentes buffer[0] = block_size; 1479aed633bb97443749f250951553287cde021a1aaaAntia Puentes } else { 1480aed633bb97443749f250951553287cde021a1aaaAntia Puentes GLuint bwidth, bheight; 1481aed633bb97443749f250951553287cde021a1aaaAntia Puentes 1482aed633bb97443749f250951553287cde021a1aaaAntia Puentes /* Returns the width and height in pixels. We return bytes */ 1483aed633bb97443749f250951553287cde021a1aaaAntia Puentes _mesa_get_format_block_size(mesaformat, &bwidth, &bheight); 1484aed633bb97443749f250951553287cde021a1aaaAntia Puentes assert(bwidth > 0 && bheight > 0); 1485aed633bb97443749f250951553287cde021a1aaaAntia Puentes 1486aed633bb97443749f250951553287cde021a1aaaAntia Puentes if (pname == GL_TEXTURE_COMPRESSED_BLOCK_WIDTH) 1487aed633bb97443749f250951553287cde021a1aaaAntia Puentes buffer[0] = block_size / bheight; 1488aed633bb97443749f250951553287cde021a1aaaAntia Puentes else 1489aed633bb97443749f250951553287cde021a1aaaAntia Puentes buffer[0] = block_size / bwidth; 1490aed633bb97443749f250951553287cde021a1aaaAntia Puentes } 1491d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1492aed633bb97443749f250951553287cde021a1aaaAntia Puentes } 1493d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1494d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_CLEAR_BUFFER: 14952066c7be61c2edc07c79ea690ee1aef92665b5ecAntia Puentes if (target != GL_TEXTURE_BUFFER) 14962066c7be61c2edc07c79ea690ee1aef92665b5ecAntia Puentes goto end; 14972066c7be61c2edc07c79ea690ee1aef92665b5ecAntia Puentes 14982066c7be61c2edc07c79ea690ee1aef92665b5ecAntia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 14992066c7be61c2edc07c79ea690ee1aef92665b5ecAntia Puentes buffer); 1500d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1501d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 1502d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_TEXTURE_VIEW: 1503d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes case GL_VIEW_COMPATIBILITY_CLASS: 1504557939c08faed7766aeee187c168ed4083c67e35Antia Puentes if (!_mesa_has_ARB_texture_view(ctx) || 1505557939c08faed7766aeee187c168ed4083c67e35Antia Puentes target == GL_TEXTURE_BUFFER || 1506557939c08faed7766aeee187c168ed4083c67e35Antia Puentes target == GL_RENDERBUFFER) 1507557939c08faed7766aeee187c168ed4083c67e35Antia Puentes goto end; 1508557939c08faed7766aeee187c168ed4083c67e35Antia Puentes 1509557939c08faed7766aeee187c168ed4083c67e35Antia Puentes if (pname == GL_TEXTURE_VIEW) { 1510557939c08faed7766aeee187c168ed4083c67e35Antia Puentes ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname, 1511557939c08faed7766aeee187c168ed4083c67e35Antia Puentes buffer); 1512557939c08faed7766aeee187c168ed4083c67e35Antia Puentes } else { 1513557939c08faed7766aeee187c168ed4083c67e35Antia Puentes GLenum view_class = _mesa_texture_view_lookup_view_class(ctx, 1514557939c08faed7766aeee187c168ed4083c67e35Antia Puentes internalformat); 1515557939c08faed7766aeee187c168ed4083c67e35Antia Puentes if (view_class == GL_FALSE) 1516557939c08faed7766aeee187c168ed4083c67e35Antia Puentes goto end; 1517557939c08faed7766aeee187c168ed4083c67e35Antia Puentes 1518557939c08faed7766aeee187c168ed4083c67e35Antia Puentes buffer[0] = view_class; 1519557939c08faed7766aeee187c168ed4083c67e35Antia Puentes } 1520d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes break; 1521d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes 15221b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick default: 1523d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes unreachable("bad param"); 15241b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick } 15251b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 1526d432337e2dc0759563c8e1ef573aa3805aa2eed8Antia Puentes end: 15271b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick if (bufSize != 0 && params == NULL) { 15281b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick /* Emit a warning to aid application debugging, but go ahead and do the 15291b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * memcpy (and probably crash) anyway. 15301b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick */ 15311b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick _mesa_warning(ctx, 15321b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick "glGetInternalformativ(bufSize = %d, but params = NULL)", 15331b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick bufSize); 15341b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick } 15351b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 15361b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick /* Copy the data from the temporary buffer to the buffer supplied by the 15371b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * application. Clamp the size of the copy to the size supplied by the 15381b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick * application. 15391b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick */ 154025ee5c60dcb49e68c80eb5157769ccb655d647faEduardo Lima Mitev memcpy(params, buffer, MIN2(bufSize, 16) * sizeof(GLint)); 15411b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick 15421b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick return; 15431b468d043e538a6302ad77a408ad123c58dc0e83Ian Romanick} 1544b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes 1545b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentesvoid GLAPIENTRY 1546b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes_mesa_GetInternalformati64v(GLenum target, GLenum internalformat, 1547b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes GLenum pname, GLsizei bufSize, GLint64 *params) 1548b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes{ 1549580816b74723af481dd85c845caca8aa41274ed5Alejandro Piñeiro GLint params32[16]; 1550580816b74723af481dd85c845caca8aa41274ed5Alejandro Piñeiro unsigned i; 1551e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro GLsizei realSize = MIN2(bufSize, 16); 1552e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro GLsizei callSize; 1553580816b74723af481dd85c845caca8aa41274ed5Alejandro Piñeiro 1554b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes GET_CURRENT_CONTEXT(ctx); 1555b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes 1556b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes ASSERT_OUTSIDE_BEGIN_END(ctx); 1557b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes 1558b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes if (!_mesa_has_ARB_internalformat_query2(ctx)) { 1559b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInternalformati64v"); 1560b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes return; 1561b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes } 1562b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes 1563e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro /* For SAMPLES there are cases where params needs to remain unmodified. As 1564e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro * no pname can return a negative value, we fill params32 with negative 1565e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro * values as reference values, that can be used to know what copy-back to 1566e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro * params */ 1567e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro memset(params32, -1, 16); 1568580816b74723af481dd85c845caca8aa41274ed5Alejandro Piñeiro 1569e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro /* For GL_MAX_COMBINED_DIMENSIONS we need to get back 2 32-bit integers, 1570e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * and at the same time we only need 2. So for that pname, we call the 1571e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * 32-bit query with bufSize 2, except on the case of bufSize 0, that is 1572e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * basically like asking to not get the value, but that is a caller 1573e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro * problem. */ 1574e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro if (pname == GL_MAX_COMBINED_DIMENSIONS && bufSize > 0) 1575e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro callSize = 2; 1576e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro else 1577e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro callSize = bufSize; 1578e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1579e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro _mesa_GetInternalformativ(target, internalformat, pname, callSize, params32); 1580e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro 1581e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro if (pname == GL_MAX_COMBINED_DIMENSIONS) { 1582e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro memcpy(params, params32, sizeof(GLint64)); 1583e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro } else { 1584e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro for (i = 0; i < realSize; i++) { 1585e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro /* We only copy back the values that changed */ 1586e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro if (params32[i] < 0) 1587e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro break; 1588e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro params[i] = (GLint64) params32[i]; 1589e976a30db8f24ec81259140f157a224c49aa373eAlejandro Piñeiro } 1590e98a3c799f5db65966f87c5d59552ae22a001084Alejandro Piñeiro } 1591b5d27bc5ddb9f30153e02f4ae1096c8d6eda3df5Antia Puentes} 1592