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 [] |
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:
void TexConversion::convertAndCache | ( | FTextureInfo & | Info, | |
DWORD | PolyFlags | |||
) | [static] |
Fill texture info structure and execute proper conversion of pixel data.
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.
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. |
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.
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.
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.
TexConversion::TextureFormat TexConversion::formats [static, private] |
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}, }