#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device packed_uint3* prevent_dce;
  texture3d<float, access::write> arg_0;
};

uint3 textureDimensions_4b26ef(tint_module_vars_struct tint_module_vars) {
  uint3 res = uint3(tint_module_vars.arg_0.get_width(0u), tint_module_vars.arg_0.get_height(0u), tint_module_vars.arg_0.get_depth(0u));
  return res;
}

fragment void fragment_main(device packed_uint3* prevent_dce [[buffer(0)]], texture3d<float, access::write> arg_0 [[texture(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce, .arg_0=arg_0};
  (*tint_module_vars.prevent_dce) = packed_uint3(textureDimensions_4b26ef(tint_module_vars));
}

kernel void compute_main(device packed_uint3* prevent_dce [[buffer(0)]], texture3d<float, access::write> arg_0 [[texture(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce, .arg_0=arg_0};
  (*tint_module_vars.prevent_dce) = packed_uint3(textureDimensions_4b26ef(tint_module_vars));
}
