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 //=============================================================================
1139 //
1140 // Function: GmmGetCompressionFormat
1141 //
1142 // Desc: See below.
1143 //
1144 // Returns:
1145 // CompressionFormat.CompressionFormat
1146 //
1147 //-----------------------------------------------------------------------------
GmmGetCompressionFormat(GMM_RESOURCE_FORMAT Format,GMM_LIB_CONTEXT * pGmmLibContext)1148 uint8_t GMM_STDCALL GmmGetCompressionFormat(GMM_RESOURCE_FORMAT Format, GMM_LIB_CONTEXT *pGmmLibContext)
1149 {
1150 return (((Format > GMM_FORMAT_INVALID) &&
1151 (Format < GMM_RESOURCE_FORMATS)) ?
1152 pGmmLibContext->GetPlatformInfo().FormatTable[Format].CompressionFormat.CompressionFormat :
1153 GMM_UNIFIED_CMF_INVALID);
1154 }
1155
1156 /////////////////////////////////////////////////////////////////////////////////////
1157 /// C wrapper for GmmResourceInfoCommon::GetHAlignSurfaceState
1158 /// @see GmmLib::GmmResourceInfoCommon::GetHAlignSurfaceState()
1159 ///
1160 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1161 /// @return HAlign
1162 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateHAlign(GMM_RESOURCE_INFO * pGmmResource)1163 uint32_t GMM_STDCALL GmmResGetSurfaceStateHAlign(GMM_RESOURCE_INFO *pGmmResource)
1164 {
1165 __GMM_ASSERTPTR(pGmmResource, 0);
1166 return pGmmResource->GetHAlignSurfaceState();
1167 }
1168
1169 /////////////////////////////////////////////////////////////////////////////////////
1170 /// C wrapper for GmmResourceInfoCommon::GetVAlignSurfaceState
1171 /// @see GmmLib::GmmResourceInfoCommon::GetVAlignSurfaceState()
1172 ///
1173 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1174 /// @return VAlign
1175 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateVAlign(GMM_RESOURCE_INFO * pGmmResource)1176 uint32_t GMM_STDCALL GmmResGetSurfaceStateVAlign(GMM_RESOURCE_INFO *pGmmResource)
1177 {
1178 __GMM_ASSERTPTR(pGmmResource, 0);
1179 return pGmmResource->GetVAlignSurfaceState();
1180 }
1181
1182 /////////////////////////////////////////////////////////////////////////////////////
1183 /// C wrapper for GmmResourceInfoCommon::GetTiledResourceModeSurfaceState
1184 /// @see GmmLib::GmmResourceInfoCommon::GetTiledResourceModeSurfaceState()
1185 ///
1186 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1187 /// @return Tiled Resource Mode
1188 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSurfaceStateTiledResourceMode(GMM_RESOURCE_INFO * pGmmResource)1189 uint32_t GMM_STDCALL GmmResGetSurfaceStateTiledResourceMode(GMM_RESOURCE_INFO *pGmmResource)
1190 {
1191 __GMM_ASSERTPTR(pGmmResource, 0);
1192 return pGmmResource->GetTiledResourceModeSurfaceState();
1193 }
1194
1195 /////////////////////////////////////////////////////////////////////////////////////
1196 /// Returns the surface offset for unified allocations. Truncates the offset to size
1197 /// of uint32_t.
1198 /// @see GmmResGetAuxSurfaceOffset64()
1199 ///
1200 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1201 /// @param[in] GmmAuxType: the type of aux the offset is needed for
1202 /// @return Surface Offset in bytes
1203 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxSurfaceOffset(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1204 uint32_t GMM_STDCALL GmmResGetAuxSurfaceOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1205 {
1206 return GFX_ULONG_CAST(GmmResGetAuxSurfaceOffset64(pGmmResource, GmmAuxType));
1207 }
1208
1209 /////////////////////////////////////////////////////////////////////////////////////
1210 /// C wrapper for GmmResourceInfoCommon::GetUnifiedAuxSurfaceOffset
1211 /// @see GmmLib::GmmResourceInfoCommon::GetUnifiedAuxSurfaceOffset()
1212 ///
1213 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1214 /// @param[in] GmmAuxType: the type of aux the offset is needed for
1215 /// @return Surface Offset in bytes
1216 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetAuxSurfaceOffset64(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1217 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetAuxSurfaceOffset64(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1218 {
1219 __GMM_ASSERTPTR(pGmmResource, 0);
1220 return pGmmResource->GetUnifiedAuxSurfaceOffset(GmmAuxType);
1221 }
1222
1223 /////////////////////////////////////////////////////////////////////////////////////
1224 /// C wrapper for GmmResourceInfoCommon::GetSizeAuxSurface
1225 /// @see GmmLib::GmmResourceInfoCommon::GetSizeAuxSurface()
1226 ///
1227 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1228 /// @param[in] GmmAuxType: the type of aux the size is needed for
1229 /// @return Surface size in bytes
1230 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSizeAuxSurface(GMM_RESOURCE_INFO * pGmmResource,GMM_UNIFIED_AUX_TYPE GmmAuxType)1231 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeAuxSurface(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType)
1232 {
1233 __GMM_ASSERTPTR(pGmmResource, 0);
1234 return pGmmResource->GetSizeAuxSurface(GmmAuxType);
1235 }
1236
1237 /////////////////////////////////////////////////////////////////////////////////////
1238 /// C wrapper for GmmResourceInfoCommon::GetSetHardwareProtection
1239 /// @see GmmLib::GmmResourceInfoCommon::GetSetHardwareProtection()
1240 /// @see GmmLib::GmmResourceInfoWin::GetSetHardwareProtection()
1241 ///
1242 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1243 /// @param[in] GetIsEncrypted: Read encryption status
1244 /// @param[in] SetIsEncrypted: Write encryption status
1245 /// @return Whether surface is encrypted or not
1246
1247 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetSetHardwareProtection(GMM_RESOURCE_INFO * pGmmResource,uint8_t GetIsEncrypted,uint8_t SetIsEncrypted)1248 uint8_t GMM_STDCALL GmmResGetSetHardwareProtection(GMM_RESOURCE_INFO *pGmmResource, uint8_t GetIsEncrypted, uint8_t SetIsEncrypted)
1249 {
1250 return pGmmResource ?
1251 pGmmResource->GetSetHardwareProtection(GetIsEncrypted, SetIsEncrypted) :
1252 0;
1253 }
1254
1255 /////////////////////////////////////////////////////////////////////////////////////
1256 /// C wrapper for GmmResourceInfoCommon::CpuBlt
1257 /// @see GmmLib::GmmResourceInfoCommon::CpuBlt()
1258 ///
1259 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1260 /// @param[in] pBlt: Describes the blit operation. See ::GMM_RES_COPY_BLT for more info.
1261 /// @return 1 if succeeded, 0 otherwise
1262 /////////////////////////////////////////////////////////////////////////////////////
GmmResCpuBlt(GMM_RESOURCE_INFO * pGmmResource,GMM_RES_COPY_BLT * pBlt)1263 uint8_t GMM_STDCALL GmmResCpuBlt(GMM_RESOURCE_INFO *pGmmResource, GMM_RES_COPY_BLT *pBlt)
1264 {
1265 __GMM_ASSERTPTR(pGmmResource, 0);
1266 return pGmmResource->CpuBlt(pBlt);
1267 }
1268
1269 /////////////////////////////////////////////////////////////////////////////////////
1270 /// C wrapper for GmmResourceInfoCommon::GetStdLayoutSize
1271 /// @see GmmLib::GmmResourceInfoCommon::GetStdLayoutSize()
1272 ///
1273 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1274 /// @return Size in bytes of Standard Layout version of surface.
1275 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetStdLayoutSize(GMM_RESOURCE_INFO * pGmmResource)1276 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetStdLayoutSize(GMM_RESOURCE_INFO *pGmmResource)
1277 {
1278 __GMM_ASSERT(pGmmResource);
1279 return pGmmResource->GetStdLayoutSize();
1280 }
1281
1282 /////////////////////////////////////////////////////////////////////////////////////
1283 /// C wrapper for GmmResourceInfoCommon::GetMappingSpanDesc
1284 /// @see GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc()
1285 ///
1286 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1287 /// @param[in] pMapping: Clients call the function with initially zero'd out GMM_GET_MAPPING.
1288 /// @return 1 if more span descriptors to report, 0 if all mapping is done
1289 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMappingSpanDesc(GMM_RESOURCE_INFO * pGmmResource,GMM_GET_MAPPING * pMapping)1290 uint8_t GMM_STDCALL GmmResGetMappingSpanDesc(GMM_RESOURCE_INFO *pGmmResource, GMM_GET_MAPPING *pMapping)
1291 {
1292 __GMM_ASSERTPTR(pGmmResource, 0);
1293 return pGmmResource->GetMappingSpanDesc(pMapping);
1294 }
1295
1296 /////////////////////////////////////////////////////////////////////////////////////
1297 /// C wrapper for GmmResourceInfoCommon::IsColorSeparation
1298 /// @see GmmLib::GmmResourceInfoCommon::IsColorSeparation()
1299 ///
1300 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1301 /// @return 1 if the resource is color separated target, 0 otherwise
1302 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsColorSeparation(GMM_RESOURCE_INFO * pGmmResource)1303 uint8_t GMM_STDCALL GmmResIsColorSeparation(GMM_RESOURCE_INFO *pGmmResource)
1304 {
1305 __GMM_ASSERTPTR(pGmmResource, 0);
1306 return pGmmResource->IsColorSeparation();
1307 }
1308
1309 /////////////////////////////////////////////////////////////////////////////////////
1310 /// C wrapper for GmmResourceInfoCommon::TranslateColorSeparationX
1311 /// @see GmmLib::GmmResourceInfoCommon::TranslateColorSeparationX()
1312 ///
1313 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1314 /// @param[in] x: X coordinate
1315 /// @return Translated color separation target x coordinate
1316 /////////////////////////////////////////////////////////////////////////////////////
GmmResTranslateColorSeparationX(GMM_RESOURCE_INFO * pGmmResource,uint32_t x)1317 uint32_t GMM_STDCALL GmmResTranslateColorSeparationX(GMM_RESOURCE_INFO *pGmmResource, uint32_t x)
1318 {
1319 __GMM_ASSERTPTR(pGmmResource, false);
1320 return pGmmResource->TranslateColorSeparationX(x);
1321 }
1322
1323 /////////////////////////////////////////////////////////////////////////////////////
1324 /// C wrapper for GmmResourceInfoCommon::GetColorSeparationArraySize
1325 /// @see GmmLib::GmmResourceInfoCommon::GetColorSeparationArraySize()
1326 ///
1327 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1328 /// @return Array size of a color separated target resource
1329 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetColorSeparationArraySize(GMM_RESOURCE_INFO * pGmmResource)1330 uint32_t GMM_STDCALL GmmResGetColorSeparationArraySize(GMM_RESOURCE_INFO *pGmmResource)
1331 {
1332 __GMM_ASSERTPTR(pGmmResource, 0);
1333 return pGmmResource->GetColorSeparationArraySize();
1334 }
1335
1336 /////////////////////////////////////////////////////////////////////////////////////
1337 /// C wrapper for GmmResourceInfoCommon::GetColorSeparationPhysicalWidth
1338 /// @see GmmLib::GmmResourceInfoCommon::GetColorSeparationPhysicalWidth()
1339 ///
1340 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1341 /// @return Physical width of a color separated target resource
1342 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetColorSeparationPhysicalWidth(GMM_RESOURCE_INFO * pGmmResource)1343 uint32_t GMM_STDCALL GmmResGetColorSeparationPhysicalWidth(GMM_RESOURCE_INFO *pGmmResource)
1344 {
1345 __GMM_ASSERTPTR(pGmmResource, 0);
1346 return pGmmResource->GetColorSeparationPhysicalWidth();
1347 }
1348
1349 //=============================================================================
1350 //
1351 // Function: GmmResGetMaxGpuVirtualAddressBits
1352 //
1353 // Desc: This function returns max no of GpuVA bits supported per surface on current platform
1354 //
1355 // Parameters:
1356 // GMM_RESOURCE_INFO *pGmmResource (Don't care)
1357 // Function will return the current Gen MaxGpuVirtualAddressBitsPerResource
1358 //
1359 // Returns:
1360 // uint32_t - Max no of GpuVA bits
1361 //-----------------------------------------------------------------------------
GmmResGetMaxGpuVirtualAddressBits(GMM_RESOURCE_INFO * pGmmResource,GMM_LIB_CONTEXT * pGmmLibContext)1362 uint32_t GMM_STDCALL GmmResGetMaxGpuVirtualAddressBits(GMM_RESOURCE_INFO *pGmmResource, GMM_LIB_CONTEXT *pGmmLibContext)
1363 {
1364 if(pGmmResource == NULL)
1365 {
1366 __GMM_ASSERTPTR(pGmmLibContext, 0);
1367 const GMM_PLATFORM_INFO &PlatformInfo = pGmmLibContext->GetPlatformInfo();
1368 return PlatformInfo.MaxGpuVirtualAddressBitsPerResource;
1369 }
1370
1371 return pGmmResource->GetMaxGpuVirtualAddressBits();
1372 }
1373
1374 /////////////////////////////////////////////////////////////////////////////////////
1375 /// C wrapper for GmmResourceInfoCommon::IsSurfaceFaultable
1376 /// @see GmmLib::GmmResourceInfoCommon::IsSurfaceFaultable()
1377 /// @see GmmLib::GmmResourceInfoWin::IsSurfaceFaultable()
1378 ///
1379 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1380 /// @return 1 is surface can be faulted on
1381 /////////////////////////////////////////////////////////////////////////////////////
GmmIsSurfaceFaultable(GMM_RESOURCE_INFO * pGmmResource)1382 uint8_t GMM_STDCALL GmmIsSurfaceFaultable(GMM_RESOURCE_INFO *pGmmResource)
1383 {
1384 __GMM_ASSERTPTR(pGmmResource, 0);
1385 return pGmmResource->IsSurfaceFaultable();
1386 }
1387
1388 /////////////////////////////////////////////////////////////////////////////////////
1389 /// C wrapper for GmmResourceInfoCommon::GetResFlags
1390 /// @see GmmLib::GmmResourceInfoCommon::GetResFlags()
1391 ///
1392 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1393 /// @return Copy of ::GMM_RESOURCE_FLAGS
1394 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetResourceFlags(const GMM_RESOURCE_INFO * pGmmResource)1395 GMM_RESOURCE_FLAG GMM_STDCALL GmmResGetResourceFlags(const GMM_RESOURCE_INFO *pGmmResource)
1396 {
1397 __GMM_ASSERT(pGmmResource);
1398 return const_cast<GMM_RESOURCE_INFO *>(pGmmResource)->GetResFlags();
1399 }
1400
1401 /////////////////////////////////////////////////////////////////////////////////////
1402 /// C wrapper for GmmResourceInfoCommon::GetMaximumRenamingListLength
1403 /// @see GmmLib::GmmResourceInfoCommon::GetMaximumRenamingListLength()
1404 ///
1405 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1406 /// @return maximum remaining list length
1407 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetMaximumRenamingListLength(GMM_RESOURCE_INFO * pGmmResource)1408 uint32_t GMM_STDCALL GmmResGetMaximumRenamingListLength(GMM_RESOURCE_INFO *pGmmResource)
1409 {
1410 __GMM_ASSERT(pGmmResource);
1411 return pGmmResource->GetMaximumRenamingListLength();
1412 }
1413
1414 //=============================================================================
1415 //
1416 // Function: GmmGetLogicalTileShape
1417 //
1418 // Desc: This function returns the logical tile shape
1419 //
1420 // Parameters:
1421 // See Function arguments
1422 //
1423 // Returns:
1424 // GMM_STATUS
1425 //-----------------------------------------------------------------------------
GmmGetLogicalTileShape(uint32_t TileMode,uint32_t * pWidthInBytes,uint32_t * pHeight,uint32_t * pDepth,GMM_LIB_CONTEXT * pGmmLibContext)1426 GMM_STATUS GMM_STDCALL GmmGetLogicalTileShape(uint32_t TileMode,
1427 uint32_t *pWidthInBytes,
1428 uint32_t *pHeight,
1429 uint32_t *pDepth,
1430 GMM_LIB_CONTEXT *pGmmLibContext)
1431 {
1432 __GMM_ASSERT(TileMode < GMM_TILE_MODES);
1433
1434 if(pWidthInBytes)
1435 {
1436 *pWidthInBytes = pGmmLibContext->GetPlatformInfo().TileInfo[TileMode].LogicalTileWidth;
1437 }
1438
1439 if(pHeight)
1440 {
1441 *pHeight = pGmmLibContext->GetPlatformInfo().TileInfo[TileMode].LogicalTileHeight;
1442 }
1443
1444 if(pDepth)
1445 {
1446 *pDepth = pGmmLibContext->GetPlatformInfo().TileInfo[TileMode].LogicalTileDepth;
1447 }
1448
1449 return GMM_SUCCESS;
1450 }
1451
1452
1453 /////////////////////////////////////////////////////////////////////////////////////
1454 /// C wrapper for GmmResourceInfoCommon::OverrideSize
1455 /// @see GmmLib::GmmResourceInfoCommon::OverrideSize()
1456 ///
1457 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1458 /// @param[in] Size: new size of the resource
1459 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationSize(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T Size)1460 void GMM_STDCALL GmmResOverrideAllocationSize(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Size)
1461 {
1462 __GMM_ASSERT(pGmmResource);
1463 pGmmResource->OverrideSize(Size);
1464 }
1465
1466 /////////////////////////////////////////////////////////////////////////////////////
1467 /// C wrapper for GmmResourceInfoCommon::OverridePitch
1468 /// @see GmmLib::GmmResourceInfoCommon::OverridePitch()
1469 ///
1470 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1471 /// @param[in] Pitch: new pitch of the resource
1472 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationPitch(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T Pitch)1473 void GMM_STDCALL GmmResOverrideAllocationPitch(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Pitch)
1474 {
1475 __GMM_ASSERT(pGmmResource);
1476 pGmmResource->OverridePitch(Pitch);
1477 }
1478
1479 /////////////////////////////////////////////////////////////////////////////////////
1480 /// C wrapper for GmmResourceInfoCommon::OverrideUnifiedAuxPitch
1481 /// @see GmmLib::GmmResourceInfoCommon::OverrideUnifiedAuxPitch()
1482 ///
1483 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1484 /// @param[in] Pitch: new pitch of the resource
1485 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAuxAllocationPitch(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T Pitch)1486 void GMM_STDCALL GmmResOverrideAuxAllocationPitch(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Pitch)
1487 {
1488 __GMM_ASSERT(pGmmResource);
1489 pGmmResource->OverrideUnifiedAuxPitch(Pitch);
1490 }
1491
1492 /////////////////////////////////////////////////////////////////////////////////////
1493 /// C wrapper for GmmResourceInfoCommon::OverrideUnifiedAuxPitch
1494 /// @see GmmLib::GmmResourceInfoCommon::OverrideUnifiedAuxPitch()
1495 ///
1496 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1497 /// @param[in] Pitch: new pitch of the resource
1498 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationFlags(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_FLAG * pFlags)1499 void GMM_STDCALL GmmResOverrideAllocationFlags(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FLAG *pFlags)
1500 {
1501 __GMM_ASSERT(pGmmResource);
1502 __GMM_ASSERT(pFlags);
1503 pGmmResource->OverrideAllocationFlags(*pFlags);
1504 }
1505
1506 /////////////////////////////////////////////////////////////////////////////////////
1507 /// C wrapper for GmmResourceInfoCommon::OverrideHAlign
1508 /// @see GmmLib::GmmResourceInfoCommon::OverrideHAlign()
1509 ///
1510 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1511 /// @param[in] Pitch: new pitch of the resource
1512 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationHAlign(GMM_RESOURCE_INFO * pGmmResource,uint32_t HAlign)1513 void GMM_STDCALL GmmResOverrideAllocationHAlign(GMM_RESOURCE_INFO *pGmmResource, uint32_t HAlign)
1514 {
1515 __GMM_ASSERT(pGmmResource);
1516 pGmmResource->OverrideHAlign(HAlign);
1517 }
1518
1519 /////////////////////////////////////////////////////////////////////////////////////
1520 /// C wrapper for GmmResourceInfoCommon::OverrideBaseAlignment
1521 /// @see GmmLib::GmmResourceInfoCommon::OverrideBaseAlignment()
1522 ///
1523 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1524 /// @param[in] Alignment: new BaseAlignment of the resource
1525 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationBaseAlignment(GMM_RESOURCE_INFO * pGmmResource,uint32_t Alignment)1526 void GMM_STDCALL GmmResOverrideAllocationBaseAlignment(GMM_RESOURCE_INFO *pGmmResource, uint32_t Alignment)
1527 {
1528 __GMM_ASSERT(pGmmResource);
1529 pGmmResource->OverrideBaseAlignment(Alignment);
1530 }
1531
1532 /////////////////////////////////////////////////////////////////////////////////////
1533 /// C wrapper for GmmResourceInfoCommon::OverrideBaseWidth
1534 /// @see GmmLib::GmmResourceInfoCommon::OverrideBaseWidth()
1535 ///
1536 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1537 /// @param[in] BaseWidth: new BaseWidth of the resource
1538 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationBaseWidth(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_SIZE_T BaseWidth)1539 void GMM_STDCALL GmmResOverrideAllocationBaseWidth(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T BaseWidth)
1540 {
1541 __GMM_ASSERT(pGmmResource);
1542 pGmmResource->OverrideBaseWidth(BaseWidth);
1543 }
1544
1545 /////////////////////////////////////////////////////////////////////////////////////
1546 /// C wrapper for GmmResourceInfoCommon::OverrideBaseHeight
1547 /// @see GmmLib::GmmResourceInfoCommon::OverrideBaseHeight()
1548 ///
1549 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1550 /// @param[in] BaseHeight: new BaseWidth of the resource
1551 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationBaseHeight(GMM_RESOURCE_INFO * pGmmResource,uint32_t BaseHeight)1552 void GMM_STDCALL GmmResOverrideAllocationBaseHeight(GMM_RESOURCE_INFO *pGmmResource, uint32_t BaseHeight)
1553 {
1554 __GMM_ASSERT(pGmmResource);
1555 pGmmResource->OverrideBaseHeight(BaseHeight);
1556 }
1557
1558 /////////////////////////////////////////////////////////////////////////////////////
1559 /// C wrapper for GmmResourceInfoCommon::OverrideDepth
1560 /// @see GmmLib::GmmResourceInfoCommon::OverrideDepth()
1561 ///
1562 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1563 /// @param[in] Depth: new Depth of the resource
1564 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationDepth(GMM_RESOURCE_INFO * pGmmResource,uint32_t Depth)1565 void GMM_STDCALL GmmResOverrideAllocationDepth(GMM_RESOURCE_INFO *pGmmResource, uint32_t Depth)
1566 {
1567 __GMM_ASSERT(pGmmResource);
1568 pGmmResource->OverrideDepth(Depth);
1569 }
1570
1571 /////////////////////////////////////////////////////////////////////////////////////
1572 /// C wrapper for GmmResourceInfoCommon::OverrideTileMode
1573 /// @see GmmLib::GmmResourceInfoCommon::OverrideTileMode()
1574 ///
1575 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1576 /// @param[in] TileMode: new tile mode of the resource
1577 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideResourceTiling(GMM_RESOURCE_INFO * pGmmResource,uint32_t TileMode)1578 void GMM_STDCALL GmmResOverrideResourceTiling(GMM_RESOURCE_INFO *pGmmResource, uint32_t TileMode)
1579 {
1580 __GMM_ASSERT(pGmmResource);
1581 pGmmResource->OverrideTileMode(static_cast<GMM_TILE_MODE>(TileMode));
1582 }
1583
1584 /////////////////////////////////////////////////////////////////////////////////////
1585 /// C wrapper for GmmResourceInfoCommon::OverrideUnifiedAuxTileMode
1586 /// @see GmmLib::GmmResourceInfoCommon::OverrideUnifiedAuxTileMode()
1587 ///
1588 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1589 /// @param[in] TileMode: new tile mode of the unified auxresource
1590 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAuxResourceTiling(GMM_RESOURCE_INFO * pGmmResource,uint32_t TileMode)1591 void GMM_STDCALL GmmResOverrideAuxResourceTiling(GMM_RESOURCE_INFO *pGmmResource, uint32_t TileMode)
1592 {
1593 __GMM_ASSERT(pGmmResource);
1594 pGmmResource->OverrideUnifiedAuxTileMode(static_cast<GMM_TILE_MODE>(TileMode));
1595 }
1596
1597 /////////////////////////////////////////////////////////////////////////////////////
1598 /// C wrapper for GmmResourceInfoCommon::OverrideSurfaceFormat
1599 /// @see GmmLib::GmmResourceInfoCommon::OverrideSurfaceFormat()
1600 ///
1601 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1602 /// @param[in] Format: new format for the resource
1603 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationFormat(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_FORMAT Format)1604 void GMM_STDCALL GmmResOverrideAllocationFormat(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FORMAT Format)
1605 {
1606 __GMM_ASSERT(pGmmResource);
1607 pGmmResource->OverrideSurfaceFormat(Format);
1608 }
1609
1610 /////////////////////////////////////////////////////////////////////////////////////
1611 /// C wrapper for GmmResourceInfoCommon::OverrideSurfaceType
1612 /// @see GmmLib::GmmResourceInfoCommon::OverrideSurfaceType()
1613 ///
1614 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1615 /// @param[in] ResourceType: new type for the resource
1616 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideSurfaceType(GMM_RESOURCE_INFO * pGmmResource,GMM_RESOURCE_TYPE ResourceType)1617 void GMM_STDCALL GmmResOverrideSurfaceType(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_TYPE ResourceType)
1618 {
1619 __GMM_ASSERT(pGmmResource);
1620 pGmmResource->OverrideSurfaceType(ResourceType);
1621 }
1622
1623
1624 /////////////////////////////////////////////////////////////////////////////////////
1625 /// C wrapper for GmmResourceInfoCommon::GmmResOverrideSvmGfxAddress
1626 /// @see GmmLib::GmmResourceInfoCommon::GmmResOverrideSvmGfxAddress()
1627 ///
1628 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1629 /// @param[in] SvmGfxAddress: new svm gfx address for the resource
1630 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideSvmGfxAddress(GMM_RESOURCE_INFO * pGmmResource,GMM_GFX_ADDRESS SvmGfxAddress)1631 void GMM_STDCALL GmmResOverrideSvmGfxAddress(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_ADDRESS SvmGfxAddress)
1632 {
1633 __GMM_ASSERT(pGmmResource);
1634 pGmmResource->OverrideSvmGfxAddress(SvmGfxAddress);
1635 }
1636
1637 /////////////////////////////////////////////////////////////////////////////////////
1638 /// C wrapper for GmmResourceInfoCommon::OverrideArraySize
1639 /// @see GmmLib::GmmResourceInfoCommon::OverrideArraySize()
1640 ///
1641 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1642 /// @param[in] ArraySize: new array size for the resource
1643 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationArraySize(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArraySize)1644 void GMM_STDCALL GmmResOverrideAllocationArraySize(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArraySize)
1645 {
1646 __GMM_ASSERT(pGmmResource);
1647 pGmmResource->OverrideArraySize(ArraySize);
1648 }
1649
1650 /////////////////////////////////////////////////////////////////////////////////////
1651 /// C wrapper for GmmResourceInfoCommon::OverrideArraySize
1652 /// @see GmmLib::GmmResourceInfoCommon::OverrideArraySize()
1653 ///
1654 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1655 /// @param[in] MaxLod: new max LOD for the resource
1656 /////////////////////////////////////////////////////////////////////////////////////
GmmResOverrideAllocationMaxLod(GMM_RESOURCE_INFO * pGmmResource,uint32_t MaxLod)1657 void GMM_STDCALL GmmResOverrideAllocationMaxLod(GMM_RESOURCE_INFO *pGmmResource, uint32_t MaxLod)
1658 {
1659 __GMM_ASSERT(pGmmResource);
1660 pGmmResource->OverrideMaxLod(MaxLod);
1661 }
1662
1663 /////////////////////////////////////////////////////////////////////////////////////
1664 /// C wrapper for GmmResourceInfoCommon::GetPlanarXOffset
1665 /// @see GmmLib::GmmResourceInfoCommon::GetPlanarXOffset()
1666 ///
1667 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1668 /// @param[in] Plane: Plane for which the offset is needed
1669 /// @return X offset
1670 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPlanarGetXOffset(GMM_RESOURCE_INFO * pGmmResource,GMM_YUV_PLANE Plane)1671 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarGetXOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane)
1672 {
1673 __GMM_ASSERT(pGmmResource);
1674 return pGmmResource->GetPlanarXOffset(Plane);
1675 }
1676
1677 /////////////////////////////////////////////////////////////////////////////////////
1678 /// C wrapper for GmmResourceInfoCommon::GetPlanarYOffset
1679 /// @see GmmLib::GmmResourceInfoCommon::GetPlanarYOffset()
1680 ///
1681 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1682 /// @param[in] Plane: Plane for which the offset is needed
1683 /// @return Y offset
1684 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPlanarGetYOffset(GMM_RESOURCE_INFO * pGmmResource,GMM_YUV_PLANE Plane)1685 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarGetYOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane)
1686 {
1687 __GMM_ASSERT(pGmmResource);
1688 return pGmmResource->GetPlanarYOffset(Plane);
1689 }
1690
1691 /////////////////////////////////////////////////////////////////////////////////////
1692 /// C wrapper for GmmResourceInfoCommon::GetPlanarAuxOffset
1693 /// @see GmmLib::GmmResourceInfoCommon::GetPlanarAuxOffset()
1694 ///
1695 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1696 /// @param[in] Plane: Plane for which the offset is needed
1697 /// @return Y offset
1698 /////////////////////////////////////////////////////////////////////////////////////
GmmResGetPlanarAuxOffset(GMM_RESOURCE_INFO * pGmmResource,uint32_t ArrayIndex,GMM_UNIFIED_AUX_TYPE AuxType)1699 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarAuxOffset(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex, GMM_UNIFIED_AUX_TYPE AuxType)
1700 {
1701 __GMM_ASSERT(pGmmResource);
1702 return pGmmResource->GetPlanarAuxOffset(ArrayIndex, AuxType);
1703 }
1704
1705 /////////////////////////////////////////////////////////////////////////////////////
1706 /// C wrapper for GmmResourceInfoCommon::SetGmmLibContext
1707 /// @see GmmLib::GmmResourceInfoCommon::SetGmmLibContext()
1708 ///
1709 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1710 /// @param[in] pLibContext: Pointer to GmmLibContext
1711 /////////////////////////////////////////////////////////////////////////////////////
GmmResSetLibContext(GMM_RESOURCE_INFO * pGmmResource,void * pLibContext)1712 void GMM_STDCALL GmmResSetLibContext(GMM_RESOURCE_INFO *pGmmResource, void *pLibContext)
1713 {
1714 if(pGmmResource)
1715 {
1716 pGmmResource->SetGmmLibContext(pLibContext);
1717 }
1718 }
1719
1720 /////////////////////////////////////////////////////////////////////////////////////
1721 /// C wrapper for GmmResourceInfoCommon::IsResourceMappedCompressible
1722 /// @see GmmLib::GmmResourceInfoCommon::IsResourceMappedCompressible()
1723 ///
1724 /// @param[in] pGmmResource: Pointer to GmmResourceInfo class
1725 /////////////////////////////////////////////////////////////////////////////////////
GmmResIsMappedCompressible(GMM_RESOURCE_INFO * pGmmResource)1726 uint32_t GMM_STDCALL GmmResIsMappedCompressible(GMM_RESOURCE_INFO *pGmmResource)
1727 {
1728 return pGmmResource->IsResourceMappedCompressible();
1729 }
1730
1731 //=============================================================================
1732 //
1733 // Function: __CanSupportStdTiling
1734 //
1735 // Desc: Verifies texture parameters can support StdTiling
1736 //
1737 // Parameters:
1738 // GMM_TEXTURE_INFO& Surf
1739 //
1740 // Returns:
1741 //
1742 //-----------------------------------------------------------------------------
__CanSupportStdTiling(GMM_TEXTURE_INFO Surf,GMM_LIB_CONTEXT * pGmmLibContext)1743 uint8_t __CanSupportStdTiling(GMM_TEXTURE_INFO Surf, GMM_LIB_CONTEXT *pGmmLibContext)
1744 {
1745 const __GMM_PLATFORM_RESOURCE *pPlatformResource = GMM_OVERRIDE_PLATFORM_INFO(&Surf, pGmmLibContext);
1746
1747 // SKL+ Tiled Resource Mode Restrictions
1748 if((Surf.Flags.Info.TiledYf || Surf.Flags.Info.TiledYs) &&
1749 !((GFX_GET_CURRENT_RENDERCORE(pPlatformResource->Platform) >= IGFX_GEN9_CORE) &&
1750 // TiledY must be set unless 1D surface.
1751 ((Surf.Flags.Info.TiledY && (Surf.Type != RESOURCE_1D)) ||
1752 (Surf.Flags.Info.Linear && (Surf.Type == RESOURCE_1D ||
1753 Surf.Type == RESOURCE_BUFFER))) &&
1754 // 8, 16, 32, 64, or 128 bpp
1755 ((!GmmIsCompressed(pGmmLibContext, Surf.Format) &&
1756 ((Surf.BitsPerPixel == 8) ||
1757 (Surf.BitsPerPixel == 16) ||
1758 (Surf.BitsPerPixel == 32) ||
1759 (Surf.BitsPerPixel == 64) ||
1760 (Surf.BitsPerPixel == 128))) ||
1761 // Compressed Modes: BC*, ETC*, EAC*, ASTC*
1762 (GmmIsCompressed(pGmmLibContext, Surf.Format) && (Surf.Format != GMM_FORMAT_FXT1)))))
1763 /* Not currently supported...
1764 // YCRCB* Formats
1765 GmmIsYUVPacked(Surf.Format) */
1766 {
1767 return 0;
1768 }
1769
1770 return 1;
1771 }
1772