summaryrefslogtreecommitdiff
path: root/src/renderer/static_pipeline.h
blob: bf5bc422cbc47458b76232e5d8fc2b86e82c2e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include "defines.h"
#include "maths_types.h"
#include "ral.h"
#include "ral_types.h"
#include "render_types.h"

typedef struct mvp_uniforms {
  mat4 model;
  mat4 view;
  mat4 projection;
} mvp_uniforms;
typedef struct my_shader_bind_group {
  mvp_uniforms mvp;
} my_shader_bind_group;

static shader_data_layout mvp_uniforms_layout(void* data) {
  my_shader_bind_group* d = (my_shader_bind_group*)data;
  bool has_data = data != NULL;

  shader_binding b1 = { .label = "Matrices",
                        .type = SHADER_BINDING_BYTES,
                        .stores_data = has_data,
                        .data = { .bytes = { .size = sizeof(mvp_uniforms) } } };

  if (has_data) {
    b1.data.bytes.data = &d->mvp;
  }
  return (shader_data_layout){ .name = "global_ubo", .bindings = { b1 }, .bindings_count = 1 };
}