GLuint build_program(const char* src_vert, const char* src_frag) { GLuint h_vert = compile_shader(GL_VERTEX_SHADER, src_vert); if(!h_vert) { std::cerr << "Error while compiling the vertex shader" << std::endl; return 0; } GLuint h_frag = compile_shader(GL_FRAGMENT_SHADER, src_frag); if(!h_frag) { std::cerr << "Error wihle compiling the fragment shader" << std::endl; return 0; } GLuint h_prog = glCreateProgram(); if(!h_prog) { std::cerr << "Program object creation failed." << std::endl; return h_prog; } glAttachShader( h_prog, h_vert ); glAttachShader( h_prog, h_frag ); glLinkProgram( h_prog ); if(!check_link_status(h_prog)) return 0; return h_prog; }
/** @brief forbid CP from going to sleep Wakes up a CP if it can sleep and increases the "ref_cnt" counter in the mem_link_device instance. @param mld the pointer to a mem_link_device instance @remark CAUTION!!! permit_cp_sleep() MUST be invoked after forbid_cp_sleep() success to decrease the "ref_cnt" counter. */ static void forbid_cp_sleep(struct mem_link_device *mld) { struct link_device *ld = &mld->link_dev; int ap_status = gpio_get_value(mld->gpio_ap_status); int cp_wakeup = gpio_get_value(mld->gpio_cp_wakeup); unsigned long flags; spin_lock_irqsave(&mld->pm_lock, flags); atomic_inc(&mld->ref_cnt); gpio_set_value(mld->gpio_ap_status, 1); gpio_set_value(mld->gpio_cp_wakeup, 1); if (work_pending(&mld->cp_sleep_dwork.work)) cancel_delayed_work(&mld->cp_sleep_dwork); spin_unlock_irqrestore(&mld->pm_lock, flags); if (!ap_status || !cp_wakeup) print_pm_status(mld); if (check_link_status(mld) < 0) { print_pm_status(mld); mif_err("%s: ERR! check_link_status fail\n", ld->name); mem_forced_cp_crash(mld); } }
GLuint ShaderAPITest::make_program(const char *vs_src, const char *fs_src) { GLuint id, vs, fs; assert_no_error(); id = glCreateProgram(); if (vs_src) { vs = make_shader(GL_VERTEX_SHADER, vs_src); glAttachShader(id, vs); glDeleteShader(vs); } if (fs_src) { fs = make_shader(GL_FRAGMENT_SHADER, fs_src); glAttachShader(id, fs); glDeleteShader(fs); } glLinkProgram(id); check_link_status(id); glUseProgram(id); glDeleteProgram(id); assert_no_error(); return id; }