Tests the OpenCL part again
This commit is contained in:
parent
dfb1e7aebf
commit
9cf9887a09
1 changed files with 78 additions and 72 deletions
48
src/main.cpp
48
src/main.cpp
|
@ -110,24 +110,8 @@ struct App {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
App a;
|
||||
|
||||
NSAppWrapper app;
|
||||
|
||||
app.create_window({
|
||||
[&](ContextParameters){
|
||||
a.initialize();
|
||||
},
|
||||
[&](ContextParameters){
|
||||
a.draw();
|
||||
},
|
||||
nullptr
|
||||
});
|
||||
|
||||
app.run();
|
||||
|
||||
struct CLApp {
|
||||
void initialize(){
|
||||
auto context = cl::Context::getDefault();
|
||||
cout << context << endl;
|
||||
|
||||
|
@ -146,8 +130,8 @@ int main(){
|
|||
cl::CommandQueue queue(context, context.getInfo<CL_CONTEXT_DEVICES>().front());
|
||||
|
||||
// make a lot of data
|
||||
constexpr size_t W = 1280 * 4;
|
||||
constexpr size_t H = 800 * 4;
|
||||
constexpr size_t W = 1280 * 1;
|
||||
constexpr size_t H = 800 * 1;
|
||||
std::vector<cl_float> input_vector(W*H);
|
||||
|
||||
for(int y = 0; y < H; ++y){
|
||||
|
@ -159,7 +143,7 @@ int main(){
|
|||
// transfer data into buffers
|
||||
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)
|
||||
for(int i = 0; i < r; ++i){
|
||||
|
@ -198,6 +182,28 @@ int main(){
|
|||
image << png::ostream<>::pixel(blue[i], red[i], green[i]);
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue