forked from Shelnutt2/cuda-wine-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
directx.c
5383 lines (4723 loc) · 231 KB
/
directx.c
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
/*
* IWineD3D implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdio.h>
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
#define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
/* The d3d device ID */
static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
/* Extension detection */
static const struct {
const char *extension_string;
GL_SupportedExt extension;
DWORD version;
} EXTENSION_MAP[] = {
/* APPLE */
{"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE, 0 },
{"GL_APPLE_fence", APPLE_FENCE, 0 },
{"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS, 0 },
{"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE, 0 },
{"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 },
{"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 },
/* ARB */
{"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT, 0 },
{"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT, 0 },
{"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP, 0 },
{"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE, 0 },
{"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS, 0 },
{"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM, 0 },
{"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER, 0 },
{"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT, 0 },
{"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 },
{"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 },
{"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 },
{"GL_ARB_imaging", ARB_IMAGING, 0 },
{"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE, 0 },
{"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
{"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 },
{"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY, 0 },
{"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT, 0 },
{"GL_ARB_point_parameters", ARB_POINT_PARAMETERS, 0 },
{"GL_ARB_point_sprite", ARB_POINT_SPRITE, 0 },
{"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX, 0 },
{"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 },
{"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 },
{"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100, 0 },
{"GL_ARB_shadow", ARB_SHADOW, 0 },
{"GL_ARB_sync", ARB_SYNC, 0 },
{"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP, 0 },
{"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION, 0 },
{"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP, 0 },
{"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD, 0 },
{"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE, 0 },
{"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3, 0 },
{"GL_ARB_texture_float", ARB_TEXTURE_FLOAT, 0 },
{"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
{"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) },
{"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 },
{"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 },
{"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA, 0 },
{"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 },
{"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 },
{"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 },
{"GL_ARB_vertex_shader", ARB_VERTEX_SHADER, 0 },
/* ATI */
{"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 },
{"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 },
{"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 },
{"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 },
{"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 },
/* EXT */
{"GL_EXT_blend_color", EXT_BLEND_COLOR, 0 },
{"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 },
{"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 },
{"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 },
{"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2, 0 },
{"GL_EXT_fog_coord", EXT_FOG_COORD, 0 },
{"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT, 0 },
{"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE, 0 },
{"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT, 0 },
{"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 },
{"GL_EXT_gpu_shader4", EXT_GPU_SHADER4, 0 },
{"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL, 0 },
{"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE, 0 },
{"GL_EXT_point_parameters", EXT_POINT_PARAMETERS, 0 },
{"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX, 0 },
{"GL_EXT_secondary_color", EXT_SECONDARY_COLOR, 0 },
{"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE, 0 },
{"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 },
{"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) },
{"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 },
{"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 },
{"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 },
{"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 },
{"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 },
{"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 },
{"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 },
{"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 },
{"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 },
/* NV */
{"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 },
{"GL_NV_fence", NV_FENCE, 0 },
{"GL_NV_fog_distance", NV_FOG_DISTANCE, 0 },
{"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM, 0 },
{"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2, 0 },
{"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 },
{"GL_NV_half_float", NV_HALF_FLOAT, 0 },
{"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 },
{"GL_NV_register_combiners", NV_REGISTER_COMBINERS, 0 },
{"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2, 0 },
{"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION, 0 },
{"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4, 0 },
{"GL_NV_texture_shader", NV_TEXTURE_SHADER, 0 },
{"GL_NV_texture_shader2", NV_TEXTURE_SHADER2, 0 },
{"GL_NV_vertex_program", NV_VERTEX_PROGRAM, 0 },
{"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1, 0 },
{"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 },
{"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION, 0 },
{"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 },
/* SGI */
{"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 },
};
/**********************************************************
* Utility functions follow
**********************************************************/
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType);
const struct min_lookup minMipLookup[] =
{
/* NONE POINT LINEAR */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
{{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
{{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
};
const struct min_lookup minMipLookup_noFilter[] =
{
/* NONE POINT LINEAR */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
};
const struct min_lookup minMipLookup_noMip[] =
{
/* NONE POINT LINEAR */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
{{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
};
const GLenum magLookup[] =
{
/* NONE POINT LINEAR */
GL_NEAREST, GL_NEAREST, GL_LINEAR,
};
const GLenum magLookup_noFilter[] =
{
/* NONE POINT LINEAR */
GL_NEAREST, GL_NEAREST, GL_NEAREST,
};
/* drawStridedSlow attributes */
glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc specular_func_3ubv;
glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
/**
* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
* i.e., there is no GL Context - Get a default rendering context to enable the
* function query some info from GL.
*/
struct wined3d_fake_gl_ctx
{
HDC dc;
HWND wnd;
HGLRC gl_ctx;
HDC restore_dc;
HGLRC restore_gl_ctx;
};
static void WineD3D_ReleaseFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
{
TRACE_(d3d_caps)("Destroying fake GL context.\n");
if (!pwglMakeCurrent(NULL, NULL))
{
ERR_(d3d_caps)("Failed to disable fake GL context.\n");
}
if (!pwglDeleteContext(ctx->gl_ctx))
{
DWORD err = GetLastError();
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
}
ReleaseDC(ctx->wnd, ctx->dc);
DestroyWindow(ctx->wnd);
if (ctx->restore_gl_ctx && !pwglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
{
ERR_(d3d_caps)("Failed to restore previous GL context.\n");
}
}
static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
{
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat;
TRACE("getting context...\n");
ctx->restore_dc = pwglGetCurrentDC();
ctx->restore_gl_ctx = pwglGetCurrentContext();
/* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
if (!ctx->wnd)
{
ERR_(d3d_caps)("Failed to create a window.\n");
goto fail;
}
ctx->dc = GetDC(ctx->wnd);
if (!ctx->dc)
{
ERR_(d3d_caps)("Failed to get a DC.\n");
goto fail;
}
/* PixelFormat selection */
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd);
if (!iPixelFormat)
{
/* If this happens something is very wrong as ChoosePixelFormat barely fails. */
ERR_(d3d_caps)("Can't find a suitable iPixelFormat.\n");
goto fail;
}
DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
/* Create a GL context. */
ctx->gl_ctx = pwglCreateContext(ctx->dc);
if (!ctx->gl_ctx)
{
WARN_(d3d_caps)("Error creating default context for capabilities initialization.\n");
goto fail;
}
/* Make it the current GL context. */
if (!context_set_current(NULL))
{
ERR_(d3d_caps)("Failed to clear current D3D context.\n");
}
if (!pwglMakeCurrent(ctx->dc, ctx->gl_ctx))
{
ERR_(d3d_caps)("Failed to make fake GL context current.\n");
goto fail;
}
return TRUE;
fail:
if (ctx->gl_ctx) pwglDeleteContext(ctx->gl_ctx);
ctx->gl_ctx = NULL;
if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
ctx->dc = NULL;
if (ctx->wnd) DestroyWindow(ctx->wnd);
ctx->wnd = NULL;
if (ctx->restore_gl_ctx && !pwglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
{
ERR_(d3d_caps)("Failed to restore previous GL context.\n");
}
return FALSE;
}
/* Adjust the amount of used texture memory */
unsigned int WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *device, unsigned int glram)
{
struct wined3d_adapter *adapter = device->adapter;
adapter->UsedTextureRam += glram;
TRACE("Adjusted gl ram by %d to %d\n", glram, adapter->UsedTextureRam);
return adapter->UsedTextureRam;
}
static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
{
HeapFree(GetProcessHeap(), 0, adapter->gl_info.gl_formats);
HeapFree(GetProcessHeap(), 0, adapter->cfgs);
}
/**********************************************************
* IUnknown parts follows
**********************************************************/
static HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *ppobj)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DDevice)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
unsigned int i;
for (i = 0; i < This->adapter_count; ++i)
{
wined3d_adapter_cleanup(&This->adapters[i]);
}
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/**********************************************************
* IWineD3D parts follows
**********************************************************/
/* GL locking is done by the caller */
static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
{
GLuint prog;
BOOL ret = FALSE;
const char *testcode =
"!!ARBvp1.0\n"
"PARAM C[66] = { program.env[0..65] };\n"
"ADDRESS A0;"
"PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
"ARL A0.x, zero.x;\n"
"MOV result.position, C[A0.x + 65];\n"
"END\n";
while(glGetError());
GL_EXTCALL(glGenProgramsARB(1, &prog));
if(!prog) {
ERR("Failed to create an ARB offset limit test program\n");
}
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(testcode), testcode));
if(glGetError() != 0) {
TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
ret = TRUE;
} else TRACE("OpenGL implementation allows offsets > 63\n");
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
GL_EXTCALL(glDeleteProgramsARB(1, &prog));
checkGLcall("ARB vp offset limit test cleanup");
return ret;
}
static DWORD ver_for_ext(GL_SupportedExt ext)
{
unsigned int i;
for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i) {
if(EXTENSION_MAP[i].extension == ext) {
return EXTENSION_MAP[i].version;
}
}
return 0;
}
static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor != HW_VENDOR_ATI) return FALSE;
if (device == CARD_ATI_RADEON_9500) return TRUE;
if (device == CARD_ATI_RADEON_X700) return TRUE;
if (device == CARD_ATI_RADEON_X1600) return TRUE;
return FALSE;
}
static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor == HW_VENDOR_NVIDIA)
{
if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
device == CARD_NVIDIA_GEFORCEFX_5600 ||
device == CARD_NVIDIA_GEFORCEFX_5800)
{
return TRUE;
}
}
return FALSE;
}
static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
/* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
* the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
* detect the Apple OpenGL implementation to apply some extension fixups afterwards.
*
* Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
* aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
* So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
* like client storage might be supported on other implementations too, but GL_APPLE_flush_render
* is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
* the chance that other implementations support them is rather small since Win32 QuickTime uses
* DirectDraw, not OpenGL.
*
* This test has been moved into wined3d_guess_gl_vendor()
*/
if (gl_vendor == GL_VENDOR_APPLE)
{
return TRUE;
}
return FALSE;
}
/* Context activation is done by the caller. */
static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
{
/* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
* but glTexSubImage from a PBO fails miserably, with the first line repeated over
* all the texture. This function detects this bug by its symptom and disables PBOs
* if the test fails.
*
* The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
* GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
* for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
* read back is compared to the original. If they are equal PBOs are assumed to work,
* otherwise the PBO extension is disabled. */
GLuint texture, pbo;
static const unsigned int pattern[] =
{
0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
};
unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
/* No PBO -> No point in testing them. */
if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
ENTER_GL();
while (glGetError());
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
checkGLcall("Specifying the PBO test texture");
GL_EXTCALL(glGenBuffersARB(1, &pbo));
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
checkGLcall("Specifying the PBO test pbo");
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
checkGLcall("Loading the PBO test texture");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
LEAVE_GL();
wglFinish(); /* just to be sure */
memset(check, 0, sizeof(check));
ENTER_GL();
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
checkGLcall("Reading back the PBO test texture");
glDeleteTextures(1, &texture);
GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
checkGLcall("PBO test cleanup");
LEAVE_GL();
if (memcmp(check, pattern, sizeof(check)))
{
WARN_(d3d_caps)("PBO test failed, read back data doesn't match original.\n");
WARN_(d3d_caps)("Disabling PBOs. This may result in slower performance.\n");
gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
}
else
{
TRACE_(d3d_caps)("PBO test successful.\n");
}
}
static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
}
static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
if (card_vendor != HW_VENDOR_ATI) return FALSE;
if (device == CARD_ATI_RADEON_X1600) return FALSE;
return TRUE;
}
static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
return gl_vendor == GL_VENDOR_FGLRX;
}
static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
/* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
* 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
* This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
* varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
* hardcoded
*
* dx10 cards usually have 64 varyings */
return gl_info->limits.glsl_varyings > 44;
}
/* A GL context is provided by the caller */
static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
GLenum error;
DWORD data[16];
if (!gl_info->supported[EXT_SECONDARY_COLOR]) return FALSE;
ENTER_GL();
while(glGetError());
GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
error = glGetError();
LEAVE_GL();
if(error == GL_NO_ERROR)
{
TRACE("GL Implementation accepts 4 component specular color pointers\n");
return TRUE;
}
else
{
TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
debug_glerror(error));
return FALSE;
}
}
static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (!match_apple(gl_info, gl_renderer, gl_vendor, card_vendor, device)) return FALSE;
return gl_info->supported[NV_TEXTURE_SHADER];
}
/* A GL context is provided by the caller */
static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
GLuint prog;
BOOL ret = FALSE;
GLint pos;
const char *testcode =
"!!ARBvp1.0\n"
"OPTION NV_vertex_program2;\n"
"MOV result.clip[0], 0.0;\n"
"MOV result.position, 0.0;\n"
"END\n";
if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
ENTER_GL();
while(glGetError());
GL_EXTCALL(glGenProgramsARB(1, &prog));
if(!prog)
{
ERR("Failed to create the NVvp clip test program\n");
LEAVE_GL();
return FALSE;
}
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(testcode), testcode));
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
if(pos != -1)
{
WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
ret = TRUE;
while(glGetError());
}
else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
GL_EXTCALL(glDeleteProgramsARB(1, &prog));
checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
LEAVE_GL();
return ret;
}
/* Context activation is done by the caller. */
static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
char data[4 * 4 * 4];
GLuint tex, fbo;
GLenum status;
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
memset(data, 0xcc, sizeof(data));
ENTER_GL();
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
checkGLcall("glTexImage2D");
gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
checkGLcall("glFramebufferTexture2D");
status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
checkGLcall("glCheckFramebufferStatus");
memset(data, 0x11, sizeof(data));
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
checkGLcall("glTexSubImage2D");
glClearColor(0.996, 0.729, 0.745, 0.792);
glClear(GL_COLOR_BUFFER_BIT);
checkGLcall("glClear");
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
checkGLcall("glGetTexImage");
gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
checkGLcall("glBindTexture");
gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
checkGLcall("glDeleteTextures");
LEAVE_GL();
return *(DWORD *)data == 0x11111111;
}
static void quirk_arb_constants(struct wined3d_gl_info *gl_info)
{
TRACE_(d3d_caps)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info->limits.arb_vs_native_constants);
gl_info->limits.glsl_vs_float_constants = gl_info->limits.arb_vs_native_constants;
TRACE_(d3d_caps)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info->limits.arb_ps_native_constants);
gl_info->limits.glsl_ps_float_constants = gl_info->limits.arb_ps_native_constants;
}
static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
{
quirk_arb_constants(gl_info);
/* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
* Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
* allow 48 different offsets or other helper immediate values. */
TRACE_(d3d_caps)("Reserving 12 GLSL constants for compiler private use.\n");
gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
}
/* fglrx crashes with a very bad kernel panic if GL_POINT_SPRITE_ARB is set to GL_COORD_REPLACE_ARB
* on more than one texture unit. This means that the d3d9 visual point size test will cause a
* kernel panic on any machine running fglrx 9.3(latest that supports r300 to r500 cards). This
* quirk only enables point sprites on the first texture unit. This keeps point sprites working in
* most games, but avoids the crash
*
* A more sophisticated way would be to find all units that need texture coordinates and enable
* point sprites for one if only one is found, and software emulate point sprites in drawStridedSlow
* if more than one unit needs texture coordinates(This requires software ffp and vertex shaders though)
*
* Note that disabling the extension entirely does not gain predictability because there is no point
* sprite capability flag in d3d, so the potential rendering bugs are the same if we disable the extension. */
static void quirk_one_point_sprite(struct wined3d_gl_info *gl_info)
{
if (gl_info->supported[ARB_POINT_SPRITE])
{
TRACE("Limiting point sprites to one texture unit.\n");
gl_info->limits.point_sprite_units = 1;
}
}
static void quirk_ati_dx9(struct wined3d_gl_info *gl_info)
{
quirk_arb_constants(gl_info);
/* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
* these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
* If real NP2 textures are used, the driver falls back to software. We could just remove the
* extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconventient
* due to the non-normalized texture coordinates. Thus set an internal extension flag,
* GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
* as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
*
* fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
* has this extension promoted to core. The extension loading code sets this extension supported
* due to that, so this code works on fglrx as well. */
if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
{
TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
gl_info->supported[WINE_NORMALIZED_TEXRECT] = TRUE;
}
/* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
* it is generally more efficient. Reserve just 8 constants. */
TRACE_(d3d_caps)("Reserving 8 GLSL constants for compiler private use.\n");
gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 8);
}
static void quirk_no_np2(struct wined3d_gl_info *gl_info)
{
/* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
* doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
* This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
* within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
* FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
* We therefore completely remove ARB_tex_npot from the list of supported extensions.
*
* Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
* triggering the software fallback. There is not much we can do here apart from disabling the
* software-emulated extension and reenable ARB_tex_rect (which was previously disabled
* in IWineD3DImpl_FillGLCaps).
* This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
* post-processing effects in the game "Max Payne 2").
* The behaviour can be verified through a simple test app attached in bugreport #14724. */
TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
}
static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
{
/* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
* with fixed function fragment processing. Ideally this flag should be detected with a test shader
* and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
* do not like vertex shaders in feedback mode and return an error, even though it should be valid
* according to the spec.
*
* We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
* makes the shader slower and eats instruction slots which should be available to the d3d app.
*
* ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
* all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
* this workaround is activated on cards that do not need it, it won't break things, just affect
* performance negatively. */
TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
}
static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
}
static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
}
static void quirk_apple_nvts(struct wined3d_gl_info *gl_info)
{
gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
}
static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
}
static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
}
struct driver_quirk
{
BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
void (*apply)(struct wined3d_gl_info *gl_info);
const char *description;
};
static const struct driver_quirk quirk_table[] =
{
{
match_ati_r300_to_500,
quirk_ati_dx9,
"ATI GLSL constant and normalized texrect quirk"
},
/* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
* used it falls back to software. While the compiler can detect if the shader uses all declared
* uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
* using relative addressing falls back to software.
*
* ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
{
match_apple,
quirk_apple_glsl_constants,
"Apple GLSL uniform override"
},
{
match_geforce5,
quirk_no_np2,
"Geforce 5 NP2 disable"
},
{
match_apple_intel,
quirk_texcoord_w,
"Init texcoord .w for Apple Intel GPU driver"
},
{
match_apple_nonr500ati,
quirk_texcoord_w,
"Init texcoord .w for Apple ATI >= r600 GPU driver"
},
{
match_fglrx,
quirk_one_point_sprite,
"Fglrx point sprite crash workaround"
},
{
match_dx10_capable,
quirk_clip_varying,
"Reserved varying for gl_ClipPos"
},
{
/* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
* GL implementations accept it. The Mac GL is the only implementation known to
* reject it.
*
* If we can pass 4 component specular colors, do it, because (a) we don't have
* to screw around with the data, and (b) the D3D fixed function vertex pipeline
* passes specular alpha to the pixel shader if any is used. Otherwise the
* specular alpha is used to pass the fog coordinate, which we pass to opengl
* via GL_EXT_fog_coord.
*/
match_allows_spec_alpha,
quirk_allows_specular_alpha,
"Allow specular alpha quirk"
},
{
/* The pixel formats provided by GL_NV_texture_shader are broken on OSX
* (rdar://5682521).
*/
match_apple_nvts,
quirk_apple_nvts,
"Apple NV_texture_shader disable"
},
{
match_broken_nv_clip,
quirk_disable_nvvp_clip,
"Apple NV_vertex_program clip bug quirk"
},
{
match_fbo_tex_update,
quirk_fbo_tex_update,
"FBO rebind for attachment updates"
},
};
/* Certain applications (Steam) complain if we report an outdated driver version. In general,
* reporting a driver version is moot because we are not the Windows driver, and we have different
* bugs, features, etc.
*
* The driver version has the form "x.y.z.w".
*
* "x" is the Windows version the driver is meant for:
* 4 -> 95/98/NT4
* 5 -> 2000
* 6 -> 2000/XP
* 7 -> Vista
* 8 -> Win 7
*
* "y" is the Direct3D level the driver supports:
* 11 -> d3d6
* 12 -> d3d7
* 13 -> d3d8
* 14 -> d3d9
* 15 -> d3d10
*
* "z" is unknown, possibly vendor specific.
*
* "w" is the vendor specific driver version.
*/
struct driver_version_information
{
WORD vendor; /* reported PCI card vendor ID */
WORD card; /* reported PCI card device ID */
const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
WORD d3d_level; /* driver hiword to report */
WORD lopart_hi, lopart_lo; /* driver loword to report */
};
static const struct driver_version_information driver_version_table[] =
{
/* Nvidia drivers. Geforce6 and newer cards are supported by the current driver (180.x)
* GeforceFX support is up to 173.x, - driver uses numbering x.y.11.7341 for 173.41 where x is the windows revision (6=2000/xp, 7=vista), y is unknown
* Geforce2MX/3/4 up to 96.x - driver uses numbering 9.6.8.9 for 96.89
* TNT/Geforce1/2 up to 71.x - driver uses numbering 7.1.8.6 for 71.86
*
* All version numbers used below are from the Linux nvidia drivers. */
{HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 },