Improve typing in render.
This commit is contained in:
@ -27,12 +27,6 @@ typedef void (*rk_MultiDrawElementsIndirectFunc)(rk_uint, rk_uint, const void *,
|
||||
static rk_DrawElementsInstancedBaseInstanceFunc rk_DrawElementsInstancedBaseInstance = nullptr;
|
||||
static rk_MultiDrawElementsIndirectFunc rk_MultiDrawElementsIndirect = nullptr;
|
||||
|
||||
struct rk_bucket {
|
||||
unsigned size;
|
||||
unsigned count;
|
||||
rk_ushort * indices;
|
||||
};
|
||||
|
||||
static unsigned rk_nbuckets = 0;
|
||||
static rk_bucket * rk_buckets = nullptr;
|
||||
|
||||
@ -325,7 +319,7 @@ rk_vertices_t rk_create_vertices(
|
||||
rk_uint nvertices,
|
||||
rk_ubyte const * _vertices,
|
||||
rk_uint nindices,
|
||||
rk_ushort const * indices,
|
||||
rk_vertex_index const * indices,
|
||||
rk_uint nmeshes,
|
||||
rk_mesh const * meshes) {
|
||||
if (!format || !nvertices || !_vertices || !nindices || !indices) {
|
||||
@ -363,8 +357,8 @@ rk_vertices_t rk_create_vertices(
|
||||
memcpy(vertices->format, format, (format_size + 1) * sizeof(rk_vertex_format));
|
||||
vertices->vertices = new rk_ubyte[nvertices * vertex_size];
|
||||
memcpy(vertices->vertices, _vertices, nvertices * vertex_size);
|
||||
vertices->indices = new rk_ushort[nindices];
|
||||
memcpy(vertices->indices, indices, nindices * sizeof(rk_ushort));
|
||||
vertices->indices = new rk_vertex_index[nindices];
|
||||
memcpy(vertices->indices, indices, nindices * sizeof(rk_vertex_index));
|
||||
vertices->meshes = new rk_mesh[nmeshes];
|
||||
memcpy(vertices->meshes, meshes, nmeshes * sizeof(rk_mesh));
|
||||
vertices->vertices_buffer = 0;
|
||||
@ -383,7 +377,7 @@ static void rk_buckets_alloc(
|
||||
for (unsigned index = 0; index < count; ++index) {
|
||||
rk_bucket & bucket = rk_buckets[index];
|
||||
bucket.size = size;
|
||||
bucket.indices = reinterpret_cast<rk_ushort *>(malloc(size * sizeof(rk_ushort)));
|
||||
bucket.indices = reinterpret_cast<rk_instance_index *>(malloc(size * sizeof(rk_instance_index)));
|
||||
}
|
||||
reallocated = true;
|
||||
}
|
||||
@ -392,7 +386,8 @@ static void rk_buckets_alloc(
|
||||
rk_bucket & bucket = rk_buckets[index];
|
||||
if (bucket.size < size) {
|
||||
bucket.size = size;
|
||||
bucket.indices = reinterpret_cast<rk_ushort *>(realloc(bucket.indices, size * sizeof(rk_ushort)));
|
||||
bucket.indices = reinterpret_cast<rk_instance_index *>(
|
||||
realloc(bucket.indices, size * sizeof(rk_instance_index)));
|
||||
reallocated = true;
|
||||
}
|
||||
}
|
||||
@ -403,13 +398,15 @@ static void rk_buckets_alloc(
|
||||
rk_bucket & bucket = rk_buckets[index];
|
||||
if (bucket.size < size) {
|
||||
bucket.size = size;
|
||||
bucket.indices = reinterpret_cast<rk_ushort *>(realloc(bucket.indices, size * sizeof(rk_ushort)));
|
||||
bucket.indices = reinterpret_cast<rk_instance_index *>(
|
||||
realloc(bucket.indices, size * sizeof(rk_instance_index)));
|
||||
}
|
||||
}
|
||||
for (unsigned index = rk_nbuckets; index < count; ++index) {
|
||||
rk_bucket & bucket = rk_buckets[index];
|
||||
bucket.size = size;
|
||||
bucket.indices = reinterpret_cast<rk_ushort *>(malloc(size * sizeof(rk_ushort)));
|
||||
bucket.indices = reinterpret_cast<rk_instance_index *>(
|
||||
malloc(size * sizeof(rk_instance_index)));
|
||||
}
|
||||
rk_nbuckets = count;
|
||||
reallocated = true;
|
||||
@ -418,7 +415,7 @@ static void rk_buckets_alloc(
|
||||
unsigned total_size = rk_nbuckets * sizeof(rk_bucket);
|
||||
for (unsigned index = 0; index < rk_nbuckets; ++index) {
|
||||
rk_bucket const & bucket = rk_buckets[index];
|
||||
total_size += bucket.size * sizeof(rk_ushort);
|
||||
total_size += bucket.size * sizeof(rk_instance_index);
|
||||
}
|
||||
printf("[RK] rk_buckets_alloc() -> %d KiB\n", total_size / 1024);
|
||||
}
|
||||
@ -426,26 +423,26 @@ static void rk_buckets_alloc(
|
||||
|
||||
static void rk_pack_vec3_float(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_vec3_float * __restrict dst = reinterpret_cast<rk_vec3_float *>(_dst);
|
||||
rk_vec3_float const * const __restrict src = reinterpret_cast<rk_vec3_float const *>(_src);
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
*dst = src[*index];
|
||||
}
|
||||
}
|
||||
|
||||
static void rk_pack_vec3_short(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_vec3_short * __restrict dst = reinterpret_cast<rk_vec3_short *>(_dst);
|
||||
rk_vec3_float const * const __restrict src = reinterpret_cast<rk_vec3_float const *>(_src);
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
rk_vec3_float const & input = src[*index];
|
||||
dst->x = static_cast<rk_short>(input.x);
|
||||
dst->y = static_cast<rk_short>(input.y);
|
||||
@ -456,14 +453,14 @@ static void rk_pack_vec3_short(
|
||||
|
||||
static void rk_pack_vec3_short_norm(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_vec3_short * __restrict dst = reinterpret_cast<rk_vec3_short *>(_dst);
|
||||
rk_vec3_float const * const __restrict src = reinterpret_cast<rk_vec3_float const *>(_src);
|
||||
#define _convert(s) (static_cast<rk_short>((s) * ((s) < 0.f ? 32768.f : 32767.f)))
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
rk_vec3_float const & input = src[*index];
|
||||
dst->x = _convert(input.x);
|
||||
dst->y = _convert(input.y);
|
||||
@ -475,14 +472,14 @@ static void rk_pack_vec3_short_norm(
|
||||
|
||||
static void rk_pack_vec3_int10(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_vec3_int10 * __restrict dst = reinterpret_cast<rk_vec3_int10 *>(_dst);
|
||||
rk_vec3_float const * const __restrict src = reinterpret_cast<rk_vec3_float const *>(_src);
|
||||
#define _convert(s) (static_cast<rk_int>((s)) & 1023)
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
rk_vec3_float const & input = src[*index];
|
||||
*dst = _convert(input.x) | (_convert(input.y) << 10) | (_convert(input.z) << 20);
|
||||
}
|
||||
@ -491,14 +488,14 @@ static void rk_pack_vec3_int10(
|
||||
|
||||
static void rk_pack_vec3_int10_norm(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_vec3_int10 * __restrict dst = reinterpret_cast<rk_vec3_int10 *>(_dst);
|
||||
rk_vec3_float const * const __restrict src = reinterpret_cast<rk_vec3_float const *>(_src);
|
||||
#define _convert(s) (static_cast<rk_int>((s) * ((s) < 0.f ? 512.f : 511.f)) & 1023)
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
rk_vec3_float const & input = src[*index];
|
||||
*dst = _convert(input.x) | (_convert(input.y) << 10) | (_convert(input.z) << 20);
|
||||
}
|
||||
@ -507,13 +504,13 @@ static void rk_pack_vec3_int10_norm(
|
||||
|
||||
static void rk_pack_mat3_float(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_mat3_float * __restrict dst = reinterpret_cast<rk_mat3_float *>(_dst);
|
||||
rk_mat3_float const * const __restrict src = reinterpret_cast<rk_mat3_float const *>(_src);
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
*dst = src[*index];
|
||||
}
|
||||
#undef _convert
|
||||
@ -521,14 +518,14 @@ static void rk_pack_mat3_float(
|
||||
|
||||
static void rk_pack_mat3_int10(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_mat3_int10 * __restrict dst = reinterpret_cast<rk_mat3_int10 *>(_dst);
|
||||
rk_mat3_float const * const __restrict src = reinterpret_cast<rk_mat3_float const *>(_src);
|
||||
#define _convert(s) (static_cast<rk_int>((s)) & 1023)
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
rk_mat3_float const & input = src[*index];
|
||||
dst->x = _convert(input.x.x) | (_convert(input.x.y) << 10) | (_convert(input.x.z) << 20);
|
||||
dst->y = _convert(input.y.x) | (_convert(input.y.y) << 10) | (_convert(input.y.z) << 20);
|
||||
@ -539,14 +536,14 @@ static void rk_pack_mat3_int10(
|
||||
|
||||
static void rk_pack_mat3_int10_norm(
|
||||
unsigned const count,
|
||||
rk_ushort const * const __restrict indices,
|
||||
rk_ubyte * __restrict _dst,
|
||||
rk_ubyte const * const __restrict _src) {
|
||||
rk_ushort const * const last_index = indices + count;
|
||||
rk_instance_index const * const __restrict indices,
|
||||
rk_param_output * __restrict _dst,
|
||||
rk_param_input const * const __restrict _src) {
|
||||
rk_instance_index const * const last_index = indices + count;
|
||||
rk_mat3_int10 * __restrict dst = reinterpret_cast<rk_mat3_int10 *>(_dst);
|
||||
rk_mat3_float const * const __restrict src = reinterpret_cast<rk_mat3_float const *>(_src);
|
||||
#define _convert(s) (static_cast<rk_int>((s) * ((s) < 0.f ? 512.f : 511.f)) & 1023)
|
||||
for (rk_ushort const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||
rk_mat3_float const & input = src[*index];
|
||||
dst->x = _convert(input.x.x) | (_convert(input.x.y) << 10) | (_convert(input.x.z) << 20);
|
||||
dst->y = _convert(input.y.x) | (_convert(input.y.y) << 10) | (_convert(input.y.z) << 20);
|
||||
@ -614,9 +611,11 @@ rk_batch_t rk_create_batch(
|
||||
batch->nparams = nparams;
|
||||
batch->vertices = vertices;
|
||||
batch->flags = new rk_instance_flags[max_size];
|
||||
batch->meshes = new rk_ushort[max_size];
|
||||
batch->indices = new rk_ushort[max_size];
|
||||
memset(batch->indices, 0xFF, max_size * sizeof(rk_ushort));
|
||||
memset(batch->flags, 0xFF, max_size * sizeof(rk_instance_flags));
|
||||
batch->meshes = new rk_mesh_index[max_size];
|
||||
memset(batch->meshes, 0xFF, max_size * sizeof(rk_mesh_index));
|
||||
batch->indices = new rk_instance_index[max_size];
|
||||
memset(batch->indices, 0, max_size * sizeof(rk_instance_index));
|
||||
batch->commands = new rk_command[vertices->nmeshes];
|
||||
memset(batch->commands, 0, vertices->nmeshes * sizeof(rk_command));
|
||||
if (nparams) {
|
||||
@ -637,7 +636,8 @@ rk_batch_t rk_create_batch(
|
||||
} else {
|
||||
glGenBuffers(1, &vertices->indices_buffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vertices->indices_buffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vertices->nindices * sizeof(rk_ushort), vertices->indices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
vertices->nindices * sizeof(rk_vertex_index), vertices->indices, GL_STATIC_DRAW);
|
||||
}
|
||||
if (rk_MultiDrawElementsIndirect) {
|
||||
glGenBuffers(1, &batch->commands_buffer);
|
||||
@ -747,7 +747,10 @@ rk_batch_t rk_create_batch(
|
||||
break;
|
||||
}
|
||||
glVertexBindingDivisor(binding, 1);
|
||||
param->source = new rk_ubyte[max_size * param->src_size];
|
||||
param->src_len = param->src_size / sizeof(rk_param_input);
|
||||
param->dst_len = param->dst_size / sizeof(rk_param_output);
|
||||
param->source = new rk_param_input[max_size * param->src_len];
|
||||
memset(param->source, 0xFF, max_size * param->src_size);
|
||||
offset += max_size * param->dst_size;
|
||||
}
|
||||
}
|
||||
@ -763,20 +766,20 @@ static void rk_sort_batch(
|
||||
bucket->count = 0;
|
||||
}
|
||||
rk_instance_flags const * __restrict flags = batch.flags;
|
||||
rk_ushort const * __restrict mesh_index = batch.meshes;
|
||||
rk_mesh_index const * __restrict mesh_index = batch.meshes;
|
||||
for (unsigned index = 0; index < batch.count; ++index, ++flags, ++mesh_index) {
|
||||
if ((*flags & RK_INSTANCE_FLAGS_SPAWNED_VISIBLE) == RK_INSTANCE_FLAGS_SPAWNED_VISIBLE) {
|
||||
rk_bucket & __restrict bucket = rk_buckets[*mesh_index];
|
||||
bucket.indices[bucket.count++] = index;
|
||||
}
|
||||
}
|
||||
rk_ushort * __restrict indices = batch.indices;
|
||||
rk_instance_index * __restrict indices = batch.indices;
|
||||
rk_command * __restrict command = batch.commands;
|
||||
rk_mesh const * __restrict mesh = batch.vertices->meshes;
|
||||
for (rk_bucket const * __restrict bucket = rk_buckets; bucket < last_bucket; ++bucket, ++mesh) {
|
||||
if (bucket->count) {
|
||||
memcpy(indices, bucket->indices, bucket->count * sizeof(rk_ushort));
|
||||
command->nvertices = static_cast<GLuint>(mesh->ntriangles) * 3;
|
||||
memcpy(indices, bucket->indices, bucket->count * sizeof(rk_instance_index));
|
||||
command->nvertices = mesh->ntriangles * 3;
|
||||
command->ninstances = bucket->count;
|
||||
command->base_index = mesh->base_index;
|
||||
command->base_instance = indices - batch.indices;
|
||||
@ -800,7 +803,7 @@ static void rk_pack_batch(
|
||||
if (param->dirty) {
|
||||
param->dirty = false;
|
||||
if (batch.ninstances) {
|
||||
rk_ubyte * const dst = reinterpret_cast<rk_ubyte *>(
|
||||
rk_param_output * const dst = reinterpret_cast<rk_param_output *>(
|
||||
glMapBufferRange(GL_ARRAY_BUFFER, param->offset, batch.ninstances * param->dst_size,
|
||||
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT));
|
||||
if (dst) {
|
||||
@ -819,8 +822,8 @@ void rk_fill_batch(
|
||||
rk_batch_t _batch,
|
||||
rk_uint count,
|
||||
rk_instance_flags const * flags,
|
||||
rk_ushort const * meshes,
|
||||
rk_ubyte const * const * params) {
|
||||
rk_mesh_index const * meshes,
|
||||
rk_param_input const * const * params) {
|
||||
rk_batch const * const batch = reinterpret_cast<rk_batch const *>(_batch);
|
||||
if (!batch || !count || count > batch->max_size) {
|
||||
rk_printf("rk_fill_batch(): invalid params.");
|
||||
@ -831,7 +834,7 @@ void rk_fill_batch(
|
||||
if (batch->nparams) {
|
||||
got_all_params = (params != nullptr);
|
||||
if (params) {
|
||||
for (rk_ubyte const * const * param = params; param < params + batch->nparams; ++param) {
|
||||
for (rk_param_input const * const * param = params; param < params + batch->nparams; ++param) {
|
||||
bool const got_param = (*param != nullptr);
|
||||
got_any_params |= got_param;
|
||||
got_all_params &= got_param;
|
||||
@ -849,23 +852,20 @@ void rk_fill_batch(
|
||||
return;
|
||||
}
|
||||
batch->count = count;
|
||||
bool const cmp_flags = (flags &&
|
||||
rk_cmp_memcpy<sizeof(rk_ubyte)>(batch->flags, flags, batch->count * sizeof(rk_instance_flags)));
|
||||
bool const cmp_meshes = (meshes &&
|
||||
rk_cmp_memcpy<sizeof(rk_ushort)>(batch->meshes, meshes, batch->count * sizeof(rk_mesh)));
|
||||
bool const cmp_flags = (flags && rk_cmp_memcpy(batch->flags, flags, batch->count));
|
||||
bool const cmp_meshes = (meshes && rk_cmp_memcpy(batch->meshes, meshes, batch->count));
|
||||
bool const need_sorting = (cmp_flags || cmp_meshes || resized);
|
||||
if (batch->nparams) {
|
||||
rk_parameter const * const last_param = batch->params + batch->nparams;
|
||||
if (got_any_params) {
|
||||
rk_ubyte const * const * src = params;
|
||||
for (rk_parameter const * dst = batch->params; dst < last_param; ++dst, ++src) {
|
||||
dst->dirty = ((*src &&
|
||||
rk_cmp_memcpy<sizeof(rk_uint)>(dst->source, *src, batch->count * dst->src_size))
|
||||
|| need_sorting);
|
||||
rk_param_input const * const * src = params;
|
||||
for (rk_parameter const * param = batch->params; param < last_param; ++param, ++src) {
|
||||
param->dirty =
|
||||
((*src && rk_cmp_memcpy(param->source, *src, batch->count * param->src_len)) || need_sorting);
|
||||
}
|
||||
} else if (need_sorting) {
|
||||
for (rk_parameter const * dst = batch->params; dst < last_param; ++dst) {
|
||||
dst->dirty = true;
|
||||
for (rk_parameter const * param = batch->params; param < last_param; ++param) {
|
||||
param->dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define _RK_ENGINE_RENDER_OPENGLES_H
|
||||
|
||||
#include "../types.hpp"
|
||||
#include "../math.hpp"
|
||||
#include <GLES3/gl32.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#include <GLES3/gl3platform.h>
|
||||
@ -44,7 +45,7 @@ struct rk_vertices {
|
||||
unsigned nmeshes;
|
||||
rk_vertex_format * format;
|
||||
rk_ubyte * vertices;
|
||||
rk_ushort * indices;
|
||||
rk_vertex_index * indices;
|
||||
rk_mesh * meshes;
|
||||
GLuint vertices_buffer;
|
||||
GLuint indices_buffer;
|
||||
@ -58,12 +59,19 @@ struct rk_command {
|
||||
GLuint base_instance;
|
||||
};
|
||||
|
||||
// param output types must be size compatible with an array of rk_param_output
|
||||
typedef rk_uint rk_param_output;
|
||||
|
||||
#define RK_CHECK_PARAM_OUTPUT_TYPE(_t) static_assert(!(sizeof(_t) % sizeof(rk_param_output)))
|
||||
|
||||
struct rk_vec3_float {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
static_assert(sizeof(rk_vec3_float) == sizeof(rk_vec3));
|
||||
|
||||
struct rk_vec3_short {
|
||||
rk_short x;
|
||||
rk_short y;
|
||||
@ -80,17 +88,29 @@ struct rk_mat3_float {
|
||||
rk_vec3_float z;
|
||||
};
|
||||
|
||||
static_assert(sizeof(rk_mat3_float) == sizeof(rk_mat3));
|
||||
|
||||
struct rk_mat3_int10 {
|
||||
rk_vec3_int10 x;
|
||||
rk_vec3_int10 y;
|
||||
rk_vec3_int10 z;
|
||||
};
|
||||
|
||||
RK_CHECK_PARAM_INPUT_TYPE(rk_vec3_float);
|
||||
RK_CHECK_PARAM_INPUT_TYPE(rk_mat3_float);
|
||||
|
||||
RK_CHECK_PARAM_OUTPUT_TYPE(rk_vec3_float);
|
||||
RK_CHECK_PARAM_OUTPUT_TYPE(rk_vec3_short);
|
||||
RK_CHECK_PARAM_OUTPUT_TYPE(rk_vec3_int10);
|
||||
RK_CHECK_PARAM_OUTPUT_TYPE(rk_vec3_uint10);
|
||||
RK_CHECK_PARAM_OUTPUT_TYPE(rk_mat3_float);
|
||||
RK_CHECK_PARAM_OUTPUT_TYPE(rk_mat3_int10);
|
||||
|
||||
typedef void (*rk_packer)(
|
||||
unsigned const, // count
|
||||
rk_ushort const * const, // indices
|
||||
rk_ubyte *, // dst
|
||||
rk_ubyte const * const); // src
|
||||
rk_instance_index const * const, // indices
|
||||
rk_param_output *, // dst
|
||||
rk_param_input const * const); // src
|
||||
|
||||
struct rk_parameter {
|
||||
mutable bool dirty;
|
||||
@ -98,10 +118,18 @@ struct rk_parameter {
|
||||
unsigned offset;
|
||||
unsigned src_size;
|
||||
unsigned dst_size;
|
||||
rk_ubyte * source;
|
||||
unsigned src_len;
|
||||
unsigned dst_len;
|
||||
rk_param_input * source;
|
||||
rk_packer packer;
|
||||
};
|
||||
|
||||
struct rk_bucket {
|
||||
unsigned size;
|
||||
unsigned count;
|
||||
rk_instance_index * indices;
|
||||
};
|
||||
|
||||
enum rk_batch_state {
|
||||
RK_BATCH_STATE_EMPTY = 0,
|
||||
RK_BATCH_STATE_FILLED = 1,
|
||||
@ -118,8 +146,8 @@ struct rk_batch {
|
||||
unsigned nparams;
|
||||
rk_vertices const * vertices;
|
||||
rk_instance_flags * flags;
|
||||
rk_ushort * meshes;
|
||||
rk_ushort * indices;
|
||||
rk_mesh_index * meshes;
|
||||
rk_instance_index * indices;
|
||||
rk_command * commands;
|
||||
rk_parameter * params;
|
||||
GLuint vertex_array;
|
||||
|
Reference in New Issue
Block a user