2018-04-12 16:08:48 +02:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2018-04-12 16:08:48 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2024-05-16 23:30:41 +02:00
|
|
|
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
2018-04-12 16:08:48 +02:00
|
|
|
*/
|
|
|
|
|
2021-08-12 23:09:01 +02:00
|
|
|
#pragma once
|
2018-04-12 16:08:48 +02:00
|
|
|
#include "taisei.h"
|
|
|
|
|
|
|
|
#include "../api.h"
|
2024-08-22 13:34:55 +02:00
|
|
|
#include "../common/magic_uniforms.h"
|
2018-04-12 16:08:48 +02:00
|
|
|
#include "opengl.h"
|
2021-02-04 00:50:10 +01:00
|
|
|
|
2024-08-22 13:34:55 +02:00
|
|
|
#include "hashtable.h"
|
|
|
|
#include "resource/shader_program.h"
|
2021-02-04 00:50:10 +01:00
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
struct ShaderProgram {
|
|
|
|
GLuint gl_handle;
|
2018-06-29 23:36:51 +02:00
|
|
|
ht_str2ptr_t uniforms;
|
2021-02-04 00:50:10 +01:00
|
|
|
Uniform *magic_uniforms[NUM_MAGIC_UNIFORMS];
|
2018-09-14 09:37:20 +02:00
|
|
|
char debug_label[R_DEBUG_LABEL_SIZE];
|
2018-04-12 16:08:48 +02:00
|
|
|
};
|
|
|
|
|
2021-11-24 08:31:40 +01:00
|
|
|
#define INVALID_UNIFORM_LOCATION 0xffffffff
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
struct Uniform {
|
2018-09-14 09:37:20 +02:00
|
|
|
// these are for sampler uniforms
|
|
|
|
LIST_INTERFACE(Uniform);
|
|
|
|
Texture **textures;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
ShaderProgram *prog;
|
2018-09-14 09:37:20 +02:00
|
|
|
size_t elem_size; // bytes
|
|
|
|
uint array_size; // elements
|
2018-04-12 16:08:48 +02:00
|
|
|
uint location;
|
|
|
|
UniformType type;
|
|
|
|
|
|
|
|
struct {
|
2018-09-14 09:37:20 +02:00
|
|
|
// buffer size = elem_size * array_size
|
|
|
|
char *pending;
|
|
|
|
char *commited;
|
|
|
|
|
|
|
|
uint update_first_idx;
|
|
|
|
uint update_last_idx;
|
2018-04-12 16:08:48 +02:00
|
|
|
} cache;
|
|
|
|
};
|
|
|
|
|
|
|
|
void gl33_sync_uniforms(ShaderProgram *prog);
|
|
|
|
|
2020-02-15 18:45:09 +01:00
|
|
|
ShaderProgram *gl33_shader_program_link(uint num_objects, ShaderObject *shobjs[num_objects]);
|
2018-09-14 09:37:20 +02:00
|
|
|
void gl33_shader_program_destroy(ShaderProgram *prog);
|
|
|
|
void gl33_shader_program_set_debug_label(ShaderProgram *prog, const char *label);
|
|
|
|
const char* gl33_shader_program_get_debug_label(ShaderProgram *prog);
|
|
|
|
|
2020-03-17 09:09:49 +01:00
|
|
|
Uniform *gl33_shader_uniform(ShaderProgram *prog, const char *uniform_name, hash_t uniform_name_hash);
|
2018-04-12 16:08:48 +02:00
|
|
|
UniformType gl33_uniform_type(Uniform *uniform);
|
2018-09-14 09:37:20 +02:00
|
|
|
void gl33_uniform(Uniform *uniform, uint offset, uint count, const void *data);
|
|
|
|
void gl33_unref_texture_from_samplers(Texture *tex);
|
2021-11-24 08:31:40 +01:00
|
|
|
void gl33_uniforms_handle_texture_pointer_renamed(Texture *pold, Texture *pnew);
|
|
|
|
bool gl33_shader_program_transfer(ShaderProgram *dst, ShaderProgram *src);
|