TexConversion Class Reference

List of all members.

Classes

struct  TextureFormat

Static Public Member Functions

static void convertAndCache (FTextureInfo &Info, DWORD PolyFlags)
static void update (FTextureInfo &Info, DWORD PolyFlags)

Static Private Member Functions

static void convertMip (FTextureInfo &Info, TextureFormat &format, DWORD PolyFlags, int mipLevel, D3D10_SUBRESOURCE_DATA &data)
Format conversion functions
static void fromPaletted (FTextureInfo &Info, DWORD PolyFlags, void *target, int mipLevel)
static void fromBGRA7 (FTextureInfo &Info, DWORD PolyFlags, void *target, int mipLevel)

Static Private Attributes

static TexConversion::TextureFormat formats []


Detailed Description

Functions to convert from Unreal format textures to standard R8G8B8A8 Direct3D 10 format inital data. Uses both Unreal and Direct3D datatypes, but no access to D3D objects like the device etc.

The game has two types of textures: static ones and dynamic. Dynamic texures are parametric ones such as water, etc. After trying multiple methods, it was determined best to create static textures as USAGE_IMMUTABLE, and dynamic ones as USAGE_DEFAULT (i.e. not USAGE_DYNAMIC). USAGE_DEFAULT textures cannot be mapped, but they are updated using a copy operation. A nice thing about this is that it allows the texture handling to be streamlined; it used to have seperate paths for map()-able and immutable textures. However copy-able and immutable textures can be handled about the same way as they both are created from initial data, instead of being filled after their creation.

Some texture types can be used by D3D without conversion; depending on the type (see formats array below) direct assignments can take place.

New textures are created by having the D3D class create a texture out of their converted/assigned mips stored as D3D_SUBRESOURCE_DATA; the texture conversion function sets the TEXTURE_2D_DESC parameters for this depending on the texture size, if it is dynamic, etc. Existing textures are updated by passing a new mip to the D3D class; only the 0th mip is updated, which should be fine (afaik there's no dynamic textures with >1 mips).

Texture conversion functions write to a void pointer so they can work unmodified regardless of the underlying memory.

Additional notes:


Member Function Documentation

void TexConversion::convertAndCache ( FTextureInfo &  Info,
DWORD  PolyFlags 
) [static]

Fill texture info structure and execute proper conversion of pixel data.

Parameters:
Info Unreal texture information, includes cache id, size information, texture data.
PolyFlags Polyflags, see polyflags.h.

void TexConversion::convertMip ( FTextureInfo &  Info,
TextureFormat format,
DWORD  PolyFlags,
int  mipLevel,
D3D10_SUBRESOURCE_DATA &  data 
) [static, private]

Fills a D3D10_SUBRESOURCE_DATA structure with converted texture data for a mipmap; if possible, assigns instead of converts.

Parameters:
Info Unreal texture info.
format Conversion parameters for the texture.
PolyFlags Polyflags. See polyflags.h.
mipLevel Which mip to convert.
data Direct3D 10 structure which will be filled.
Note:
Caller must free data.pSysMem for non-directAssign textures.

void TexConversion::fromBGRA7 ( FTextureInfo &  Info,
DWORD  PolyFlags,
void *  target,
int  mipLevel 
) [static, private]

BGRA7 to RGBA8. Used for lightmaps and fog. Straightforward, just multiply by 2.

Note:
IMPORTANT these textures do not have valid data outside of their U/VClamp; there's garbage outside UClamp and reading it outside VClamp sometimes results in access violations. Unfortunately this means a direct assignment is not possible as we need to manually repeat the rows/columns outside of the clamping range.

This format is only used for fog and lightmap; it is also the only format used for those. As such, we can at least do the swizzling and scaling in-shader and use memcpy() here.

Deprecated:
Direct assignment instead.

void TexConversion::fromPaletted ( FTextureInfo &  Info,
DWORD  PolyFlags,
void *  target,
int  mipLevel 
) [static, private]

Convert from palleted 8bpp to r8g8b8a8.

void TexConversion::update ( FTextureInfo &  Info,
DWORD  PolyFlags 
) [static]

Update a dynamic texture by converting its 0th mip and letting D3D update it.


Member Data Documentation

Initial value:

 
{
        {true,0,false,DXGI_FORMAT_R8G8B8A8_UNORM,&TexConversion::fromPaletted},         
        {true,0,true,DXGI_FORMAT_R8G8B8A8_UNORM,NULL},                                                          
        {false,0,true,DXGI_FORMAT_R8G8B8A8_UNORM,NULL},                                                         
        {true,4,true,DXGI_FORMAT_BC1_UNORM,NULL},                                                                       
        {false,0,true,DXGI_FORMAT_UNKNOWN,NULL},                                                                        
        {true,0,true,DXGI_FORMAT_R8G8B8A8_UNORM,NULL},                                                          
}
Mappings from Unreal to our texture info


The documentation for this class was generated from the following files:

Generated on Sat Jun 20 17:03:22 2009 for D3D10DRV by  doxygen 1.5.9