- Main Page
- Classes
- Files

- File List
- File Members

# flMemoryVMem.h

Go to the documentation of this file.

    00001 // Funclib Memory VMem v1.0.0
    00002 //
    00003 // This module contains functions for video memory management.
    00004 //
    00005 // Contributor(s): VRAM code was written from scratch by Flatmush but based off Raphaels vram manager idea.
    00006
    00007
    00008
    00009 #ifndef FLMEMORYVMEM_H
    00010 #define FLMEMORYVMEM_H
    00011
    00012 #include "flGlobal.h"
    00013 #include "flMemory.h"
    00014
    00015 #define MEMORY_VMEM_BASE       0x04000000
    00016 #define MEMORY_VMEM_SIZE       0x00200000
    00017
    00018 #if FL_MEMORY_VMEM != 0
    00019
    00020 #ifdef __cplusplus
    00021 extern "C" {
    00022 #endif
    00023
    00024 typedef struct {
    00025      void* vmsbStart;
    00026      u32   vmsbStride;
    00027
    00028      u32   vmsbBlockSize;
    00029      u32   vmsbBlockCount;
    00030      u32   vmsbBlockAlign;
    00031      u8*   vmsbBlockTable;
    00032
    00033      void* vmsbLast;
    00034      void* vmsbNext;
    00035 } VmemStrideBlock;
    00036
    00037 extern u32   vmemStart;
    00038 extern u32   vmemSize;
    00039 extern u32*  vmemBlockTable;
    00040 extern u32   vmemBlocks;
    00041 extern u32   vmemFreeBlocks;
    00042 extern bool  vmemInitialized;
    00043
    00044 extern VmemStrideBlock* vmemStrideBlocks;
    00045
    00046 extern void  vmemInit();
    00047 extern void  vmemTerm();
    00048
    00049 extern void* vmemNormalPtr(void* inPtr);
    00050 #define vmemNormalPointer(inPtr) vmemNormalPtr(inPtr)
    00051
    00052 extern u32   vmemFreeSpace();
    00053 extern u32   vmemLargestFreeBlock();
    00054 extern float vmemFragmentation();
    00055
    00056 extern void* vmemAllocBuffer(u32 inWidth, u32 inHeight, u8 inBitDepth, u32 inStride);
    00057 #if (FL_DEBUG != 0) && (FL_DEBUG_CALLEDFROM != 0)
    00058 extern void* vmemAllocFrom(u32 inSize, const char* inFile, const char* inFunc, int inLine);
    00059 extern void* vmemCallocFrom(u32 inSize0, u32 inSize1, const char* inFile, const char* inFunc, int inLine);
    00060 extern void* vmemReallocFrom(void* inData, u32 inSize, const char* inFile, const char* inFunc, int inLine);
    00061 extern void  vmemFreeFrom(void* inData, const char* inFile, const char* inFunc, int inLine);
    00062 #define vmemAlloc(inSize) vmemAllocFrom(inSize, __FILE__, __FUNCTION__, __LINE__)
    00063 #define vmemCalloc(inSize0, inSize1) vmemCallocFrom(inSize0, inSize1, __FILE__, __FUNCTION__, __LINE__)
    00064 #define vmemRealloc(inData, inSize) vmemReallocFrom(inData, inSize, __FILE__, __FUNCTION__, __LINE__)
    00065 #define vmemFree(inData) vmemFreeFrom(inData, __FILE__, __FUNCTION__, __LINE__)
    00066 #else
    00067 extern void* vmemAlloc(u32 inSize);
    00068 extern void* vmemCalloc(u32 inSize0, u32 inSize1);
    00069 extern void* vmemRealloc(void* inData, u32 inSize);
    00070 extern void  vmemFree(void* inData);
    00071 #endif
    00072
    00073 extern void  vmemStrideBlockAdd(void* inStart, u32 inStride, u32 inBlockSize, u32 inBlockCount);
    00074 extern void  vmemStrideBlockDel(VmemStrideBlock* inBlock);
    00075 extern void  vmemStrideBlockDelRecursive(VmemStrideBlock* inBlock);
    00076
    00077 extern void* vmemStrideAlign(u32 inAlign, u32 inSize);
    00078 extern void* vmemStrideAlloc(u32 inSize);
    00079 extern void* vmemStrideCalloc(u32 inSize0, u32 inSize1);
    00080 extern bool  vmemStrideFree(void* inData);
    00081 extern float vmemStrideUsage();
    00082 extern u32   vmemStrideFreeSpace();
    00083
    00084 #ifdef __cplusplus
    00085 }
    00086 #endif
    00087
    00088 #endif
    00089
    00090 #define vmemAbsolutePtr(inPtr) ((void*)((unsigned int)(inPtr) | MEMORY_VMEM_BASE))
    00091 #define vmemRelativePtr(inPtr) ((void*)((unsigned int)(inPtr) & ~MEMORY_VMEM_BASE))
    00092 #define vmemPtr(inPtr) (((unsigned int)memCachedPtr(inPtr) >= MEMORY_VMEM_BASE) && ((unsigned int)memCachedPtr(inPtr) < (MEMORY_VMEM_BASE + (MEMORY_VMEM_SIZE << 2))))
    00093 #define vmemAbsPtr(inPtr) vmemAbsolutePtr(inPtr)
    00094 #define vmemRelPtr(inPtr) vmemRelativePtr(inPtr)
    00095 #define vmemAbsolutePointer(inPtr) vmemAbsolutePtr(inPtr)
    00096 #define vmemRelativePointer(inPtr) vmemRelativePtr(inPtr)
    00097 #define vmemPointer(inPtr) vmemPtr(inPtr)
    00098
    00099 #endif