ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_direct_state_access / create-programpipelines.c
blob90e15880aca444b6e4e73a4eebf30add84960fcf
1 /*
2 * Copyright 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 /** @file create-programpipelines.c
26 * Tests glCreateProgramPipelines to see if it behaves in the expected way,
27 * throwing the correct errors, etc.
29 * From OpenGL 4.5, section 7.4 "Program Pipeline Objects", page 116:
31 * "void CreateProgramPipelines( sizei n, uint *pipelines );
33 * CreateProgramPipelinesreturns n previously unused program pipeline names
34 * in pipelines, each representing a new program pipeline object which is a
35 * state vector comprising all the state and with the same initial values
36 * listed in table 23.31.
38 * Errors
39 * An INVALID_VALUE error is generated if n is negative."
42 #include "piglit-util-gl.h"
43 #include "dsa-utils.h"
45 PIGLIT_GL_TEST_CONFIG_BEGIN
47 config.supports_gl_core_version = 31;
49 config.window_visual = PIGLIT_GL_VISUAL_RGBA |
50 PIGLIT_GL_VISUAL_DOUBLE;
51 config.khr_no_error_support = PIGLIT_NO_ERRORS;
53 PIGLIT_GL_TEST_CONFIG_END
55 void
56 piglit_init(int argc, char **argv)
58 piglit_require_extension("GL_ARB_direct_state_access");
59 piglit_require_extension("GL_ARB_separate_shader_objects");
62 enum piglit_result
63 piglit_display(void)
65 bool pass = true;
66 GLchar label[11];
67 GLsizei length;
68 GLuint ids[10];
69 GLint param;
71 /* Throw some invalid inputs at glCreateProgramPipelines */
72 if (!piglit_khr_no_error) {
73 /* n is negative */
74 glCreateProgramPipelines(-1, ids);
75 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE, pass, "n < 0");
78 /* Throw some valid inputs at glCreateProgramPipelines. */
80 /* n is zero */
81 glCreateProgramPipelines(0, NULL);
82 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR, pass, "n == 0");
84 /* n is more than 1 */
85 glCreateProgramPipelines(10, ids);
86 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR, pass, "n > 1");
88 /* test the default state of dsa-created program pipeline objects */
89 PIGLIT_SUBTEST_CONDITION(glIsProgramPipeline(ids[2]), pass,
90 "IsProgramPipeline()");
92 glGetProgramPipelineiv(ids[2], GL_ACTIVE_PROGRAM, &param);
93 piglit_check_gl_error(GL_NO_ERROR);
94 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
95 "default active program(%d) == 0", param);
97 glGetProgramPipelineiv(ids[2], GL_VERTEX_SHADER, &param);
98 piglit_check_gl_error(GL_NO_ERROR);
99 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
100 "default vertex shader program(%d) == 0", param);
102 glGetProgramPipelineiv(ids[2], GL_GEOMETRY_SHADER, &param);
103 piglit_check_gl_error(GL_NO_ERROR);
104 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
105 "default geometry shader program(%d) == 0", param);
107 glGetProgramPipelineiv(ids[2], GL_FRAGMENT_SHADER, &param);
108 piglit_check_gl_error(GL_NO_ERROR);
109 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
110 "default fragment shader program(%d) == 0", param);
112 if (piglit_is_extension_supported("GL_ARB_compute_shader")) {
113 glGetProgramPipelineiv(ids[2], GL_COMPUTE_SHADER, &param);
114 piglit_check_gl_error(GL_NO_ERROR);
115 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
116 "default compute shader program(%d) == 0",
117 param);
118 } else {
119 piglit_report_subtest_result(PIGLIT_SKIP,
120 "default compute shader program == 0");
123 if (piglit_is_extension_supported("GL_ARB_tessellation_shader")) {
124 glGetProgramPipelineiv(ids[2], GL_TESS_CONTROL_SHADER, &param);
125 piglit_check_gl_error(GL_NO_ERROR);
126 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
127 "default TCS(%d) == 0", param);
129 glGetProgramPipelineiv(ids[2], GL_TESS_EVALUATION_SHADER,
130 &param);
131 piglit_check_gl_error(GL_NO_ERROR);
132 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
133 "default TES(%d) == 0", param);
134 } else {
135 piglit_report_subtest_result(PIGLIT_SKIP,
136 "default TCS == 0");
138 piglit_report_subtest_result(PIGLIT_SKIP,
139 "default TES == 0");
142 glGetProgramPipelineiv(ids[2], GL_VALIDATE_STATUS, &param);
143 piglit_check_gl_error(GL_NO_ERROR);
144 PIGLIT_SUBTEST_CONDITION(param == GL_FALSE, pass,
145 "default validate status(%d) == FALSE", param);
147 glGetProgramPipelineiv(ids[2], GL_INFO_LOG_LENGTH, &param);
148 piglit_check_gl_error(GL_NO_ERROR);
149 PIGLIT_SUBTEST_CONDITION(param == 0, pass,
150 "startup log length(%d) == 0", param);
152 glGetObjectLabel(GL_PROGRAM_PIPELINE, ids[2], 11, &length, label);
153 piglit_check_gl_error(GL_NO_ERROR);
154 PIGLIT_SUBTEST_CONDITION(length == 0, pass,
155 "default label size(%d) == 0", length);
157 glDeleteProgramPipelines(10, ids);
159 return pass ? PIGLIT_PASS : PIGLIT_FAIL;