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

typedef struct _GskGpuColormatrixInstance GskGpuColormatrixInstance;

struct _GskGpuColormatrixInstance {
  float color_matrix[16];
  float color_offset[4];
  float rect[4];
  float tex_rect[4];
  guint32 tex_id;
};

static inline void
gsk_gpu_colormatrix_setup_vao (gsize offset)
{
  glEnableVertexAttribArray (0);
  glVertexAttribDivisor (0, 1);
  glVertexAttribPointer (0,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix)));
  glEnableVertexAttribArray (1);
  glVertexAttribDivisor (1, 1);
  glVertexAttribPointer (1,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix) + sizeof (float) * 4));
  glEnableVertexAttribArray (2);
  glVertexAttribDivisor (2, 1);
  glVertexAttribPointer (2,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix) + sizeof (float) * 8));
  glEnableVertexAttribArray (3);
  glVertexAttribDivisor (3, 1);
  glVertexAttribPointer (3,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix) + sizeof (float) * 12));
  glEnableVertexAttribArray (4);
  glVertexAttribDivisor (4, 1);
  glVertexAttribPointer (4,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_offset)));
  glEnableVertexAttribArray (5);
  glVertexAttribDivisor (5, 1);
  glVertexAttribPointer (5,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, rect)));
  glEnableVertexAttribArray (6);
  glVertexAttribDivisor (6, 1);
  glVertexAttribPointer (6,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuColormatrixInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, tex_rect)));
  glEnableVertexAttribArray (7);
  glVertexAttribDivisor (7, 1);
  glVertexAttribIPointer (7,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuColormatrixInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuColormatrixInstance, tex_id)));
}


static void
gsk_gpu_colormatrix_setup_attrib_locations (GLuint program)
{
  glBindAttribLocation (program, 0, "in_color_matrix");
  glBindAttribLocation (program, 4, "in_color_offset");
  glBindAttribLocation (program, 5, "in_rect");
  glBindAttribLocation (program, 6, "in_tex_rect");
  glBindAttribLocation (program, 7, "in_tex_id");
}


#ifdef GDK_RENDERING_VULKAN

static const VkPipelineVertexInputStateCreateInfo gsk_gpu_colormatrix_info = {
  .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  .vertexBindingDescriptionCount = 1,
  .pVertexBindingDescriptions = (VkVertexInputBindingDescription[1]) {
      {
        .binding = 0,
        .stride = sizeof (GskGpuColormatrixInstance),
        .inputRate = VK_VERTEX_INPUT_RATE_INSTANCE
      }
  },
  .vertexAttributeDescriptionCount = 8,
  .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[8]) {
      {
        .location = 0,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix),
      },
      {
        .location = 1,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix) + sizeof (float) * 4,
      },
      {
        .location = 2,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix) + sizeof (float) * 8,
      },
      {
        .location = 3,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_matrix) + sizeof (float) * 12,
      },
      {
        .location = 4,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, color_offset),
      },
      {
        .location = 5,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, rect),
      },
      {
        .location = 6,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, tex_rect),
      },
      {
        .location = 7,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuColormatrixInstance, tex_id),
      },
  },
};

#endif

