Wow! I removed std140 padding of matrices in geom.h and nothing broke
This commit is contained in:
parent
5b8ecd8020
commit
8cc0b43a5d
@ -152,21 +152,13 @@ NODISCARD VecU8 codegen_name_xmatnm(SpanU8 xmat, int cols, int rows) {
|
||||
return VecU8_fmt("%s%cx%c", xmat, '0' + cols, '0' + rows);
|
||||
}
|
||||
|
||||
void codegen_append_xmatnm_struct_and_methods(VecU8* res,
|
||||
SpanU8 xmat, SpanU8 xvec, SpanU8 memb, int cols, int rows, int sizeof_member
|
||||
) {
|
||||
void codegen_append_xmatnm_struct_and_methods(VecU8* res, SpanU8 xmat, SpanU8 xvec, SpanU8 memb, int cols, int rows) {
|
||||
VecU8 xmatnm = codegen_name_xmatnm(xmat, cols, rows);
|
||||
VecU8 xvecm = codegen_name_xvecn(xvec, rows);
|
||||
|
||||
/* Structure xmatnm. todo: NO, std140 is NOT OUR EVERYTHING. TODO: get rid of padding
|
||||
* With columns padded to 16 bytes (for std140, std140 is our everything) */
|
||||
int sv = (rows * sizeof_member) % 16;
|
||||
VecU8_append_cstr(res, "typedef struct {\n");
|
||||
for (int x = 0; x < cols; x++) {
|
||||
VecU8_append_fmt(res, SPACE "%r %s;\n", xvecm, vec_field_name(x));
|
||||
if (sv) {
|
||||
VecU8_append_fmt(res, SPACE "char _padding_%u[%u];\n", (U64)x, (U64)(16 - sv));
|
||||
}
|
||||
}
|
||||
VecU8_append_fmt(res, "} %r;\n\n", xmatnm);
|
||||
/* xmatnm_new method */
|
||||
@ -503,12 +495,10 @@ void codegen_append_xvec234_structs_and_cool_methods(VecU8* res, SpanU8 xvec, Sp
|
||||
codegen_append_xvec3_method_cross(res, xvec);
|
||||
}
|
||||
|
||||
void codegen_append_xmat234x234_structs_and_base_methods(VecU8* res,
|
||||
SpanU8 xmat, SpanU8 xvec, SpanU8 memb, int sizeof_member
|
||||
){
|
||||
void codegen_append_xmat234x234_structs_and_base_methods(VecU8* res,SpanU8 xmat, SpanU8 xvec, SpanU8 memb){
|
||||
for (int cols = 2; cols <= 4; cols++) {
|
||||
for (int rows = 2; rows <= 4; rows++) {
|
||||
codegen_append_xmatnm_struct_and_methods(res, xmat, xvec, memb, cols, rows, sizeof_member);
|
||||
codegen_append_xmatnm_struct_and_methods(res, xmat, xvec, memb, cols, rows);
|
||||
}
|
||||
}
|
||||
for (int cols = 2; cols <= 4; cols++) {
|
||||
@ -529,10 +519,8 @@ void codegen_append_xmat234x234_structs_and_base_methods(VecU8* res,
|
||||
codegen_append_xmat234_det_method(res, xmat, xvec, memb);
|
||||
}
|
||||
|
||||
void codegen_append_xmat234x234_structs_and_cool_methods(VecU8* res,
|
||||
SpanU8 xmat, SpanU8 xvec, SpanU8 memb, int sizeof_member
|
||||
){
|
||||
codegen_append_xmat234x234_structs_and_base_methods(res, xmat, xvec, memb, sizeof_member);
|
||||
void codegen_append_xmat234x234_structs_and_cool_methods(VecU8* res, SpanU8 xmat, SpanU8 xvec, SpanU8 memb){
|
||||
codegen_append_xmat234x234_structs_and_base_methods(res, xmat, xvec, memb);
|
||||
codegen_append_xmat_inverse_methods(res, xmat, xvec, memb);
|
||||
}
|
||||
|
||||
@ -552,9 +540,8 @@ void generate_geom_header() {
|
||||
codegen_append_xvec234_structs_and_cool_methods(&res.result, cstr("vec"), cstr("float"), cstr("sqrtf"));
|
||||
codegen_append_xvec234_structs_and_cool_methods(&res.result, cstr("dvec"), cstr("double"), cstr("sqrt"));
|
||||
|
||||
// todo: remove padding from matrix structure. VERY IMPORTANT!!! Add padding on the fly when transferring to vulkan
|
||||
codegen_append_xmat234x234_structs_and_cool_methods(&res.result, cstr("mat"), cstr("vec"), cstr("float"), sizeof(float));
|
||||
codegen_append_xmat234x234_structs_and_base_methods(&res.result, cstr("s64mat"), cstr("s64vec"), cstr("S64"), sizeof(S64));
|
||||
codegen_append_xmat234x234_structs_and_cool_methods(&res.result, cstr("mat"), cstr("vec"), cstr("float"));
|
||||
codegen_append_xmat234x234_structs_and_base_methods(&res.result, cstr("s64mat"), cstr("s64vec"), cstr("S64"));
|
||||
|
||||
finish_header(res);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user