Commit ab82318
authored
fix: HLSL row_major matrices + GLSL namedExpressions leak (v0.14.1)
* fix(hlsl): row_major matrices, mul() reversal, unique entry points, typed call results
- Add row_major qualifier for matrix-typed struct members and cbuffer
declarations (fixes WGSL M[i] column access → HLSL row access mismatch
that caused DX12 MSDF text to be invisible due to w=-378 clipping)
- Reverse mul() arguments for matrix multiply (row_major transposes
storage, so mul(right, left) matches WGSL left * right semantics)
- Use stage prefix + original name for unique entry point names
(vs_vs_main, ps_fs_main, ps_fs_main_outline, ps_fs_main_shadow)
- Declare typed local variables for function call results (_crN)
- Map output local variable to _output with output struct type
- Add containsMatrix helper for arrays-of-matrices
- Add TestE2E_MatrixRowMajor, TestE2E_MatrixMulReversed tests
- Update existing tests for row_major assertions
* fix(glsl): clear namedExpressions between functions
GLSL writer shared namedExpressions map across all functions in
a module. When compiling multi-function shaders (e.g., MSDF text),
expression names from earlier functions leaked into later ones.
Example: sampleSD() stored namedExpressions[8]="_fc8", then in
vs_main expression handle 8 (literal 0 for transform[0]) resolved
to "_fc8" instead of "0", producing invalid GLSL:
uniforms.transform[_fc8] // undeclared identifier
Fix: reset namedExpressions at start of writeFunction() and
writeEntryPoint(), matching HLSL/MSL backends which already do this.
* refactor(hlsl): reduce writeEntryPointWithIO complexity, update CHANGELOG for v0.14.1
Extract writeReturnSemantic and writeEntryPointLocalVars helpers
to bring cognitive complexity from 32 to under 30 (gocognit limit).
Add CHANGELOG entry for v0.14.1 (HLSL row_major + GLSL namedExpressions fixes).1 parent 97fe275 commit ab82318
File tree
9 files changed
+484
-61
lines changed- glsl
- hlsl
9 files changed
+484
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
8 | 21 | | |
9 | 22 | | |
10 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| 725 | + | |
725 | 726 | | |
726 | 727 | | |
727 | 728 | | |
| |||
782 | 783 | | |
783 | 784 | | |
784 | 785 | | |
| 786 | + | |
785 | 787 | | |
786 | 788 | | |
787 | 789 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
418 | 437 | | |
419 | 438 | | |
420 | 439 | | |
| |||
1050 | 1069 | | |
1051 | 1070 | | |
1052 | 1071 | | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
1053 | 1075 | | |
1054 | | - | |
1055 | | - | |
1056 | 1076 | | |
1057 | 1077 | | |
1058 | 1078 | | |
| |||
1120 | 1140 | | |
1121 | 1141 | | |
1122 | 1142 | | |
1123 | | - | |
1124 | | - | |
1125 | 1143 | | |
1126 | 1144 | | |
1127 | 1145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 240 | + | |
255 | 241 | | |
256 | 242 | | |
257 | 243 | | |
| |||
261 | 247 | | |
262 | 248 | | |
263 | 249 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
285 | 254 | | |
286 | 255 | | |
287 | | - | |
288 | | - | |
| 256 | + | |
| 257 | + | |
289 | 258 | | |
290 | 259 | | |
291 | 260 | | |
| |||
296 | 265 | | |
297 | 266 | | |
298 | 267 | | |
299 | | - | |
| 268 | + | |
300 | 269 | | |
301 | 270 | | |
302 | 271 | | |
| |||
323 | 292 | | |
324 | 293 | | |
325 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
326 | 351 | | |
327 | 352 | | |
328 | 353 | | |
| |||
0 commit comments