/* This file is auto-generated; any change will not be preserved */
#pragma once

typedef struct _GskGpuMaskInstance GskGpuMaskInstance;

struct _GskGpuMaskInstance {
  float rect[4];
  float source_rect[4];
  guint32 source_id;
  float mask_rect[4];
  guint32 mask_id;
  float opacity;
};

static inline void
gsk_gpu_mask_setup_vao (gsize offset)
{
  glEnableVertexAttribArray (0);
  glVertexAttribDivisor (0, 1);
  glVertexAttribPointer (0,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuMaskInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuMaskInstance, rect)));
  glEnableVertexAttribArray (1);
  glVertexAttribDivisor (1, 1);
  glVertexAttribPointer (1,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuMaskInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuMaskInstance, source_rect)));
  glEnableVertexAttribArray (2);
  glVertexAttribDivisor (2, 1);
  glVertexAttribIPointer (2,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuMaskInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuMaskInstance, source_id)));
  glEnableVertexAttribArray (3);
  glVertexAttribDivisor (3, 1);
  glVertexAttribPointer (3,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuMaskInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuMaskInstance, mask_rect)));
  glEnableVertexAttribArray (4);
  glVertexAttribDivisor (4, 1);
  glVertexAttribIPointer (4,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuMaskInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuMaskInstance, mask_id)));
  glEnableVertexAttribArray (5);
  glVertexAttribDivisor (5, 1);
  glVertexAttribPointer (5,
                         1,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuMaskInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuMaskInstance, opacity)));
}


static void
gsk_gpu_mask_setup_attrib_locations (GLuint program)
{
  glBindAttribLocation (program, 0, "in_rect");
  glBindAttribLocation (program, 1, "in_source_rect");
  glBindAttribLocation (program, 2, "in_source_id");
  glBindAttribLocation (program, 3, "in_mask_rect");
  glBindAttribLocation (program, 4, "in_mask_id");
  glBindAttribLocation (program, 5, "in_opacity");
}


#ifdef GDK_RENDERING_VULKAN

static const VkPipelineVertexInputStateCreateInfo gsk_gpu_mask_info = {
  .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  .vertexBindingDescriptionCount = 1,
  .pVertexBindingDescriptions = (VkVertexInputBindingDescription[1]) {
      {
        .binding = 0,
        .stride = sizeof (GskGpuMaskInstance),
        .inputRate = VK_VERTEX_INPUT_RATE_INSTANCE
      }
  },
  .vertexAttributeDescriptionCount = 6,
  .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[6]) {
      {
        .location = 0,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuMaskInstance, rect),
      },
      {
        .location = 1,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuMaskInstance, source_rect),
      },
      {
        .location = 2,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuMaskInstance, source_id),
      },
      {
        .location = 3,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuMaskInstance, mask_rect),
      },
      {
        .location = 4,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuMaskInstance, mask_id),
      },
      {
        .location = 5,
        .binding = 0,
        .format = VK_FORMAT_R32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuMaskInstance, opacity),
      },
  },
};

#endif

