|
@ -110,24 +110,8 @@ struct App { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct CLApp { |
|
|
int main(){ |
|
|
void initialize(){ |
|
|
App a; |
|
|
|
|
|
|
|
|
|
|
|
NSAppWrapper app; |
|
|
|
|
|
|
|
|
|
|
|
app.create_window({ |
|
|
|
|
|
[&](ContextParameters){ |
|
|
|
|
|
a.initialize(); |
|
|
|
|
|
}, |
|
|
|
|
|
[&](ContextParameters){ |
|
|
|
|
|
a.draw(); |
|
|
|
|
|
}, |
|
|
|
|
|
nullptr |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
app.run(); |
|
|
|
|
|
|
|
|
|
|
|
auto context = cl::Context::getDefault(); |
|
|
auto context = cl::Context::getDefault(); |
|
|
cout << context << endl; |
|
|
cout << context << endl; |
|
|
|
|
|
|
|
@ -146,8 +130,8 @@ int main(){ |
|
|
cl::CommandQueue queue(context, context.getInfo<CL_CONTEXT_DEVICES>().front()); |
|
|
cl::CommandQueue queue(context, context.getInfo<CL_CONTEXT_DEVICES>().front()); |
|
|
|
|
|
|
|
|
// make a lot of data
|
|
|
// make a lot of data
|
|
|
constexpr size_t W = 1280 * 4; |
|
|
constexpr size_t W = 1280 * 1; |
|
|
constexpr size_t H = 800 * 4; |
|
|
constexpr size_t H = 800 * 1; |
|
|
std::vector<cl_float> input_vector(W*H); |
|
|
std::vector<cl_float> input_vector(W*H); |
|
|
|
|
|
|
|
|
for(int y = 0; y < H; ++y){ |
|
|
for(int y = 0; y < H; ++y){ |
|
@ -159,7 +143,7 @@ int main(){ |
|
|
// transfer data into buffers
|
|
|
// transfer data into buffers
|
|
|
cl::Buffer input(context, input_vector.begin(), input_vector.end(), false, true); |
|
|
cl::Buffer input(context, input_vector.begin(), input_vector.end(), false, true); |
|
|
|
|
|
|
|
|
int r = 80, g = 40, b = 20; |
|
|
int r = 20, g = 20, b = 20; |
|
|
|
|
|
|
|
|
// DO IT (in place)
|
|
|
// DO IT (in place)
|
|
|
for(int i = 0; i < r; ++i){ |
|
|
for(int i = 0; i < r; ++i){ |
|
@ -198,6 +182,28 @@ int main(){ |
|
|
image << png::ostream<>::pixel(blue[i], red[i], green[i]); |
|
|
image << png::ostream<>::pixel(blue[i], red[i], green[i]); |
|
|
} |
|
|
} |
|
|
cout << "png is saved" << endl; |
|
|
cout << "png is saved" << endl; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main() { |
|
|
|
|
|
App a; |
|
|
|
|
|
CLApp b; |
|
|
|
|
|
|
|
|
|
|
|
NSAppWrapper app; |
|
|
|
|
|
|
|
|
|
|
|
app.create_window({ |
|
|
|
|
|
[&](ContextParameters){ |
|
|
|
|
|
a.initialize(); |
|
|
|
|
|
b.initialize(); |
|
|
|
|
|
}, |
|
|
|
|
|
[&](ContextParameters){ |
|
|
|
|
|
a.draw(); |
|
|
|
|
|
}, |
|
|
|
|
|
nullptr |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
app.run(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|