Compare commits
No commits in common. "81d52086fe73507fc53317f7b9a2706c6940b0b2" and "f463db316fc9eae9f26a83605d1c05f662b6e7de" have entirely different histories.
81d52086fe
...
f463db316f
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ cpp/math.cpp
|
|||||||
|
|
||||||
OUTPUTFILE = engine.so
|
OUTPUTFILE = engine.so
|
||||||
|
|
||||||
CXXFLAGS = -std=c++17 -Wall -Werror -O2 -msse2 -fpic -flto -fno-rtti -fno-exceptions
|
CXXFLAGS = -Wall -Werror -O2 -msse2 -ffast-math -fpic -flto -fno-rtti -fno-exceptions
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: clean $(OUTPUTFILE)
|
all: clean $(OUTPUTFILE)
|
||||||
|
@ -16,11 +16,10 @@
|
|||||||
#ifndef RK_ENGINE_CMP_MEMCPY_H
|
#ifndef RK_ENGINE_CMP_MEMCPY_H
|
||||||
#define RK_ENGINE_CMP_MEMCPY_H
|
#define RK_ENGINE_CMP_MEMCPY_H
|
||||||
|
|
||||||
#include "../types.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
template<typename _small>
|
template<typename _small>
|
||||||
[[RK_FAST]]
|
bool _rk_cmp_memcpy_small(
|
||||||
inline bool _rk_cmp_memcpy_small(
|
|
||||||
_small * __restrict dst,
|
_small * __restrict dst,
|
||||||
_small const * __restrict src,
|
_small const * __restrict src,
|
||||||
unsigned count) {
|
unsigned count) {
|
||||||
@ -33,8 +32,7 @@ inline bool _rk_cmp_memcpy_small(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename _big, typename _small>
|
template<typename _big, typename _small>
|
||||||
[[RK_FAST, RK_FLATTEN]]
|
bool _rk_cmp_memcpy_big(
|
||||||
inline bool _rk_cmp_memcpy_big(
|
|
||||||
_small * const __restrict _dst,
|
_small * const __restrict _dst,
|
||||||
_small const * const __restrict _src,
|
_small const * const __restrict _src,
|
||||||
unsigned const _count) {
|
unsigned const _count) {
|
||||||
@ -63,7 +61,6 @@ inline bool _rk_cmp_memcpy_big(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename _small>
|
template<typename _small>
|
||||||
[[RK_HOT, RK_FAST, RK_FLATTEN]]
|
|
||||||
bool rk_cmp_memcpy(
|
bool rk_cmp_memcpy(
|
||||||
_small * const __restrict _dst,
|
_small * const __restrict _dst,
|
||||||
_small const * const __restrict _src,
|
_small const * const __restrict _src,
|
@ -85,15 +85,22 @@ enum : rk_uint {
|
|||||||
|
|
||||||
typedef rk_ushort rk_vertex_index;
|
typedef rk_ushort rk_vertex_index;
|
||||||
typedef rk_ushort rk_mesh_index;
|
typedef rk_ushort rk_mesh_index;
|
||||||
typedef rk_uint rk_vertex_input;
|
|
||||||
typedef rk_uint rk_vertex_output;
|
|
||||||
typedef rk_vertex_input rk_param_input;
|
|
||||||
|
|
||||||
struct rk_mesh {
|
struct rk_mesh {
|
||||||
rk_uint base_index;
|
rk_uint base_index;
|
||||||
rk_uint ntriangles;
|
rk_uint ntriangles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// param input types must be size compatible with an array of rk_param_input
|
||||||
|
typedef rk_uint rk_param_input;
|
||||||
|
|
||||||
|
template<typename _input_type>
|
||||||
|
void rk_param_get_input_size(unsigned & _size, unsigned & _len) {
|
||||||
|
static_assert((sizeof(_input_type) % sizeof(rk_param_input)) == 0);
|
||||||
|
_size = sizeof(_input_type);
|
||||||
|
_len = sizeof(_input_type) / sizeof(rk_param_input);
|
||||||
|
}
|
||||||
|
|
||||||
RK_EXPORT void rk_render_initialize(
|
RK_EXPORT void rk_render_initialize(
|
||||||
rk_bool debug);
|
rk_bool debug);
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "../render.hpp"
|
||||||
#include "render_opengles.hpp"
|
#include "render_opengles.hpp"
|
||||||
#include "vertex_format_opengles.hpp"
|
|
||||||
#include "../display/display_glx.hpp"
|
#include "../display/display_glx.hpp"
|
||||||
#include "../utils/cmp_memcpy.hpp"
|
#include "../cmp_memcpy.hpp"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -331,13 +331,13 @@ rk_vertices_t rk_create_vertices(
|
|||||||
for (rk_vertex_format const * f = format; *f; ++f, ++format_size) {
|
for (rk_vertex_format const * f = format; *f; ++f, ++format_size) {
|
||||||
switch (*f & RK_VERTEX_FORMAT_MASK) {
|
switch (*f & RK_VERTEX_FORMAT_MASK) {
|
||||||
case RK_VERTEX_FORMAT_VEC3_FLOAT:
|
case RK_VERTEX_FORMAT_VEC3_FLOAT:
|
||||||
vertex_size += rk_vec3_float::get_output_size();
|
vertex_size += sizeof(rk_vec3_float);
|
||||||
break;
|
break;
|
||||||
case RK_VERTEX_FORMAT_VEC3_INT10:
|
case RK_VERTEX_FORMAT_VEC3_INT10:
|
||||||
vertex_size += rk_vec3_int10::get_output_size();
|
vertex_size += sizeof(rk_vec3_int10);
|
||||||
break;
|
break;
|
||||||
case RK_VERTEX_FORMAT_VEC3_UINT10:
|
case RK_VERTEX_FORMAT_VEC3_UINT10:
|
||||||
vertex_size += rk_vec3_uint10::get_output_size();
|
vertex_size += sizeof(rk_vec3_uint10);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rk_printf("rk_create_vertices(): invalid vertex format.");
|
rk_printf("rk_create_vertices(): invalid vertex format.");
|
||||||
@ -421,6 +421,143 @@ static void rk_buckets_alloc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define rk_pack_short_norm(_f) (static_cast<rk_int>((_f) * 32767.f) & 65536)
|
||||||
|
// #define rk_pack_short_norm(_f) (((static_cast<rk_int>((_f) * 32767.f) - 1) / 2) & 65535)
|
||||||
|
|
||||||
|
#define rk_pack_int10_norm(_f) (static_cast<rk_int>((_f) * 511.f) & 1023)
|
||||||
|
// #define rk_pack_int10_norm(_f) (((static_cast<rk_int>((_f) * 1023.f) - 1) / 2) & 1023)
|
||||||
|
|
||||||
|
static void rk_pack_vec3_float(
|
||||||
|
unsigned const 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_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||||
|
*dst = src[*index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_vec3_short(
|
||||||
|
unsigned const 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_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);
|
||||||
|
dst->z = static_cast<rk_short>(input.z);
|
||||||
|
dst->pad = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_vec3_short_norm(
|
||||||
|
unsigned const 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) rk_pack_short_norm(s)
|
||||||
|
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);
|
||||||
|
dst->z = _convert(input.z);
|
||||||
|
dst->pad = 0;
|
||||||
|
}
|
||||||
|
#undef _convert
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_vec3_int10(
|
||||||
|
unsigned const 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_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);
|
||||||
|
}
|
||||||
|
#undef _convert
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_vec3_int10_norm(
|
||||||
|
unsigned const 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) rk_pack_int10_norm(s)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#undef _convert
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_mat3_float(
|
||||||
|
unsigned const 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_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
||||||
|
*dst = src[*index];
|
||||||
|
}
|
||||||
|
#undef _convert
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_mat3_int10(
|
||||||
|
unsigned const 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_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);
|
||||||
|
dst->z = _convert(input.z.x) | (_convert(input.z.y) << 10) | (_convert(input.z.z) << 20);
|
||||||
|
}
|
||||||
|
#undef _convert
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rk_pack_mat3_int10_norm(
|
||||||
|
unsigned const 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) rk_pack_int10_norm(s)
|
||||||
|
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);
|
||||||
|
dst->z = _convert(input.z.x) | (_convert(input.z.y) << 10) | (_convert(input.z.z) << 20);
|
||||||
|
}
|
||||||
|
#undef _convert
|
||||||
|
}
|
||||||
|
|
||||||
rk_batch_t rk_create_batch(
|
rk_batch_t rk_create_batch(
|
||||||
rk_vertices_t _vertices,
|
rk_vertices_t _vertices,
|
||||||
rk_uint max_size,
|
rk_uint max_size,
|
||||||
@ -434,13 +571,13 @@ rk_batch_t rk_create_batch(
|
|||||||
for (rk_vertex_format const * f = vertices->format; *f; ++f) {
|
for (rk_vertex_format const * f = vertices->format; *f; ++f) {
|
||||||
switch (*f & RK_VERTEX_FORMAT_MASK) {
|
switch (*f & RK_VERTEX_FORMAT_MASK) {
|
||||||
case RK_VERTEX_FORMAT_VEC3_FLOAT:
|
case RK_VERTEX_FORMAT_VEC3_FLOAT:
|
||||||
vertex_size += rk_vec3_float::get_output_size();
|
vertex_size += sizeof(rk_vec3_float);
|
||||||
break;
|
break;
|
||||||
case RK_VERTEX_FORMAT_VEC3_INT10:
|
case RK_VERTEX_FORMAT_VEC3_INT10:
|
||||||
vertex_size += rk_vec3_int10::get_output_size();
|
vertex_size += sizeof(rk_vec3_int10);
|
||||||
break;
|
break;
|
||||||
case RK_VERTEX_FORMAT_VEC3_UINT10:
|
case RK_VERTEX_FORMAT_VEC3_UINT10:
|
||||||
vertex_size += rk_vec3_uint10::get_output_size();
|
vertex_size += sizeof(rk_vec3_uint10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,19 +587,19 @@ rk_batch_t rk_create_batch(
|
|||||||
for (rk_param_format const * f = params_format; *f; ++f, ++nparams) {
|
for (rk_param_format const * f = params_format; *f; ++f, ++nparams) {
|
||||||
switch (*f & RK_PARAM_FORMAT_MASK) {
|
switch (*f & RK_PARAM_FORMAT_MASK) {
|
||||||
case RK_PARAM_FORMAT_VEC3_FLOAT:
|
case RK_PARAM_FORMAT_VEC3_FLOAT:
|
||||||
params_size += rk_vec3_float::get_output_size();
|
params_size += sizeof(rk_vec3_float);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_VEC3_SHORT:
|
case RK_PARAM_FORMAT_VEC3_SHORT:
|
||||||
params_size += rk_vec3_short::get_output_size();
|
params_size += sizeof(rk_vec3_short);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_VEC3_INT10:
|
case RK_PARAM_FORMAT_VEC3_INT10:
|
||||||
params_size += rk_vec3_int10::get_output_size();
|
params_size += sizeof(rk_vec3_int10);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_MAT3_FLOAT:
|
case RK_PARAM_FORMAT_MAT3_FLOAT:
|
||||||
params_size += rk_mat3_float::get_output_size();
|
params_size += sizeof(rk_mat3_float);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_MAT3_INT10:
|
case RK_PARAM_FORMAT_MAT3_INT10:
|
||||||
params_size += rk_mat3_int10::get_output_size();
|
params_size += sizeof(rk_mat3_int10);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rk_printf("rk_create_batch(): invalid param format.");
|
rk_printf("rk_create_batch(): invalid param format.");
|
||||||
@ -531,19 +668,19 @@ rk_batch_t rk_create_batch(
|
|||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, offset);
|
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, offset);
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
offset += rk_vec3_float::get_output_size();
|
offset += sizeof(rk_vec3_float);
|
||||||
break;
|
break;
|
||||||
case RK_VERTEX_FORMAT_VEC3_INT10:
|
case RK_VERTEX_FORMAT_VEC3_INT10:
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, offset);
|
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, offset);
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
offset += rk_vec3_int10::get_output_size();
|
offset += sizeof(rk_vec3_int10);
|
||||||
break;
|
break;
|
||||||
case RK_VERTEX_FORMAT_VEC3_UINT10:
|
case RK_VERTEX_FORMAT_VEC3_UINT10:
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 4, GL_UNSIGNED_INT_2_10_10_10_REV, norm, offset);
|
glVertexAttribFormat(attrib, 4, GL_UNSIGNED_INT_2_10_10_10_REV, norm, offset);
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
offset += rk_vec3_uint10::get_output_size();
|
offset += sizeof(rk_vec3_uint10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -558,66 +695,64 @@ rk_batch_t rk_create_batch(
|
|||||||
param->offset = offset;
|
param->offset = offset;
|
||||||
switch (*f & RK_PARAM_FORMAT_MASK) {
|
switch (*f & RK_PARAM_FORMAT_MASK) {
|
||||||
case RK_PARAM_FORMAT_VEC3_FLOAT:
|
case RK_PARAM_FORMAT_VEC3_FLOAT:
|
||||||
param->src_size = rk_vec3_float::get_input_size();
|
rk_param_get_input_size<rk_vec3>(param->src_size, param->src_len);
|
||||||
param->dst_size = rk_vec3_float::get_output_size();
|
rk_param_get_output_size<rk_vec3_float>(param->dst_size, param->dst_len);
|
||||||
param->packer = rk_vec3_float::param_packer;
|
param->packer = rk_pack_vec3_float;
|
||||||
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, 0);
|
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, 0);
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_VEC3_SHORT:
|
case RK_PARAM_FORMAT_VEC3_SHORT:
|
||||||
param->src_size = rk_vec3_short::get_input_size();
|
rk_param_get_input_size<rk_vec3>(param->src_size, param->src_len);
|
||||||
param->dst_size = rk_vec3_short::get_output_size();
|
rk_param_get_output_size<rk_vec3_short>(param->dst_size, param->dst_len);
|
||||||
param->packer = norm ? rk_vec3_short_norm::param_packer : rk_vec3_short::param_packer;
|
param->packer = norm ? rk_pack_vec3_short_norm : rk_pack_vec3_short;
|
||||||
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 3, GL_SHORT, norm, 0);
|
glVertexAttribFormat(attrib, 3, GL_SHORT, norm, 0);
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_VEC3_INT10:
|
case RK_PARAM_FORMAT_VEC3_INT10:
|
||||||
param->src_size = rk_vec3_int10::get_input_size();
|
rk_param_get_input_size<rk_vec3>(param->src_size, param->src_len);
|
||||||
param->dst_size = rk_vec3_int10::get_output_size();
|
rk_param_get_output_size<rk_vec3_int10>(param->dst_size, param->dst_len);
|
||||||
param->packer = norm ? rk_vec3_int10_norm::param_packer : rk_vec3_int10::param_packer;
|
param->packer = norm ? rk_pack_vec3_int10_norm : rk_pack_vec3_int10;
|
||||||
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, 0);
|
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, 0);
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_MAT3_FLOAT:
|
case RK_PARAM_FORMAT_MAT3_FLOAT:
|
||||||
param->src_size = rk_mat3_float::get_input_size();
|
rk_param_get_input_size<rk_mat3>(param->src_size, param->src_len);
|
||||||
param->dst_size = rk_mat3_float::get_output_size();
|
rk_param_get_output_size<rk_mat3_float>(param->dst_size, param->dst_len);
|
||||||
param->packer = rk_mat3_float::param_packer;
|
param->packer = rk_pack_mat3_float;
|
||||||
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, rk_mat3_float::get_output_offset(0));
|
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, offsetof(rk_mat3_float, x));
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, rk_mat3_float::get_output_offset(1));
|
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, offsetof(rk_mat3_float, y));
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, rk_mat3_float::get_output_offset(2));
|
glVertexAttribFormat(attrib, 3, GL_FLOAT, GL_FALSE, offsetof(rk_mat3_float, z));
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
break;
|
break;
|
||||||
case RK_PARAM_FORMAT_MAT3_INT10:
|
case RK_PARAM_FORMAT_MAT3_INT10:
|
||||||
param->src_size = rk_mat3_int10::get_input_size();
|
rk_param_get_input_size<rk_mat3>(param->src_size, param->src_len);
|
||||||
param->dst_size = rk_mat3_int10::get_output_size();
|
rk_param_get_output_size<rk_mat3_int10>(param->dst_size, param->dst_len);
|
||||||
param->packer = norm ? rk_mat3_int10_norm::param_packer : rk_mat3_int10::param_packer;
|
param->packer = norm ? rk_pack_mat3_int10_norm : rk_pack_mat3_int10;
|
||||||
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
glBindVertexBuffer(binding, batch->params_buffer, param->offset, param->dst_size);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, rk_mat3_int10::get_output_offset(0));
|
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, offsetof(rk_mat3_int10, x));
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, rk_mat3_int10::get_output_offset(1));
|
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, offsetof(rk_mat3_int10, y));
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
glEnableVertexAttribArray(attrib);
|
glEnableVertexAttribArray(attrib);
|
||||||
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, rk_mat3_int10::get_output_offset(2));
|
glVertexAttribFormat(attrib, 4, GL_INT_2_10_10_10_REV, norm, offsetof(rk_mat3_int10, z));
|
||||||
glVertexAttribBinding(attrib++, binding);
|
glVertexAttribBinding(attrib++, binding);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
glVertexBindingDivisor(binding, 1);
|
glVertexBindingDivisor(binding, 1);
|
||||||
param->src_len = param->src_size / sizeof(rk_param_output);
|
|
||||||
param->dst_len = param->dst_size / sizeof(rk_param_output);
|
|
||||||
param->source = new rk_param_input[max_size * param->src_len];
|
param->source = new rk_param_input[max_size * param->src_len];
|
||||||
memset(param->source, 0xFF, max_size * param->src_size);
|
memset(param->source, 0xFF, max_size * param->src_size);
|
||||||
offset += max_size * param->dst_size;
|
offset += max_size * param->dst_size;
|
||||||
@ -628,7 +763,6 @@ rk_batch_t rk_create_batch(
|
|||||||
return reinterpret_cast<rk_batch_t>(batch);
|
return reinterpret_cast<rk_batch_t>(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[RK_HOT, RK_FAST]]
|
|
||||||
static void rk_sort_batch(
|
static void rk_sort_batch(
|
||||||
rk_batch const & batch) {
|
rk_batch const & batch) {
|
||||||
rk_bucket const * const last_bucket = rk_buckets + batch.vertices->nmeshes;
|
rk_bucket const * const last_bucket = rk_buckets + batch.vertices->nmeshes;
|
||||||
@ -665,7 +799,6 @@ static void rk_sort_batch(
|
|||||||
batch.state = RK_BATCH_STATE_SORTED;
|
batch.state = RK_BATCH_STATE_SORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[RK_HOT, RK_FAST]]
|
|
||||||
static void rk_pack_batch(
|
static void rk_pack_batch(
|
||||||
rk_batch const & batch) {
|
rk_batch const & batch) {
|
||||||
if (batch.nparams) {
|
if (batch.nparams) {
|
||||||
@ -689,7 +822,6 @@ static void rk_pack_batch(
|
|||||||
batch.state = RK_BATCH_STATE_PACKED;
|
batch.state = RK_BATCH_STATE_PACKED;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[RK_HOT, RK_FAST]]
|
|
||||||
void rk_fill_batch(
|
void rk_fill_batch(
|
||||||
rk_batch_t _batch,
|
rk_batch_t _batch,
|
||||||
rk_uint count,
|
rk_uint count,
|
||||||
|
@ -16,15 +16,12 @@
|
|||||||
#ifndef _RK_ENGINE_RENDER_OPENGLES_H
|
#ifndef _RK_ENGINE_RENDER_OPENGLES_H
|
||||||
#define _RK_ENGINE_RENDER_OPENGLES_H
|
#define _RK_ENGINE_RENDER_OPENGLES_H
|
||||||
|
|
||||||
#include "../render.hpp"
|
#include "../types.hpp"
|
||||||
|
#include "../math.hpp"
|
||||||
#include <GLES3/gl32.h>
|
#include <GLES3/gl32.h>
|
||||||
#include <GLES3/gl3ext.h>
|
#include <GLES3/gl3ext.h>
|
||||||
#include <GLES3/gl3platform.h>
|
#include <GLES3/gl3platform.h>
|
||||||
|
|
||||||
static_assert(sizeof(rk_vertex_output) == 4);
|
|
||||||
|
|
||||||
typedef rk_vertex_output rk_param_output;
|
|
||||||
|
|
||||||
struct rk_shader {
|
struct rk_shader {
|
||||||
GLuint vertex;
|
GLuint vertex;
|
||||||
GLuint fragment;
|
GLuint fragment;
|
||||||
@ -62,11 +59,53 @@ struct rk_command {
|
|||||||
GLuint base_instance;
|
GLuint base_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// param output types must be size compatible with an array of rk_param_output
|
||||||
|
typedef rk_uint rk_param_output;
|
||||||
|
|
||||||
|
template<typename _output_type>
|
||||||
|
void rk_param_get_output_size(unsigned & _size, unsigned & _len) {
|
||||||
|
static_assert((sizeof(_output_type) % sizeof(rk_param_output)) == 0);
|
||||||
|
_size = sizeof(_output_type);
|
||||||
|
_len = sizeof(_output_type) / 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;
|
||||||
|
rk_short z;
|
||||||
|
rk_short pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef rk_int rk_vec3_int10;
|
||||||
|
typedef rk_uint rk_vec3_uint10;
|
||||||
|
|
||||||
|
struct rk_mat3_float {
|
||||||
|
rk_vec3_float x;
|
||||||
|
rk_vec3_float y;
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
typedef void (*rk_packer)(
|
typedef void (*rk_packer)(
|
||||||
unsigned const, // count
|
unsigned const, // count
|
||||||
rk_instance_index const * const __restrict, // indices
|
rk_instance_index const * const, // indices
|
||||||
rk_param_output * __restrict, // dst
|
rk_param_output *, // dst
|
||||||
rk_param_input const * const __restrict); // src
|
rk_param_input const * const); // src
|
||||||
|
|
||||||
struct rk_parameter {
|
struct rk_parameter {
|
||||||
mutable bool dirty;
|
mutable bool dirty;
|
||||||
|
@ -1,230 +0,0 @@
|
|||||||
// Copyright (C) 2023 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_VERTEX_FORMAT_H
|
|
||||||
#define RK_ENGINE_VERTEX_FORMAT_H
|
|
||||||
|
|
||||||
#include "render_opengles.hpp"
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace rk_vertex {
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
|
|
||||||
template<typename _type>
|
|
||||||
struct alignas(alignof(_type)) rk_input {
|
|
||||||
_type input;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _type, typename _input, bool _signed, bool _normalized>
|
|
||||||
struct alignas(alignof(_type)) rk_output {
|
|
||||||
_type output;
|
|
||||||
|
|
||||||
[[RK_FAST]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input<_input> const & __restrict src) {
|
|
||||||
output = static_cast<_type>(src.input);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _type, bool _signed>
|
|
||||||
struct alignas(alignof(_type)) rk_output<_type, rk_float, _signed, true> {
|
|
||||||
_type output;
|
|
||||||
|
|
||||||
[[RK_FAST]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input<rk_float> const & __restrict src) {
|
|
||||||
enum : _type { max = std::numeric_limits<_type>::max() };
|
|
||||||
output = static_cast<_type>(src.input * static_cast<float>(max));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#pragma pack(4)
|
|
||||||
|
|
||||||
template<typename _input, unsigned _cols>
|
|
||||||
struct alignas(4) rk_input_row {
|
|
||||||
rk_input<_input> input_col[_cols];
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _output, typename _input, unsigned _cols, bool _signed, bool _normalized>
|
|
||||||
struct alignas(4) rk_output_row {
|
|
||||||
rk_output<_output, _input, _signed, _normalized> output_col[_cols];
|
|
||||||
|
|
||||||
[[RK_FAST, RK_FLATTEN, RK_UNROLLED]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_row<_input, _cols> const & __restrict src) {
|
|
||||||
for (unsigned col = 0; col < _cols; ++col) {
|
|
||||||
output_col[col].convert(src.input_col[col]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _input, unsigned _cols, bool _signed, bool _normalized>
|
|
||||||
struct alignas(4) rk_output_row<rk_packed<_signed, _cols>, _input, _cols, _signed, _normalized> {
|
|
||||||
rk_output<rk_packed<_signed, _cols>, _input, _signed, _normalized> output_cols;
|
|
||||||
|
|
||||||
[[RK_FAST, RK_FLATTEN]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_row<_input, _cols> const & __restrict src) {
|
|
||||||
output_cols.convert(src);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _input, unsigned _cols, unsigned _rows>
|
|
||||||
struct alignas(4) rk_input_format {
|
|
||||||
rk_input_row<_input, _cols> input_row[_rows];
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _output, typename _input, unsigned _cols, unsigned _rows, bool _signed, bool _normalized>
|
|
||||||
struct alignas(4) rk_output_format {
|
|
||||||
rk_output_row<_output, _input, _cols, _signed, _normalized> output_row[_rows];
|
|
||||||
|
|
||||||
[[RK_FAST, RK_FLATTEN, RK_UNROLLED]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_format<_input, _cols, _rows> const & __restrict src) {
|
|
||||||
for (unsigned row = 0; row < _rows; ++row) {
|
|
||||||
output_row[row].convert(src.input_row[row]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _input, bool _signed, bool _normalized>
|
|
||||||
struct alignas(alignof(rk_packed<_signed, 3>)) rk_output<rk_packed<_signed, 3>, _input, _signed, _normalized> {
|
|
||||||
rk_packed<_signed, 3> output;
|
|
||||||
|
|
||||||
[[RK_FAST]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_row<_input, 3> const & __restrict src) {
|
|
||||||
typedef typename rk_packed<_signed, 3>::type packed_type;
|
|
||||||
output.packed =
|
|
||||||
((static_cast<packed_type>(src.input_col[0].input) & 1023)) |
|
|
||||||
((static_cast<packed_type>(src.input_col[1].input) & 1023) << 10) |
|
|
||||||
((static_cast<packed_type>(src.input_col[2].input) & 1023) << 20);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _input, bool _signed, bool _normalized>
|
|
||||||
struct alignas(alignof(rk_packed<_signed, 4>)) rk_output<rk_packed<_signed, 4>, _input, _signed, _normalized> {
|
|
||||||
rk_packed<_signed, 4> output;
|
|
||||||
|
|
||||||
[[RK_FAST]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_row<_input, 4> const & __restrict src) {
|
|
||||||
typedef typename rk_packed<_signed, 4>::type packed_type;
|
|
||||||
output.packed =
|
|
||||||
((static_cast<packed_type>(src.input_col[0].input) & 1023)) |
|
|
||||||
((static_cast<packed_type>(src.input_col[1].input) & 1023) << 10) |
|
|
||||||
((static_cast<packed_type>(src.input_col[2].input) & 1023) << 20) |
|
|
||||||
((static_cast<packed_type>(src.input_col[3].input) & 3) << 30);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct alignas(alignof(rk_packed<true, 3>)) rk_output<rk_packed<true, 3>, rk_float, true, true> {
|
|
||||||
rk_packed<true, 3> output;
|
|
||||||
|
|
||||||
[[RK_FAST]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_row<rk_float, 3> const & __restrict src) {
|
|
||||||
output.packed =
|
|
||||||
((static_cast<rk_int>(src.input_col[0].input * 511.f) & 1023)) |
|
|
||||||
((static_cast<rk_int>(src.input_col[1].input * 511.f) & 1023) << 10) |
|
|
||||||
((static_cast<rk_int>(src.input_col[2].input * 511.f) & 1023) << 20);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct alignas(alignof(rk_packed<true, 4>)) rk_output<rk_packed<true, 4>, rk_float, true, true> {
|
|
||||||
rk_packed<true, 4> output;
|
|
||||||
|
|
||||||
[[RK_FAST]]
|
|
||||||
inline void convert(
|
|
||||||
rk_input_row<rk_float, 4> const & __restrict src) {
|
|
||||||
output.packed =
|
|
||||||
((static_cast<rk_uint>(src.input_col[0].input * 511.f) & 1023)) |
|
|
||||||
((static_cast<rk_uint>(src.input_col[1].input * 511.f) & 1023) << 10) |
|
|
||||||
((static_cast<rk_uint>(src.input_col[2].input * 511.f) & 1023) << 20) |
|
|
||||||
((static_cast<rk_uint>(src.input_col[3].input) & 3) << 30);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
template<typename _output, typename _input, unsigned _cols, unsigned _rows, bool _signed, bool _normalized>
|
|
||||||
struct rk_format {
|
|
||||||
typedef rk_input<_input> input;
|
|
||||||
typedef rk_output<_output, input, _signed, _normalized> output;
|
|
||||||
|
|
||||||
typedef rk_input_row<_input, _cols> input_row;
|
|
||||||
typedef rk_output_row<_output, _input, _cols, _signed, _normalized> output_row;
|
|
||||||
|
|
||||||
typedef rk_input_format<_input, _cols, _rows> input_format;
|
|
||||||
typedef rk_output_format<_output, _input, _cols, _rows, _signed, _normalized> output_format;
|
|
||||||
|
|
||||||
static_assert(sizeof(input) == sizeof(_input));
|
|
||||||
static_assert(sizeof(output) == sizeof(_output));
|
|
||||||
static_assert((sizeof(input_row) % sizeof(rk_vertex_input)) == 0);
|
|
||||||
static_assert((sizeof(output_row) % sizeof(rk_vertex_output)) == 0);
|
|
||||||
static_assert((sizeof(input_format) % sizeof(rk_vertex_input)) == 0);
|
|
||||||
static_assert((sizeof(output_format) % sizeof(rk_vertex_output)) == 0);
|
|
||||||
|
|
||||||
static unsigned get_input_size() {
|
|
||||||
return sizeof(input_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned get_output_size() {
|
|
||||||
return sizeof(output_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned get_output_offset(unsigned const index) {
|
|
||||||
return index * sizeof(output_row);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[RK_FAST, RK_FLATTEN]]
|
|
||||||
inline static void convert(
|
|
||||||
output_format & __restrict dst,
|
|
||||||
input_format const & __restrict src) {
|
|
||||||
dst.convert(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[RK_HOT, RK_FAST, RK_FLATTEN]]
|
|
||||||
static void param_packer(
|
|
||||||
unsigned const 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;
|
|
||||||
output_format * __restrict dst = reinterpret_cast<output_format *>(_dst);
|
|
||||||
input_format const * const __restrict src = reinterpret_cast<input_format const *>(_src);
|
|
||||||
for (rk_instance_index const * __restrict index = indices; index < last_index; ++index, ++dst) {
|
|
||||||
dst->convert(src[*index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namepace rk_vertex
|
|
||||||
|
|
||||||
typedef rk_vertex::rk_format<rk_float, rk_float, 3, 1, true, false> rk_vec3_float;
|
|
||||||
typedef rk_vertex::rk_format<rk_short, rk_float, 3, 1, true, false> rk_vec3_short;
|
|
||||||
typedef rk_vertex::rk_format<rk_short, rk_float, 3, 1, true, true> rk_vec3_short_norm;
|
|
||||||
typedef rk_vertex::rk_format<rk_packed<true, 3>, rk_float, 3, 1, true, false> rk_vec3_int10;
|
|
||||||
typedef rk_vertex::rk_format<rk_packed<true, 3>, rk_float, 3, 1, true, true> rk_vec3_int10_norm;
|
|
||||||
typedef rk_vertex::rk_format<rk_packed<true, 3>, rk_float, 3, 1, true, false> rk_vec3_uint10;
|
|
||||||
typedef rk_vertex::rk_format<rk_packed<true, 3>, rk_float, 3, 1, true, true> rk_vec3_uint10_norm;
|
|
||||||
typedef rk_vertex::rk_format<rk_float, rk_float, 3, 3, true, false> rk_mat3_float;
|
|
||||||
typedef rk_vertex::rk_format<rk_packed<true, 3>, rk_float, 3, 3, true, false> rk_mat3_int10;
|
|
||||||
typedef rk_vertex::rk_format<rk_packed<true, 3>, rk_float, 3, 3, true, true> rk_mat3_int10_norm;
|
|
||||||
|
|
||||||
#endif // RK_ENGINE_VERTEX_FORMAT_H
|
|
@ -20,11 +20,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define RK_EXPORT extern "C"
|
#define RK_EXPORT extern "C"
|
||||||
#define RK_HOT gnu::hot
|
|
||||||
#define RK_FLATTEN gnu::flatten
|
|
||||||
#define RK_UNROLLED gnu::optimize("unroll-loops")
|
|
||||||
#define RK_FAST gnu::optimize("Ofast")
|
|
||||||
#define RK_INVALID_HANDLE nullptr
|
|
||||||
#define RK_FLAG(_bit) (1 << (_bit))
|
#define RK_FLAG(_bit) (1 << (_bit))
|
||||||
|
|
||||||
typedef bool rk_bool;
|
typedef bool rk_bool;
|
||||||
@ -43,28 +38,6 @@ typedef unsigned __int128 rk_ullong;
|
|||||||
typedef float rk_float;
|
typedef float rk_float;
|
||||||
typedef void * rk_handle_t;
|
typedef void * rk_handle_t;
|
||||||
|
|
||||||
static_assert(sizeof(rk_char) == 1);
|
#define RK_INVALID_HANDLE nullptr
|
||||||
static_assert(sizeof(rk_wchar) == 4);
|
|
||||||
static_assert(sizeof(rk_float) == 4);
|
|
||||||
|
|
||||||
#pragma pack(push, 4)
|
|
||||||
|
|
||||||
template<bool _signed, unsigned _cols>
|
|
||||||
struct rk_packed {
|
|
||||||
};
|
|
||||||
|
|
||||||
template<unsigned _cols>
|
|
||||||
struct alignas(alignof(rk_int)) rk_packed<true, _cols> {
|
|
||||||
typedef rk_int type;
|
|
||||||
rk_int packed;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<unsigned _cols>
|
|
||||||
struct alignas(alignof(rk_uint)) rk_packed<false, _cols> {
|
|
||||||
typedef rk_uint type;
|
|
||||||
rk_uint packed;
|
|
||||||
};
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#endif // _RK_ENGINE_TYPES_H
|
#endif // _RK_ENGINE_TYPES_H
|
||||||
|
Loading…
Reference in New Issue
Block a user