icculus / mojoshader

Use Direct3D shaders with other 3D rendering APIs.
https://icculus.org/mojoshader/
zlib License
139 stars 36 forks source link

[Effects] Struct parameters with nested structs #8

Open flibitijibibo opened 5 years ago

flibitijibibo commented 5 years ago

Issue migrated from https://github.com/FNA-XNA/FNA/issues/255

CC @kg

flibitijibibo commented 5 years ago

This fixes the matrix assertion failure found in SquaredBitmapShader, but the memory layout may be incorrect:

diff -r 3e07483a681c mojoshader_effects.c
--- a/mojoshader_effects.c      Sat Apr 27 17:03:28 2019 -0400
+++ b/mojoshader_effects.c      Tue May 21 15:33:12 2019 -0400
@@ -373,7 +373,7 @@

             // !!! FIXME: Nested structs! -flibit
             assert(mem->info.parameter_class >= MOJOSHADER_SYMCLASS_SCALAR
-                && mem->info.parameter_class <= MOJOSHADER_SYMCLASS_VECTOR);
+                && mem->info.parameter_class <= MOJOSHADER_SYMCLASS_MATRIX_COLUMNS);
             assert(mem->info.parameter_type >= MOJOSHADER_SYMTYPE_BOOL
                 && mem->info.parameter_type <= MOJOSHADER_SYMTYPE_FLOAT);
             mem->info.member_count = 0;
flibitijibibo commented 5 years ago

The matrices are indeed laid out properly, so nested structs are what's left. Good luck to anyone who actually needs that...