rk_engine/cpp/render/render_opengles.hpp

115 lines
2.7 KiB
C++
Raw Normal View History

2022-08-28 04:23:13 +02:00
// Copyright (C) 2022 RozK
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _RK_ENGINE_RENDER_OPENGLES_H
#define _RK_ENGINE_RENDER_OPENGLES_H
2023-01-05 03:39:32 +01:00
#include "../render.hpp"
2022-08-28 04:23:13 +02:00
#include <GLES3/gl32.h>
#include <GLES3/gl3ext.h>
#include <GLES3/gl3platform.h>
2023-01-06 17:05:09 +01:00
static_assert(sizeof(rk_vertex_output) == 4);
typedef rk_vertex_output rk_param_output;
2022-08-28 04:23:13 +02:00
struct rk_shader {
GLuint vertex;
GLuint fragment;
GLuint program;
};
struct rk_texture {
2022-12-20 07:01:58 +01:00
unsigned nlevels;
2022-08-28 04:23:13 +02:00
GLuint texture;
};
struct rk_triangles {
2022-12-20 07:01:58 +01:00
unsigned size;
2022-08-28 04:23:13 +02:00
GLuint array;
GLuint vertices;
};
struct rk_vertices {
unsigned nvertices;
unsigned nindices;
2023-01-03 12:59:07 +01:00
unsigned nmeshes;
rk_vertex_format * format;
rk_ubyte * vertices;
2023-01-04 09:33:49 +01:00
rk_vertex_index * indices;
2023-01-03 12:59:07 +01:00
rk_mesh * meshes;
GLuint vertices_buffer;
GLuint indices_buffer;
2022-08-28 04:23:13 +02:00
};
2022-12-30 10:50:56 +01:00
struct rk_command {
GLuint nvertices;
GLuint ninstances;
GLuint base_index;
GLint base_vertex;
GLuint base_instance;
};
typedef void (*rk_packer)(
unsigned const, // count
2023-01-06 17:05:09 +01:00
rk_instance_index const * const __restrict, // indices
rk_param_output * __restrict, // dst
rk_param_input const * const __restrict); // src
2022-12-17 04:58:19 +01:00
2022-12-30 10:50:56 +01:00
struct rk_parameter {
2023-01-02 17:01:36 +01:00
mutable bool dirty;
unsigned binding;
2022-12-30 10:50:56 +01:00
unsigned offset;
2023-01-02 17:01:36 +01:00
unsigned src_size;
2023-01-04 09:33:49 +01:00
unsigned src_len;
2023-01-04 12:41:05 +01:00
unsigned dst_size;
2023-01-04 09:33:49 +01:00
unsigned dst_len;
rk_param_input * source;
2022-12-30 10:50:56 +01:00
rk_packer packer;
2022-08-28 04:23:13 +02:00
};
2023-01-04 09:33:49 +01:00
struct rk_bucket {
unsigned size;
unsigned count;
rk_instance_index * indices;
};
2023-01-02 17:01:36 +01:00
enum rk_batch_state {
RK_BATCH_STATE_EMPTY = 0,
RK_BATCH_STATE_FILLED = 1,
RK_BATCH_STATE_SORTED = 2,
RK_BATCH_STATE_PACKED = 3
};
2022-08-28 04:23:13 +02:00
struct rk_batch {
2023-01-02 17:01:36 +01:00
mutable rk_batch_state state;
mutable unsigned count;
mutable unsigned ninstances;
mutable unsigned ncommands;
2022-12-30 10:50:56 +01:00
unsigned max_size;
2022-12-20 07:01:58 +01:00
unsigned nparams;
2023-01-03 14:05:25 +01:00
rk_vertices const * vertices;
2023-01-02 17:01:36 +01:00
rk_instance_flags * flags;
2023-01-04 09:33:49 +01:00
rk_mesh_index * meshes;
rk_instance_index * indices;
2022-08-28 04:23:13 +02:00
rk_command * commands;
2022-12-30 10:50:56 +01:00
rk_parameter * params;
GLuint vertex_array;
GLuint commands_buffer;
GLuint params_buffer;
2022-08-28 04:23:13 +02:00
};
#endif // _RK_ENGINE_RENDER_OPENGLES_H