@@ -991,14 +991,12 @@ fn @make_gpu_device( dev_id: i32
991991 ignis_load_image(filename, &mut pixel_data, &mut width, &mut height, channel_count);
992992
993993 let stride = width; // Drop mutable attribute
994- let q = pixel_data as &addrspace(1)[f32] ;
994+ let q = accs( pixel_data, 0 /* Ignored */) ;
995995 if channel_count == 1 {
996- make_image_mono(if is_nvvm { @ |x, y| nvvm_ldg_f32(&q(y * stride + x)) }
997- else { @ |x, y| q(y * stride + x) },
996+ make_image_mono(@ |x, y| q.load_f32(y*stride + x),
998997 width, height)
999998 } else {
1000- make_image_rgba32(if is_nvvm { @ |x, y| nvvm_load_vec4(q, y * stride + x) }
1001- else { @ |x, y| amdgpu_load_vec4(q, y * stride + x) },
999+ make_image_rgba32(@ |x, y| q.load_vec4(y*stride * channel_count + x * channel_count),
10021000 width, height)
10031001 }
10041002 },
@@ -1009,14 +1007,12 @@ fn @make_gpu_device( dev_id: i32
10091007 ignis_load_image_by_id(id, &mut pixel_data, &mut width, &mut height, channel_count);
10101008
10111009 let stride = width; // Drop mutable attribute
1012- let q = pixel_data as &addrspace(1)[f32] ;
1010+ let q = accs( pixel_data, 0 /* Ignored */) ;
10131011 if channel_count == 1 {
1014- make_image_mono(if is_nvvm { @ |x, y| nvvm_ldg_f32(&q(y * stride + x)) }
1015- else { @ |x, y| q(y * stride + x) },
1012+ make_image_mono(@ |x, y| q.load_f32(y*stride + x),
10161013 width, height)
10171014 } else {
1018- make_image_rgba32(if is_nvvm { @ |x, y| nvvm_load_vec4(q, y * stride + x) }
1019- else { @ |x, y| amdgpu_load_vec4(q, y * stride + x) },
1015+ make_image_rgba32(@ |x, y| q.load_vec4(y*stride * channel_count + x * channel_count),
10201016 width, height)
10211017 }
10221018 },
@@ -1188,3 +1184,78 @@ fn @make_amdgpu_device(dev: i32, config: RenderConfig, gpu_config: GPUKernelConf
11881184 false
11891185 )
11901186}
1187+
1188+ #[import(cc = "device", name = "atomic_max")] fn opencl_atomic_max_global(&mut addrspace(1)i32, i32) -> i32;
1189+ #[import(cc = "device", name = "atomic_max")] fn opencl_atomic_max_shared(&mut addrspace(3)i32, i32) -> i32;
1190+
1191+ fn @make_opencl_device(dev: i32, config: RenderConfig, gpu_config: GPUKernelConfiguration) -> Device {
1192+ let dev_id = runtime_device(2, dev);
1193+ let atomics = Atomics {
1194+ add_global_i32 = @ |p, i| opencl_atomic_add_global(p as &mut addrspace(1)i32, i),
1195+ add_global_f32 = @ |p, i| opencl_atomic_add_global_f32(p as &mut addrspace(1)f32, i),
1196+ min_global_i32 = @ |p, i| opencl_atomic_min_global(p as &mut addrspace(1)i32, i),
1197+ max_global_i32 = @ |_p, _i| 0:i32, // opencl_atomic_max_global(p as &mut addrspace(1)i32, i), //< TODO
1198+ add_shared_i32 = @ |p, i| opencl_atomic_add_shared(p, i),
1199+ add_shared_f32 = @ |p, i| atomic_p3(11:u32, p, i, 2:u32, "wavefront")
1200+ };
1201+ let accessor = DeviceBufferGlobalElementAccessor {
1202+ load_f32 = @|p: &addrspace(1)[f32], i: i32| p(i),
1203+ load_i32 = @|p: &addrspace(1)[i32], i: i32| p(i),
1204+ load_vf32 = @|p: &addrspace(1)[f32], i: i32| {
1205+ let v = (p as &addrspace(1)[simd[f32 * 4]])(i);
1206+ (v(0), v(1), v(2), v(3))
1207+ },
1208+ load_vi32 = @|p: &addrspace(1)[i32], i: i32| {
1209+ let v = (p as &addrspace(1)[simd[i32 * 4]])(i);
1210+ (v(0), v(1), v(2), v(3))
1211+ }
1212+ };
1213+
1214+ make_gpu_device(
1215+ dev_id,
1216+ config,
1217+ opencl_spirv_accelerator(dev),
1218+ gpu_config,
1219+ make_default_min_max(),
1220+ @ |ptr, size| make_gpu_buffer(dev_id, ptr as &addrspace(1)[f32], size, atomics, accessor),
1221+ @ |ptr, size| make_gpu_shallow_buffer(ptr as &addrspace(1)[f32], size, accessor),
1222+ atomics,
1223+ false
1224+ )
1225+ }
1226+
1227+ // fn @make_vulkan_device(dev: i32, config: RenderConfig, gpu_config: GPUKernelConfiguration) -> Device {
1228+ // let dev_id = runtime_device(6, dev);
1229+ // let atomics = Atomics {
1230+ // add_global_i32 = @ |p, i| opencl_atomic_add_global(p as &mut addrspace(1)i32, i),
1231+ // add_global_f32 = @ |p, i| opencl_atomic_add_global_f32(p as &mut addrspace(1)f32, i),
1232+ // min_global_i32 = @ |p, i| opencl_atomic_min_global(p as &mut addrspace(1)i32, i),
1233+ // max_global_i32 = @ |p, i| opencl_atomic_max_global(p as &mut addrspace(1)i32, i),
1234+ // add_shared_i32 = @ |p, i| opencl_atomic_add_shared(p, i),
1235+ // add_shared_f32 = @ |p, i| atomic_p3(11:u32, p, i, 2:u32, "wavefront")
1236+ // };
1237+ // let accessor = DeviceBufferGlobalElementAccessor {
1238+ // load_f32 = @|p: &addrspace(1)[f32], i: i32| p(i),
1239+ // load_i32 = @|p: &addrspace(1)[i32], i: i32| p(i),
1240+ // load_vf32 = @|p: &addrspace(1)[f32], i: i32| {
1241+ // let v = (p as &addrspace(1)[simd[f32 * 4]])(i);
1242+ // (v(0), v(1), v(2), v(3))
1243+ // },
1244+ // load_vi32 = @|p: &addrspace(1)[i32], i: i32| {
1245+ // let v = (p as &addrspace(1)[simd[i32 * 4]])(i);
1246+ // (v(0), v(1), v(2), v(3))
1247+ // }
1248+ // };
1249+
1250+ // make_gpu_device(
1251+ // dev_id,
1252+ // config,
1253+ // vulkan_accelerator(dev),
1254+ // gpu_config,
1255+ // make_default_min_max(),
1256+ // @ |ptr, size| make_gpu_buffer(dev_id, ptr as &addrspace(1)[f32], size, atomics, accessor),
1257+ // @ |ptr, size| make_gpu_shallow_buffer(ptr as &addrspace(1)[f32], size, accessor),
1258+ // atomics,
1259+ // false
1260+ // )
1261+ // }
0 commit comments