In CAL scratch buffer sample, the scratch buffer size is computed in the following way:
The NUM_PS_THREADS is the amount of the threads? But actually there are (Info.Width * Info.Heigth) threads in total.
And why tHeight is 1024?
/* Calculate the dimensions of the scratch buffer */ static const CALuint R600NumQuadPipeElements = 16; static const CALuint NUM_PS_THREADS = Info.Width; static const CALuint numQdPipes = 4; static const CALuint numScratchRegsNeeded = 2; static const CALuint RoundUpBufSize = 4096; CALuint scratchRingSizeInBytes = numScratchRegsNeeded * 4 * R600NumQuadPipeElements * numQdPipes * NUM_PS_THREADS * sizeof(CALuint); scratchRingSizeInBytes = (scratchRingSizeInBytes + (RoundUpBufSize-1)) & ~(RoundUpBufSize-1); tWidth = scratchRingSizeInBytes / 1024; tHeight = 1024; flag = CAL_RESALLOC_GLOBAL_BUFFER; mComponents = Info.SrcComponents;