Closed dancsi closed 12 years ago
Could you please add the line
print source
at this position (line 17)? Then we can see what the source that is compiled actually looks like.
Also, how can you run this with Python 3.2 when it uses 2.7 syntax? Did you run 2to3?
Yep, I ran 2to3, and made some manual corrections (changed some floats to ints, because the opencl complained about the function signatures). I have already done this and I believe that the source is fine (only the 2 template variables replaced), but I will post it anyway, in a couple of minutes
I also tested it with the gp4vp profile and it worked fine here. Did you try running the original version with Python2?
In the meantime, you can also use python main.py --disable-advanced-rendering 8000
. The rendering will look bad, but the simulation will run.
Here is the source:
static const float sigma = 5;
static const float radius = 20;
sampler2D texSampler : TEXUNIT0 = sampler_state {
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = clamp;
AddressV = clamp;
};
void passVertex(float4 pos : POSITION, float2 tex : TEXCOORD0, out float4 outPos : POSITION, out float2 outTex: TEXCOORD0) {
outPos = pos;
outTex = tex;
}
float blurFragment(float2 uv : TEXCOORD0, uniform float2 direction, uniform float2 texelSize) : COLOR {
float sum = 0;
float wsum = 0;
for(int r = -radius; r <= radius; r+=1) {
float sample = tex2D(texSampler, uv + (float)r*direction*texelSize).x;
float v = (float)r/sigma;
float w = exp(-v*v/2.);
sum += sample * w;
wsum += w;
}
if(wsum > 0.) {
sum /= wsum;
}
return sum;
}
No, I didn't try it with python2 yet, but will try it in a few moments. I can upload my fork, so you can try with python3. EDIT: Here is my fork
Unfortunately, I can't run using Python3 because I can't manage to install pyopencl with this version. However, if I run your code with python2, there is no error.
Once this is resolved, it would be cool if you could send me a pull request for the python3 conversion. Then it will be compatible with both python2 and python3.
That's great :) Now I'm debugging lines 163 and 164 in cg/cg_shader.py . They both seem to produce the same error.
Ok, fixed this one in my fork. The problem was in the fact that entrypoint and code strings were of type str
, so I casted all of the first to byte
arrays, and then to c_char_p
s
Cool, so it was a 2to3 issue after all. Thanks.
Just to let you know, I finally got around to making pysph Python 3 compatible.
Yay, that is great :)
The program fails compiling blur.cg, saying that there is a syntax error
When I try to compile it with cgc version 3.1.0013, it compiles without an error, and gives
I'm using a NVIDIA GeForce 9600 GT, on Windows 8 Release Preview x64, with the latest 302.8 drivers. The python (version 3.2) and all the libraries are 64bit.