static bool probe_buffers(const GLuint *xfb, const GLuint *queries, unsigned primitive_n) { bool pass; unsigned i; GLuint query_result; float *first; float *second; const unsigned first_n = primitive_n * BUF_1_FLOAT_N; const unsigned second_n = primitive_n * BUF_2_FLOAT_N; glGetQueryObjectuiv(queries[0], GL_QUERY_RESULT, &query_result); if (query_result != primitive_n) { printf("Expected %u primitives written, got %u\n", primitive_n, query_result); piglit_report_result(PIGLIT_FAIL); } glGetQueryObjectuiv(queries[1], GL_QUERY_RESULT, &query_result); if (query_result != primitive_n) { printf("Expected %u primitives generated, got %u\n", primitive_n, query_result); piglit_report_result(PIGLIT_FAIL); } first = malloc(first_n * sizeof(float)); second = malloc(second_n * sizeof(float)); for (i = 0; i < primitive_n; ++i) { first[i * BUF_1_FLOAT_N + 0] = i + 1.0; /* x1 */ first[i * BUF_1_FLOAT_N + 1] = i + 2.0; /* x2[0] */ first[i * BUF_1_FLOAT_N + 2] = i + 3.0; /* x2[1] */ first[i * BUF_1_FLOAT_N + 3] = i + 4.0; /* x3[0] */ first[i * BUF_1_FLOAT_N + 4] = i + 5.0; /* x3[1] */ first[i * BUF_1_FLOAT_N + 5] = i + 6.0; /* x3[2] */ second[i * BUF_2_FLOAT_N + 0] = i + 7.0; /* y1 */ second[i * BUF_2_FLOAT_N + 1] = i + 8.0; /* y2[0] */ second[i * BUF_2_FLOAT_N + 2] = i + 9.0; /* y2[1] */ second[i * BUF_2_FLOAT_N + 3] = i + 10.0; /* y2[2] */ second[i * BUF_2_FLOAT_N + 4] = i + 11.0; /* y2u3] */ } pass = piglit_probe_buffer(xfb[0], GL_TRANSFORM_FEEDBACK_BUFFER, "first", 1, first_n, first); pass = piglit_probe_buffer(xfb[1], GL_TRANSFORM_FEEDBACK_BUFFER, "second", 1, second_n, second) && pass; free(first); free(second); return pass; }
static bool probe_buffers(const GLuint *xfb, const GLuint *queries, unsigned primitive_n) { bool pass; unsigned i; GLuint query_result; float *expected[STREAMS]; int expected_n[STREAMS]; for (i = 0; i < STREAMS; i++) { expected_n[i] = stream_float_counts[i] * primitive_n; } for (i = 0; i < STREAMS; i++) { glGetQueryObjectuiv(queries[i], GL_QUERY_RESULT, &query_result); if (query_result != primitive_n) { printf("Expected %u primitives generated, got %u\n", primitive_n, query_result); piglit_report_result(PIGLIT_FAIL); } glGetQueryObjectuiv(queries[STREAMS+i], GL_QUERY_RESULT, &query_result); if (query_result != primitive_n) { printf("Expected %u TF primitives written, got %u\n", primitive_n, query_result); piglit_report_result(PIGLIT_FAIL); } } for (i = 0; i < STREAMS; i++) { expected[i] = malloc(expected_n[i] * sizeof(float)); } for (i = 0; i < primitive_n; ++i) { expected[0][i * stream_float_counts[0] + 0] = i + 1.0; /* stream0_0 */ expected[1][i * stream_float_counts[1] + 0] = i + 2.0; /* stream1_0[0] */ expected[1][i * stream_float_counts[1] + 1] = i + 3.0; /* stream1_0[1] */ expected[1][i * stream_float_counts[1] + 2] = i + 4.0; /* stream1_1[0] */ expected[1][i * stream_float_counts[1] + 3] = i + 5.0; /* stream1_1[1] */ expected[1][i * stream_float_counts[1] + 4] = i + 6.0; /* stream1_1[2] */ expected[2][i * stream_float_counts[2] + 0] = i + 7.0; /* stream2_0 */ expected[2][i * stream_float_counts[2] + 1] = i + 8.0; /* stream2_1[0] */ expected[2][i * stream_float_counts[2] + 2] = i + 9.0; /* stream2_1[1] */ expected[2][i * stream_float_counts[2] + 3] = i + 10.0; /* stream2_1[2] */ expected[2][i * stream_float_counts[2] + 4] = i + 11.0; /* stream2_1[3] */ expected[3][i * stream_float_counts[3] + 0] = i + 12.0; /* stream3_0[0] */ expected[3][i * stream_float_counts[3] + 1] = i + 13.0; /* stream3_0[1] */ expected[3][i * stream_float_counts[3] + 2] = i + 14.0; /* stream3_0[2] */ } for (i = 0; i < STREAMS; ++i) { char *name; asprintf(&name, "stream%d", i); pass = piglit_probe_buffer(xfb[i], GL_TRANSFORM_FEEDBACK_BUFFER, name, 1, expected_n[i], expected[i]); free(name); } for (i = 0; i < STREAMS; i++) { free(expected[i]); } return pass; }
void piglit_init(int argc, char **argv) { enum piglit_result result = PIGLIT_PASS; GLuint data_bo = 0; GLfloat *data_buf; GLint ok = 1; GLint prog = 0; GLuint shader; const float one = 1.0f; piglit_require_extension("GL_ARB_compute_shader"); piglit_require_extension("GL_INTEL_blackhole_render"); data_buf = calloc(SIZE_X, sizeof(*data_buf)); glGenBuffers(1, &data_bo); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, data_bo); glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(float) * SIZE_X, data_buf, GL_STATIC_DRAW); free(data_buf); shader = glCreateShader(GL_COMPUTE_SHADER); glShaderSource(shader, 1, (const GLchar **) &compute_shader, NULL); glCompileShader(shader); glGetShaderiv(shader, GL_COMPILE_STATUS, &ok); assert(ok); prog = glCreateProgram(); glAttachShader(prog, shader); glLinkProgram(prog); glGetProgramiv(prog, GL_LINK_STATUS, &ok); assert(ok); glUseProgram(prog); assert(!glIsEnabled(GL_BLACKHOLE_RENDER_INTEL)); glMemoryBarrier(GL_ALL_BARRIER_BITS); glUniform1f(glGetUniformLocation(prog, "value"), 1.0f); glDispatchCompute(SIZE_X, 1, 1); glMemoryBarrier(GL_ALL_BARRIER_BITS); if (!piglit_probe_buffer(data_bo, GL_SHADER_STORAGE_BUFFER, "output_values", SIZE_X, 1, &one)) result = PIGLIT_FAIL; glEnable(GL_BLACKHOLE_RENDER_INTEL); assert(glIsEnabled(GL_BLACKHOLE_RENDER_INTEL)); glMemoryBarrier(GL_ALL_BARRIER_BITS); glUniform1f(glGetUniformLocation(prog, "value"), 2.0f); glDispatchCompute(SIZE_X, 1, 1); glMemoryBarrier(GL_ALL_BARRIER_BITS); if (!piglit_probe_buffer(data_bo, GL_SHADER_STORAGE_BUFFER, "output_values", SIZE_X, 1, &one)) result = PIGLIT_FAIL; piglit_report_result(result); }