#include <metal_stdlib>

using namespace metal;
uint3 textureDimensions_d8f887(texture3d<uint, access::write> tint_symbol) {
  uint3 res = uint3(tint_symbol.get_width(), tint_symbol.get_height(), tint_symbol.get_depth());
  return res;
}

fragment void fragment_main(device packed_uint3* tint_symbol_1 [[buffer(0)]], texture3d<uint, access::write> tint_symbol_2 [[texture(0)]]) {
  *(tint_symbol_1) = packed_uint3(textureDimensions_d8f887(tint_symbol_2));
  return;
}

kernel void compute_main(device packed_uint3* tint_symbol_3 [[buffer(0)]], texture3d<uint, access::write> tint_symbol_4 [[texture(0)]]) {
  *(tint_symbol_3) = packed_uint3(textureDimensions_d8f887(tint_symbol_4));
  return;
}

