static void get_resource_args(enum pipe_texture_target target, bool invalid,
                              struct virgl_renderer_resource_create_args *args,
                              struct pipe_box *box, int nsamples, int large_flags)
{
  memset(args, 0, sizeof(*args));
  memset(box, 0, sizeof(*box));

  args->handle = 1;
  args->target = target;
  if (args->target == PIPE_BUFFER) {
    args->format = PIPE_FORMAT_R8_UNORM;
    args->bind = PIPE_BIND_VERTEX_BUFFER;
  } else {
    args->bind = PIPE_BIND_SAMPLER_VIEW;
    args->format = PIPE_FORMAT_B8G8R8X8_UNORM;
  }
  args->nr_samples = nsamples;
  args->flags = 0;

  if (large_flags & LARGE_FLAG_WIDTH)
     if (args->target == PIPE_BUFFER)
        args->width = 65536*2;
     else if (args->target == PIPE_TEXTURE_3D)
        args->width = 1024;
     else
        args->width = 4096;
  else
    args->width = 50;
  args->height = args->depth = args->array_size = 1;

  switch (target) {
  case PIPE_TEXTURE_CUBE_ARRAY:
    args->array_size = 12;
    args->height = args->width;
    break;
  case PIPE_TEXTURE_1D_ARRAY:
  case PIPE_TEXTURE_2D_ARRAY:
    args->array_size = 10;
    break;
  case PIPE_TEXTURE_3D:
    args->depth = 8;
    break;
  case PIPE_TEXTURE_CUBE:
    args->array_size = 6;
    args->height = args->width;
    break;
  default:
    break;
  }

  switch (target) {
  case PIPE_BUFFER:
  case PIPE_TEXTURE_1D:
  case PIPE_TEXTURE_1D_ARRAY:
  case PIPE_TEXTURE_CUBE:
  case PIPE_TEXTURE_CUBE_ARRAY:
     break;
  default:
    if (large_flags & LARGE_FLAG_HEIGHT) {
       if (args->target == PIPE_BUFFER)
          args->height = 64000;
       else if (args->target == PIPE_TEXTURE_3D)
          args->height = 1024;
       else
          args->height = 4096;
    } else
      args->height = 50;
    break;
  }

  if (invalid) {
    box->width = args->width + 10;
    box->height = args->height;
    box->depth = 1;
  } else {
    box->width = args->width;
    box->height = args->height;
    box->depth = 1;
    if (args->depth > 1)
      box->depth = 6;
    if (args->array_size > 1)
      box->depth = 4;
  }
}
static void get_resource_args(enum pipe_texture_target target, bool invalid,
                              struct virgl_renderer_resource_create_args *args,
                              struct pipe_box *box, int nsamples, int large_flags)
{
  memset(args, 0, sizeof(*args));
  memset(box, 0, sizeof(*box));

  args->handle = 1;
  args->target = target;
  if (args->target == PIPE_BUFFER) {
    args->format = PIPE_FORMAT_R8_UNORM;
    args->bind = PIPE_BIND_VERTEX_BUFFER;
  } else {
    args->bind = PIPE_BIND_SAMPLER_VIEW;
    args->format = PIPE_FORMAT_B8G8R8X8_UNORM;
  }
  args->nr_samples = nsamples;
  args->flags = 0;

  if (large_flags & LARGE_FLAG_WIDTH)
     if (args->target == PIPE_BUFFER)
        args->width = 65536*2;
     else if (args->target == PIPE_TEXTURE_3D)
        args->width = 1024;
     else
        args->width = 4096;
  else
    args->width = 50;
  args->height = args->depth = args->array_size = 1;

  switch (target) {
  case PIPE_TEXTURE_CUBE_ARRAY:
    args->array_size = 12;
    args->height = args->width;
    break;
  case PIPE_TEXTURE_1D_ARRAY:
  case PIPE_TEXTURE_2D_ARRAY:
    args->array_size = 10;
    break;
  case PIPE_TEXTURE_3D:
    args->depth = 8;
    break;
  case PIPE_TEXTURE_CUBE:
    args->array_size = 6;
    args->height = args->width;
    break;
  default:
    break;
  }

  switch (target) {
  case PIPE_BUFFER:
  case PIPE_TEXTURE_1D:
  case PIPE_TEXTURE_1D_ARRAY:
  case PIPE_TEXTURE_CUBE:
  case PIPE_TEXTURE_CUBE_ARRAY:
     break;
  default:
    if (large_flags & LARGE_FLAG_HEIGHT) {
       if (args->target == PIPE_BUFFER)
          args->height = 64000;
       else if (args->target == PIPE_TEXTURE_3D)
          args->height = 1024;
       else
          args->height = 4096;
    } else
      args->height = 50;
    break;
  }

  if (invalid) {
    box->width = args->width + 10;
    box->height = args->height;
    box->depth = 1;
  } else {
    box->width = args->width;
    box->height = args->height;
    box->depth = 1;
    if (args->depth > 1)
      box->depth = 6;
    if (args->array_size > 1)
      box->depth = 4;
  }
}