- 573 名前:536 mailto:sage [2007/04/23(月) 18:28:24 ]
- あー、載せるの忘れてた。CPU版のソースはこんな感じ。これをGPUのサンプルのtransform()と入れ替えて辻褄合わせた。
#でも、CUDAではgetData()相当で単純に整数化しないでニアレストネイバーか何かでサンプリングしているのでその分更に差が開く…… static float getData(float * data, float x, float y, int width, int height) { int ix = static_cast<int>((x + 1) * width + 0.5f); int iy = static_cast<int>((y + 1) * height + 0.5f); ix %= width; iy %= height; return data[iy * width + ix]; } void transform(float * rdata, float* g_odata, int width, int height, float theta) { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { float u = x / (float) width; float v = y / (float) height; u -= 0.5f; v -= 0.5f; float tu = u*cosf(theta) - v*sinf(theta) + 0.5f; float tv = v*cosf(theta) + u*sinf(theta) + 0.5f; rdata[y*width + x] = getData(g_odata, tu, tv, width, height); } } } このコード、Celeron1.2GHzでは109msだった。
|

|