diff options
Diffstat (limited to 'template')
-rw-r--r-- | template/kernel.mako | 2 | ||||
-rw-r--r-- | template/opengl.mako | 28 | ||||
-rw-r--r-- | template/particles.mako | 10 | ||||
-rw-r--r-- | template/sdf.cl.mako | 4 | ||||
-rw-r--r-- | template/streamline.mako | 10 |
5 files changed, 25 insertions, 29 deletions
diff --git a/template/kernel.mako b/template/kernel.mako index dd8eaee..2e26124 100644 --- a/template/kernel.mako +++ b/template/kernel.mako @@ -105,4 +105,4 @@ __kernel void collect_moments(__global ${float_type}* f, % for i, expr in enumerate(moments_assignment): moments[${pop_offset(i)} + gid] = ${ccode(expr.rhs)}; % endfor -} +}
\ No newline at end of file diff --git a/template/opengl.mako b/template/opengl.mako index 47264e8..daf5f66 100644 --- a/template/opengl.mako +++ b/template/opengl.mako @@ -13,11 +13,22 @@ def moments_cell(): 2: '(int2)(get_global_id(0), get_global_id(1))', 3: '(int4)(get_global_id(0), get_global_id(1), get_global_id(2), 0)' }.get(descriptor.d) + +def neighbor_offset(c_i): + return { + 2: lambda: c_i[1]*memory.size_x + c_i[0], + 3: lambda: c_i[2]*memory.size_x*memory.size_y + c_i[1]*memory.size_x + c_i[0] + }.get(descriptor.d)() + %> -__kernel void collect_gl_moments(__global ${float_type}* f, - __global int* material, - __global float4* moments) +__kernel void collect_gl_moments_and_materials_to_texture(__global ${float_type}* f, + __global int* material, +% if descriptor.d == 2: + __write_only image2d_t moments) +% elif descriptor.d == 3: + __write_only image3d_t moments) +% endif { const unsigned int gid = ${gid()}; @@ -52,18 +63,9 @@ __kernel void collect_gl_moments(__global ${float_type}* f, data.w = -material[gid]; } - moments[gid] = data; + write_imagef(moments, ${moments_cell()}, data); } -<% -def neighbor_offset(c_i): - return { - 2: lambda: c_i[1]*memory.size_x + c_i[0], - 3: lambda: c_i[2]*memory.size_x*memory.size_y + c_i[1]*memory.size_x + c_i[0] - }.get(descriptor.d)() - -%> - __kernel void collect_gl_moments_to_texture(__global ${float_type}* f, % if descriptor.d == 2: __write_only image2d_t moments) diff --git a/template/particles.mako b/template/particles.mako index 48191d9..0b9a67e 100644 --- a/template/particles.mako +++ b/template/particles.mako @@ -1,4 +1,4 @@ -__kernel void update_particles(__global float4* moments, +__kernel void update_particles(__global float* moments, __global int* material, __global float4* particles, __global float4* init_particles, @@ -14,13 +14,11 @@ __kernel void update_particles(__global float4* moments, const unsigned int gid = floor(particle.z)*${memory.size_x*memory.size_y} + floor(particle.y)*${memory.size_x} + floor(particle.x); % endif - const float4 moment = moments[gid]; - if (material[gid] == 1 && particle.w < 1.0) { - particle.x += moment.y; - particle.y += moment.z; + particle.x += moments[${1*memory.volume}+gid]; + particle.y += moments[${2*memory.volume}+gid]; % if descriptor.d == 3: - particle.z += moment.w; + particle.z += moments[${3*memory.volume}+gid]; % endif particle.w += min(particle.x, particle.y) * aging; } else { diff --git a/template/sdf.cl.mako b/template/sdf.cl.mako index b98b35f..0a62f4b 100644 --- a/template/sdf.cl.mako +++ b/template/sdf.cl.mako @@ -13,9 +13,7 @@ __constant float3 center = (float3)(${geometry.size_x/2.5}, ${geometry.size_y/2} <%include file="sdf.lib.glsl.mako"/> -float sdf(vec3 v) { - ${sdf_src} -} +${sdf_src} __kernel void setup_channel_with_sdf_obstacle(__global int* material) { const unsigned x = get_global_id(0); diff --git a/template/streamline.mako b/template/streamline.mako index 73c80e2..adf5efd 100644 --- a/template/streamline.mako +++ b/template/streamline.mako @@ -31,7 +31,7 @@ float3 blueRedPalette(float x) { ); } -__kernel void draw_streamline(__global float4* moments, +__kernel void draw_streamline(__global float* moments, __global int* material, __global float2* origins, __read_write image2d_t streamlines) @@ -40,14 +40,12 @@ __kernel void draw_streamline(__global float4* moments, for (int i = 0; i < ${2*memory.size_x}; ++i) { const unsigned int gid = round(particle.y)*${memory.size_x} + round(particle.x); - const float4 moment = moments[gid]; - if (material[gid] != 1) { break; } - particle.x += 0.5 * moment.y / 0.01; - particle.y += 0.5 * moment.z / 0.01; + particle.x += 0.5 * moments[${1*memory.volume}+gid] / 0.01; + particle.y += 0.5 * moments[${2*memory.volume}+gid] / 0.01; const int2 pos = (int2)(round(particle.x), round(particle.y)); @@ -56,4 +54,4 @@ __kernel void draw_streamline(__global float4* moments, write_imagef(streamlines, pos, color); } -} +}
\ No newline at end of file |