aboutsummaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authorAdrian Kummerlaender2020-06-20 15:06:03 +0200
committerAdrian Kummerlaender2020-06-20 15:06:03 +0200
commitab616f6f6762a895eb5d49b0048d68ff3ca01650 (patch)
tree53ec68eec0cc89c78dc67f5acb9584ce7850c9ba /template
parenta3ac409a49803956986f4cab35a1f90f8d4b8e81 (diff)
downloadsymlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.tar
symlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.tar.gz
symlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.tar.bz2
symlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.tar.lz
symlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.tar.xz
symlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.tar.zst
symlbm_playground-ab616f6f6762a895eb5d49b0048d68ff3ca01650.zip
Fix usage of MomentsTexture in volumetric examples
Diffstat (limited to 'template')
-rw-r--r--template/opengl.mako44
1 files changed, 40 insertions, 4 deletions
diff --git a/template/opengl.mako b/template/opengl.mako
index 2029623..6958db8 100644
--- a/template/opengl.mako
+++ b/template/opengl.mako
@@ -64,12 +64,12 @@ def neighbor_offset(c_i):
%>
-__kernel void collect_gl_moments_to_texture(__global ${float_type}* f,
- __global int* material,
+__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)
+ __write_only image2d_t moments)
% elif descriptor.d == 3:
- __write_only image3d_t moments)
+ __write_only image3d_t moments)
% endif
{
const unsigned int gid = ${gid()};
@@ -107,3 +107,39 @@ __kernel void collect_gl_moments_to_texture(__global ${float_type}* f,
write_imagef(moments, ${moments_cell()}, data);
}
+
+__kernel void collect_gl_moments_to_texture(__global ${float_type}* f,
+% if descriptor.d == 2:
+ __write_only image2d_t moments)
+% elif descriptor.d == 3:
+ __write_only image3d_t moments)
+% endif
+{
+ const unsigned int gid = ${gid()};
+
+ __global ${float_type}* preshifted_f = f + gid;
+
+% for i in range(0,descriptor.q):
+ const ${float_type} f_curr_${i} = preshifted_f[${pop_offset(i)}];
+% endfor
+
+% for i, expr in enumerate(moments_subexpr):
+ const ${float_type} ${expr[0]} = ${ccode(expr[1])};
+% endfor
+
+ float4 data;
+
+% if descriptor.d == 2:
+ data.x = ${ccode(moments_assignment[0].rhs)};
+ data.y = ${ccode(moments_assignment[1].rhs)};
+ data.z = ${ccode(moments_assignment[2].rhs)};
+ data.w = sqrt(data.y*data.y + data.z*data.z);
+% elif descriptor.d == 3:
+ data.x = ${ccode(moments_assignment[0].rhs)};
+ data.y = ${ccode(moments_assignment[1].rhs)};
+ data.z = ${ccode(moments_assignment[2].rhs)};
+ data.w = ${ccode(moments_assignment[3].rhs)};
+% endif
+
+ write_imagef(moments, ${moments_cell()}, data);
+}