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

typedef struct _GskGpuBlendmodeInstance GskGpuBlendmodeInstance;

struct _GskGpuBlendmodeInstance {
  float rect[4];
  float bottom_rect[4];
  guint32 bottom_id;
  float top_rect[4];
  guint32 top_id;
  float opacity;
};

static inline void
gsk_gpu_blendmode_setup_vao (gsize offset)
{
  glEnableVertexAttribArray (0);
  glVertexAttribDivisor (0, 1);
  glVertexAttribPointer (0,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuBlendmodeInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuBlendmodeInstance, rect)));
  glEnableVertexAttribArray (1);
  glVertexAttribDivisor (1, 1);
  glVertexAttribPointer (1,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuBlendmodeInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuBlendmodeInstance, bottom_rect)));
  glEnableVertexAttribArray (2);
  glVertexAttribDivisor (2, 1);
  glVertexAttribIPointer (2,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuBlendmodeInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuBlendmodeInstance, bottom_id)));
  glEnableVertexAttribArray (3);
  glVertexAttribDivisor (3, 1);
  glVertexAttribPointer (3,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuBlendmodeInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuBlendmodeInstance, top_rect)));
  glEnableVertexAttribArray (4);
  glVertexAttribDivisor (4, 1);
  glVertexAttribIPointer (4,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuBlendmodeInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuBlendmodeInstance, top_id)));
  glEnableVertexAttribArray (5);
  glVertexAttribDivisor (5, 1);
  glVertexAttribPointer (5,
                         1,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuBlendmodeInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuBlendmodeInstance, opacity)));
}


static void
gsk_gpu_blendmode_setup_attrib_locations (GLuint program)
{
  glBindAttribLocation (program, 0, "in_rect");
  glBindAttribLocation (program, 1, "in_bottom_rect");
  glBindAttribLocation (program, 2, "in_bottom_id");
  glBindAttribLocation (program, 3, "in_top_rect");
  glBindAttribLocation (program, 4, "in_top_id");
  glBindAttribLocation (program, 5, "in_opacity");
}


#ifdef GDK_RENDERING_VULKAN

static const VkPipelineVertexInputStateCreateInfo gsk_gpu_blendmode_info = {
  .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  .vertexBindingDescriptionCount = 1,
  .pVertexBindingDescriptions = (VkVertexInputBindingDescription[1]) {
      {
        .binding = 0,
        .stride = sizeof (GskGpuBlendmodeInstance),
        .inputRate = VK_VERTEX_INPUT_RATE_INSTANCE
      }
  },
  .vertexAttributeDescriptionCount = 6,
  .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[6]) {
      {
        .location = 0,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuBlendmodeInstance, rect),
      },
      {
        .location = 1,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuBlendmodeInstance, bottom_rect),
      },
      {
        .location = 2,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuBlendmodeInstance, bottom_id),
      },
      {
        .location = 3,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuBlendmodeInstance, top_rect),
      },
      {
        .location = 4,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuBlendmodeInstance, top_id),
      },
      {
        .location = 5,
        .binding = 0,
        .format = VK_FORMAT_R32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuBlendmodeInstance, opacity),
      },
  },
};

#endif

