1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
/*
* Copyright © 2014 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/**
* \file invalid-internal-format.c
*
* From the GL_ARB_clear_buffer_object spec:
* "<internalformat> must be set to one of the format tokens listed in
* Table 3.15, "Internal formats for buffer textures"."
*
* This table only includes a subset of available internal formats. In
* particular, the table does not include:
* -- unsized formats (e.g.: GL_RGBA)
* -- depth or stencil formats
* -- compressed formats
* -- formats with a component with a bitwidth that is not a multiple of 8
* (e.g.: GL_RGB5_A1).
* -- formats with a total bitwidth that is not a multiple of 32
* (e.g.: GL_RGB8).
*
* Test that the required GL_INVALID_ENUM error is generated for these formats.
*/
#include "piglit-util-gl.h"
PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 15;
config.khr_no_error_support = PIGLIT_HAS_ERRORS;
PIGLIT_GL_TEST_CONFIG_END
static const struct {
GLenum internal_format;
GLenum format;
GLenum type;
} formats[] = {
/* legacy OpenGL 1.0 "formats" */
{1, GL_ALPHA, GL_UNSIGNED_BYTE},
{2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
{3, GL_RGB, GL_UNSIGNED_BYTE},
{4, GL_RGBA, GL_UNSIGNED_BYTE},
/* unsized formats */
{GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
{GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE},
{GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE},
{GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
{GL_INTENSITY, GL_INTENSITY, GL_UNSIGNED_BYTE},
{GL_RGB, GL_RGB, GL_UNSIGNED_BYTE},
{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
/* depth formats */
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT},
{GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
{GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
/* component not multiple of 8 bit wide */
{GL_ALPHA4, GL_ALPHA, GL_UNSIGNED_BYTE},
{GL_ALPHA12, GL_ALPHA, GL_UNSIGNED_SHORT},
{GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE},
{GL_LUMINANCE12, GL_LUMINANCE, GL_UNSIGNED_SHORT},
{GL_LUMINANCE12_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_INT},
{GL_LUMINANCE12_ALPHA12, GL_LUMINANCE_ALPHA, GL_UNSIGNED_INT},
{GL_INTENSITY4, GL_INTENSITY, GL_UNSIGNED_BYTE},
{GL_INTENSITY12, GL_INTENSITY, GL_UNSIGNED_SHORT},
{GL_R3_G3_B2, GL_RGB, GL_UNSIGNED_BYTE_3_3_2},
{GL_RGB4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4},
{GL_RGB5, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1},
{GL_RGB10, GL_RGB, GL_UNSIGNED_INT_10_10_10_2},
{GL_RGB12, GL_RGB, GL_UNSIGNED_SHORT},
{GL_RGBA2, GL_RGBA, GL_UNSIGNED_BYTE},
{GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
{GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1},
{GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_10_10_10_2},
{GL_RGBA12, GL_RGBA, GL_UNSIGNED_SHORT},
/* format not multiple of 32 bit wide */
{GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE},
/* compressed formats */
{GL_COMPRESSED_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
{GL_COMPRESSED_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE},
{GL_COMPRESSED_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
{GL_COMPRESSED_INTENSITY, GL_INTENSITY, GL_UNSIGNED_BYTE},
{GL_COMPRESSED_RGB, GL_RGB, GL_UNSIGNED_BYTE},
{GL_COMPRESSED_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
{GL_STENCIL_INDEX8, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE},
};
static bool
test_format(const int i)
{
printf("Testing %s... ",
piglit_get_gl_enum_name(formats[i].internal_format));
glClearBufferData(GL_ARRAY_BUFFER, formats[i].internal_format,
formats[i].format, formats[i].type, NULL);
if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
printf("Failed!\n");
return false;
}
printf("Passed.\n");
return true;
}
void
piglit_init(int argc, char **argv)
{
bool pass = true;
int i;
const int buffer_size = 3<<20;
unsigned int buffer;
piglit_require_extension("GL_ARB_clear_buffer_object");
glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, buffer_size, NULL, GL_STREAM_READ);
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
for (i = 0; i < ARRAY_SIZE(formats); ++i)
test_format(i);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &buffer);
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
enum piglit_result
piglit_display(void)
{
return PIGLIT_PASS;
}
|