# NNS_GfdAllocTexVram

## Syntax

      #include <nnsys/gfd.h>

      NNSGfdTexKey NNS_GfdAllocTexVram(u32 szByte, BOOL is4x4comp, u32 opt);

## Arguments

`szByte` | Size of the texture-use memory you want to allocate (16 to 524272 bytes).
`is4x4comp` | `TRUE` if a 4x4 texel compressed texture-use region is being allocated.
`opt` | Options for the VRAM Memory Manager.

## Return Values

The key data showing the texture-use memory.

## Description

Allocates texture-use memory of the size specified by `szByte` from VRAM. The TWL-System library uses this function to allocate texture-use memory from VRAM.

The `NNS_GfdAllocTexVram` function is defined as shown below. The only process this function conducts internally is calling the function set in the global function pointer `NNS_GfdDefaultFuncAllocTexVram`.

    static inline NNSGfdTexKey
    NNS_GfdAllocTexVram(u32 szByte, BOOL is4x4comp, u32 opt)
    {
        return (*NNS_GfdDefaultFuncAllocTexVram)(szByte, is4x4comp, opt );
    }

`NNS_GfdAllocTexVram` works by registering the appropriate function for allocating texture-use memory in this function pointer. With this setup, the user can control the acquisition of texture-use memory from the library. In the initial state, the function that is set in `NNS_GfdDefaultFuncAllocTexVram` does nothing and returns an error. If an error occurs when texture-use memory is being allocated, the key `NNS_GFD_ALLOC_ERROR_TEXKEY` is returned, indicating an error.

The `opt` parameter enables you to freely select how to use the function set in `NNS_GfdDefaultFuncAllocTexVram` for allocating texture-use memory.

Due to the specification of the bit expression inside the texture key, the size of `szByte` that you can specify is restricted. In addition, the amount of memory that you can allocate at one time depends on the implementation of the VRAM manager used for memory allocation.

## See Also

`NNS_GfdFreeTexVram`

## Revision History

2008/06/20 Changed NITRO-System to TWL-System.
2007/01/31 Added note specific to allocated sizes.
2005/01/31 Added note specific to size regions.
2004/07/16 Initial version.

CONFIDENTIAL