-
Notifications
You must be signed in to change notification settings - Fork 69
/
CX22.0.0-vkd3d-1.4.patch
8452 lines (7859 loc) · 332 KB
/
CX22.0.0-vkd3d-1.4.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 71a22164652e8a654e77aa0c294f2637039f86b9 Mon Sep 17 00:00:00 2001
From: Dean M Greer <[email protected]>
Date: Sat, 3 Sep 2022 21:53:50 -0400
Subject: [PATCH] vkd3d: Import upstream release 1.4.
---
dlls/concrt140/details.c | 16 -
dlls/msvcp90/details.c | 16 -
include/winnt.h | 115 +-
libs/vkd3d/AUTHORS | 2 +
libs/vkd3d/config.h | 4 +-
libs/vkd3d/include/private/vkd3d_common.h | 75 +
libs/vkd3d/include/private/vkd3d_debug.h | 1 +
libs/vkd3d/include/private/vkd3d_version.h | 2 +-
libs/vkd3d/include/vkd3d.h | 18 +
libs/vkd3d/include/vkd3d_shader.h | 16 +
libs/vkd3d/include/vkd3d_types.h | 4 +
libs/vkd3d/libs/vkd3d-common/debug.c | 28 +-
libs/vkd3d/libs/vkd3d-shader/dxbc.c | 1 +
libs/vkd3d/libs/vkd3d-shader/hlsl.c | 123 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 14 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.l | 6 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 830 ++++++++---
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 404 +++++-
.../libs/vkd3d-shader/hlsl_constant_ops.c | 200 ++-
libs/vkd3d/libs/vkd3d-shader/hlsl_sm1.c | 6 +-
libs/vkd3d/libs/vkd3d-shader/hlsl_sm4.c | 648 +++++----
libs/vkd3d/libs/vkd3d-shader/preproc.l | 5 +-
libs/vkd3d/libs/vkd3d-shader/preproc.y | 34 +-
libs/vkd3d/libs/vkd3d-shader/sm4.h | 1 +
libs/vkd3d/libs/vkd3d-shader/spirv.c | 18 +-
libs/vkd3d/libs/vkd3d-shader/trace.c | 1 +
.../libs/vkd3d-shader/vkd3d_shader_main.c | 37 +
.../libs/vkd3d-shader/vkd3d_shader_private.h | 5 +
libs/vkd3d/libs/vkd3d/command.c | 1277 +++++++++++++----
libs/vkd3d/libs/vkd3d/device.c | 403 +++++-
libs/vkd3d/libs/vkd3d/resource.c | 497 ++++++-
libs/vkd3d/libs/vkd3d/state.c | 234 ++-
libs/vkd3d/libs/vkd3d/vkd3d_main.c | 6 +
libs/vkd3d/libs/vkd3d/vkd3d_private.h | 189 ++-
libs/vkd3d/libs/vkd3d/vulkan_procs.h | 5 +
35 files changed, 4135 insertions(+), 1106 deletions(-)
diff --git a/dlls/concrt140/details.c b/dlls/concrt140/details.c
index 72bb74474..8fd186eb7 100644
--- a/dlls/concrt140/details.c
+++ b/dlls/concrt140/details.c
@@ -193,22 +193,6 @@ static void spin_wait(int *counter)
}
}
-#ifdef _WIN64
-static size_t InterlockedIncrementSizeT(size_t volatile *dest)
-{
- size_t v;
-
- do
- {
- v = *dest;
- } while(InterlockedCompareExchange64((LONGLONG*)dest, v+1, v) != v);
-
- return v+1;
-}
-#else
-#define InterlockedIncrementSizeT(dest) InterlockedIncrement((LONG*)dest)
-#endif
-
static void CALLBACK queue_push_finally(BOOL normal, void *ctx)
{
threadsafe_queue *queue = ctx;
diff --git a/dlls/msvcp90/details.c b/dlls/msvcp90/details.c
index d63a47667..d2a741b49 100644
--- a/dlls/msvcp90/details.c
+++ b/dlls/msvcp90/details.c
@@ -207,22 +207,6 @@ static void spin_wait(int *counter)
}
}
-#ifdef _WIN64
-static size_t InterlockedIncrementSizeT(size_t volatile *dest)
-{
- size_t v;
-
- do
- {
- v = *dest;
- } while(InterlockedCompareExchange64((LONGLONG*)dest, v+1, v) != v);
-
- return v+1;
-}
-#else
-#define InterlockedIncrementSizeT(dest) InterlockedIncrement((LONG*)dest)
-#endif
-
static void CALLBACK queue_push_finally(BOOL normal, void *ctx)
{
threadsafe_queue *queue = ctx;
diff --git a/include/winnt.h b/include/winnt.h
index 85082ad5e..781f430d9 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -6272,19 +6272,24 @@ typedef enum _PROCESS_MITIGATION_POLICY
#define BitScanReverse _BitScanReverse
#define InterlockedAdd _InlineInterlockedAdd
#define InterlockedAnd _InterlockedAnd
+#define InterlockedAnd64 _InterlockedAnd64
#define InterlockedCompareExchange _InterlockedCompareExchange
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
#define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
#define InterlockedDecrement _InterlockedDecrement
#define InterlockedDecrement16 _InterlockedDecrement16
+#define InterlockedDecrement64 _InterlockedDecrement64
#define InterlockedExchange _InterlockedExchange
#define InterlockedExchangeAdd _InterlockedExchangeAdd
#define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
#define InterlockedExchangePointer _InterlockedExchangePointer
#define InterlockedIncrement _InterlockedIncrement
#define InterlockedIncrement16 _InterlockedIncrement16
+#define InterlockedIncrement64 _InterlockedIncrement64
#define InterlockedOr _InterlockedOr
+#define InterlockedOr64 _InterlockedOr64
#define InterlockedXor _InterlockedXor
+#define InterlockedXor64 _InterlockedXor64
#ifdef _MSC_VER
@@ -6316,33 +6321,88 @@ short _InterlockedIncrement16(short volatile*);
long _InterlockedOr(long volatile *,long);
long _InterlockedXor(long volatile *,long);
-static FORCEINLINE long InterlockedAdd( long volatile *dest, long val )
-{
- return InterlockedExchangeAdd( dest, val ) + val;
-}
-
-#if !defined(__i386__) || _MSC_VER >= 1600
+#ifndef __i386__
+#pragma intrinsic(_InterlockedAnd64)
#pragma intrinsic(_InterlockedCompareExchangePointer)
+#pragma intrinsic(_InterlockedDecrement64)
+#pragma intrinsic(_InterlockedExchangeAdd64)
#pragma intrinsic(_InterlockedExchangePointer)
-
-void *_InterlockedCompareExchangePointer(void *volatile*,void*,void*);
-void *_InterlockedExchangePointer(void *volatile*,void*);
+#pragma intrinsic(_InterlockedIncrement64)
+#pragma intrinsic(_InterlockedOr64)
+#pragma intrinsic(_InterlockedXor64)
+
+__int64 _InterlockedAnd64(__int64 volatile *, __int64);
+void * _InterlockedCompareExchangePointer(void *volatile*,void*,void*);
+__int64 _InterlockedDecrement64(__int64 volatile *);
+__int64 _InterlockedExchangeAdd64(__int64 volatile *, __int64);
+void * _InterlockedExchangePointer(void *volatile*,void*);
+__int64 _InterlockedIncrement64(__int64 volatile *);
+__int64 _InterlockedOr64(__int64 volatile *, __int64);
+__int64 _InterlockedXor64(__int64 volatile *, __int64);
#else
+static FORCEINLINE __int64 InterlockedAnd64( __int64 volatile *dest, __int64 val )
+{
+ __int64 prev;
+ do prev = *dest; while (InterlockedCompareExchange64( dest, prev & val, prev ) != prev);
+ return prev;
+}
+
static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
{
return (void *)_InterlockedCompareExchange( (long volatile*)dest, (long)xchg, (long)compare );
}
+static FORCEINLINE __int64 InterlockedExchangeAdd64( __int64 volatile *dest, __int64 val )
+{
+ __int64 prev;
+ do prev = *dest; while (InterlockedCompareExchange64( dest, prev + val, prev ) != prev);
+ return prev;
+}
+
static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
{
return (void *)_InterlockedExchange( (long volatile*)dest, (long)val );
}
+static FORCEINLINE __int64 InterlockedIncrement64( __int64 volatile *dest )
+{
+ return InterlockedExchangeAdd64( dest, 1 ) + 1;
+}
+
+static FORCEINLINE __int64 InterlockedDecrement64( __int64 volatile *dest )
+{
+ return InterlockedExchangeAdd64( dest, -1 ) - 1;
+}
+
+static FORCEINLINE __int64 InterlockedOr64( __int64 volatile *dest, __int64 val )
+{
+ __int64 prev;
+ do prev = *dest; while (InterlockedCompareExchange64( dest, prev | val, prev ) != prev);
+ return prev;
+}
+
+static FORCEINLINE __int64 InterlockedXor64( __int64 volatile *dest, __int64 val )
+{
+ __int64 prev;
+ do prev = *dest; while (InterlockedCompareExchange64( dest, prev ^ val, prev ) != prev);
+ return prev;
+}
+
#endif /* __i386__ */
+static FORCEINLINE long InterlockedAdd( long volatile *dest, long val )
+{
+ return InterlockedExchangeAdd( dest, val ) + val;
+}
+
+static FORCEINLINE __int64 InterlockedAdd64( __int64 volatile *dest, __int64 val )
+{
+ return InterlockedExchangeAdd64( dest, val ) + val;
+}
+
#ifdef __i386__
static FORCEINLINE void MemoryBarrier(void)
@@ -6353,10 +6413,7 @@ static FORCEINLINE void MemoryBarrier(void)
#elif defined(__x86_64__)
-#pragma intrinsic(_InterlockedExchangeAdd64)
#pragma intrinsic(__faststorefence)
-
-long long _InterlockedExchangeAdd64(long long volatile *, long long);
void __faststorefence(void);
static FORCEINLINE void MemoryBarrier(void)
@@ -6399,11 +6456,21 @@ static FORCEINLINE LONG WINAPI InterlockedAdd( LONG volatile *dest, LONG val )
return __sync_add_and_fetch( dest, val );
}
+static FORCEINLINE LONGLONG WINAPI InterlockedAdd64( LONGLONG volatile *dest, LONGLONG val )
+{
+ return __sync_add_and_fetch( dest, val );
+}
+
static FORCEINLINE LONG WINAPI InterlockedAnd( LONG volatile *dest, LONG val )
{
return __sync_fetch_and_and( dest, val );
}
+static FORCEINLINE LONGLONG WINAPI InterlockedAnd64( LONGLONG volatile *dest, LONGLONG val )
+{
+ return __sync_fetch_and_and( dest, val );
+}
+
static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
{
return __sync_val_compare_and_swap( dest, compare, xchg );
@@ -6453,6 +6520,11 @@ static FORCEINLINE short WINAPI InterlockedIncrement16( short volatile *dest )
return __sync_add_and_fetch( dest, 1 );
}
+static FORCEINLINE LONGLONG WINAPI InterlockedIncrement64( LONGLONG volatile *dest )
+{
+ return __sync_add_and_fetch( dest, 1 );
+}
+
static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile * HOSTPTR dest )
{
return __sync_add_and_fetch( dest, -1 );
@@ -6463,6 +6535,11 @@ static FORCEINLINE short WINAPI InterlockedDecrement16( short volatile *dest )
return __sync_add_and_fetch( dest, -1 );
}
+static FORCEINLINE LONGLONG WINAPI InterlockedDecrement64( LONGLONG volatile *dest )
+{
+ return __sync_add_and_fetch( dest, -1 );
+}
+
static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
{
void *ret;
@@ -6485,11 +6562,21 @@ static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val )
return __sync_fetch_and_or( dest, val );
}
+static FORCEINLINE LONGLONG WINAPI InterlockedOr64( LONGLONG volatile *dest, LONGLONG val )
+{
+ return __sync_fetch_and_or( dest, val );
+}
+
static FORCEINLINE LONG WINAPI InterlockedXor( LONG volatile *dest, LONG val )
{
return __sync_fetch_and_xor( dest, val );
}
+static FORCEINLINE LONGLONG WINAPI InterlockedXor64( LONGLONG volatile *dest, LONGLONG val )
+{
+ return __sync_fetch_and_xor( dest, val );
+}
+
static FORCEINLINE void MemoryBarrier(void)
{
__sync_synchronize();
@@ -6525,11 +6612,15 @@ static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64
#endif
+#define InterlockedDecrementSizeT(a) InterlockeDecrement64((LONGLONG *)(a))
#define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)(a), (b))
+#define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)(a))
#else /* _WIN64 */
+#define InterlockedDecrementSizeT(a) InterlockeDecrement((LONG *)(a))
#define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)(a), (b))
+#define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)(a))
#endif /* _WIN64 */
diff --git a/libs/vkd3d/AUTHORS b/libs/vkd3d/AUTHORS
index bc2e08f6c..18a8b2073 100644
--- a/libs/vkd3d/AUTHORS
+++ b/libs/vkd3d/AUTHORS
@@ -5,8 +5,10 @@ Atharva Nimbalkar
Biswapriyo Nath
Chip Davis
Conor McCarthy
+David Gow
Derek Lesho
Francisco Casas
+Francois Gouget
Giovanni Mascellani
Hans-Kristian Arntzen
Henri Verbeet
diff --git a/libs/vkd3d/config.h b/libs/vkd3d/config.h
index 9b6daff5e..146adb801 100644
--- a/libs/vkd3d/config.h
+++ b/libs/vkd3d/config.h
@@ -1,5 +1,5 @@
#define PACKAGE_NAME "vkd3d"
-#define PACKAGE_STRING "vkd3d 1.3"
-#define PACKAGE_VERSION "1.3"
+#define PACKAGE_STRING "vkd3d 1.4"
+#define PACKAGE_VERSION "1.4"
#define PATH_MAX 1024
#define SONAME_LIBVULKAN "vulkan-1.dll"
diff --git a/libs/vkd3d/include/private/vkd3d_common.h b/libs/vkd3d/include/private/vkd3d_common.h
index 4ee8ccd43..68eb60cf1 100644
--- a/libs/vkd3d/include/private/vkd3d_common.h
+++ b/libs/vkd3d/include/private/vkd3d_common.h
@@ -27,6 +27,7 @@
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
+#include <stdio.h>
#ifdef _MSC_VER
#include <intrin.h>
@@ -210,6 +211,10 @@ static inline LONG InterlockedIncrement(LONG volatile *x)
{
return __sync_add_and_fetch(x, 1);
}
+static inline LONG64 InterlockedIncrement64(LONG64 volatile *x)
+{
+ return __sync_add_and_fetch(x, 1);
+}
static inline LONG InterlockedAdd(LONG volatile *x, LONG val)
{
return __sync_add_and_fetch(x, val);
@@ -242,4 +247,74 @@ static inline void vkd3d_parse_version(const char *version, int *major, int *min
HRESULT hresult_from_vkd3d_result(int vkd3d_result);
+#ifdef _WIN32
+static inline void *vkd3d_dlopen(const char *name)
+{
+ return LoadLibraryA(name);
+}
+
+static inline void *vkd3d_dlsym(void *handle, const char *symbol)
+{
+ return GetProcAddress(handle, symbol);
+}
+
+static inline int vkd3d_dlclose(void *handle)
+{
+ return FreeLibrary(handle);
+}
+
+static inline const char *vkd3d_dlerror(void)
+{
+ unsigned int error = GetLastError();
+ static char message[256];
+
+ if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, message, sizeof(message), NULL))
+ return message;
+ sprintf(message, "Unknown error %u.\n", error);
+ return message;
+}
+#elif defined(HAVE_DLFCN_H)
+#include <dlfcn.h>
+
+static inline void *vkd3d_dlopen(const char *name)
+{
+ return dlopen(name, RTLD_NOW);
+}
+
+static inline void *vkd3d_dlsym(void *handle, const char *symbol)
+{
+ return dlsym(handle, symbol);
+}
+
+static inline int vkd3d_dlclose(void *handle)
+{
+ return dlclose(handle);
+}
+
+static inline const char *vkd3d_dlerror(void)
+{
+ return dlerror();
+}
+#else
+static inline void *vkd3d_dlopen(const char *name)
+{
+ return NULL;
+}
+
+static inline void *vkd3d_dlsym(void *handle, const char *symbol)
+{
+ return NULL;
+}
+
+static inline int vkd3d_dlclose(void *handle)
+{
+ return 0;
+}
+
+static inline const char *vkd3d_dlerror(void)
+{
+ return "Not implemented for this platform.\n";
+}
+#endif
+
#endif /* __VKD3D_COMMON_H */
diff --git a/libs/vkd3d/include/private/vkd3d_debug.h b/libs/vkd3d/include/private/vkd3d_debug.h
index 8ab653aef..579c33d36 100644
--- a/libs/vkd3d/include/private/vkd3d_debug.h
+++ b/libs/vkd3d/include/private/vkd3d_debug.h
@@ -47,6 +47,7 @@ enum vkd3d_dbg_level
enum vkd3d_dbg_level vkd3d_dbg_get_level(void);
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4);
+void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback);
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2);
const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args);
diff --git a/libs/vkd3d/include/private/vkd3d_version.h b/libs/vkd3d/include/private/vkd3d_version.h
index 712ddcf84..ddf661001 100644
--- a/libs/vkd3d/include/private/vkd3d_version.h
+++ b/libs/vkd3d/include/private/vkd3d_version.h
@@ -1 +1 @@
-#define VKD3D_VCS_ID " (git d773dc05c687)"
+#define VKD3D_VCS_ID " (git 9d4df5e70468)"
diff --git a/libs/vkd3d/include/vkd3d.h b/libs/vkd3d/include/vkd3d.h
index e998ee3f6..fcbc7933f 100644
--- a/libs/vkd3d/include/vkd3d.h
+++ b/libs/vkd3d/include/vkd3d.h
@@ -60,6 +60,7 @@ enum vkd3d_api_version
VKD3D_API_VERSION_1_1,
VKD3D_API_VERSION_1_2,
VKD3D_API_VERSION_1_3,
+ VKD3D_API_VERSION_1_4,
};
typedef HRESULT (*PFN_vkd3d_signal_event)(HANDLE event);
@@ -212,6 +213,20 @@ VKD3D_API HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED
VKD3D_API HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer);
+/**
+ * Set a callback to be called when vkd3d outputs debug logging.
+ *
+ * If NULL, or if this function has not been called, libvkd3d will print all
+ * enabled log output to stderr.
+ *
+ * Calling this function will also set the log callback for libvkd3d-shader.
+ *
+ * \param callback Callback function to set.
+ *
+ * \since 1.4
+ */
+VKD3D_API void vkd3d_set_log_callback(PFN_vkd3d_log callback);
+
#endif /* VKD3D_NO_PROTOTYPES */
/*
@@ -255,6 +270,9 @@ typedef HRESULT (*PFN_vkd3d_serialize_versioned_root_signature)(const D3D12_VERS
typedef HRESULT (*PFN_vkd3d_create_versioned_root_signature_deserializer)(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer);
+/** Type of vkd3d_set_log_callback(). \since 1.4 */
+typedef void (*PFN_vkd3d_set_log_callback)(PFN_vkd3d_log callback);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libs/vkd3d/include/vkd3d_shader.h b/libs/vkd3d/include/vkd3d_shader.h
index 05d235f9d..ebddbba77 100644
--- a/libs/vkd3d/include/vkd3d_shader.h
+++ b/libs/vkd3d/include/vkd3d_shader.h
@@ -45,6 +45,7 @@ enum vkd3d_shader_api_version
VKD3D_SHADER_API_VERSION_1_1,
VKD3D_SHADER_API_VERSION_1_2,
VKD3D_SHADER_API_VERSION_1_3,
+ VKD3D_SHADER_API_VERSION_1_4,
};
/** The type of a chained structure. */
@@ -1806,6 +1807,18 @@ VKD3D_SHADER_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_sig
VKD3D_SHADER_API int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, char **messages);
+/**
+ * Set a callback to be called when vkd3d-shader outputs debug logging.
+ *
+ * If NULL, or if this function has not been called, libvkd3d-shader will print
+ * all enabled log output to stderr.
+ *
+ * \param callback Callback function to set.
+ *
+ * \since 1.4
+ */
+VKD3D_SHADER_API void vkd3d_shader_set_log_callback(PFN_vkd3d_log callback);
+
#endif /* VKD3D_SHADER_NO_PROTOTYPES */
/** Type of vkd3d_shader_get_version(). */
@@ -1859,6 +1872,9 @@ typedef void (*PFN_vkd3d_shader_free_shader_signature)(struct vkd3d_shader_signa
typedef void (*PFN_vkd3d_shader_preprocess)(struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, char **messages);
+/** Type of vkd3d_shader_set_log_callback(). \since 1.4 */
+typedef void (*PFN_vkd3d_shader_set_log_callback)(PFN_vkd3d_log callback);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libs/vkd3d/include/vkd3d_types.h b/libs/vkd3d/include/vkd3d_types.h
index 0e4ff7b77..12ceef42f 100644
--- a/libs/vkd3d/include/vkd3d_types.h
+++ b/libs/vkd3d/include/vkd3d_types.h
@@ -19,6 +19,8 @@
#ifndef __VKD3D_TYPES_H
#define __VKD3D_TYPES_H
+#include <stdarg.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -53,6 +55,8 @@ enum vkd3d_result
VKD3D_FORCE_32_BIT_ENUM(VKD3D_RESULT),
};
+typedef void (*PFN_vkd3d_log)(const char *format, va_list args);
+
#ifdef _WIN32
# define VKD3D_IMPORT
# define VKD3D_EXPORT
diff --git a/libs/vkd3d/libs/vkd3d-common/debug.c b/libs/vkd3d/libs/vkd3d-common/debug.c
index 4868f3fba..0b9e765ac 100644
--- a/libs/vkd3d/libs/vkd3d-common/debug.c
+++ b/libs/vkd3d/libs/vkd3d-common/debug.c
@@ -68,6 +68,25 @@ enum vkd3d_dbg_level vkd3d_dbg_get_level(void)
return level;
}
+static PFN_vkd3d_log log_callback;
+
+static void vkd3d_dbg_voutput(const char *fmt, va_list args)
+{
+ if (log_callback)
+ log_callback(fmt, args);
+ else
+ vfprintf(stderr, fmt, args);
+}
+
+static void vkd3d_dbg_output(const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vkd3d_dbg_voutput(fmt, args);
+ va_end(args);
+}
+
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...)
{
va_list args;
@@ -77,12 +96,17 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const ch
assert(level < ARRAY_SIZE(debug_level_names));
- fprintf(stderr, "%s:%s: ", debug_level_names[level], function);
+ vkd3d_dbg_output("%s:%s ", debug_level_names[level], function);
va_start(args, fmt);
- vfprintf(stderr, fmt, args);
+ vkd3d_dbg_voutput(fmt, args);
va_end(args);
}
+void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback)
+{
+ log_callback = callback;
+}
+
static char *get_buffer(void)
{
static char buffers[VKD3D_DEBUG_BUFFER_COUNT][VKD3D_DEBUG_BUFFER_SIZE];
diff --git a/libs/vkd3d/libs/vkd3d-shader/dxbc.c b/libs/vkd3d/libs/vkd3d-shader/dxbc.c
index 1ab71ca47..17be23065 100644
--- a/libs/vkd3d/libs/vkd3d-shader/dxbc.c
+++ b/libs/vkd3d/libs/vkd3d-shader/dxbc.c
@@ -837,6 +837,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] =
{VKD3D_SM5_OP_DDIV, VKD3DSIH_DDIV, "d", "dd"},
{VKD3D_SM5_OP_DFMA, VKD3DSIH_DFMA, "d", "ddd"},
{VKD3D_SM5_OP_DRCP, VKD3DSIH_DRCP, "d", "d"},
+ {VKD3D_SM5_OP_MSAD, VKD3DSIH_MSAD, "u", "uuu"},
{VKD3D_SM5_OP_DTOI, VKD3DSIH_DTOI, "i", "d"},
{VKD3D_SM5_OP_DTOU, VKD3DSIH_DTOU, "u", "d"},
{VKD3D_SM5_OP_ITOD, VKD3DSIH_ITOD, "d", "i"},
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.c b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
index ea5e35d20..7239b1837 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
@@ -202,6 +202,13 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
}
}
+/* Returns the size of a type, considered as part of an array of that type.
+ * As such it includes padding after the type. */
+unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type)
+{
+ return align(type->reg_size, 4);
+}
+
static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class type_class,
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
{
@@ -225,6 +232,85 @@ static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, e
return type;
}
+/* Returns the register offset of a given component within a type, given its index.
+ * *comp_type will be set to the type of the component. */
+unsigned int hlsl_compute_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type,
+ unsigned int idx, struct hlsl_type **comp_type)
+{
+ switch (type->type)
+ {
+ case HLSL_CLASS_SCALAR:
+ case HLSL_CLASS_VECTOR:
+ {
+ assert(idx < type->dimx * type->dimy);
+ *comp_type = hlsl_get_scalar_type(ctx, type->base_type);
+ return idx;
+ }
+ case HLSL_CLASS_MATRIX:
+ {
+ unsigned int minor, major, x = idx % type->dimx, y = idx / type->dimx;
+
+ assert(idx < type->dimx * type->dimy);
+
+ if (hlsl_type_is_row_major(type))
+ {
+ minor = x;
+ major = y;
+ }
+ else
+ {
+ minor = y;
+ major = x;
+ }
+
+ *comp_type = hlsl_get_scalar_type(ctx, type->base_type);
+ return 4 * major + minor;
+ }
+
+ case HLSL_CLASS_ARRAY:
+ {
+ unsigned int elem_comp_count = hlsl_type_component_count(type->e.array.type);
+ unsigned int array_idx = idx / elem_comp_count;
+ unsigned int idx_in_elem = idx % elem_comp_count;
+
+ assert(array_idx < type->e.array.elements_count);
+
+ return array_idx * hlsl_type_get_array_element_reg_size(type->e.array.type) +
+ hlsl_compute_component_offset(ctx, type->e.array.type, idx_in_elem, comp_type);
+ }
+
+ case HLSL_CLASS_STRUCT:
+ {
+ struct hlsl_struct_field *field;
+
+ LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
+ {
+ unsigned int elem_comp_count = hlsl_type_component_count(field->type);
+
+ if (idx < elem_comp_count)
+ {
+ return field->reg_offset +
+ hlsl_compute_component_offset(ctx, field->type, idx, comp_type);
+ }
+ idx -= elem_comp_count;
+ }
+
+ assert(0);
+ return 0;
+ }
+
+ case HLSL_CLASS_OBJECT:
+ {
+ assert(idx == 0);
+ *comp_type = type;
+ return 0;
+ }
+ }
+
+ assert(0);
+ return 0;
+}
+
struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type, unsigned int array_size)
{
struct hlsl_type *type;
@@ -556,27 +642,44 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir
return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc);
}
-struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc)
+struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type,
+ const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_constant *c;
+ assert(type->type <= HLSL_CLASS_VECTOR);
+
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
- c->value[0].i = n;
+
+ init_node(&c->node, HLSL_IR_CONSTANT, type, *loc);
+
+ return c;
+}
+
+struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
+ const struct vkd3d_shader_location *loc)
+{
+ struct hlsl_ir_constant *c;
+
+ c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
+
+ if (c)
+ c->value[0].i = n;
+
return c;
}
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc)
+ const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_constant *c;
- if (!(c = hlsl_alloc(ctx, sizeof(*c))))
- return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
- c->value[0].u = n;
+ c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
+
+ if (c)
+ c->value[0].u = n;
+
return c;
}
@@ -1144,7 +1247,7 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl
switch (type->base_type)
{
case HLSL_TYPE_BOOL:
- vkd3d_string_buffer_printf(buffer, "%s ", value->b ? "true" : "false");
+ vkd3d_string_buffer_printf(buffer, "%s ", value->u ? "true" : "false");
break;
case HLSL_TYPE_DOUBLE:
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
index 7fd1eb159..762be8419 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
@@ -152,6 +152,7 @@ struct hlsl_struct_field
struct hlsl_type *type;
const char *name;
struct hlsl_semantic semantic;
+ unsigned int modifiers;
unsigned int reg_offset;
size_t name_bytecode_offset;
@@ -415,7 +416,6 @@ struct hlsl_ir_constant
int32_t i;
float f;
double d;
- bool b;
} value[4];
struct hlsl_reg reg;
};
@@ -733,12 +733,14 @@ struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type
const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc);
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,
const struct vkd3d_shader_location *loc);
+struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type,
+ const struct vkd3d_shader_location *loc);
struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node);
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc);
struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc);
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc);
+ const struct vkd3d_shader_location *loc);
struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc);
struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_type *type, struct vkd3d_shader_location loc);
@@ -757,7 +759,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam
const struct vkd3d_shader_location loc);
struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format);
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc);
+ const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
struct vkd3d_shader_location loc);
struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
@@ -783,6 +785,9 @@ bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type);
struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
unsigned int default_majority, unsigned int modifiers);
unsigned int hlsl_type_component_count(struct hlsl_type *type);
+unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type);
+unsigned int hlsl_compute_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type,
+ unsigned int idx, struct hlsl_type **comp_type);
unsigned int hlsl_type_get_sm4_offset(const struct hlsl_type *type, unsigned int offset);
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2);
@@ -793,8 +798,7 @@ unsigned int hlsl_swizzle_from_writemask(unsigned int writemask);
bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, unsigned int *offset);
unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
-struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
- const struct hlsl_type *type);
+struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context);
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.l b/libs/vkd3d/libs/vkd3d-shader/hlsl.l
index 267c8c304..ff7b712f7 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.l
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.l
@@ -197,15 +197,15 @@ row_major {return KW_ROW_MAJOR; }
return C_FLOAT;
}
0x[0-9a-fA-F]+ {
- sscanf(yytext, "0x%x", &yylval->intval);
+ yylval->intval = vkd3d_parse_integer(yytext);
return C_INTEGER;
}
0[0-7]+ {
- sscanf(yytext, "0%o", &yylval->intval);
+ yylval->intval = vkd3d_parse_integer(yytext);
return C_INTEGER;
}
[0-9]+ {
- yylval->intval = (atoi(yytext));
+ yylval->intval = vkd3d_parse_integer(yytext);
return C_INTEGER;
}
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
index 92dcb3f2a..df5fda472 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
@@ -48,6 +48,7 @@ struct parse_initializer
struct hlsl_ir_node **args;
unsigned int args_count;
struct list *instrs;
+ bool braces;
};
struct parse_array_sizes
@@ -265,7 +266,10 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
return false;
}
-static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *var_node,
+ struct hlsl_ir_node *offset, struct hlsl_type *data_type, const struct vkd3d_shader_location loc);
+
+static struct hlsl_ir_node *add_cast(struct hlsl_ctx *ctx, struct list *instrs,
struct hlsl_ir_node *node, struct hlsl_type *dst_type, const struct vkd3d_shader_location *loc)
{
struct hlsl_type *src_type = node->data_type;
@@ -274,6 +278,99 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
if (hlsl_types_are_equal(src_type, dst_type))
return node;
+ if ((src_type->type == HLSL_CLASS_MATRIX || dst_type->type == HLSL_CLASS_MATRIX)
+ && src_type->type <= HLSL_CLASS_LAST_NUMERIC && dst_type->type <= HLSL_CLASS_LAST_NUMERIC)
+ {
+ struct vkd3d_string_buffer *name;
+ static unsigned int counter = 0;
+ struct hlsl_ir_load *load;
+ struct hlsl_ir_var *var;
+ unsigned int dst_idx;
+ bool broadcast;
+
+ broadcast = src_type->dimx == 1 && src_type->dimy == 1;
+ assert(dst_type->dimx * dst_type->dimy <= src_type->dimx * src_type->dimy || broadcast);
+ if (src_type->type == HLSL_CLASS_MATRIX && dst_type->type == HLSL_CLASS_MATRIX && !broadcast)
+ {
+ assert(dst_type->dimx <= src_type->dimx);
+ assert(dst_type->dimy <= src_type->dimy);
+ }
+
+ name = vkd3d_string_buffer_get(&ctx->string_buffers);
+ vkd3d_string_buffer_printf(name, "<cast-%u>", counter++);
+ var = hlsl_new_synthetic_var(ctx, name->buffer, dst_type, *loc);
+ vkd3d_string_buffer_release(&ctx->string_buffers, name);
+ if (!var)
+ return NULL;
+
+ for (dst_idx = 0; dst_idx < dst_type->dimx * dst_type->dimy; ++dst_idx)
+ {
+ struct hlsl_type *src_scalar_type, *dst_scalar_type;
+ unsigned int src_idx, src_offset, dst_offset;
+ struct hlsl_ir_store *store;
+ struct hlsl_ir_constant *c;
+
+ if (broadcast)
+ {
+ src_idx = 0;
+ }
+ else
+ {
+ if (src_type->type == HLSL_CLASS_MATRIX && dst_type->type == HLSL_CLASS_MATRIX)
+ {
+ unsigned int x = dst_idx % dst_type->dimx, y = dst_idx / dst_type->dimx;
+
+ src_idx = y * src_type->dimx + x;
+ }
+ else
+ {
+ src_idx = dst_idx;
+ }
+ }
+
+ dst_offset = hlsl_compute_component_offset(ctx, dst_type, dst_idx, &dst_scalar_type);
+ src_offset = hlsl_compute_component_offset(ctx, src_type, src_idx, &src_scalar_type);
+
+ if (!(c = hlsl_new_uint_constant(ctx, src_offset, loc)))
+ return NULL;
+ list_add_tail(instrs, &c->node.entry);
+
+ if (!(load = add_load(ctx, instrs, node, &c->node, src_scalar_type, *loc)))
+ return NULL;
+
+ if (!(cast = hlsl_new_cast(ctx, &load->node, dst_scalar_type, loc)))
+ return NULL;
+ list_add_tail(instrs, &cast->node.entry);
+
+ if (!(c = hlsl_new_uint_constant(ctx, dst_offset, loc)))
+ return NULL;
+ list_add_tail(instrs, &c->node.entry);
+
+ if (!(store = hlsl_new_store(ctx, var, &c->node, &cast->node, 0, *loc)))
+ return NULL;
+ list_add_tail(instrs, &store->node.entry);
+ }
+
+ if (!(load = hlsl_new_load(ctx, var, NULL, dst_type, *loc)))
+ return NULL;
+ list_add_tail(instrs, &load->node.entry);
+
+ return &load->node;
+ }
+ else
+ {
+ if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
+ return NULL;
+ list_add_tail(instrs, &cast->node.entry);
+ return &cast->node;
+ }