Cuda中的纹理坐标
我正在研究使用cuda实现DCT: 有关部分如下:Cuda中的纹理坐标,c,cuda,coordinates,textures,C,Cuda,Coordinates,Textures,我正在研究使用cuda实现DCT: 有关部分如下: __shared__ float CurBlockLocal1[BLOCK_SIZE2]; __global__ void CUDAkernel1DCT(float *Dst, int ImgWidth, int OffsetXBlocks, int OffsetYBlocks) { // Block index const int bx = blockIdx.x + OffsetXBlocks; const int
__shared__ float CurBlockLocal1[BLOCK_SIZE2];
__global__ void CUDAkernel1DCT(float *Dst, int ImgWidth, int OffsetXBlocks, int OffsetYBlocks)
{
// Block index
const int bx = blockIdx.x + OffsetXBlocks;
const int by = blockIdx.y + OffsetYBlocks;
// Thread index (current coefficient)
const int tx = threadIdx.x;
const int ty = threadIdx.y;
// Texture coordinates
const float tex_x = (float)( (bx << BLOCK_SIZE_LOG2) + tx ) + 0.5f;
const float tex_y = (float)( (by << BLOCK_SIZE_LOG2) + ty ) + 0.5f;
//copy current image pixel to the first block
CurBlockLocal1[ (ty << BLOCK_SIZE_LOG2) + tx ] = tex2D(TexSrc, tex_x, tex_y);
//synchronize threads to make sure the block is copied
__syncthreads();
\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
__全局无效CUDAkernel1DCT(浮点*Dst、整数ImgWidth、整数offsetXblock、整数offsetBlocks)
{
//块索引
const int bx=blockIdx.x+offsetxblock;
const int by=blockIdx.y+OffsetYBlocks;
//螺纹指数(电流系数)
const int tx=threadIdx.x;
const int ty=threadIdx.y;
//纹理坐标
const float tex_x=(float)((bx按相反顺序回答您的问题:
如标准C或C++,以相反的顺序回答你的问题:
如标准C或C++中的
__shared__ float CurBlockLocal1[BLOCK_SIZE2];
__global__ void CUDAkernel1DCT(float *Dst, int ImgWidth, int OffsetXBlocks, int OffsetYBlocks)
{
// Block index
const int bx = blockIdx.x + OffsetXBlocks;
const int by = blockIdx.y + OffsetYBlocks;
// Thread index (current coefficient)
const int tx = threadIdx.x;
const int ty = threadIdx.y;
// Texture coordinates
const float tex_x = (float)( (bx * BLOCK_SIZE) + tx ) + 0.5f;
const float tex_y = (float)( (by * BLOCK_SIZE) + ty ) + 0.5f;
//copy current image pixel to the first block
CurBlockLocal1[ (ty * BLOCK_SIZE) + tx ] = tex2D(TexSrc, tex_x, tex_y);
......
}