我無法抓取浮動紋理。紋理被定義爲如下:正在抓取CUDA紋理問題
texture<float, 2, cudaReadModeElementType> cornerTexture;
的結合和參數設置爲:
cornerTexture.addressMode[0] = cudaAddressModeClamp;
cornerTexture.addressMode[1] = cudaAddressModeClamp;
cornerTexture.filterMode = cudaFilterModePoint;
cornerTexture.normalized = false;
cudaChannelFormatDesc cornerDescription = cudaCreateChannelDesc<float>();
cudaBindTexture2D(0, &cornerTexture, cornerImage->imageData_device, &cornerDescription, cornerImage->width, cornerImage->height, cornerImage->widthStep);
height
和width
是兩個維度的尺寸中的元素的數量而言。 widthStep
用字節數表示。在內核訪問發生如下:
thisValue = tex2D(cornerTexture, thisPixel.x, thisPixel.y);
printf("thisPixel.x: %i thisPixel.y: %i thisValue: %f\n", thisPixel.x, thisPixel.y, thisValue);
thisValue
應始終是一個非負浮點數。 printf()
給了我奇怪的,無用的值,它與線性內存實際存儲的值不同。我試圖用兩個座標上的0.5f
來抵消訪問,但它給了我相同的錯誤結果。
任何想法?
更新似乎有一個隱藏的對齊要求。根據我的推論,傳遞給cudaBindTexture
函數的音調需要是32個字節的倍數。
cudaBindTexture2D(0, &debugTexture, deviceFloats, &debugDescription, 32, 10, 128)
我不知道是否:例如,下面獲取的紋理時,但以下(其寬度和高度切換在同一陣列)效果很好給出不正確的結果
cudaBindTexture2D(0, &debugTexture, deviceFloats, &debugDescription, 10, 32, 40)
我錯過了一些東西,或者球場上真的有一些限制。
更新2:我已經向Nvidia提交了一個錯誤報告。有興趣的人可以在他們的開發區查看,但我會在這裏回覆。
如果在printf中使用」%f「佔位符而非%i,則會發生什麼情況 – Mat 2011-04-25 12:12:30
廢話,你是對的,有史以來最愚蠢的錯誤... – 2011-04-25 12:18:59
其實,問題仍然存在,它仍然給我不正確的值 – 2011-04-25 12:45:08