1 /*==============================================================================
2 Copyright(c) 2017 Intel Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files(the "Software"),
6 to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and / or sell copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
21 ============================================================================*/
22
23 #include "Internal/Common/GmmLibInc.h"
24
25 #include <stdlib.h>
26
27 /////////////////////////////////////////////////////////////////////////////////////
28 /// C wrapper for GmmResourceInfoCommon::Create.
29 /// @see GmmLib::GmmResourceInfoCommon::Create()
30 ///
31 /// @param[in] pCreateParams: Flags which specify what sort of resource to create
32 /// @return Pointer to GmmResourceInfo class.
33 /////////////////////////////////////////////////////////////////////////////////////
GmmResCreate(GMM_RESCREATE_PARAMS * pCreateParams,GMM_LIB_CONTEXT * pLibContext)34 GMM_RESOURCE_INFO *GMM_STDCALL GmmResCreate(GMM_RESCREATE_PARAMS *pCreateParams, GMM_LIB_CONTEXT *pLibContext)
35 {
36 GMM_RESOURCE_INFO *pRes = NULL;
37
38 #if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
39 pRes = GmmResCreateThroughClientCtxt(pCreateParams);
40 return pRes;
41 #else
42
43 // GMM_RESOURCE_INFO...
44 if(pCreateParams->pPreallocatedResInfo)
45 {
46 pRes = new(pCreateParams->pPreallocatedResInfo) GmmLib::GmmResourceInfo(); // Use preallocated memory as a class
47 pCreateParams->Flags.Info.__PreallocatedResInfo =
48 pRes->GetResFlags().Info.__PreallocatedResInfo = 1; // Set both in case we can die before copying over the flags.
49 }
50 else
51 {
52 if((pRes = new GMM_RESOURCE_INFO) == NULL)
53 {
54 GMM_ASSERTDPF(0, "Allocation failed!");
55 goto ERROR_CASE;
56 }
57 }
58
59 if(pRes->Create(*pLibContext, *pCreateParams) != GMM_SUCCESS)
60 {
61 goto ERROR_CASE;
62 }
63
64 return (pRes);
65
66 ERROR_CASE:
67 if(pRes)
68 {
69 GmmResFree(pRes);
70 }
71
72 GMM_DPF_EXIT;
73 return (NULL);
74
75 #endif
76 }
77
78 /////////////////////////////////////////////////////////////////////////////////////
79 /// C wrapper for GmmResourceInfoCommon::opeartor=. Allocates a new class and
80 /// returns a pointer to it. The new class must be free'd explicitly by the client.
81 ///
82 /// @see GmmLib::GmmResourceInfoCommon::operator=()
83 ///
84 /// @param[in] pRes: Pointer to the GmmResourceInfo class that needs to be copied
85 /// @return Pointer to newly copied GmmResourceInfo class
86 /////////////////////////////////////////////////////////////////////////////////////
GmmResCopy(GMM_RESOURCE_INFO * pRes)87 GMM_RESOURCE_INFO *GMM_STDCALL GmmResCopy(GMM_RESOURCE_INFO *pRes)
88 {
89 GMM_RESOURCE_INFO *pResCopy = NULL;
90
91 GMM_DPF_ENTER;
92 __GMM_ASSERTPTR(pRes, NULL);
93
94 #if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
95 pResCopy = GmmResCopyThroughClientCtxt(pRes);
96 return pResCopy;
97 #else
98
99 pResCopy = new GMM_RESOURCE_INFO;
100
101 if(!pResCopy)
102 {
103 GMM_ASSERTDPF(0, "Allocation failed.");
104 return NULL;
105 }
106
107 *pResCopy = *pRes;
108
109 // We are allocating new class, flag must be false to avoid leak at DestroyResource
110 pResCopy->GetResFlags().Info.__PreallocatedResInfo = 0;
111
112 GMM_DPF_EXIT;
113 return (pResCopy);
114
115 #endif
116 }
117
118 /////////////////////////////////////////////////////////////////////////////////////
119 /// Helps clients copy one GmmResourceInfo object to another
120 ///
121 /// @param[in] pDst: Pointer to memory when pSrc will be copied.
122 /// @param[in] pSrc: Pointer to GmmResourceInfo class that needs to be copied
123 /////////////////////////////////////////////////////////////////////////////////////
GmmResMemcpy(void * pDst,void * pSrc)124 void GMM_STDCALL GmmResMemcpy(void *pDst, void *pSrc)
125 {
126 #if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
127 GmmResMemcpyThroughClientCtxt(pDst, pSrc);
128 #else
129 GMM_RESOURCE_INFO *pResSrc = reinterpret_cast<GMM_RESOURCE_INFO *>(pSrc);
130 // Init memory correctly, in case the pointer is a raw memory pointer
131 GMM_RESOURCE_INFO *pResDst = new(pDst) GMM_RESOURCE_INFO();
132
133 *pResDst = *pResSrc;
134 #endif
135 }
136
137 /////////////////////////////////////////////////////////////////////////////////////
138 /// C wrapper for ~GmmResourceInfoCommon. Frees the resource if it wasn't part of
139 /// ::GMM_RESCREATE_PARAMS::pPreallocatedResInfo.
140 /// @see GmmLib::GmmResourceInfoCommon::~GmmResourceInfoCommon()
141 ///
142 /// @param[in] pRes: Pointer to the GmmResourceInfo class that needs to be freed
143 /////////////////////////////////////////////////////////////////////////////////////
GmmResFree(GMM_RESOURCE_INFO * pRes)144 void GMM_STDCALL GmmResFree(GMM_RESOURCE_INFO *pRes)
145 {
146 GMM_DPF_ENTER;
147 __GMM_ASSERTPTR(pRes, VOIDRETURN);
148
149 #if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
150 GmmResFreeThroughClientCtxt(pRes);
151 #else
152
153 if(pRes->GetResFlags().Info.__PreallocatedResInfo)
154 {
155 *pRes = GmmLib::GmmResourceInfo();
156 }
157 else
158 {
159 delete pRes;
160 pRes = NULL;
161 }
162
163 #endif
164 }
165
166 /////////////////////////////////////////////////////////////////////////////////////
167 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetSystemMemPointer.
168 /// @see GmmLib::GmmResourceInfoCommon::GetSystemMemPointer()
169 ///
170 /// @param[in] pRes: Pointer to the GmmResourceInfo class
171 /// @param[in] IsD3DDdiAllocation: Specifies where allocation was made by a D3D client
172 /// @return Pointer to system memory. NULL if not available.
173 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSystemMemPointer(GMM_RESOURCE_INFO * pRes,uint8_t IsD3DDdiAllocation)174 void *GMM_STDCALL GmmResGetSystemMemPointer(GMM_RESOURCE_INFO *pRes,
175 uint8_t IsD3DDdiAllocation)
176 {
177 GMM_DPF_ENTER;
178 __GMM_ASSERTPTR(pRes, NULL);
179
180 return pRes->GetSystemMemPointer(IsD3DDdiAllocation);
181 }
182
183 /////////////////////////////////////////////////////////////////////////////////////
184 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetSystemMemSize.
185 /// @see GmmLib::GmmResourceInfoCommon::GetSystemMemSize()
186 ///
187 /// @param[in] pRes: Pointer to the GmmResourceInfo class
188 /// @return Size of memory.
189 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSystemMemSize(GMM_RESOURCE_INFO * pRes)190 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSystemMemSize(GMM_RESOURCE_INFO *pRes)
191 {
192 __GMM_ASSERTPTR(pRes, ((GMM_GFX_SIZE_T)0));
193 return pRes->GetSystemMemSize();
194 }
195
196 /////////////////////////////////////////////////////////////////////////////////////
197 /// This function returns size of GMM_RESOURCE_INFO
198 ///
199 /// @return size of class
200 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSizeOfStruct(void)201 uint32_t GMM_STDCALL GmmResGetSizeOfStruct(void)
202 {
203 return (sizeof(GMM_RESOURCE_INFO));
204 }
205
206 /////////////////////////////////////////////////////////////////////////////////////
207 /// This function returns resource flags
208 ///
209 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
210 /// @param[out] pFlags: Memory where resource flags will be copied
211 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetFlags(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_FLAG * pFlags)212 void GMM_STDCALL GmmResGetFlags(GMM_RESOURCE_INFO *pGmmResource,
213 GMM_RESOURCE_FLAG *pFlags /*output*/)
214 {
215 GMM_DPF_ENTER;
216 __GMM_ASSERTPTR(pGmmResource, VOIDRETURN);
217 __GMM_ASSERTPTR(pFlags, VOIDRETURN);
218
219 *pFlags = GmmResGetResourceFlags(pGmmResource);
220
221 GMM_DPF_EXIT;
222 }
223
224 /////////////////////////////////////////////////////////////////////////////////////
225 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetResourceType.
226 /// @see GmmLib::GmmResourceInfoCommon::GetResourceType()
227 ///
228 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
229 /// @return Resource Type
230 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetResourceType(GMM_RESOURCE_INFO * pGmmResource)231 GMM_RESOURCE_TYPE GMM_STDCALL GmmResGetResourceType(GMM_RESOURCE_INFO *pGmmResource)
232 {
233 __GMM_ASSERTPTR(pGmmResource, RESOURCE_INVALID);
234 return pGmmResource->GetResourceType();
235 }
236
237 /////////////////////////////////////////////////////////////////////////////////////
238 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetResourceFormat.
239 /// @see GmmLib::GmmResourceInfoCommon::GetResourceFormat()
240 ///
241 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
242 /// @return Resource Format
243 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetResourceFormat(GMM_RESOURCE_INFO * pGmmResource)244 GMM_RESOURCE_FORMAT GMM_STDCALL GmmResGetResourceFormat(GMM_RESOURCE_INFO *pGmmResource)
245 {
246 __GMM_ASSERTPTR(pGmmResource, GMM_FORMAT_INVALID);
247 return pGmmResource->GetResourceFormat();
248 }
249
250 /////////////////////////////////////////////////////////////////////////////////////
251 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetPaddedWidth.
252 /// @see GmmLib::GmmResourceInfoCommon::GetPaddedWidth()
253 ///
254 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
255 /// @param[in] MipLevel: Requested mip level
256 /// @return Padded Width
257 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPaddedWidth(GMM_RESOURCE_INFO * pGmmResource,uint32_t MipLevel)258 uint32_t GMM_STDCALL GmmResGetPaddedWidth(GMM_RESOURCE_INFO *pGmmResource,
259 uint32_t MipLevel)
260 {
261 __GMM_ASSERTPTR(pGmmResource, 0);
262 return pGmmResource->GetPaddedWidth(MipLevel);
263 }
264
265 /////////////////////////////////////////////////////////////////////////////////////
266 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetPaddedHeight.
267 /// @see GmmLib::GmmResourceInfoCommon::GetPaddedHeight()
268 ///
269 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
270 /// @param[in] MipLevel: Requested mip level
271 /// @return Padded Height
272 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPaddedHeight(GMM_RESOURCE_INFO * pGmmResource,uint32_t MipLevel)273 uint32_t GMM_STDCALL GmmResGetPaddedHeight(GMM_RESOURCE_INFO *pGmmResource,
274 uint32_t MipLevel)
275 {
276 __GMM_ASSERTPTR(pGmmResource, 0);
277 return pGmmResource->GetPaddedHeight(MipLevel);
278 }
279
280 /////////////////////////////////////////////////////////////////////////////////////
281 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetPaddedPitch.
282 /// @see GmmLib::GmmResourceInfoCommon::GetPaddedPitch()
283 ///
284 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
285 /// @param[in] MipLevel: Requested mip level
286 /// @return Padded Pitch
287 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPaddedPitch(GMM_RESOURCE_INFO * pGmmResource,uint32_t MipLevel)288 uint32_t GMM_STDCALL GmmResGetPaddedPitch(GMM_RESOURCE_INFO *pGmmResource,
289 uint32_t MipLevel)
290 {
291 __GMM_ASSERTPTR(pGmmResource, 0);
292 return pGmmResource->GetPaddedPitch(MipLevel);
293 }
294
295 /////////////////////////////////////////////////////////////////////////////////////
296 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetBaseWidth. Truncates width to
297 /// 32-bit.
298 /// @see GmmLib::GmmResourceInfoCommon::GetBaseWidth()
299 ///
300 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
301 /// @return Width
302 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetBaseWidth(GMM_RESOURCE_INFO * pGmmResource)303 uint32_t GMM_STDCALL GmmResGetBaseWidth(GMM_RESOURCE_INFO *pGmmResource)
304 {
305 __GMM_ASSERTPTR(pGmmResource, 0);
306 return GFX_ULONG_CAST(pGmmResource->GetBaseWidth());
307 }
308
309 /////////////////////////////////////////////////////////////////////////////////////
310 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetBaseWidth.
311 /// @see GmmLib::GmmResourceInfoCommon::GetBaseWidth()
312 ///
313 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
314 /// @return Width
315 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetBaseWidth64(GMM_RESOURCE_INFO * pGmmResource)316 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetBaseWidth64(GMM_RESOURCE_INFO *pGmmResource)
317 {
318 __GMM_ASSERTPTR(pGmmResource, 0);
319 return pGmmResource->GetBaseWidth();
320 }
321
322 /////////////////////////////////////////////////////////////////////////////////////
323 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetBaseAlignment.
324 /// @see GmmLib::GmmResourceInfoCommon::GetBaseAlignment()
325 ///
326 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
327 /// @return Base Alignment
328 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetBaseAlignment(GMM_RESOURCE_INFO * pGmmResource)329 uint32_t GMM_STDCALL GmmResGetBaseAlignment(GMM_RESOURCE_INFO *pGmmResource)
330 {
331 __GMM_ASSERTPTR(pGmmResource, 0);
332 return pGmmResource->GetBaseAlignment();
333 }
334
335 /////////////////////////////////////////////////////////////////////////////////////
336 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetBaseHeight.
337 /// @see GmmLib::GmmResourceInfoCommon::GetBaseHeight()
338 ///
339 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
340 /// @return Height
341 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetBaseHeight(GMM_RESOURCE_INFO * pGmmResource)342 uint32_t GMM_STDCALL GmmResGetBaseHeight(GMM_RESOURCE_INFO *pGmmResource)
343 {
344 __GMM_ASSERTPTR(pGmmResource, 0);
345 return pGmmResource->GetBaseHeight();
346 }
347
348 /////////////////////////////////////////////////////////////////////////////////////
349 /// C wrapper for GmmLib::GmmResourceInfoCommon::GmmResGetDepth.
350 /// @see GmmLib::GmmResourceInfoCommon::GmmResGetDepth()
351 ///
352 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
353 /// @return Depth
354 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetDepth(GMM_RESOURCE_INFO * pGmmResource)355 uint32_t GMM_STDCALL GmmResGetDepth(GMM_RESOURCE_INFO *pGmmResource)
356 {
357 __GMM_ASSERTPTR(pGmmResource, 0);
358 return pGmmResource->GetBaseDepth();
359 }
360
361 /////////////////////////////////////////////////////////////////////////////////////
362 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMaxLod.
363 /// @see GmmLib::GmmResourceInfoCommon::GetMaxLod()
364 ///
365 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
366 /// @return Max Lod
367 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMaxLod(GMM_RESOURCE_INFO * pGmmResource)368 uint32_t GMM_STDCALL GmmResGetMaxLod(GMM_RESOURCE_INFO *pGmmResource)
369 {
370 __GMM_ASSERTPTR(pGmmResource, 0);
371 return pGmmResource->GetMaxLod();
372 }
373
374 /////////////////////////////////////////////////////////////////////////////////////
375 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMipTailStartLod.SurfaceState
376 /// @see GmmLib::GmmResourceInfoCommon::GetMipTailStartLodSurfaceState()
377 ///
378 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
379 /// @return Mip Tail Starts
380 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateMipTailStartLod(GMM_RESOURCE_INFO * pGmmResource)381 uint32_t GMM_STDCALL GmmResGetSurfaceStateMipTailStartLod(GMM_RESOURCE_INFO *pGmmResource)
382 {
383 __GMM_ASSERT(pGmmResource);
384 return pGmmResource->GetMipTailStartLodSurfaceState();
385 }
386
387 /////////////////////////////////////////////////////////////////////////////////////
388 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetTileAddressMappingMode.SurfaceState
389 /// @see GmmLib::GmmResourceInfoCommon::GetTileAddressMappingModeSurfaceState()
390 ///
391 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
392 /// @return Tile Address Mapping Mode
393 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateTileAddressMappingMode(GMM_RESOURCE_INFO * pGmmResource)394 uint32_t GMM_STDCALL GmmResGetSurfaceStateTileAddressMappingMode(GMM_RESOURCE_INFO *pGmmResource)
395 {
396 __GMM_ASSERT(pGmmResource);
397 return pGmmResource->GetTileAddressMappingModeSurfaceState();
398 }
399
400 /////////////////////////////////////////////////////////////////////////////////////
401 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetStdTilingModeExt.SurfaceState
402 /// @see GmmLib::GmmResourceInfoCommon::GetStdTilingModeExtSurfaceState()
403 ///
404 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
405 /// @return Std Tiling Mode Ext
406 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateStdTilingModeExt(GMM_RESOURCE_INFO * pGmmResource)407 uint32_t GMM_STDCALL GmmResGetSurfaceStateStdTilingModeExt(GMM_RESOURCE_INFO *pGmmResource)
408 {
409 __GMM_ASSERTPTR(pGmmResource, GMM_INVALIDPARAM);
410 return pGmmResource->GetStdTilingModeExtSurfaceState();
411 }
412
413 /////////////////////////////////////////////////////////////////////////////////////
414 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetArraySize.
415 /// @see GmmLib::GmmResourceInfoCommon::GetArraySize()
416 ///
417 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
418 /// @return Array Size
419 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetArraySize(GMM_RESOURCE_INFO * pGmmResource)420 uint32_t GMM_STDCALL GmmResGetArraySize(GMM_RESOURCE_INFO *pGmmResource)
421 {
422 __GMM_ASSERTPTR(pGmmResource, 0);
423 return pGmmResource->GetArraySize();
424 }
425
426 #if(LHDM)
427 /////////////////////////////////////////////////////////////////////////////////////
428 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetRefreshRate.
429 /// @see GmmLib::GmmResourceInfoCommon::GetRefreshRate()
430 ///
431 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
432 /// @return Refresh rate
433 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetRefreshRate(GMM_RESOURCE_INFO * pGmmResource)434 D3DDDI_RATIONAL GMM_STDCALL GmmResGetRefreshRate(GMM_RESOURCE_INFO *pGmmResource)
435 {
436 D3DDDI_RATIONAL RetVal = {0};
437 __GMM_ASSERTPTR(pGmmResource, RetVal);
438 return pGmmResource->GetRefreshRate();
439 }
440 #endif // LHDM
441
442 #if(LHDM)
443 /////////////////////////////////////////////////////////////////////////////////////
444 /// C wrapper for GmmLib::GmmResourceInfoWin::GetD3d9Flags.
445 /// @see GmmLib::GmmResourceInfoWin::GetD3d9Flags()
446 ///
447 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
448 /// @param[out] pD3d9Flags: Mscaps data is copied to this param
449 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetD3d9Flags(GMM_RESOURCE_INFO * pGmmResource,D3DDDI_RESOURCEFLAGS * pD3d9Flags)450 void GMM_STDCALL GmmResGetD3d9Flags(GMM_RESOURCE_INFO * pGmmResource,
451 D3DDDI_RESOURCEFLAGS *pD3d9Flags)
452 {
453 __GMM_ASSERTPTR(pGmmResource, VOIDRETURN);
454 __GMM_ASSERTPTR(pD3d9Flags, VOIDRETURN);
455
456 *pD3d9Flags = pGmmResource->GetD3d9Flags();
457 }
458
459 /////////////////////////////////////////////////////////////////////////////////////
460 /// C wrapper for GmmLib::GmmResourceInfoWin::GetD3d9Format.
461 /// @see GmmLib::GmmResourceInfoWin::GetD3d9Format()
462 ///
463 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
464 /// @return D3d9 format for the resource
465 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetD3d9Format(GMM_RESOURCE_INFO * pGmmResource)466 D3DDDIFORMAT GMM_STDCALL GmmResGetD3d9Format(GMM_RESOURCE_INFO *pGmmResource)
467 {
468 __GMM_ASSERTPTR(pGmmResource, (D3DDDIFORMAT)0);
469 return pGmmResource->GetD3d9Format();
470 }
471
472
473 /////////////////////////////////////////////////////////////////////////////////////
474 /// C wrapper for GmmLib::GmmResourceInfoWin::GetVidSourceId.
475 /// @see GmmLib::GmmResourceInfoWin::GetVidSourceId()
476 ///
477 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
478 /// @return Source Id
479 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetVidSourceId(GMM_RESOURCE_INFO * pGmmResource)480 D3DDDI_VIDEO_PRESENT_SOURCE_ID GMM_STDCALL GmmResGetVidSourceId(GMM_RESOURCE_INFO *pGmmResource)
481 {
482 __GMM_ASSERTPTR(pGmmResource, 0);
483 return pGmmResource->GetVidSourceId();
484 }
485
486 #endif // LHDM
487
488 /////////////////////////////////////////////////////////////////////////////////////
489 /// C wrapper for GmmLib::GmmResourceInfoWin::Is64KBPageSuitable.
490 /// @see GmmLib::GmmResourceInfoWin::Is64KBPageSuitable()
491 ///
492 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
493 /// @return 1/0
494 /////////////////////////////////////////////////////////////////////////////////////
GmmResIs64KBPageSuitable(GMM_RESOURCE_INFO * pGmmResource)495 uint8_t GMM_STDCALL GmmResIs64KBPageSuitable(GMM_RESOURCE_INFO *pGmmResource)
496 {
497 __GMM_ASSERTPTR(pGmmResource, 0);
498 return pGmmResource->Is64KBPageSuitable();
499 }
500
501
502
503 /////////////////////////////////////////////////////////////////////////////////////
504 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetRotateInfo.
505 /// @see GmmLib::GmmResourceInfoCommon::GetRotateInfo()
506 ///
507 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
508 /// @return rotation info
509 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetRotateInfo(GMM_RESOURCE_INFO * pGmmResource)510 uint32_t GMM_STDCALL GmmResGetRotateInfo(GMM_RESOURCE_INFO *pGmmResource)
511 {
512 __GMM_ASSERTPTR(pGmmResource, 0);
513 return pGmmResource->GetRotateInfo();
514 }
515
516 /////////////////////////////////////////////////////////////////////////////////////
517 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetAuxQPitch.
518 /// @see GmmLib::GmmResourceInfoCommon::GetAuxQPitch()
519 ///
520 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
521 /// @return Aux QPitch
522 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxQPitch(GMM_RESOURCE_INFO * pGmmResource)523 uint32_t GMM_STDCALL GmmResGetAuxQPitch(GMM_RESOURCE_INFO *pGmmResource)
524 {
525 __GMM_ASSERTPTR(pGmmResource, 0);
526 return pGmmResource->GetAuxQPitch();
527 }
528
529 /////////////////////////////////////////////////////////////////////////////////////
530 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetQPitch.
531 /// @see GmmLib::GmmResourceInfoCommon::GetQPitch()
532 ///
533 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
534 /// @return QPitch
535 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetQPitch(GMM_RESOURCE_INFO * pGmmResource)536 uint32_t GMM_STDCALL GmmResGetQPitch(GMM_RESOURCE_INFO *pGmmResource)
537 {
538 __GMM_ASSERTPTR(pGmmResource, 0);
539 return pGmmResource->GetQPitch();
540 }
541
542 /////////////////////////////////////////////////////////////////////////////////////
543 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetQPitchPlanar.
544 /// @see GmmLib::GmmResourceInfoCommon::GetQPitchPlanar()
545 ///
546 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
547 /// @return Planar QPitch
548 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetQPitchPlanar(GMM_RESOURCE_INFO * pGmmResource,GMM_YUV_PLANE Plane)549 uint32_t GMM_STDCALL GmmResGetQPitchPlanar(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane)
550 {
551 __GMM_ASSERTPTR(pGmmResource, 0);
552 return pGmmResource->GetQPitchPlanar(Plane);
553 }
554
555 /////////////////////////////////////////////////////////////////////////////////////
556 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetQPitchInBytes.
557 /// @see GmmLib::GmmResourceInfoCommon::GetQPitchInBytes()
558 ///
559 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
560 /// @return QPitch
561 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetQPitchInBytes(GMM_RESOURCE_INFO * pGmmResource)562 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetQPitchInBytes(GMM_RESOURCE_INFO *pGmmResource)
563 {
564 __GMM_ASSERT(pGmmResource);
565 return pGmmResource->GetQPitchInBytes();
566 }
567
568 /////////////////////////////////////////////////////////////////////////////////////
569 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetRenderPitch.
570 /// @see GmmLib::GmmResourceInfoCommon::GetRenderPitch()
571 ///
572 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
573 /// @return Pitch
574 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetRenderPitch(GMM_RESOURCE_INFO * pGmmResource)575 uint32_t GMM_STDCALL GmmResGetRenderPitch(GMM_RESOURCE_INFO *pGmmResource)
576 {
577 __GMM_ASSERTPTR(pGmmResource, 0);
578 return GFX_ULONG_CAST(pGmmResource->GetRenderPitch());
579 }
580
581 /////////////////////////////////////////////////////////////////////////////////////
582 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetRenderPitchTiles.
583 /// @see GmmLib::GmmResourceInfoCommon::GetRenderPitchTiles()
584 ///
585 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
586 /// @return Pitch in tiles
587 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetRenderPitchTiles(GMM_RESOURCE_INFO * pGmmResource)588 uint32_t GMM_STDCALL GmmResGetRenderPitchTiles(GMM_RESOURCE_INFO *pGmmResource)
589 {
590 __GMM_ASSERTPTR(pGmmResource, 0);
591 return pGmmResource->GetRenderPitchTiles();
592 }
593
594 /////////////////////////////////////////////////////////////////////////////////////
595 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetRenderAuxPitchTiles.
596 /// @see GmmLib::GmmResourceInfoCommon::GetRenderAuxPitchTiles()
597 ///
598 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
599 /// @return Aux Pitch in tiles
600 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetRenderAuxPitchTiles(GMM_RESOURCE_INFO * pGmmResource)601 uint32_t GMM_STDCALL GmmResGetRenderAuxPitchTiles(GMM_RESOURCE_INFO *pGmmResource)
602 {
603 __GMM_ASSERTPTR(pGmmResource, 0);
604 return pGmmResource->GetRenderAuxPitchTiles();
605 }
606
607 /////////////////////////////////////////////////////////////////////////////////////
608 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetUnifiedAuxPitch.
609 /// @see GmmLib::GmmResourceInfoCommon::GetUnifiedAuxPitch()
610 ///
611 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
612 /// @return Aux Pitch
613 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxPitch(GMM_RESOURCE_INFO * pGmmResource)614 uint32_t GMM_STDCALL GmmResGetAuxPitch(GMM_RESOURCE_INFO *pGmmResource)
615 {
616 __GMM_ASSERTPTR(pGmmResource, 0);
617 return GFX_ULONG_CAST(pGmmResource->GetUnifiedAuxPitch());
618 }
619
620 /////////////////////////////////////////////////////////////////////////////////////
621 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetBitsPerPixel.
622 /// @see GmmLib::GmmResourceInfoCommon::GetBitsPerPixel()
623 ///
624 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
625 /// @return bpp
626 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetBitsPerPixel(GMM_RESOURCE_INFO * pGmmResource)627 uint32_t GMM_STDCALL GmmResGetBitsPerPixel(GMM_RESOURCE_INFO *pGmmResource)
628 {
629 __GMM_ASSERTPTR(pGmmResource, 0);
630 return pGmmResource->GetBitsPerPixel();
631 }
632
633 /////////////////////////////////////////////////////////////////////////////////////
634 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetUnifiedAuxBitsPerPixel.
635 /// @see GmmLib::GmmResourceInfoCommon::GetUnifiedAuxBitsPerPixel()
636 ///
637 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
638 /// @return bpp
639 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxBitsPerPixel(GMM_RESOURCE_INFO * pGmmResource)640 uint32_t GMM_STDCALL GmmResGetAuxBitsPerPixel(GMM_RESOURCE_INFO *pGmmResource)
641 {
642 __GMM_ASSERTPTR(pGmmResource, 0);
643 return pGmmResource->GetUnifiedAuxBitsPerPixel();
644 }
645
646 /////////////////////////////////////////////////////////////////////////////////////
647 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetCompressionBlockXxx.
648 /// @see GmmLib::GmmResourceInfoCommon::GetCompressionBlockWidth()
649 /// @see GmmLib::GmmResourceInfoCommon::GetCompressionBlockHeight()
650 /// @see GmmLib::GmmResourceInfoCommon::GetCompressionBlockDepth()
651 ///
652 /// @param[in] pRes: Pointer to the GmmResourceInfo class
653 /// @return Compression Block Width/Height/Depth
654 /////////////////////////////////////////////////////////////////////////////////////
655 #define GmmResGetCompressionBlockXxx(Xxx) \
656 uint32_t GMM_STDCALL GmmResGetCompressionBlock##Xxx(GMM_RESOURCE_INFO *pGmmResource) \
657 { \
658 __GMM_ASSERTPTR(pGmmResource, 1); \
659 return pGmmResource->GetCompressionBlock##Xxx(); \
660 } ///////////////////////////////////////////////////////
661 GmmResGetCompressionBlockXxx(Width)
GmmResGetCompressionBlockXxx(Height)662 GmmResGetCompressionBlockXxx(Height)
663 GmmResGetCompressionBlockXxx(Depth)
664
665 /////////////////////////////////////////////////////////////////////////////////////
666 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetUnifiedAuxBitsPerPixel.
667 /// @see GmmLib::GmmResourceInfoCommon::GetUnifiedAuxBitsPerPixel()
668 ///
669 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
670 /// @param[in][out] pReqInfo: Has info about which offset client is requesting. Offset is also
671 /// passed back to the client in this parameter.
672 /// @return ::GMM_STATUS
673 /////////////////////////////////////////////////////////////////////////////////////
674 GMM_STATUS GMM_STDCALL GmmResGetOffset(GMM_RESOURCE_INFO * pGmmResource,
675 GMM_REQ_OFFSET_INFO *pReqInfo)
676 {
677 __GMM_ASSERTPTR(pGmmResource, GMM_ERROR);
678 __GMM_ASSERTPTR(pReqInfo, GMM_ERROR);
679
680 return pGmmResource->GetOffset(*pReqInfo);
681 }
682
683 /////////////////////////////////////////////////////////////////////////////////////
684 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetTextureLayout.
685 /// @see GmmLib::GmmResourceInfoCommon::GetTextureLayout()
686 ///
687 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
688 /// @return GMM_2D_LAYOUT_RIGHT or GMM_2D_LAYOUT_BELOW
689 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetTextureLayout(GMM_RESOURCE_INFO * pGmmResource)690 GMM_TEXTURE_LAYOUT GMM_STDCALL GmmResGetTextureLayout(GMM_RESOURCE_INFO *pGmmResource)
691 {
692 __GMM_ASSERT(pGmmResource);
693 return pGmmResource->GetTextureLayout();
694 }
695
696 /////////////////////////////////////////////////////////////////////////////////////
697 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetTileType.
698 /// @see GmmLib::GmmResourceInfoCommon::GetTileType()
699 ///
700 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
701 /// @return ::GMM_TILE_TYPE
702 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetTileType(GMM_RESOURCE_INFO * pGmmResource)703 GMM_TILE_TYPE GMM_STDCALL GmmResGetTileType(GMM_RESOURCE_INFO *pGmmResource)
704 {
705 __GMM_ASSERT(pGmmResource);
706 return pGmmResource->GetTileType();
707 }
708
709 /////////////////////////////////////////////////////////////////////////////////////
710 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMipHeight.
711 /// @see GmmLib::GmmResourceInfoCommon::GetMipHeight()
712 ///
713 /// @param[in] pResourceInfo: Pointer to the GmmResourceInfo class
714 /// @param[in] MipLevel: Mip level for which the info is needed
715 /// @return Mip Height
716 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMipHeight(GMM_RESOURCE_INFO * pResourceInfo,uint32_t MipLevel)717 uint32_t GMM_STDCALL GmmResGetMipHeight(GMM_RESOURCE_INFO *pResourceInfo, uint32_t MipLevel)
718 {
719 return pResourceInfo->GetMipHeight(MipLevel);
720 }
721
722 /////////////////////////////////////////////////////////////////////////////////////
723 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMipWidth.
724 /// @see GmmLib::GmmResourceInfoCommon::GetMipWidth()
725 ///
726 /// @param[in] pResourceInfo: Pointer to the GmmResourceInfo class
727 /// @param[in] MipLevel: Mip level for which the info is needed
728 /// @return Mip Width
729 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMipWidth(GMM_RESOURCE_INFO * pResourceInfo,uint32_t MipLevel)730 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetMipWidth(GMM_RESOURCE_INFO *pResourceInfo, uint32_t MipLevel)
731 {
732 return pResourceInfo->GetMipWidth(MipLevel);
733 }
734
735 /////////////////////////////////////////////////////////////////////////////////////
736 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMipDepth.
737 /// @see GmmLib::GmmResourceInfoCommon::GetMipDepth()
738 ///
739 /// @param[in] pResourceInfo: Pointer to the GmmResourceInfo class
740 /// @param[in] MipLevel: Mip level for which the info is needed
741 /// @return Mip Depth
742 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMipDepth(GMM_RESOURCE_INFO * pResourceInfo,uint32_t MipLevel)743 uint32_t GMM_STDCALL GmmResGetMipDepth(GMM_RESOURCE_INFO *pResourceInfo, uint32_t MipLevel)
744 {
745 return pResourceInfo->GetMipDepth(MipLevel);
746 }
747
748 //=============================================================================
749 //
750 // Function:GmmResGetCornerTexelMode
751 //
752 // Desc:
753 // Simple getter function to return the Corner Texel Mode of a surface.
754 //
755 // Parameters:
756 // pGmmResource: ==> A previously allocated resource.
757 //
758 // Returns:
759 // CornerTexelMode flag ==> uint8_t
760 //-----------------------------------------------------------------------------
GmmResGetCornerTexelMode(GMM_RESOURCE_INFO * pGmmResource)761 uint8_t GMM_STDCALL GmmResGetCornerTexelMode(GMM_RESOURCE_INFO *pGmmResource)
762 {
763 GMM_DPF_ENTER;
764 __GMM_ASSERT(pGmmResource);
765
766 return ((pGmmResource->GetResFlags().Info.CornerTexelMode) ? 1 : 0);
767 }
768
769 /////////////////////////////////////////////////////////////////////////////////////
770 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetCpuCacheType.
771 /// @see GmmLib::GmmResourceInfoCommon::GetCpuCacheType()
772 ///
773 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
774 /// @return ::GMM_CPU_CACHE_TYPE
775 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetCpuCacheType(GMM_RESOURCE_INFO * pGmmResource)776 GMM_CPU_CACHE_TYPE GMM_STDCALL GmmResGetCpuCacheType(GMM_RESOURCE_INFO *pGmmResource)
777 {
778 __GMM_ASSERT(pGmmResource);
779 return pGmmResource->GetCpuCacheType();
780 }
781
782 /////////////////////////////////////////////////////////////////////////////////////
783 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMmcMode.
784 /// @see GmmLib::GmmResourceInfoCommon::GetMmcMode()
785 ///
786 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
787 /// @param[in] ArrayIndex: ArrayIndex for which this info is needed
788 /// @return Media Memory Compression Mode (Disabled, Horizontal, Vertical)
789 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMmcMode(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArrayIndex)790 GMM_RESOURCE_MMC_INFO GMM_STDCALL GmmResGetMmcMode(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex)
791 {
792 __GMM_ASSERT(pGmmResource);
793 return pGmmResource->GetMmcMode(ArrayIndex);
794 }
795
796 /////////////////////////////////////////////////////////////////////////////////////
797 /// C wrapper for GmmLib::GmmResourceInfoCommon::SetMmcMode.
798 /// @see GmmLib::GmmResourceInfoCommon::SetMmcMode()
799 ///
800 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
801 /// @param[in] Mode Media Memory Compression Mode (Disabled, Horizontal, Vertical)
802 /// @param[in] ArrayIndex ArrayIndex for which this info needs to be set
803 /////////////////////////////////////////////////////////////////////////////////////
GmmResSetMmcMode(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_MMC_INFO Mode,uint32_t ArrayIndex)804 void GMM_STDCALL GmmResSetMmcMode(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_MMC_INFO Mode, uint32_t ArrayIndex)
805 {
806 __GMM_ASSERTPTR(pGmmResource, VOIDRETURN);
807 pGmmResource->SetMmcMode(Mode, ArrayIndex);
808 }
809
810 /////////////////////////////////////////////////////////////////////////////////////
811 /// C wrapper for GmmLib::GmmResourceInfoCommon::IsMediaMemoryCompressed.
812 /// @see GmmLib::GmmResourceInfoCommon::IsMediaMemoryCompressed()
813 ///
814 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
815 /// @param[in] ArrayIndex ArrayIndex for which this info is needed
816 /// @return 1 (enabled), 0 (disabled)
817 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsMediaMemoryCompressed(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArrayIndex)818 uint8_t GMM_STDCALL GmmResIsMediaMemoryCompressed(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex)
819 {
820 return pGmmResource->IsMediaMemoryCompressed(ArrayIndex);
821 }
822
823 /////////////////////////////////////////////////////////////////////////////////////
824 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetMmcHint.
825 /// @see GmmLib::GmmResourceInfoCommon::GetMmcHint()
826 ///
827 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
828 /// @param[in] ArrayIndex ArrayIndex for which this info is needed
829 /// @return true/false
830 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMmcHint(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArrayIndex)831 GMM_RESOURCE_MMC_HINT GMM_STDCALL GmmResGetMmcHint(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex)
832 {
833 __GMM_ASSERT(pGmmResource);
834 return pGmmResource->GetMmcHint(ArrayIndex);
835 }
836
837 /////////////////////////////////////////////////////////////////////////////////////
838 /// C wrapper for GmmLib::GmmResourceInfoCommon::SetMmcHint.
839 /// @see GmmLib::GmmResourceInfoCommon::SetMmcHint()
840 ///
841 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
842 /// @param[in] Hint Mmc hint to store
843 /// @param[in] ArrayIndex ArrayIndex for which this info is needed
844 /// @return true/false
845 /////////////////////////////////////////////////////////////////////////////////////
GmmResSetMmcHint(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_MMC_HINT Hint,uint32_t ArrayIndex)846 void GMM_STDCALL GmmResSetMmcHint(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_MMC_HINT Hint, uint32_t ArrayIndex)
847 {
848 __GMM_ASSERTPTR(pGmmResource, VOIDRETURN);
849 pGmmResource->SetMmcHint(Hint, ArrayIndex);
850 }
851
852 /////////////////////////////////////////////////////////////////////////////////////
853 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetNumSamples.
854 /// @see GmmLib::GmmResourceInfoCommon::GetNumSamples()
855 ///
856 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
857 /// @return Sample count
858 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetNumSamples(GMM_RESOURCE_INFO * pGmmResource)859 uint32_t GMM_STDCALL GmmResGetNumSamples(GMM_RESOURCE_INFO *pGmmResource)
860 {
861 __GMM_ASSERTPTR(pGmmResource, 0);
862 return pGmmResource->GetNumSamples();
863 }
864
865 /////////////////////////////////////////////////////////////////////////////////////
866 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetSamplePattern.
867 /// @see GmmLib::GmmResourceInfoCommon::GetSamplePattern()
868 ///
869 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
870 /// @return Sample count
871 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSamplePattern(GMM_RESOURCE_INFO * pGmmResource)872 GMM_MSAA_SAMPLE_PATTERN GMM_STDCALL GmmResGetSamplePattern(GMM_RESOURCE_INFO *pGmmResource)
873 {
874 __GMM_ASSERT(pGmmResource);
875 return pGmmResource->GetSamplePattern();
876 }
877
878 /////////////////////////////////////////////////////////////////////////////////////
879 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetHAlign.
880 /// @see GmmLib::GmmResourceInfoCommon::GetHAlign()
881 ///
882 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
883 /// @return HAlign
884 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetHAlign(GMM_RESOURCE_INFO * pGmmResource)885 uint32_t GMM_STDCALL GmmResGetHAlign(GMM_RESOURCE_INFO *pGmmResource)
886 {
887 __GMM_ASSERTPTR(pGmmResource, 0);
888 return pGmmResource->GetHAlign();
889 }
890
891 /////////////////////////////////////////////////////////////////////////////////////
892 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetVAlign.
893 /// @see GmmLib::GmmResourceInfoCommon::GetVAlign()
894 ///
895 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
896 /// @return VAlign
897 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetVAlign(GMM_RESOURCE_INFO * pGmmResource)898 uint32_t GMM_STDCALL GmmResGetVAlign(GMM_RESOURCE_INFO *pGmmResource)
899 {
900 __GMM_ASSERTPTR(pGmmResource, 0);
901 return pGmmResource->GetVAlign();
902 }
903
904 /////////////////////////////////////////////////////////////////////////////////////
905 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetAuxHAlign.
906 /// @see GmmLib::GmmResourceInfoCommon::GetAuxHAlign()
907 ///
908 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
909 /// @return HAlign
910 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxHAlign(GMM_RESOURCE_INFO * pGmmResource)911 uint32_t GMM_STDCALL GmmResGetAuxHAlign(GMM_RESOURCE_INFO *pGmmResource)
912 {
913 __GMM_ASSERTPTR(pGmmResource, 0);
914 return pGmmResource->GetAuxHAlign();
915 }
916
917 /////////////////////////////////////////////////////////////////////////////////////
918 /// C wrapper for GmmLib::GmmResourceInfoCommon::GetAuxVAlign.
919 /// @see GmmLib::GmmResourceInfoCommon::GetAuxVAlign()
920 ///
921 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
922 /// @return VAlign
923 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxVAlign(GMM_RESOURCE_INFO * pGmmResource)924 uint32_t GMM_STDCALL GmmResGetAuxVAlign(GMM_RESOURCE_INFO *pGmmResource)
925 {
926 __GMM_ASSERTPTR(pGmmResource, 0);
927 return pGmmResource->GetAuxVAlign();
928 }
929
930 /////////////////////////////////////////////////////////////////////////////////////
931 /// C wrapper for GmmLib::GmmResourceInfoCommon::IsArraySpacingSingleLod.
932 /// @see GmmLib::GmmResourceInfoCommon::IsArraySpacingSingleLod()
933 ///
934 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
935 /// @return 1/0
936 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsArraySpacingSingleLod(GMM_RESOURCE_INFO * pGmmResource)937 uint8_t GMM_STDCALL GmmResIsArraySpacingSingleLod(GMM_RESOURCE_INFO *pGmmResource)
938 {
939 __GMM_ASSERTPTR(pGmmResource, 0);
940 return pGmmResource->IsArraySpacingSingleLod();
941 }
942
943 /////////////////////////////////////////////////////////////////////////////////////
944 /// C wrapper for GmmLib::GmmResourceInfoCommon::IsASTC.
945 /// @see GmmLib::GmmResourceInfoCommon::IsASTC()
946 ///
947 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
948 /// @return 1/0
949 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsASTC(GMM_RESOURCE_INFO * pGmmResource)950 uint8_t GMM_STDCALL GmmResIsASTC(GMM_RESOURCE_INFO *pGmmResource)
951 {
952 __GMM_ASSERTPTR(pGmmResource, 0);
953 return pGmmResource->IsASTC();
954 }
955
956 /////////////////////////////////////////////////////////////////////////////////////
957 /// C wrapper for GmmLib::GmmResourceInfoCommon::IsMsaaFormatDepthStencil.
958 /// @see GmmLib::GmmResourceInfoCommon::IsMsaaFormatDepthStencil()
959 ///
960 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
961 /// @return 1/0
962 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsMsaaFormatDepthStencil(GMM_RESOURCE_INFO * pGmmResource)963 uint8_t GMM_STDCALL GmmResIsMsaaFormatDepthStencil(GMM_RESOURCE_INFO *pGmmResource)
964 {
965 __GMM_ASSERTPTR(pGmmResource, 0);
966 return pGmmResource->IsMsaaFormatDepthStencil();
967 }
968
969 /////////////////////////////////////////////////////////////////////////////////////
970 /// C wrapper for GmmLib::GmmResourceInfoCommon::IsSvm.
971 /// @see GmmLib::GmmResourceInfoCommon::IsSvm()
972 ///
973 /// @param[in] pGmmResource: Pointer to the GmmResourceInfo class
974 /// @return 1/0
975 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsSvm(GMM_RESOURCE_INFO * pGmmResource)976 uint8_t GMM_STDCALL GmmResIsSvm(GMM_RESOURCE_INFO *pGmmResource)
977 {
978 __GMM_ASSERTPTR(pGmmResource, 0);
979 return pGmmResource->IsSvm();
980 }
981
982 /////////////////////////////////////////////////////////////////////////////////////
983 /// C wrapper for GmmResourceInfoCommon::ValidateParams
984 /// @see GmmLib::GmmResourceInfoCommon::ValidateParams()
985 ///
986 /// @param[in] pResourceInfo: Pointer to GmmResourceInfo class
987 /// @return 1 is validation passed. 0 otherwise.
988 /////////////////////////////////////////////////////////////////////////////////////
GmmResValidateParams(GMM_RESOURCE_INFO * pResourceInfo)989 uint8_t GMM_STDCALL GmmResValidateParams(GMM_RESOURCE_INFO *pResourceInfo)
990 {
991 return pResourceInfo->ValidateParams();
992 }
993
994 /////////////////////////////////////////////////////////////////////////////////////
995 /// C wrapper for GmmResourceInfoCommon::SetPrivateData
996 /// @see GmmLib::GmmResourceInfoCommon::SetPrivateData()
997 ///
998 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
999 /// @param[in] pPrivateData: Pointer to opaque private data from clients
1000 /////////////////////////////////////////////////////////////////////////////////////
GmmResSetPrivateData(GMM_RESOURCE_INFO * pGmmResource,void * pPrivateData)1001 void GMM_STDCALL GmmResSetPrivateData(GMM_RESOURCE_INFO *pGmmResource, void *pPrivateData)
1002 {
1003 __GMM_ASSERTPTR(pGmmResource, VOIDRETURN);
1004 pGmmResource->SetPrivateData(pPrivateData);
1005 }
1006
1007 /////////////////////////////////////////////////////////////////////////////////////
1008 /// C wrapper for GmmResourceInfoCommon::GetPrivateData
1009 /// @see GmmLib::GmmResourceInfoCommon::GetPrivateData()
1010 ///
1011 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1012 /// @return pointer to opaque private data
1013 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPrivateData(GMM_RESOURCE_INFO * pGmmResource)1014 void *GMM_STDCALL GmmResGetPrivateData(GMM_RESOURCE_INFO *pGmmResource)
1015 {
1016 __GMM_ASSERTPTR(pGmmResource, 0);
1017 return pGmmResource->GetPrivateData();
1018 }
1019
1020 /////////////////////////////////////////////////////////////////////////////////////
1021 /// C wrapper for GmmResourceInfoCommon::GetGfxAddress
1022 /// @see GmmLib::GmmResourceInfoCommon::GetGfxAddress()
1023 ///
1024 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1025 /// @return Gfx address
1026 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetGfxAddress(GMM_RESOURCE_INFO * pGmmResource)1027 GMM_GFX_ADDRESS GMM_STDCALL GmmResGetGfxAddress(GMM_RESOURCE_INFO *pGmmResource)
1028 {
1029 __GMM_ASSERTPTR(pGmmResource, 0);
1030 return pGmmResource->GetGfxAddress();
1031 }
1032
1033 /////////////////////////////////////////////////////////////////////////////////////
1034 /// C wrapper for GmmResourceInfoCommon::GetTallBufferHeight
1035 /// @see GmmLib::GmmResourceInfoCommon::GetTallBufferHeight()
1036 ///
1037 /// @param[in] pResourceInfo: Pointer to GmmResourceInfo class
1038 /// @return Surface height
1039 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetTallBufferHeight(GMM_RESOURCE_INFO * pResourceInfo)1040 uint32_t GMM_STDCALL GmmResGetTallBufferHeight(GMM_RESOURCE_INFO *pResourceInfo)
1041 {
1042 __GMM_ASSERTPTR(pResourceInfo, 0);
1043 return pResourceInfo->GetTallBufferHeight();
1044 };
1045
1046
1047 /////////////////////////////////////////////////////////////////////////////////////
1048 /// C wrapper for GmmResourceInfoCommon::GetSizeMainSurface
1049 /// @see GmmLib::GmmResourceInfoCommon::GetSizeMainSurface()
1050 ///
1051 /// @param[in] pResourceInfo: Pointer to GmmResourceInfo class
1052 /// @return Size of main surface
1053 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSizeMainSurface(const GMM_RESOURCE_INFO * pResourceInfo)1054 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeMainSurface(const GMM_RESOURCE_INFO *pResourceInfo)
1055 {
1056 return pResourceInfo->GetSizeMainSurface();
1057 }
1058
1059 //TODO(Low) : Remove when client moves to new interface
1060 /////////////////////////////////////////////////////////////////////////////////////
1061 /// C wrapper for GmmResourceInfoCommon::GetSizeSurface
1062 /// @see GmmLib::GmmResourceInfoCommon::GetSizeSurface()
1063 ///
1064 /// @param[in] pResourceInfo: Pointer to GmmResourceInfo class
1065 /// @return Surface Size
1066 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetRenderSize(GMM_RESOURCE_INFO * pResourceInfo)1067 uint32_t GMM_STDCALL GmmResGetRenderSize(GMM_RESOURCE_INFO *pResourceInfo)
1068 {
1069 __GMM_ASSERTPTR(pResourceInfo, 0);
1070 return GFX_ULONG_CAST(pResourceInfo->GetSizeSurface());
1071 }
1072
GmmResGetAuxSurfaceSize(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1073 uint32_t GMM_STDCALL GmmResGetAuxSurfaceSize(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1074 {
1075 return GFX_ULONG_CAST(GmmResGetSizeAuxSurface(pGmmResource, GmmAuxType));
1076 }
1077
1078 /////////////////////////////////////////////////////////////////////////////////////
1079 /// C wrapper for GmmResourceInfoCommon::GetSizeSurface
1080 /// @see GmmLib::GmmResourceInfoCommon::GetSizeSurface()
1081 ///
1082 /// @param[in] pResourceInfo: Pointer to GmmResourceInfo class
1083 /// @return Surface Size
1084 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSizeSurface(GMM_RESOURCE_INFO * pResourceInfo)1085 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeSurface(GMM_RESOURCE_INFO *pResourceInfo)
1086 {
1087 __GMM_ASSERTPTR(pResourceInfo, 0);
1088 return pResourceInfo->GetSizeSurface();
1089 }
1090
1091 /////////////////////////////////////////////////////////////////////////////////////
1092 /// C wrapper for GmmResourceInfoCommon::GetSizeAllocation
1093 /// @see GmmLib::GmmResourceInfoCommon::GetSizeAllocation()
1094 ///
1095 /// @param[in] pResourceInfo: Pointer to GmmResourceInfo class
1096 /// @return Allocation Size
1097 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSizeAllocation(GMM_RESOURCE_INFO * pResourceInfo)1098 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeAllocation(GMM_RESOURCE_INFO *pResourceInfo)
1099 {
1100 __GMM_ASSERTPTR(pResourceInfo, 0);
1101 return pResourceInfo->GetSizeAllocation();
1102 }
1103
1104 /////////////////////////////////////////////////////////////////////////////////////
1105 /// C wrapper for GmmResourceInfoCommon::GetResourceFormatSurfaceState
1106 /// @see GmmLib::GmmResourceInfoCommon::GetResourceFormatSurfaceState()
1107 ///
1108 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1109 /// @return Resource format
1110 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateFormat(GMM_RESOURCE_INFO * pGmmResource)1111 GMM_SURFACESTATE_FORMAT GMM_STDCALL GmmResGetSurfaceStateFormat(GMM_RESOURCE_INFO *pGmmResource)
1112 {
1113 __GMM_ASSERTPTR(pGmmResource, GMM_SURFACESTATE_FORMAT_INVALID);
1114 return pGmmResource->GetResourceFormatSurfaceState();
1115 }
1116
1117 //=============================================================================
1118 //
1119 // Function: GmmGetSurfaceStateFormat
1120 //
1121 // Desc: See below.
1122 //
1123 // Returns:
1124 // SURFACE_STATE.Format for the given resource or
1125 // GMM_SURFACESTATE_FORMAT_INVALID if resource wasn't created with a
1126 // direct SURFACE_STATE.Format.
1127 //
1128 //-----------------------------------------------------------------------------
GmmGetSurfaceStateFormat(GMM_RESOURCE_FORMAT Format,GMM_LIB_CONTEXT * pGmmLibContext)1129 GMM_SURFACESTATE_FORMAT GMM_STDCALL GmmGetSurfaceStateFormat(GMM_RESOURCE_FORMAT Format, GMM_LIB_CONTEXT *pGmmLibContext)
1130 {
1131 return ((Format > GMM_FORMAT_INVALID) &&
1132 (Format < GMM_RESOURCE_FORMATS)) ?
1133 pGmmLibContext->GetPlatformInfo().FormatTable[Format].SurfaceStateFormat :
1134 GMM_SURFACESTATE_FORMAT_INVALID;
1135 }
1136
1137 /////////////////////////////////////////////////////////////////////////////////////
1138 /// C wrapper for GmmResourceInfoCommon::GetHAlignSurfaceState
1139 /// @see GmmLib::GmmResourceInfoCommon::GetHAlignSurfaceState()
1140 ///
1141 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1142 /// @return HAlign
1143 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateHAlign(GMM_RESOURCE_INFO * pGmmResource)1144 uint32_t GMM_STDCALL GmmResGetSurfaceStateHAlign(GMM_RESOURCE_INFO *pGmmResource)
1145 {
1146 __GMM_ASSERTPTR(pGmmResource, 0);
1147 return pGmmResource->GetHAlignSurfaceState();
1148 }
1149
1150 /////////////////////////////////////////////////////////////////////////////////////
1151 /// C wrapper for GmmResourceInfoCommon::GetVAlignSurfaceState
1152 /// @see GmmLib::GmmResourceInfoCommon::GetVAlignSurfaceState()
1153 ///
1154 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1155 /// @return VAlign
1156 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateVAlign(GMM_RESOURCE_INFO * pGmmResource)1157 uint32_t GMM_STDCALL GmmResGetSurfaceStateVAlign(GMM_RESOURCE_INFO *pGmmResource)
1158 {
1159 __GMM_ASSERTPTR(pGmmResource, 0);
1160 return pGmmResource->GetVAlignSurfaceState();
1161 }
1162
1163 /////////////////////////////////////////////////////////////////////////////////////
1164 /// C wrapper for GmmResourceInfoCommon::GetTiledResourceModeSurfaceState
1165 /// @see GmmLib::GmmResourceInfoCommon::GetTiledResourceModeSurfaceState()
1166 ///
1167 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1168 /// @return Tiled Resource Mode
1169 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateTiledResourceMode(GMM_RESOURCE_INFO * pGmmResource)1170 uint32_t GMM_STDCALL GmmResGetSurfaceStateTiledResourceMode(GMM_RESOURCE_INFO *pGmmResource)
1171 {
1172 __GMM_ASSERTPTR(pGmmResource, 0);
1173 return pGmmResource->GetTiledResourceModeSurfaceState();
1174 }
1175
1176 /////////////////////////////////////////////////////////////////////////////////////
1177 /// Returns the surface offset for unified allocations. Truncates the offset to size
1178 /// of uint32_t.
1179 /// @see GmmResGetAuxSurfaceOffset64()
1180 ///
1181 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1182 /// @param[in] GmmAuxType: the type of aux the offset is needed for
1183 /// @return Surface Offset in bytes
1184 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxSurfaceOffset(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1185 uint32_t GMM_STDCALL GmmResGetAuxSurfaceOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1186 {
1187 return GFX_ULONG_CAST(GmmResGetAuxSurfaceOffset64(pGmmResource, GmmAuxType));
1188 }
1189
1190 /////////////////////////////////////////////////////////////////////////////////////
1191 /// C wrapper for GmmResourceInfoCommon::GetUnifiedAuxSurfaceOffset
1192 /// @see GmmLib::GmmResourceInfoCommon::GetUnifiedAuxSurfaceOffset()
1193 ///
1194 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1195 /// @param[in] GmmAuxType: the type of aux the offset is needed for
1196 /// @return Surface Offset in bytes
1197 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxSurfaceOffset64(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1198 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetAuxSurfaceOffset64(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1199 {
1200 __GMM_ASSERTPTR(pGmmResource, 0);
1201 return pGmmResource->GetUnifiedAuxSurfaceOffset(GmmAuxType);
1202 }
1203
1204 /////////////////////////////////////////////////////////////////////////////////////
1205 /// C wrapper for GmmResourceInfoCommon::GetSizeAuxSurface
1206 /// @see GmmLib::GmmResourceInfoCommon::GetSizeAuxSurface()
1207 ///
1208 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1209 /// @param[in] GmmAuxType: the type of aux the size is needed for
1210 /// @return Surface size in bytes
1211 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSizeAuxSurface(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1212 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeAuxSurface(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1213 {
1214 __GMM_ASSERTPTR(pGmmResource, 0);
1215 return pGmmResource->GetSizeAuxSurface(GmmAuxType);
1216 }
1217
1218 /////////////////////////////////////////////////////////////////////////////////////
1219 /// C wrapper for GmmResourceInfoCommon::GetSetHardwareProtection
1220 /// @see GmmLib::GmmResourceInfoCommon::GetSetHardwareProtection()
1221 /// @see GmmLib::GmmResourceInfoWin::GetSetHardwareProtection()
1222 ///
1223 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1224 /// @param[in] GetIsEncrypted: Read encryption status
1225 /// @param[in] SetIsEncrypted: Write encryption status
1226 /// @return Whether surface is encrypted or not
1227
1228 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSetHardwareProtection(GMM_RESOURCE_INFO * pGmmResource,uint8_t GetIsEncrypted,uint8_t SetIsEncrypted)1229 uint8_t GMM_STDCALL GmmResGetSetHardwareProtection(GMM_RESOURCE_INFO *pGmmResource, uint8_t GetIsEncrypted, uint8_t SetIsEncrypted)
1230 {
1231 return pGmmResource ?
1232 pGmmResource->GetSetHardwareProtection(GetIsEncrypted, SetIsEncrypted) :
1233 0;
1234 }
1235
1236 /////////////////////////////////////////////////////////////////////////////////////
1237 /// C wrapper for GmmResourceInfoCommon::CpuBlt
1238 /// @see GmmLib::GmmResourceInfoCommon::CpuBlt()
1239 ///
1240 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1241 /// @param[in] pBlt: Describes the blit operation. See ::GMM_RES_COPY_BLT for more info.
1242 /// @return 1 if succeeded, 0 otherwise
1243 /////////////////////////////////////////////////////////////////////////////////////
GmmResCpuBlt(GMM_RESOURCE_INFO * pGmmResource,GMM_RES_COPY_BLT * pBlt)1244 uint8_t GMM_STDCALL GmmResCpuBlt(GMM_RESOURCE_INFO *pGmmResource, GMM_RES_COPY_BLT *pBlt)
1245 {
1246 __GMM_ASSERTPTR(pGmmResource, 0);
1247 return pGmmResource->CpuBlt(pBlt);
1248 }
1249
1250 /////////////////////////////////////////////////////////////////////////////////////
1251 /// C wrapper for GmmResourceInfoCommon::GetStdLayoutSize
1252 /// @see GmmLib::GmmResourceInfoCommon::GetStdLayoutSize()
1253 ///
1254 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1255 /// @return Size in bytes of Standard Layout version of surface.
1256 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetStdLayoutSize(GMM_RESOURCE_INFO * pGmmResource)1257 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetStdLayoutSize(GMM_RESOURCE_INFO *pGmmResource)
1258 {
1259 __GMM_ASSERT(pGmmResource);
1260 return pGmmResource->GetStdLayoutSize();
1261 }
1262
1263 /////////////////////////////////////////////////////////////////////////////////////
1264 /// C wrapper for GmmResourceInfoCommon::GetMappingSpanDesc
1265 /// @see GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc()
1266 ///
1267 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1268 /// @param[in] pMapping: Clients call the function with initially zero'd out GMM_GET_MAPPING.
1269 /// @return 1 if more span descriptors to report, 0 if all mapping is done
1270 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMappingSpanDesc(GMM_RESOURCE_INFO * pGmmResource,GMM_GET_MAPPING * pMapping)1271 uint8_t GMM_STDCALL GmmResGetMappingSpanDesc(GMM_RESOURCE_INFO *pGmmResource, GMM_GET_MAPPING *pMapping)
1272 {
1273 __GMM_ASSERTPTR(pGmmResource, 0);
1274 return pGmmResource->GetMappingSpanDesc(pMapping);
1275 }
1276
1277 /////////////////////////////////////////////////////////////////////////////////////
1278 /// C wrapper for GmmResourceInfoCommon::IsColorSeparation
1279 /// @see GmmLib::GmmResourceInfoCommon::IsColorSeparation()
1280 ///
1281 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1282 /// @return 1 if the resource is color separated target, 0 otherwise
1283 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsColorSeparation(GMM_RESOURCE_INFO * pGmmResource)1284 uint8_t GMM_STDCALL GmmResIsColorSeparation(GMM_RESOURCE_INFO *pGmmResource)
1285 {
1286 __GMM_ASSERTPTR(pGmmResource, 0);
1287 return pGmmResource->IsColorSeparation();
1288 }
1289
1290 /////////////////////////////////////////////////////////////////////////////////////
1291 /// C wrapper for GmmResourceInfoCommon::TranslateColorSeparationX
1292 /// @see GmmLib::GmmResourceInfoCommon::TranslateColorSeparationX()
1293 ///
1294 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1295 /// @param[in] x: X coordinate
1296 /// @return Translated color separation target x coordinate
1297 /////////////////////////////////////////////////////////////////////////////////////
GmmResTranslateColorSeparationX(GMM_RESOURCE_INFO * pGmmResource,uint32_t x)1298 uint32_t GMM_STDCALL GmmResTranslateColorSeparationX(GMM_RESOURCE_INFO *pGmmResource, uint32_t x)
1299 {
1300 __GMM_ASSERTPTR(pGmmResource, false);
1301 return pGmmResource->TranslateColorSeparationX(x);
1302 }
1303
1304 /////////////////////////////////////////////////////////////////////////////////////
1305 /// C wrapper for GmmResourceInfoCommon::GetColorSeparationArraySize
1306 /// @see GmmLib::GmmResourceInfoCommon::GetColorSeparationArraySize()
1307 ///
1308 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1309 /// @return Array size of a color separated target resource
1310 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetColorSeparationArraySize(GMM_RESOURCE_INFO * pGmmResource)1311 uint32_t GMM_STDCALL GmmResGetColorSeparationArraySize(GMM_RESOURCE_INFO *pGmmResource)
1312 {
1313 __GMM_ASSERTPTR(pGmmResource, 0);
1314 return pGmmResource->GetColorSeparationArraySize();
1315 }
1316
1317 /////////////////////////////////////////////////////////////////////////////////////
1318 /// C wrapper for GmmResourceInfoCommon::GetColorSeparationPhysicalWidth
1319 /// @see GmmLib::GmmResourceInfoCommon::GetColorSeparationPhysicalWidth()
1320 ///
1321 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1322 /// @return Physical width of a color separated target resource
1323 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetColorSeparationPhysicalWidth(GMM_RESOURCE_INFO * pGmmResource)1324 uint32_t GMM_STDCALL GmmResGetColorSeparationPhysicalWidth(GMM_RESOURCE_INFO *pGmmResource)
1325 {
1326 __GMM_ASSERTPTR(pGmmResource, 0);
1327 return pGmmResource->GetColorSeparationPhysicalWidth();
1328 }
1329
1330 //=============================================================================
1331 //
1332 // Function: GmmResGetMaxGpuVirtualAddressBits
1333 //
1334 // Desc: This function returns max no of GpuVA bits supported per surface on current platform
1335 //
1336 // Parameters:
1337 // GMM_RESOURCE_INFO *pGmmResource (Don't care)
1338 // Function will return the current Gen MaxGpuVirtualAddressBitsPerResource
1339 //
1340 // Returns:
1341 // uint32_t - Max no of GpuVA bits
1342 //-----------------------------------------------------------------------------
GmmResGetMaxGpuVirtualAddressBits(GMM_RESOURCE_INFO * pGmmResource,GMM_LIB_CONTEXT * pGmmLibContext)1343 uint32_t GMM_STDCALL GmmResGetMaxGpuVirtualAddressBits(GMM_RESOURCE_INFO *pGmmResource, GMM_LIB_CONTEXT *pGmmLibContext)
1344 {
1345 if(pGmmResource == NULL)
1346 {
1347 __GMM_ASSERTPTR(pGmmLibContext, 0);
1348 const GMM_PLATFORM_INFO &PlatformInfo = pGmmLibContext->GetPlatformInfo();
1349 return PlatformInfo.MaxGpuVirtualAddressBitsPerResource;
1350 }
1351
1352 return pGmmResource->GetMaxGpuVirtualAddressBits();
1353 }
1354
1355 /////////////////////////////////////////////////////////////////////////////////////
1356 /// C wrapper for GmmResourceInfoCommon::IsSurfaceFaultable
1357 /// @see GmmLib::GmmResourceInfoCommon::IsSurfaceFaultable()
1358 /// @see GmmLib::GmmResourceInfoWin::IsSurfaceFaultable()
1359 ///
1360 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1361 /// @return 1 is surface can be faulted on
1362 /////////////////////////////////////////////////////////////////////////////////////
GmmIsSurfaceFaultable(GMM_RESOURCE_INFO * pGmmResource)1363 uint8_t GMM_STDCALL GmmIsSurfaceFaultable(GMM_RESOURCE_INFO *pGmmResource)
1364 {
1365 __GMM_ASSERTPTR(pGmmResource, 0);
1366 return pGmmResource->IsSurfaceFaultable();
1367 }
1368
1369 /////////////////////////////////////////////////////////////////////////////////////
1370 /// C wrapper for GmmResourceInfoCommon::GetResFlags
1371 /// @see GmmLib::GmmResourceInfoCommon::GetResFlags()
1372 ///
1373 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1374 /// @return Copy of ::GMM_RESOURCE_FLAGS
1375 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetResourceFlags(const GMM_RESOURCE_INFO * pGmmResource)1376 GMM_RESOURCE_FLAG GMM_STDCALL GmmResGetResourceFlags(const GMM_RESOURCE_INFO *pGmmResource)
1377 {
1378 __GMM_ASSERT(pGmmResource);
1379 return const_cast<GMM_RESOURCE_INFO *>(pGmmResource)->GetResFlags();
1380 }
1381
1382 /////////////////////////////////////////////////////////////////////////////////////
1383 /// C wrapper for GmmResourceInfoCommon::GetMaximumRenamingListLength
1384 /// @see GmmLib::GmmResourceInfoCommon::GetMaximumRenamingListLength()
1385 ///
1386 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1387 /// @return maximum remaining list length
1388 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMaximumRenamingListLength(GMM_RESOURCE_INFO * pGmmResource)1389 uint32_t GMM_STDCALL GmmResGetMaximumRenamingListLength(GMM_RESOURCE_INFO *pGmmResource)
1390 {
1391 __GMM_ASSERT(pGmmResource);
1392 return pGmmResource->GetMaximumRenamingListLength();
1393 }
1394
1395 //=============================================================================
1396 //
1397 // Function: GmmGetLogicalTileShape
1398 //
1399 // Desc: This function returns the logical tile shape
1400 //
1401 // Parameters:
1402 // See Function arguments
1403 //
1404 // Returns:
1405 // GMM_STATUS
1406 //-----------------------------------------------------------------------------
GmmGetLogicalTileShape(uint32_t TileMode,uint32_t * pWidthInBytes,uint32_t * pHeight,uint32_t * pDepth,GMM_LIB_CONTEXT * pGmmLibContext)1407 GMM_STATUS GMM_STDCALL GmmGetLogicalTileShape(uint32_t TileMode,
1408 uint32_t *pWidthInBytes,
1409 uint32_t *pHeight,
1410 uint32_t *pDepth,
1411 GMM_LIB_CONTEXT *pGmmLibContext)
1412 {
1413 __GMM_ASSERT(TileMode < GMM_TILE_MODES);
1414
1415 if(pWidthInBytes)
1416 {
1417 *pWidthInBytes = pGmmLibContext->GetPlatformInfo().TileInfo[TileMode].LogicalTileWidth;
1418 }
1419
1420 if(pHeight)
1421 {
1422 *pHeight = pGmmLibContext->GetPlatformInfo().TileInfo[TileMode].LogicalTileHeight;
1423 }
1424
1425 if(pDepth)
1426 {
1427 *pDepth = pGmmLibContext->GetPlatformInfo().TileInfo[TileMode].LogicalTileDepth;
1428 }
1429
1430 return GMM_SUCCESS;
1431 }
1432
1433
1434 /////////////////////////////////////////////////////////////////////////////////////
1435 /// C wrapper for GmmResourceInfoCommon::OverrideSize
1436 /// @see GmmLib::GmmResourceInfoCommon::OverrideSize()
1437 ///
1438 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1439 /// @param[in] Size: new size of the resource
1440 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationSize(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T Size)1441 void GMM_STDCALL GmmResOverrideAllocationSize(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Size)
1442 {
1443 __GMM_ASSERT(pGmmResource);
1444 pGmmResource->OverrideSize(Size);
1445 }
1446
1447 /////////////////////////////////////////////////////////////////////////////////////
1448 /// C wrapper for GmmResourceInfoCommon::OverridePitch
1449 /// @see GmmLib::GmmResourceInfoCommon::OverridePitch()
1450 ///
1451 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1452 /// @param[in] Pitch: new pitch of the resource
1453 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationPitch(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T Pitch)1454 void GMM_STDCALL GmmResOverrideAllocationPitch(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Pitch)
1455 {
1456 __GMM_ASSERT(pGmmResource);
1457 pGmmResource->OverridePitch(Pitch);
1458 }
1459
1460 /////////////////////////////////////////////////////////////////////////////////////
1461 /// C wrapper for GmmResourceInfoCommon::OverrideUnifiedAuxPitch
1462 /// @see GmmLib::GmmResourceInfoCommon::OverrideUnifiedAuxPitch()
1463 ///
1464 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1465 /// @param[in] Pitch: new pitch of the resource
1466 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAuxAllocationPitch(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T Pitch)1467 void GMM_STDCALL GmmResOverrideAuxAllocationPitch(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Pitch)
1468 {
1469 __GMM_ASSERT(pGmmResource);
1470 pGmmResource->OverrideUnifiedAuxPitch(Pitch);
1471 }
1472
1473 /////////////////////////////////////////////////////////////////////////////////////
1474 /// C wrapper for GmmResourceInfoCommon::OverrideUnifiedAuxPitch
1475 /// @see GmmLib::GmmResourceInfoCommon::OverrideUnifiedAuxPitch()
1476 ///
1477 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1478 /// @param[in] Pitch: new pitch of the resource
1479 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationFlags(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_FLAG * pFlags)1480 void GMM_STDCALL GmmResOverrideAllocationFlags(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FLAG *pFlags)
1481 {
1482 __GMM_ASSERT(pGmmResource);
1483 __GMM_ASSERT(pFlags);
1484 pGmmResource->OverrideAllocationFlags(*pFlags);
1485 }
1486
1487 /////////////////////////////////////////////////////////////////////////////////////
1488 /// C wrapper for GmmResourceInfoCommon::OverrideHAlign
1489 /// @see GmmLib::GmmResourceInfoCommon::OverrideHAlign()
1490 ///
1491 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1492 /// @param[in] Pitch: new pitch of the resource
1493 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationHAlign(GMM_RESOURCE_INFO * pGmmResource,uint32_t HAlign)1494 void GMM_STDCALL GmmResOverrideAllocationHAlign(GMM_RESOURCE_INFO *pGmmResource, uint32_t HAlign)
1495 {
1496 __GMM_ASSERT(pGmmResource);
1497 pGmmResource->OverrideHAlign(HAlign);
1498 }
1499
1500 /////////////////////////////////////////////////////////////////////////////////////
1501 /// C wrapper for GmmResourceInfoCommon::OverrideBaseAlignment
1502 /// @see GmmLib::GmmResourceInfoCommon::OverrideBaseAlignment()
1503 ///
1504 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1505 /// @param[in] Alignment: new BaseAlignment of the resource
1506 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationBaseAlignment(GMM_RESOURCE_INFO * pGmmResource,uint32_t Alignment)1507 void GMM_STDCALL GmmResOverrideAllocationBaseAlignment(GMM_RESOURCE_INFO *pGmmResource, uint32_t Alignment)
1508 {
1509 __GMM_ASSERT(pGmmResource);
1510 pGmmResource->OverrideBaseAlignment(Alignment);
1511 }
1512
1513 /////////////////////////////////////////////////////////////////////////////////////
1514 /// C wrapper for GmmResourceInfoCommon::OverrideBaseWidth
1515 /// @see GmmLib::GmmResourceInfoCommon::OverrideBaseWidth()
1516 ///
1517 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1518 /// @param[in] BaseWidth: new BaseWidth of the resource
1519 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationBaseWidth(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T BaseWidth)1520 void GMM_STDCALL GmmResOverrideAllocationBaseWidth(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T BaseWidth)
1521 {
1522 __GMM_ASSERT(pGmmResource);
1523 pGmmResource->OverrideBaseWidth(BaseWidth);
1524 }
1525
1526 /////////////////////////////////////////////////////////////////////////////////////
1527 /// C wrapper for GmmResourceInfoCommon::OverrideBaseHeight
1528 /// @see GmmLib::GmmResourceInfoCommon::OverrideBaseHeight()
1529 ///
1530 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1531 /// @param[in] BaseHeight: new BaseWidth of the resource
1532 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationBaseHeight(GMM_RESOURCE_INFO * pGmmResource,uint32_t BaseHeight)1533 void GMM_STDCALL GmmResOverrideAllocationBaseHeight(GMM_RESOURCE_INFO *pGmmResource, uint32_t BaseHeight)
1534 {
1535 __GMM_ASSERT(pGmmResource);
1536 pGmmResource->OverrideBaseHeight(BaseHeight);
1537 }
1538
1539 /////////////////////////////////////////////////////////////////////////////////////
1540 /// C wrapper for GmmResourceInfoCommon::OverrideDepth
1541 /// @see GmmLib::GmmResourceInfoCommon::OverrideDepth()
1542 ///
1543 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1544 /// @param[in] Depth: new Depth of the resource
1545 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationDepth(GMM_RESOURCE_INFO * pGmmResource,uint32_t Depth)1546 void GMM_STDCALL GmmResOverrideAllocationDepth(GMM_RESOURCE_INFO *pGmmResource, uint32_t Depth)
1547 {
1548 __GMM_ASSERT(pGmmResource);
1549 pGmmResource->OverrideDepth(Depth);
1550 }
1551
1552 /////////////////////////////////////////////////////////////////////////////////////
1553 /// C wrapper for GmmResourceInfoCommon::OverrideTileMode
1554 /// @see GmmLib::GmmResourceInfoCommon::OverrideTileMode()
1555 ///
1556 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1557 /// @param[in] TileMode: new tile mode of the resource
1558 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideResourceTiling(GMM_RESOURCE_INFO * pGmmResource,uint32_t TileMode)1559 void GMM_STDCALL GmmResOverrideResourceTiling(GMM_RESOURCE_INFO *pGmmResource, uint32_t TileMode)
1560 {
1561 __GMM_ASSERT(pGmmResource);
1562 pGmmResource->OverrideTileMode(static_cast<GMM_TILE_MODE>(TileMode));
1563 }
1564
1565 /////////////////////////////////////////////////////////////////////////////////////
1566 /// C wrapper for GmmResourceInfoCommon::OverrideUnifiedAuxTileMode
1567 /// @see GmmLib::GmmResourceInfoCommon::OverrideUnifiedAuxTileMode()
1568 ///
1569 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1570 /// @param[in] TileMode: new tile mode of the unified auxresource
1571 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAuxResourceTiling(GMM_RESOURCE_INFO * pGmmResource,uint32_t TileMode)1572 void GMM_STDCALL GmmResOverrideAuxResourceTiling(GMM_RESOURCE_INFO *pGmmResource, uint32_t TileMode)
1573 {
1574 __GMM_ASSERT(pGmmResource);
1575 pGmmResource->OverrideUnifiedAuxTileMode(static_cast<GMM_TILE_MODE>(TileMode));
1576 }
1577
1578 /////////////////////////////////////////////////////////////////////////////////////
1579 /// C wrapper for GmmResourceInfoCommon::OverrideSurfaceFormat
1580 /// @see GmmLib::GmmResourceInfoCommon::OverrideSurfaceFormat()
1581 ///
1582 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1583 /// @param[in] Format: new format for the resource
1584 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationFormat(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_FORMAT Format)1585 void GMM_STDCALL GmmResOverrideAllocationFormat(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FORMAT Format)
1586 {
1587 __GMM_ASSERT(pGmmResource);
1588 pGmmResource->OverrideSurfaceFormat(Format);
1589 }
1590
1591 /////////////////////////////////////////////////////////////////////////////////////
1592 /// C wrapper for GmmResourceInfoCommon::OverrideSurfaceType
1593 /// @see GmmLib::GmmResourceInfoCommon::OverrideSurfaceType()
1594 ///
1595 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1596 /// @param[in] ResourceType: new type for the resource
1597 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideSurfaceType(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_TYPE ResourceType)1598 void GMM_STDCALL GmmResOverrideSurfaceType(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_TYPE ResourceType)
1599 {
1600 __GMM_ASSERT(pGmmResource);
1601 pGmmResource->OverrideSurfaceType(ResourceType);
1602 }
1603
1604
1605 /////////////////////////////////////////////////////////////////////////////////////
1606 /// C wrapper for GmmResourceInfoCommon::GmmResOverrideSvmGfxAddress
1607 /// @see GmmLib::GmmResourceInfoCommon::GmmResOverrideSvmGfxAddress()
1608 ///
1609 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1610 /// @param[in] SvmGfxAddress: new svm gfx address for the resource
1611 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideSvmGfxAddress(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_ADDRESS SvmGfxAddress)1612 void GMM_STDCALL GmmResOverrideSvmGfxAddress(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_ADDRESS SvmGfxAddress)
1613 {
1614 __GMM_ASSERT(pGmmResource);
1615 pGmmResource->OverrideSvmGfxAddress(SvmGfxAddress);
1616 }
1617
1618 /////////////////////////////////////////////////////////////////////////////////////
1619 /// C wrapper for GmmResourceInfoCommon::OverrideArraySize
1620 /// @see GmmLib::GmmResourceInfoCommon::OverrideArraySize()
1621 ///
1622 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1623 /// @param[in] ArraySize: new array size for the resource
1624 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationArraySize(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArraySize)1625 void GMM_STDCALL GmmResOverrideAllocationArraySize(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArraySize)
1626 {
1627 __GMM_ASSERT(pGmmResource);
1628 pGmmResource->OverrideArraySize(ArraySize);
1629 }
1630
1631 /////////////////////////////////////////////////////////////////////////////////////
1632 /// C wrapper for GmmResourceInfoCommon::OverrideArraySize
1633 /// @see GmmLib::GmmResourceInfoCommon::OverrideArraySize()
1634 ///
1635 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1636 /// @param[in] MaxLod: new max LOD for the resource
1637 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationMaxLod(GMM_RESOURCE_INFO * pGmmResource,uint32_t MaxLod)1638 void GMM_STDCALL GmmResOverrideAllocationMaxLod(GMM_RESOURCE_INFO *pGmmResource, uint32_t MaxLod)
1639 {
1640 __GMM_ASSERT(pGmmResource);
1641 pGmmResource->OverrideMaxLod(MaxLod);
1642 }
1643
1644 /////////////////////////////////////////////////////////////////////////////////////
1645 /// C wrapper for GmmResourceInfoCommon::GetPlanarXOffset
1646 /// @see GmmLib::GmmResourceInfoCommon::GetPlanarXOffset()
1647 ///
1648 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1649 /// @param[in] Plane: Plane for which the offset is needed
1650 /// @return X offset
1651 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPlanarGetXOffset(GMM_RESOURCE_INFO * pGmmResource,GMM_YUV_PLANE Plane)1652 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarGetXOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane)
1653 {
1654 __GMM_ASSERT(pGmmResource);
1655 return pGmmResource->GetPlanarXOffset(Plane);
1656 }
1657
1658 /////////////////////////////////////////////////////////////////////////////////////
1659 /// C wrapper for GmmResourceInfoCommon::GetPlanarYOffset
1660 /// @see GmmLib::GmmResourceInfoCommon::GetPlanarYOffset()
1661 ///
1662 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1663 /// @param[in] Plane: Plane for which the offset is needed
1664 /// @return Y offset
1665 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPlanarGetYOffset(GMM_RESOURCE_INFO * pGmmResource,GMM_YUV_PLANE Plane)1666 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarGetYOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane)
1667 {
1668 __GMM_ASSERT(pGmmResource);
1669 return pGmmResource->GetPlanarYOffset(Plane);
1670 }
1671
1672 /////////////////////////////////////////////////////////////////////////////////////
1673 /// C wrapper for GmmResourceInfoCommon::GetPlanarAuxOffset
1674 /// @see GmmLib::GmmResourceInfoCommon::GetPlanarAuxOffset()
1675 ///
1676 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1677 /// @param[in] Plane: Plane for which the offset is needed
1678 /// @return Y offset
1679 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPlanarAuxOffset(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArrayIndex,GMM_UNIFIED_AUX_TYPE AuxType)1680 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarAuxOffset(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex, GMM_UNIFIED_AUX_TYPE AuxType)
1681 {
1682 __GMM_ASSERT(pGmmResource);
1683 return pGmmResource->GetPlanarAuxOffset(ArrayIndex, AuxType);
1684 }
1685
1686 /////////////////////////////////////////////////////////////////////////////////////
1687 /// C wrapper for GmmResourceInfoCommon::SetGmmLibContext
1688 /// @see GmmLib::GmmResourceInfoCommon::SetGmmLibContext()
1689 ///
1690 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1691 /// @param[in] pLibContext: Pointer to GmmLibContext
1692 /////////////////////////////////////////////////////////////////////////////////////
GmmResSetLibContext(GMM_RESOURCE_INFO * pGmmResource,void * pLibContext)1693 void GMM_STDCALL GmmResSetLibContext(GMM_RESOURCE_INFO *pGmmResource, void *pLibContext)
1694 {
1695 if(pGmmResource)
1696 {
1697 pGmmResource->SetGmmLibContext(pLibContext);
1698 }
1699 }
1700
1701 //=============================================================================
1702 //
1703 // Function: __CanSupportStdTiling
1704 //
1705 // Desc: Verifies texture parameters can support StdTiling
1706 //
1707 // Parameters:
1708 // GMM_TEXTURE_INFO& Surf
1709 //
1710 // Returns:
1711 //
1712 //-----------------------------------------------------------------------------
__CanSupportStdTiling(GMM_TEXTURE_INFO Surf,GMM_LIB_CONTEXT * pGmmLibContext)1713 uint8_t __CanSupportStdTiling(GMM_TEXTURE_INFO Surf, GMM_LIB_CONTEXT *pGmmLibContext)
1714 {
1715 const __GMM_PLATFORM_RESOURCE *pPlatformResource = GMM_OVERRIDE_PLATFORM_INFO(&Surf, pGmmLibContext);
1716
1717 // SKL+ Tiled Resource Mode Restrictions
1718 if((Surf.Flags.Info.TiledYf || Surf.Flags.Info.TiledYs) &&
1719 !((GFX_GET_CURRENT_RENDERCORE(pPlatformResource->Platform) >= IGFX_GEN9_CORE) &&
1720 // TiledY must be set unless 1D surface.
1721 ((Surf.Flags.Info.TiledY && (Surf.Type != RESOURCE_1D)) ||
1722 (Surf.Flags.Info.Linear && (Surf.Type == RESOURCE_1D ||
1723 Surf.Type == RESOURCE_BUFFER))) &&
1724 // 8, 16, 32, 64, or 128 bpp
1725 ((!GmmIsCompressed(pGmmLibContext, Surf.Format) &&
1726 ((Surf.BitsPerPixel == 8) ||
1727 (Surf.BitsPerPixel == 16) ||
1728 (Surf.BitsPerPixel == 32) ||
1729 (Surf.BitsPerPixel == 64) ||
1730 (Surf.BitsPerPixel == 128))) ||
1731 // Compressed Modes: BC*, ETC*, EAC*, ASTC*
1732 (GmmIsCompressed(pGmmLibContext, Surf.Format) && (Surf.Format != GMM_FORMAT_FXT1)))))
1733 /* Not currently supported...
1734 // YCRCB* Formats
1735 GmmIsYUVPacked(Surf.Format) */
1736 {
1737 return 0;
1738 }
1739
1740 return 1;
1741 }
1742