void piglit_init(int argc, char **argv) { bool blit_to_fbo; if (argc != 2) print_usage_and_exit(argv[0]); if (strcmp(argv[1], "window") == 0) blit_to_fbo = false; else if (strcmp(argv[1], "fbo") == 0) blit_to_fbo = true; else { blit_to_fbo = false; print_usage_and_exit(argv[0]); } piglit_require_extension("GL_ARB_framebuffer_object"); src_fbo = setup_framebuffer(); ref_fbo = setup_framebuffer(); if (blit_to_fbo) dst_fbo = setup_framebuffer(); else dst_fbo = 0; }
void GLCpuPosInstancedArraysBench::setup(const GrGLContext* ctx) { const GrGLInterface* gl = ctx->interface(); setup_framebuffer(gl, kScreenWidth, kScreenHeight); fProgram = compile_shader(ctx); // setup matrices int index = 0; SkMatrix viewMatrices[kNumTri]; setup_matrices(kNumTri, [&index, &viewMatrices](const SkMatrix& m) { viewMatrices[index++] = m; }); // setup VAO GR_GL_CALL(gl, GenVertexArrays(1, &fVAO)); GR_GL_CALL(gl, BindVertexArray(fVAO)); switch (fVboSetup) { case kUseOne_VboSetup: this->setupSingleVbo(gl, viewMatrices); break; case kUseTwo_VboSetup: this->setupDoubleVbo(gl, viewMatrices); break; case kUseInstance_VboSetup: this->setupInstanceVbo(gl, viewMatrices); break; } // clear screen GR_GL_CALL(gl, ClearColor(0.03f, 0.03f, 0.03f, 1.0f)); GR_GL_CALL(gl, Clear(GR_GL_COLOR_BUFFER_BIT)); // set us up to draw GR_GL_CALL(gl, UseProgram(fProgram)); GR_GL_CALL(gl, BindVertexArray(fVAO)); }
void GLGpuPosInstancedArraysBench::setup(const GrGLInterface* gl) { setup_framebuffer(gl, kScreenWidth, kScreenHeight); // compile and use shaders GrGLint shaderProgram = compile_shader(gl, gpu_vertex_shader, fragment_shader); // translations int index = 0; GrGLfloat viewMatrices[fNumQuads * fSkMatrixNumCells]; setup_matrices(fNumQuads, [&index, &viewMatrices](const SkMatrix& m) { GrGLGetMatrix<3>(&viewMatrices[index], m); index += fSkMatrixNumCells; }); // Constants for our various shader programs GrGLfloat quad_vertices[] = { // Positions // Colors -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f }; // update vertex data GrGLuint quadVAO, quadVBO; GR_GL_CALL(gl, GenVertexArrays(1, &quadVAO)); GR_GL_CALL(gl, GenBuffers(1, &quadVBO)); GR_GL_CALL(gl, BindVertexArray(quadVAO)); GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, quadVBO)); GR_GL_CALL(gl, EnableVertexAttribArray(0)); GR_GL_CALL(gl, VertexAttribPointer(0, 2, GR_GL_FLOAT, GR_GL_FALSE, 5 * sizeof(GrGLfloat), (GrGLvoid*)0)); GR_GL_CALL(gl, EnableVertexAttribArray(1)); GR_GL_CALL(gl, VertexAttribPointer(1, 3, GR_GL_FLOAT, GR_GL_FALSE, 5 * sizeof(GrGLfloat), (GrGLvoid*)(2 * sizeof(GrGLfloat)))); GR_GL_CALL(gl, BufferData(GR_GL_ARRAY_BUFFER, sizeof(quad_vertices), quad_vertices, GR_GL_STATIC_DRAW)); // Also set instance data GrGLuint instanceVBO; GR_GL_CALL(gl, GenBuffers(1, &instanceVBO)); GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, instanceVBO)); GR_GL_CALL(gl, BufferData(GR_GL_ARRAY_BUFFER, sizeof(GrGLfloat) * fSkMatrixNumCells * fNumQuads, &viewMatrices[0], GR_GL_STATIC_DRAW)); GR_GL_CALL(gl, EnableVertexAttribArray(2)); GR_GL_CALL(gl, EnableVertexAttribArray(3)); GR_GL_CALL(gl, EnableVertexAttribArray(4)); GR_GL_CALL(gl, VertexAttribPointer(2, 3, GR_GL_FLOAT, GR_GL_FALSE, 9 * sizeof(GrGLfloat), (GrGLvoid*)0)); GR_GL_CALL(gl, VertexAttribPointer(3, 3, GR_GL_FLOAT, GR_GL_FALSE, 9 * sizeof(GrGLfloat), (GrGLvoid*)(3 * sizeof(GrGLfloat)))); GR_GL_CALL(gl, VertexAttribPointer(4, 3, GR_GL_FLOAT, GR_GL_FALSE, 9 * sizeof(GrGLfloat), (GrGLvoid*)(6 * sizeof(GrGLfloat)))); GR_GL_CALL(gl, VertexAttribDivisor(2, 1)); GR_GL_CALL(gl, VertexAttribDivisor(3, 1)); GR_GL_CALL(gl, VertexAttribDivisor(4, 1)); // draw GR_GL_CALL(gl, ClearColor(0.03f, 0.03f, 0.03f, 1.0f)); GR_GL_CALL(gl, Clear(GR_GL_COLOR_BUFFER_BIT)); // set us up to draw GR_GL_CALL(gl, UseProgram(shaderProgram)); GR_GL_CALL(gl, BindVertexArray(quadVAO)); }
int main(int argc, char *argv[]) { int count = -1; int quiet = 0; struct decode_data decode_inst1, decode_inst2; pthread_t tid1, tid2; void *fb_buffer; int fb_fd; argv0 = argv[0]; /* parse arguments */ while (1) { int c, option_index = 0; static struct option long_options[] = { {"help", 0, 0, 'h'}, {"quiet", 0, 0, 'q'}, {"count", 1, 0, 'c'}, {0, 0, 0, 0} }; if ((c = getopt_long(argc, argv, "hc:q", long_options, &option_index)) == -1) break; switch(c) { case 'h': // help print_usage(); return 0; case 'c': count = strtol(optarg, NULL, 0); break; case 'q': quiet = 1; break; default: fprintf(stderr, "unknown option 0%x.\n", c); print_usage(); return 1; } } if (optind > argc) { print_usage(); return 1; } setup_framebuffer("/dev/fb0", &fb_fd, &fb_buffer); decode_inst1.fb_buffer = fb_buffer; decode_inst1.pattern = 0; decode_inst1.count = count; decode_inst2.fb_buffer = fb_buffer + fb_info.line_length / 2; decode_inst2.pattern = 1; decode_inst2.count = count; pthread_create(&tid1, NULL, decode_thread, &decode_inst1); pthread_create(&tid2, NULL, decode_thread, &decode_inst2); pthread_join(tid1, NULL); pthread_join(tid2, NULL); printf("done!\n"); return 0; }