1 /**************************************************************************
2 *
3 * Copyright 2012-2021 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 **************************************************************************/
27
28 /*
29 * Device.cpp --
30 * Functions that provide the 3D device functionality.
31 */
32
33
34 #include "Draw.h"
35 #include "DxgiFns.h"
36 #include "InputAssembly.h"
37 #include "OutputMerger.h"
38 #include "Query.h"
39 #include "Rasterizer.h"
40 #include "Resource.h"
41 #include "Shader.h"
42 #include "State.h"
43 #include "Format.h"
44
45 #include "Debug.h"
46
47 #include "util/u_sampler.h"
48
49
50 static void APIENTRY DestroyDevice(D3D10DDI_HDEVICE hDevice);
51 static void APIENTRY RelocateDeviceFuncs(D3D10DDI_HDEVICE hDevice,
52 __in struct D3D10DDI_DEVICEFUNCS *pDeviceFunctions);
53 static void APIENTRY RelocateDeviceFuncs1(D3D10DDI_HDEVICE hDevice,
54 __in struct D3D10_1DDI_DEVICEFUNCS *pDeviceFunctions);
55 static void APIENTRY Flush(D3D10DDI_HDEVICE hDevice);
56 static void APIENTRY CheckFormatSupport(D3D10DDI_HDEVICE hDevice, DXGI_FORMAT Format,
57 __out UINT *pFormatCaps);
58 static void APIENTRY CheckMultisampleQualityLevels(D3D10DDI_HDEVICE hDevice,
59 DXGI_FORMAT Format,
60 UINT SampleCount,
61 __out UINT *pNumQualityLevels);
62 static void APIENTRY SetTextFilterSize(D3D10DDI_HDEVICE hDevice, UINT Width, UINT Height);
63
64
65 /*
66 * ----------------------------------------------------------------------
67 *
68 * CalcPrivateDeviceSize --
69 *
70 * The CalcPrivateDeviceSize function determines the size of a memory
71 * region that the user-mode display driver requires from the Microsoft
72 * Direct3D runtime to store frequently-accessed data.
73 *
74 * ----------------------------------------------------------------------
75 */
76
77 SIZE_T APIENTRY
CalcPrivateDeviceSize(D3D10DDI_HADAPTER hAdapter,__in const D3D10DDIARG_CALCPRIVATEDEVICESIZE * pData)78 CalcPrivateDeviceSize(D3D10DDI_HADAPTER hAdapter, // IN
79 __in const D3D10DDIARG_CALCPRIVATEDEVICESIZE *pData) // IN
80 {
81 return sizeof(Device);
82 }
83
84 /*
85 * ----------------------------------------------------------------------
86 *
87 * CreateDevice --
88 *
89 * The CreateDevice function creates a graphics context that is
90 * referenced in subsequent calls.
91 *
92 * ----------------------------------------------------------------------
93 */
94
95 HRESULT APIENTRY
CreateDevice(D3D10DDI_HADAPTER hAdapter,__in D3D10DDIARG_CREATEDEVICE * pCreateData)96 CreateDevice(D3D10DDI_HADAPTER hAdapter, // IN
97 __in D3D10DDIARG_CREATEDEVICE *pCreateData) // IN
98 {
99 LOG_ENTRYPOINT();
100
101 if (0) {
102 DebugPrintf("hAdapter = %p\n", hAdapter);
103 DebugPrintf("pKTCallbacks = %p\n", pCreateData->pKTCallbacks);
104 DebugPrintf("p10_1DeviceFuncs = %p\n", pCreateData->p10_1DeviceFuncs);
105 DebugPrintf("hDrvDevice = %p\n", pCreateData->hDrvDevice);
106 DebugPrintf("DXGIBaseDDI = %p\n", pCreateData->DXGIBaseDDI);
107 DebugPrintf("hRTCoreLayer = %p\n", pCreateData->hRTCoreLayer);
108 DebugPrintf("pUMCallbacks = %p\n", pCreateData->pUMCallbacks);
109 }
110
111 switch (pCreateData->Interface) {
112 case D3D10_0_DDI_INTERFACE_VERSION:
113 case D3D10_0_x_DDI_INTERFACE_VERSION:
114 case D3D10_0_7_DDI_INTERFACE_VERSION:
115 #if SUPPORT_D3D10_1
116 case D3D10_1_DDI_INTERFACE_VERSION:
117 case D3D10_1_x_DDI_INTERFACE_VERSION:
118 case D3D10_1_7_DDI_INTERFACE_VERSION:
119 #endif
120 break;
121 default:
122 DebugPrintf("%s: unsupported interface version 0x%08x\n",
123 __func__, pCreateData->Interface);
124 return E_FAIL;
125 }
126
127 Adapter *pAdapter = CastAdapter(hAdapter);
128
129 Device *pDevice = CastDevice(pCreateData->hDrvDevice);
130 memset(pDevice, 0, sizeof *pDevice);
131
132 struct pipe_screen *screen = pAdapter->screen;
133 struct pipe_context *pipe = screen->context_create(screen, NULL, 0);
134 pDevice->pipe = pipe;
135 pDevice->cso = cso_create_context(pipe, CSO_NO_VBUF);
136
137 pDevice->empty_vs = CreateEmptyShader(pDevice, PIPE_SHADER_VERTEX);
138 pDevice->empty_fs = CreateEmptyShader(pDevice, PIPE_SHADER_FRAGMENT);
139
140 pipe->bind_vs_state(pipe, pDevice->empty_vs);
141 pipe->bind_fs_state(pipe, pDevice->empty_fs);
142
143 pDevice->max_dual_source_render_targets =
144 screen->get_param(screen, PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS);
145
146 pDevice->hRTCoreLayer = pCreateData->hRTCoreLayer;
147 pDevice->hDevice = (HANDLE)pCreateData->hRTDevice.handle;
148 pDevice->KTCallbacks = *pCreateData->pKTCallbacks;
149 pDevice->UMCallbacks = *pCreateData->pUMCallbacks;
150 pDevice->pDXGIBaseCallbacks = pCreateData->DXGIBaseDDI.pDXGIBaseCallbacks;
151
152 pDevice->draw_so_target = NULL;
153
154 if (0) {
155 DebugPrintf("pDevice = %p\n", pDevice);
156 }
157
158 st_debug_parse();
159
160 /*
161 * Fill in the D3D10 DDI functions
162 */
163 D3D10DDI_DEVICEFUNCS *pDeviceFuncs = pCreateData->pDeviceFuncs;
164 pDeviceFuncs->pfnDefaultConstantBufferUpdateSubresourceUP = ResourceUpdateSubResourceUP;
165 pDeviceFuncs->pfnVsSetConstantBuffers = VsSetConstantBuffers;
166 pDeviceFuncs->pfnPsSetShaderResources = PsSetShaderResources;
167 pDeviceFuncs->pfnPsSetShader = PsSetShader;
168 pDeviceFuncs->pfnPsSetSamplers = PsSetSamplers;
169 pDeviceFuncs->pfnVsSetShader = VsSetShader;
170 pDeviceFuncs->pfnDrawIndexed = DrawIndexed;
171 pDeviceFuncs->pfnDraw = Draw;
172 pDeviceFuncs->pfnDynamicIABufferMapNoOverwrite = ResourceMap;
173 pDeviceFuncs->pfnDynamicIABufferUnmap = ResourceUnmap;
174 pDeviceFuncs->pfnDynamicConstantBufferMapDiscard = ResourceMap;
175 pDeviceFuncs->pfnDynamicIABufferMapDiscard = ResourceMap;
176 pDeviceFuncs->pfnDynamicConstantBufferUnmap = ResourceUnmap;
177 pDeviceFuncs->pfnPsSetConstantBuffers = PsSetConstantBuffers;
178 pDeviceFuncs->pfnIaSetInputLayout = IaSetInputLayout;
179 pDeviceFuncs->pfnIaSetVertexBuffers = IaSetVertexBuffers;
180 pDeviceFuncs->pfnIaSetIndexBuffer = IaSetIndexBuffer;
181 pDeviceFuncs->pfnDrawIndexedInstanced = DrawIndexedInstanced;
182 pDeviceFuncs->pfnDrawInstanced = DrawInstanced;
183 pDeviceFuncs->pfnDynamicResourceMapDiscard = ResourceMap;
184 pDeviceFuncs->pfnDynamicResourceUnmap = ResourceUnmap;
185 pDeviceFuncs->pfnGsSetConstantBuffers = GsSetConstantBuffers;
186 pDeviceFuncs->pfnGsSetShader = GsSetShader;
187 pDeviceFuncs->pfnIaSetTopology = IaSetTopology;
188 pDeviceFuncs->pfnStagingResourceMap = ResourceMap;
189 pDeviceFuncs->pfnStagingResourceUnmap = ResourceUnmap;
190 pDeviceFuncs->pfnVsSetShaderResources = VsSetShaderResources;
191 pDeviceFuncs->pfnVsSetSamplers = VsSetSamplers;
192 pDeviceFuncs->pfnGsSetShaderResources = GsSetShaderResources;
193 pDeviceFuncs->pfnGsSetSamplers = GsSetSamplers;
194 pDeviceFuncs->pfnSetRenderTargets = SetRenderTargets;
195 pDeviceFuncs->pfnShaderResourceViewReadAfterWriteHazard = ShaderResourceViewReadAfterWriteHazard;
196 pDeviceFuncs->pfnResourceReadAfterWriteHazard = ResourceReadAfterWriteHazard;
197 pDeviceFuncs->pfnSetBlendState = SetBlendState;
198 pDeviceFuncs->pfnSetDepthStencilState = SetDepthStencilState;
199 pDeviceFuncs->pfnSetRasterizerState = SetRasterizerState;
200 pDeviceFuncs->pfnQueryEnd = QueryEnd;
201 pDeviceFuncs->pfnQueryBegin = QueryBegin;
202 pDeviceFuncs->pfnResourceCopyRegion = ResourceCopyRegion;
203 pDeviceFuncs->pfnResourceUpdateSubresourceUP = ResourceUpdateSubResourceUP;
204 pDeviceFuncs->pfnSoSetTargets = SoSetTargets;
205 pDeviceFuncs->pfnDrawAuto = DrawAuto;
206 pDeviceFuncs->pfnSetViewports = SetViewports;
207 pDeviceFuncs->pfnSetScissorRects = SetScissorRects;
208 pDeviceFuncs->pfnClearRenderTargetView = ClearRenderTargetView;
209 pDeviceFuncs->pfnClearDepthStencilView = ClearDepthStencilView;
210 pDeviceFuncs->pfnSetPredication = SetPredication;
211 pDeviceFuncs->pfnQueryGetData = QueryGetData;
212 pDeviceFuncs->pfnFlush = Flush;
213 pDeviceFuncs->pfnGenMips = GenMips;
214 pDeviceFuncs->pfnResourceCopy = ResourceCopy;
215 pDeviceFuncs->pfnResourceResolveSubresource = ResourceResolveSubResource;
216 pDeviceFuncs->pfnResourceMap = ResourceMap;
217 pDeviceFuncs->pfnResourceUnmap = ResourceUnmap;
218 pDeviceFuncs->pfnResourceIsStagingBusy = ResourceIsStagingBusy;
219 pDeviceFuncs->pfnRelocateDeviceFuncs = RelocateDeviceFuncs;
220 pDeviceFuncs->pfnCalcPrivateResourceSize = CalcPrivateResourceSize;
221 pDeviceFuncs->pfnCalcPrivateOpenedResourceSize = CalcPrivateOpenedResourceSize;
222 pDeviceFuncs->pfnCreateResource = CreateResource;
223 pDeviceFuncs->pfnOpenResource = OpenResource;
224 pDeviceFuncs->pfnDestroyResource = DestroyResource;
225 pDeviceFuncs->pfnCalcPrivateShaderResourceViewSize = CalcPrivateShaderResourceViewSize;
226 pDeviceFuncs->pfnCreateShaderResourceView = CreateShaderResourceView;
227 pDeviceFuncs->pfnDestroyShaderResourceView = DestroyShaderResourceView;
228 pDeviceFuncs->pfnCalcPrivateRenderTargetViewSize = CalcPrivateRenderTargetViewSize;
229 pDeviceFuncs->pfnCreateRenderTargetView = CreateRenderTargetView;
230 pDeviceFuncs->pfnDestroyRenderTargetView = DestroyRenderTargetView;
231 pDeviceFuncs->pfnCalcPrivateDepthStencilViewSize = CalcPrivateDepthStencilViewSize;
232 pDeviceFuncs->pfnCreateDepthStencilView = CreateDepthStencilView;
233 pDeviceFuncs->pfnDestroyDepthStencilView = DestroyDepthStencilView;
234 pDeviceFuncs->pfnCalcPrivateElementLayoutSize = CalcPrivateElementLayoutSize;
235 pDeviceFuncs->pfnCreateElementLayout = CreateElementLayout;
236 pDeviceFuncs->pfnDestroyElementLayout = DestroyElementLayout;
237 pDeviceFuncs->pfnCalcPrivateBlendStateSize = CalcPrivateBlendStateSize;
238 pDeviceFuncs->pfnCreateBlendState = CreateBlendState;
239 pDeviceFuncs->pfnDestroyBlendState = DestroyBlendState;
240 pDeviceFuncs->pfnCalcPrivateDepthStencilStateSize = CalcPrivateDepthStencilStateSize;
241 pDeviceFuncs->pfnCreateDepthStencilState = CreateDepthStencilState;
242 pDeviceFuncs->pfnDestroyDepthStencilState = DestroyDepthStencilState;
243 pDeviceFuncs->pfnCalcPrivateRasterizerStateSize = CalcPrivateRasterizerStateSize;
244 pDeviceFuncs->pfnCreateRasterizerState = CreateRasterizerState;
245 pDeviceFuncs->pfnDestroyRasterizerState = DestroyRasterizerState;
246 pDeviceFuncs->pfnCalcPrivateShaderSize = CalcPrivateShaderSize;
247 pDeviceFuncs->pfnCreateVertexShader = CreateVertexShader;
248 pDeviceFuncs->pfnCreateGeometryShader = CreateGeometryShader;
249 pDeviceFuncs->pfnCreatePixelShader = CreatePixelShader;
250 pDeviceFuncs->pfnCalcPrivateGeometryShaderWithStreamOutput = CalcPrivateGeometryShaderWithStreamOutput;
251 pDeviceFuncs->pfnCreateGeometryShaderWithStreamOutput = CreateGeometryShaderWithStreamOutput;
252 pDeviceFuncs->pfnDestroyShader = DestroyShader;
253 pDeviceFuncs->pfnCalcPrivateSamplerSize = CalcPrivateSamplerSize;
254 pDeviceFuncs->pfnCreateSampler = CreateSampler;
255 pDeviceFuncs->pfnDestroySampler = DestroySampler;
256 pDeviceFuncs->pfnCalcPrivateQuerySize = CalcPrivateQuerySize;
257 pDeviceFuncs->pfnCreateQuery = CreateQuery;
258 pDeviceFuncs->pfnDestroyQuery = DestroyQuery;
259 pDeviceFuncs->pfnCheckFormatSupport = CheckFormatSupport;
260 pDeviceFuncs->pfnCheckMultisampleQualityLevels = CheckMultisampleQualityLevels;
261 pDeviceFuncs->pfnCheckCounterInfo = CheckCounterInfo;
262 pDeviceFuncs->pfnCheckCounter = CheckCounter;
263 pDeviceFuncs->pfnDestroyDevice = DestroyDevice;
264 pDeviceFuncs->pfnSetTextFilterSize = SetTextFilterSize;
265 if (pCreateData->Interface == D3D10_1_DDI_INTERFACE_VERSION ||
266 pCreateData->Interface == D3D10_1_x_DDI_INTERFACE_VERSION ||
267 pCreateData->Interface == D3D10_1_7_DDI_INTERFACE_VERSION) {
268 D3D10_1DDI_DEVICEFUNCS *p10_1DeviceFuncs = pCreateData->p10_1DeviceFuncs;
269 p10_1DeviceFuncs->pfnRelocateDeviceFuncs = RelocateDeviceFuncs1;
270 p10_1DeviceFuncs->pfnCalcPrivateShaderResourceViewSize = CalcPrivateShaderResourceViewSize1;
271 p10_1DeviceFuncs->pfnCreateShaderResourceView = CreateShaderResourceView1;
272 p10_1DeviceFuncs->pfnCalcPrivateBlendStateSize = CalcPrivateBlendStateSize1;
273 p10_1DeviceFuncs->pfnCreateBlendState = CreateBlendState1;
274 p10_1DeviceFuncs->pfnResourceConvert = ResourceCopy;
275 p10_1DeviceFuncs->pfnResourceConvertRegion = ResourceCopyRegion;
276 }
277
278 /*
279 * Fill in DXGI DDI functions
280 */
281 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnPresent =
282 _Present;
283 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnGetGammaCaps =
284 _GetGammaCaps;
285 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnSetDisplayMode =
286 _SetDisplayMode;
287 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnSetResourcePriority =
288 _SetResourcePriority;
289 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnQueryResourceResidency =
290 _QueryResourceResidency;
291 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnRotateResourceIdentities =
292 _RotateResourceIdentities;
293 pCreateData->DXGIBaseDDI.pDXGIDDIBaseFunctions->pfnBlt =
294 _Blt;
295
296 if (0) {
297 return S_OK;
298 } else {
299 // Tell DXGI to not use the shared resource presentation path when
300 // communicating with DWM:
301 // http://msdn.microsoft.com/en-us/library/windows/hardware/ff569887(v=vs.85).aspx
302 return DXGI_STATUS_NO_REDIRECTION;
303 }
304 }
305
306
307 /*
308 * ----------------------------------------------------------------------
309 *
310 * DestroyDevice --
311 *
312 * The DestroyDevice function destroys a graphics context.
313 *
314 * ----------------------------------------------------------------------
315 */
316
317 void APIENTRY
DestroyDevice(D3D10DDI_HDEVICE hDevice)318 DestroyDevice(D3D10DDI_HDEVICE hDevice) // IN
319 {
320 unsigned i;
321
322 LOG_ENTRYPOINT();
323
324 Device *pDevice = CastDevice(hDevice);
325 struct pipe_context *pipe = pDevice->pipe;
326
327 pipe->flush(pipe, NULL, 0);
328
329 for (i = 0; i < PIPE_MAX_SO_BUFFERS; ++i) {
330 pipe_so_target_reference(&pDevice->so_targets[i], NULL);
331 }
332 if (pDevice->draw_so_target) {
333 pipe_so_target_reference(&pDevice->draw_so_target, NULL);
334 }
335
336 pipe->bind_fs_state(pipe, NULL);
337 pipe->bind_vs_state(pipe, NULL);
338 cso_destroy_context(pDevice->cso);
339
340 DeleteEmptyShader(pDevice, PIPE_SHADER_FRAGMENT, pDevice->empty_fs);
341 DeleteEmptyShader(pDevice, PIPE_SHADER_VERTEX, pDevice->empty_vs);
342
343 pipe_surface_reference(&pDevice->fb.zsbuf, NULL);
344 for (i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) {
345 pipe_surface_reference(&pDevice->fb.cbufs[i], NULL);
346 }
347
348 for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) {
349 if (!pDevice->vertex_buffers[i].is_user_buffer) {
350 pipe_resource_reference(&pDevice->vertex_buffers[i].buffer.resource, NULL);
351 }
352 }
353
354 pipe_resource_reference(&pDevice->index_buffer, NULL);
355
356 static struct pipe_sampler_view * sampler_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
357 memset(sampler_views, 0, sizeof sampler_views);
358 pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
359 PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, false, sampler_views);
360 pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0,
361 PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, false, sampler_views);
362 pipe->set_sampler_views(pipe, PIPE_SHADER_GEOMETRY, 0,
363 PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, false, sampler_views);
364
365 pipe->destroy(pipe);
366 }
367
368
369 /*
370 * ----------------------------------------------------------------------
371 *
372 * RelocateDeviceFuncs --
373 *
374 * The RelocateDeviceFuncs function notifies the user-mode
375 * display driver about the new location of the driver function table.
376 *
377 * ----------------------------------------------------------------------
378 */
379
380 void APIENTRY
RelocateDeviceFuncs(D3D10DDI_HDEVICE hDevice,__in struct D3D10DDI_DEVICEFUNCS * pDeviceFunctions)381 RelocateDeviceFuncs(D3D10DDI_HDEVICE hDevice, // IN
382 __in struct D3D10DDI_DEVICEFUNCS *pDeviceFunctions) // IN
383 {
384 LOG_ENTRYPOINT();
385
386 /*
387 * Nothing to do as we don't store a pointer to this entity.
388 */
389 }
390
391
392 /*
393 * ----------------------------------------------------------------------
394 *
395 * RelocateDeviceFuncs1 --
396 *
397 * The RelocateDeviceFuncs function notifies the user-mode
398 * display driver about the new location of the driver function table.
399 *
400 * ----------------------------------------------------------------------
401 */
402
403 void APIENTRY
RelocateDeviceFuncs1(D3D10DDI_HDEVICE hDevice,__in struct D3D10_1DDI_DEVICEFUNCS * pDeviceFunctions)404 RelocateDeviceFuncs1(D3D10DDI_HDEVICE hDevice, // IN
405 __in struct D3D10_1DDI_DEVICEFUNCS *pDeviceFunctions) // IN
406 {
407 LOG_ENTRYPOINT();
408
409 /*
410 * Nothing to do as we don't store a pointer to this entity.
411 */
412 }
413
414
415 /*
416 * ----------------------------------------------------------------------
417 *
418 * Flush --
419 *
420 * The Flush function submits outstanding hardware commands that
421 * are in the hardware command buffer to the display miniport driver.
422 *
423 * ----------------------------------------------------------------------
424 */
425
426 void APIENTRY
Flush(D3D10DDI_HDEVICE hDevice)427 Flush(D3D10DDI_HDEVICE hDevice) // IN
428 {
429 LOG_ENTRYPOINT();
430
431 struct pipe_context *pipe = CastPipeContext(hDevice);
432
433 pipe->flush(pipe, NULL, 0);
434 }
435
436
437 /*
438 * ----------------------------------------------------------------------
439 *
440 * CheckFormatSupport --
441 *
442 * The CheckFormatSupport function retrieves the capabilites that
443 * the device has with the specified format.
444 *
445 * ----------------------------------------------------------------------
446 */
447
448 void APIENTRY
CheckFormatSupport(D3D10DDI_HDEVICE hDevice,DXGI_FORMAT Format,__out UINT * pFormatCaps)449 CheckFormatSupport(D3D10DDI_HDEVICE hDevice, // IN
450 DXGI_FORMAT Format, // IN
451 __out UINT *pFormatCaps) // OUT
452 {
453 //LOG_ENTRYPOINT();
454
455 struct pipe_context *pipe = CastPipeContext(hDevice);
456 struct pipe_screen *screen = pipe->screen;
457
458 *pFormatCaps = 0;
459
460 enum pipe_format format = FormatTranslate(Format, false);
461 if (format == PIPE_FORMAT_NONE) {
462 *pFormatCaps = D3D10_DDI_FORMAT_SUPPORT_NOT_SUPPORTED;
463 return;
464 }
465
466 if (Format == DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM) {
467 /*
468 * We only need to support creation.
469 * http://msdn.microsoft.com/en-us/library/windows/hardware/ff552818.aspx
470 */
471 return;
472 }
473
474 if (screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, 0,
475 PIPE_BIND_RENDER_TARGET)) {
476 *pFormatCaps |= D3D10_DDI_FORMAT_SUPPORT_RENDERTARGET;
477 *pFormatCaps |= D3D10_DDI_FORMAT_SUPPORT_BLENDABLE;
478
479 #if SUPPORT_MSAA
480 if (screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 4, 4,
481 PIPE_BIND_RENDER_TARGET)) {
482 *pFormatCaps |= D3D10_DDI_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET;
483 }
484 #endif
485 }
486
487 if (screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, 0,
488 PIPE_BIND_SAMPLER_VIEW)) {
489 *pFormatCaps |= D3D10_DDI_FORMAT_SUPPORT_SHADER_SAMPLE;
490
491 #if SUPPORT_MSAA
492 if (screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 4, 4,
493 PIPE_BIND_RENDER_TARGET)) {
494 *pFormatCaps |= D3D10_DDI_FORMAT_SUPPORT_MULTISAMPLE_LOAD;
495 }
496 #endif
497 }
498 }
499
500
501 /*
502 * ----------------------------------------------------------------------
503 *
504 * CheckMultisampleQualityLevels --
505 *
506 * The CheckMultisampleQualityLevels function retrieves the number
507 * of quality levels that the device supports for the specified
508 * number of samples.
509 *
510 * ----------------------------------------------------------------------
511 */
512
513 void APIENTRY
CheckMultisampleQualityLevels(D3D10DDI_HDEVICE hDevice,DXGI_FORMAT Format,UINT SampleCount,__out UINT * pNumQualityLevels)514 CheckMultisampleQualityLevels(D3D10DDI_HDEVICE hDevice, // IN
515 DXGI_FORMAT Format, // IN
516 UINT SampleCount, // IN
517 __out UINT *pNumQualityLevels) // OUT
518 {
519 //LOG_ENTRYPOINT();
520
521 /* XXX: Disable MSAA */
522 *pNumQualityLevels = 0;
523 }
524
525
526 /*
527 * ----------------------------------------------------------------------
528 *
529 * SetTextFilterSize --
530 *
531 * The SetTextFilterSize function sets the width and height
532 * of the monochrome convolution filter.
533 *
534 * ----------------------------------------------------------------------
535 */
536
537 void APIENTRY
SetTextFilterSize(D3D10DDI_HDEVICE hDevice,UINT Width,UINT Height)538 SetTextFilterSize(D3D10DDI_HDEVICE hDevice, // IN
539 UINT Width, // IN
540 UINT Height) // IN
541 {
542 LOG_ENTRYPOINT();
543
544 LOG_UNSUPPORTED(Width != 1 || Height != 1);
545 }
546