1 #include <kiba/gpu/surface.h>
3 b8 gpu_surface_create(
gpu_surface surface,
void *window_data) {
4 return gpu_backend_surface_create(&surface->bs, window_data);
7 void gpu_surface_destroy(
gpu_surface surface) { gpu_backend_surface_destroy(&surface->bs); }
10 surface->device = device;
11 surface->config = config;
12 return gpu_backend_surface_configure(&surface->bs, &device->bd, config);
16 gpu_backend_surface_unconfigure(&surface->bs, &surface->device->bd);
21 if (!gpu_device_resource_texture_create(surface->device, texture)) {
26 .format = surface->config.format,
27 .dimension = GPU_TEXTURE_DIMENSION_D2,
28 .size = {.width = surface->config.width, .height = surface->config.height, .depth = 1},
29 .usage = GPU_TEXTURE_USAGE_RENDER_ATTACHMENT,
34 texture_data->device->textures[texture_data->tracker_id].start_use = GPU_TEXTURE_USE_PRESENT;
35 surface->presentation = *texture;
36 return gpu_backend_surface_get_current_texture(&surface->bs, &surface->device->bd, &texture_data->bt, suboptimal);
39 b8 gpu_surface_present(
gpu_surface surface, b8 *suboptimal) {
40 b8 ret = gpu_backend_surface_present(&surface->bs, &surface->device->bd, &surface->presentation->bt, suboptimal);
41 gpu_device_resource_texture_release(surface->presentation);