#include "nvlib.h" #include using namespace std; int main(int argc, char** argv) { unique_ptr dev(nv_device::open_default()); unique_ptr runner(new nv_gl_process(&*dev)); int channel = nv_find_idle_channel(&*dev); if(channel < 0) throw runtime_error("Unable to find idle channel for GL process.\n"); std::shared_ptr hwchan(dev->hwchannel(channel)); unique_ptr chan(new nv_channel_vram(hwchan)); //unique_ptr chan(new nv_channel_parasite(hwchan, &*runner)); cerr << "Channel " << hwchan->channel << endl; unsigned grclasses[8]; hwchan->get_grclasses(grclasses); // for(unsigned i = 0; i < 8; ++i) // cout << grclasses[i] << endl; vector > commands; ifstream fin; istream& in = argc >= 2 ? fin : cin; if(argc >= 2) fin.open(argv[1]); for(;;) { unsigned grclass, method, value; unsigned subc; in >> grclass >> method >> value; if(!in.good()) break; for(subc = 0; subc < 8; ++subc) { if(!((grclass ^ grclasses[subc]) & 0xff)) break; } if(subc == 8) { cerr << "Unable to find subchannel for grclass " << grclass << endl; return 1; } //cout << subc << ' ' << method << ' ' << value << endl; commands.push_back(make_pair(RING(subc, method, 1), value)); } for(unsigned i = 0; i < commands.size(); ++i) { chan->wait(2); chan->out(commands[i].first); chan->out(commands[i].second); } os->trace_marker("nvexec: before fire"); chan->fire(); chan->wait_idle(); return 0; }