I am trying to write a gaussian filter with Brahma with the DirectX provider, but I get a "The generated HLSL was invalid." exception. Has anyone written anything similar? Could you tell me if my approach is ok? The code I have written so far is :
var provider = new ComputationProvider();
var data = new DataParallelArray2D<float>(provider, src.Height, src.Width, (x, y) => (float)src[x, y]);
PerformanceTimer.Start();
CompiledQuery sums = provider.Compile<DataParallelArray2D<float>>(
d => from value in d
let wlTemp = output.CurrentX - currentOffset
let htTemp = output.CurrentY - currentOffset
let wrTemp = output.CurrentX + currentOffset
let hbTemp = output.CurrentY + currentOffset
let wl = (wlTemp < 0) ? 0 : wlTemp
let ht = (htTemp < 0) ? 0 : htTemp
let wr = (wrTemp >= d.Width) ? d.Width : wrTemp
let hb = (hbTemp >= d.Height) ? d.Height : hbTemp
select value +
(d[output.CurrentX, ht] * currentKernelValue) +
(d[output.CurrentX, hb] * currentKernelValue) +
(d[ht, output.CurrentY] * currentKernelValue) +
(d[hb, output.CurrentY] * currentKernelValue)
);
var dataSize = new int[] { src.Width, src.Height };
DataParallelArray2D<float> currentData = data;
for (int i = 0; i < offset; i++)
{
currentOffset = i;
currentKernelValue = (float)kernel[currentOffset + offset];
var tempData = provider.Run(sums, currentData, dataSize);
currentData.Dispose();
currentData = (DataParallelArray2D<float>)tempData;
}
CompiledQuery divide = provider.Compile<DataParallelArray2D<float>>(
d => from value in d
select value / kernelSum
);
var result = provider.Run(divide, currentData, dataSize);
Note that the first query is the one that throws the exception when compiled.