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

#define gsk_gpu_convertcicp_n_textures 1

typedef struct _GskGpuConvertcicpInstance GskGpuConvertcicpInstance;

struct _GskGpuConvertcicpInstance {
  float rect[4];
  float tex_rect[4];
  float opacity;
  guint32 color_primaries;
  guint32 transfer_function;
  guint32 matrix_coefficients;
  guint32 range;
};

static inline void
gsk_gpu_convertcicp_setup_vao (gsize offset)
{
  glEnableVertexAttribArray (0);
  glVertexAttribDivisor (0, 1);
  glVertexAttribPointer (0,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuConvertcicpInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, rect)));
  glEnableVertexAttribArray (1);
  glVertexAttribDivisor (1, 1);
  glVertexAttribPointer (1,
                         4,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuConvertcicpInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, tex_rect)));
  glEnableVertexAttribArray (2);
  glVertexAttribDivisor (2, 1);
  glVertexAttribPointer (2,
                         1,
                         GL_FLOAT,
                         GL_FALSE,
                         sizeof (GskGpuConvertcicpInstance),
                         GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, opacity)));
  glEnableVertexAttribArray (3);
  glVertexAttribDivisor (3, 1);
  glVertexAttribIPointer (3,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuConvertcicpInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, color_primaries)));
  glEnableVertexAttribArray (4);
  glVertexAttribDivisor (4, 1);
  glVertexAttribIPointer (4,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuConvertcicpInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, transfer_function)));
  glEnableVertexAttribArray (5);
  glVertexAttribDivisor (5, 1);
  glVertexAttribIPointer (5,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuConvertcicpInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, matrix_coefficients)));
  glEnableVertexAttribArray (6);
  glVertexAttribDivisor (6, 1);
  glVertexAttribIPointer (6,
                          1,
                          GL_UNSIGNED_INT,
                          sizeof (GskGpuConvertcicpInstance),
                          GSIZE_TO_POINTER (offset + G_STRUCT_OFFSET(GskGpuConvertcicpInstance, range)));
}


static void
gsk_gpu_convertcicp_setup_attrib_locations (GLuint program)
{
  glBindAttribLocation (program, 0, "in_rect");
  glBindAttribLocation (program, 1, "in_tex_rect");
  glBindAttribLocation (program, 2, "in_opacity");
  glBindAttribLocation (program, 3, "in_color_primaries");
  glBindAttribLocation (program, 4, "in_transfer_function");
  glBindAttribLocation (program, 5, "in_matrix_coefficients");
  glBindAttribLocation (program, 6, "in_range");
}


#ifdef GDK_RENDERING_VULKAN

static const VkPipelineVertexInputStateCreateInfo gsk_gpu_convertcicp_info = {
  .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  .vertexBindingDescriptionCount = 1,
  .pVertexBindingDescriptions = (VkVertexInputBindingDescription[1]) {
      {
        .binding = 0,
        .stride = sizeof (GskGpuConvertcicpInstance),
        .inputRate = VK_VERTEX_INPUT_RATE_INSTANCE
      }
  },
  .vertexAttributeDescriptionCount = 7,
  .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[7]) {
      {
        .location = 0,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, rect),
      },
      {
        .location = 1,
        .binding = 0,
        .format = VK_FORMAT_R32G32B32A32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, tex_rect),
      },
      {
        .location = 2,
        .binding = 0,
        .format = VK_FORMAT_R32_SFLOAT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, opacity),
      },
      {
        .location = 3,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, color_primaries),
      },
      {
        .location = 4,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, transfer_function),
      },
      {
        .location = 5,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, matrix_coefficients),
      },
      {
        .location = 6,
        .binding = 0,
        .format = VK_FORMAT_R32_UINT,
        .offset = G_STRUCT_OFFSET(GskGpuConvertcicpInstance, range),
      },
  },
};

#endif

