Share via


Set RAM Attributes for Best Graphics Performance (Compact 2013)

3/26/2014

This topic shows you how to set RAM attributes to obtain the best graphics performance.

To set RAM attributes, implement the function OEMSetMemoryAttributes for your platform. This function is critical for graphic performance by enabling the write-combine capability if the platform supports it. Write-combining enables bus write transfers to be combined into a larger transfer before the direct memory access (DMA) hardware sends a burst. This setting increases performance by reducing the overhead of repeated write operations to the graphics subsystem.

Note

For ARMv6 and later versions, set the attributes to inner/outer write-through, no write-allocate. See the sample implementation for ARM in this topic.

Set RAM Attributes

Use the following procedure to set RAM attributes for your platform.

To set RAM Attributes

  1. Implement OEMSetMemoryAttributes for your platform. You can use the ARM platform example in the next section. You can also see an example x86 implementation in the file %_WINCEROOT%\platform\common\src\x86\common\memory\memory.c.

  2. Modify your platform OEMInit function to register your implementation by adding the following line of code:

    OEMInit()
    {
      // Add this line to OEMInit:
      g_pOemGlobal->pfnSetMemoryAttributes = OEMSetMemoryAttributes;
    }
    

Set RAM Attributes on an ARM Platform

The following code demonstrates how to set RAM attributes on an ARM platform by implementing the OEMSetMemoryAttributes function to handle setting the PAGE_WRITECOMBINE attribute.

// Sets inner/outer write-through, no write-allocate. 
// See ARM reference manual for your device
#define TEX_C_B_MASK 0x1CC 

BOOL OEMSetMemoryAttributes (LPVOID pVirtAddr, LPVOID pPhysAddr, DWORD cbSize, DWORD dwAttrib)
{
  BOOL bRet = FALSE;
 
  OALMSG((OAL_FUNC), (L"+OEMSetMemoryAttributes(%x,%x,%x,%x)\r\n",
      pVirtAddr, pPhysAddr, cbSize, dwAttrib));
 
  switch (dwAttrib) {
 
  case PAGE_WRITECOMBINE:
    // change page attribute to TEX[0]=0,C=0,B=1 (normal memory, uncacheable)
    bRet = NKVirtualSetAttributes(pVirtAddr, cbSize, 0x8, TEX_C_B_MASK, &dwAttrib);
    break;
 
  default:
    break;
  }
 
  OALMSG((OAL_FUNC), (L"-OEMSetMemoryAttributes(%d)\r\n", bRet));
  return bRet;
}

See Also

Concepts

Optimize Runtime Performance