diff --git a/src/Common/Image/D3DFormat.h b/src/Common/Image/D3DFormat.h index cf03fb746..90f671cfb 100644 --- a/src/Common/Image/D3DFormat.h +++ b/src/Common/Image/D3DFormat.h @@ -2,107 +2,111 @@ #include "Utils/FileUtils.h" -enum D3DFORMAT +// This is a redefinition to make this enum available on platforms without DirectX headers +namespace oat { - D3DFMT_UNKNOWN = 0, - - D3DFMT_R8G8B8 = 20, - D3DFMT_A8R8G8B8 = 21, - D3DFMT_X8R8G8B8 = 22, - D3DFMT_R5G6B5 = 23, - D3DFMT_X1R5G5B5 = 24, - D3DFMT_A1R5G5B5 = 25, - D3DFMT_A4R4G4B4 = 26, - D3DFMT_R3G3B2 = 27, - D3DFMT_A8 = 28, - D3DFMT_A8R3G3B2 = 29, - D3DFMT_X4R4G4B4 = 30, - D3DFMT_A2B10G10R10 = 31, - D3DFMT_A8B8G8R8 = 32, - D3DFMT_X8B8G8R8 = 33, - D3DFMT_G16R16 = 34, - D3DFMT_A2R10G10B10 = 35, - D3DFMT_A16B16G16R16 = 36, - - D3DFMT_A8P8 = 40, - D3DFMT_P8 = 41, - - D3DFMT_L8 = 50, - D3DFMT_A8L8 = 51, - D3DFMT_A4L4 = 52, - - D3DFMT_V8U8 = 60, - D3DFMT_L6V5U5 = 61, - D3DFMT_X8L8V8U8 = 62, - D3DFMT_Q8W8V8U8 = 63, - D3DFMT_V16U16 = 64, - D3DFMT_A2W10V10U10 = 67, - - D3DFMT_UYVY = FileUtils::MakeMagic32('U', 'Y', 'V', 'Y'), - D3DFMT_R8G8_B8G8 = FileUtils::MakeMagic32('R', 'G', 'B', 'G'), - D3DFMT_YUY2 = FileUtils::MakeMagic32('Y', 'U', 'Y', '2'), - D3DFMT_G8R8_G8B8 = FileUtils::MakeMagic32('G', 'R', 'G', 'B'), - D3DFMT_DXT1 = FileUtils::MakeMagic32('D', 'X', 'T', '1'), - D3DFMT_DXT2 = FileUtils::MakeMagic32('D', 'X', 'T', '2'), - D3DFMT_DXT3 = FileUtils::MakeMagic32('D', 'X', 'T', '3'), - D3DFMT_DXT4 = FileUtils::MakeMagic32('D', 'X', 'T', '4'), - D3DFMT_DXT5 = FileUtils::MakeMagic32('D', 'X', 'T', '5'), - - D3DFMT_D16_LOCKABLE = 70, - D3DFMT_D32 = 71, - D3DFMT_D15S1 = 73, - D3DFMT_D24S8 = 75, - D3DFMT_D24X8 = 77, - D3DFMT_D24X4S4 = 79, - D3DFMT_D16 = 80, - - D3DFMT_D32F_LOCKABLE = 82, - D3DFMT_D24FS8 = 83, - - /* D3D9Ex only -- */ - - /* Z-Stencil formats valid for CPU access */ - D3DFMT_D32_LOCKABLE = 84, - D3DFMT_S8_LOCKABLE = 85, - - /* -- D3D9Ex only */ - - D3DFMT_L16 = 81, - - D3DFMT_VERTEXDATA = 100, - D3DFMT_INDEX16 = 101, - D3DFMT_INDEX32 = 102, - - D3DFMT_Q16W16V16U16 = 110, - - D3DFMT_MULTI2_ARGB8 = FileUtils::MakeMagic32('M', 'E', 'T', '1'), - - // Floating point surface formats - - // s10e5 formats (16-bits per channel) - D3DFMT_R16F = 111, - D3DFMT_G16R16F = 112, - D3DFMT_A16B16G16R16F = 113, - - // IEEE s23e8 formats (32-bits per channel) - D3DFMT_R32F = 114, - D3DFMT_G32R32F = 115, - D3DFMT_A32B32G32R32F = 116, - - D3DFMT_CxV8U8 = 117, - - /* D3D9Ex only -- */ - - // Monochrome 1 bit per pixel format - D3DFMT_A1 = 118, - - // 2.8 biased fixed point - D3DFMT_A2B10G10R10_XR_BIAS = 119, - - // Binary format indicating that the data has no inherent type - D3DFMT_BINARYBUFFER = 199, - - /* -- D3D9Ex only */ - - D3DFMT_FORCE_DWORD = 0x7fffffff -}; + enum D3DFORMAT + { + D3DFMT_UNKNOWN = 0, + + D3DFMT_R8G8B8 = 20, + D3DFMT_A8R8G8B8 = 21, + D3DFMT_X8R8G8B8 = 22, + D3DFMT_R5G6B5 = 23, + D3DFMT_X1R5G5B5 = 24, + D3DFMT_A1R5G5B5 = 25, + D3DFMT_A4R4G4B4 = 26, + D3DFMT_R3G3B2 = 27, + D3DFMT_A8 = 28, + D3DFMT_A8R3G3B2 = 29, + D3DFMT_X4R4G4B4 = 30, + D3DFMT_A2B10G10R10 = 31, + D3DFMT_A8B8G8R8 = 32, + D3DFMT_X8B8G8R8 = 33, + D3DFMT_G16R16 = 34, + D3DFMT_A2R10G10B10 = 35, + D3DFMT_A16B16G16R16 = 36, + + D3DFMT_A8P8 = 40, + D3DFMT_P8 = 41, + + D3DFMT_L8 = 50, + D3DFMT_A8L8 = 51, + D3DFMT_A4L4 = 52, + + D3DFMT_V8U8 = 60, + D3DFMT_L6V5U5 = 61, + D3DFMT_X8L8V8U8 = 62, + D3DFMT_Q8W8V8U8 = 63, + D3DFMT_V16U16 = 64, + D3DFMT_A2W10V10U10 = 67, + + D3DFMT_UYVY = FileUtils::MakeMagic32('U', 'Y', 'V', 'Y'), + D3DFMT_R8G8_B8G8 = FileUtils::MakeMagic32('R', 'G', 'B', 'G'), + D3DFMT_YUY2 = FileUtils::MakeMagic32('Y', 'U', 'Y', '2'), + D3DFMT_G8R8_G8B8 = FileUtils::MakeMagic32('G', 'R', 'G', 'B'), + D3DFMT_DXT1 = FileUtils::MakeMagic32('D', 'X', 'T', '1'), + D3DFMT_DXT2 = FileUtils::MakeMagic32('D', 'X', 'T', '2'), + D3DFMT_DXT3 = FileUtils::MakeMagic32('D', 'X', 'T', '3'), + D3DFMT_DXT4 = FileUtils::MakeMagic32('D', 'X', 'T', '4'), + D3DFMT_DXT5 = FileUtils::MakeMagic32('D', 'X', 'T', '5'), + + D3DFMT_D16_LOCKABLE = 70, + D3DFMT_D32 = 71, + D3DFMT_D15S1 = 73, + D3DFMT_D24S8 = 75, + D3DFMT_D24X8 = 77, + D3DFMT_D24X4S4 = 79, + D3DFMT_D16 = 80, + + D3DFMT_D32F_LOCKABLE = 82, + D3DFMT_D24FS8 = 83, + + /* D3D9Ex only -- */ + + /* Z-Stencil formats valid for CPU access */ + D3DFMT_D32_LOCKABLE = 84, + D3DFMT_S8_LOCKABLE = 85, + + /* -- D3D9Ex only */ + + D3DFMT_L16 = 81, + + D3DFMT_VERTEXDATA = 100, + D3DFMT_INDEX16 = 101, + D3DFMT_INDEX32 = 102, + + D3DFMT_Q16W16V16U16 = 110, + + D3DFMT_MULTI2_ARGB8 = FileUtils::MakeMagic32('M', 'E', 'T', '1'), + + // Floating point surface formats + + // s10e5 formats (16-bits per channel) + D3DFMT_R16F = 111, + D3DFMT_G16R16F = 112, + D3DFMT_A16B16G16R16F = 113, + + // IEEE s23e8 formats (32-bits per channel) + D3DFMT_R32F = 114, + D3DFMT_G32R32F = 115, + D3DFMT_A32B32G32R32F = 116, + + D3DFMT_CxV8U8 = 117, + + /* D3D9Ex only -- */ + + // Monochrome 1 bit per pixel format + D3DFMT_A1 = 118, + + // 2.8 biased fixed point + D3DFMT_A2B10G10R10_XR_BIAS = 119, + + // Binary format indicating that the data has no inherent type + D3DFMT_BINARYBUFFER = 199, + + /* -- D3D9Ex only */ + + D3DFMT_FORCE_DWORD = 0x7fffffff + }; +} // namespace oat diff --git a/src/Common/Image/DdsTypes.h b/src/Common/Image/DdsTypes.h index d20f46767..0d368dad5 100644 --- a/src/Common/Image/DdsTypes.h +++ b/src/Common/Image/DdsTypes.h @@ -103,7 +103,7 @@ enum DDS_HEADER_DXT10_MISC2 struct DDS_HEADER_DXT10 { - DXGI_FORMAT dxgiFormat; + oat::DXGI_FORMAT dxgiFormat; D3D10_RESOURCE_DIMENSION resourceDimension; uint32_t miscFlag; uint32_t arraySize; diff --git a/src/Common/Image/DxgiFormat.h b/src/Common/Image/DxgiFormat.h index 3e17a2047..be8525e7a 100644 --- a/src/Common/Image/DxgiFormat.h +++ b/src/Common/Image/DxgiFormat.h @@ -1,5 +1,6 @@ #pragma once +// Modified for OAT /* * Copyright 2016 Józef Kucia for CodeWeavers * @@ -18,130 +19,134 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -const unsigned int DXGI_FORMAT_DEFINED = 1; - -enum DXGI_FORMAT +namespace oat { - DXGI_FORMAT_UNKNOWN = 0x00, - DXGI_FORMAT_R32G32B32A32_TYPELESS = 0x01, - DXGI_FORMAT_R32G32B32A32_FLOAT = 0x02, - DXGI_FORMAT_R32G32B32A32_UINT = 0x03, - DXGI_FORMAT_R32G32B32A32_SINT = 0x04, - DXGI_FORMAT_R32G32B32_TYPELESS = 0x05, - DXGI_FORMAT_R32G32B32_FLOAT = 0x06, - DXGI_FORMAT_R32G32B32_UINT = 0x07, - DXGI_FORMAT_R32G32B32_SINT = 0x08, - DXGI_FORMAT_R16G16B16A16_TYPELESS = 0x09, - DXGI_FORMAT_R16G16B16A16_FLOAT = 0x0a, - DXGI_FORMAT_R16G16B16A16_UNORM = 0x0b, - DXGI_FORMAT_R16G16B16A16_UINT = 0x0c, - DXGI_FORMAT_R16G16B16A16_SNORM = 0x0d, - DXGI_FORMAT_R16G16B16A16_SINT = 0x0e, - DXGI_FORMAT_R32G32_TYPELESS = 0x0f, - DXGI_FORMAT_R32G32_FLOAT = 0x10, - DXGI_FORMAT_R32G32_UINT = 0x11, - DXGI_FORMAT_R32G32_SINT = 0x12, - DXGI_FORMAT_R32G8X24_TYPELESS = 0x13, - DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 0x14, - DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 0x15, - DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 0x16, - DXGI_FORMAT_R10G10B10A2_TYPELESS = 0x17, - DXGI_FORMAT_R10G10B10A2_UNORM = 0x18, - DXGI_FORMAT_R10G10B10A2_UINT = 0x19, - DXGI_FORMAT_R11G11B10_FLOAT = 0x1a, - DXGI_FORMAT_R8G8B8A8_TYPELESS = 0x1b, - DXGI_FORMAT_R8G8B8A8_UNORM = 0x1c, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 0x1d, - DXGI_FORMAT_R8G8B8A8_UINT = 0x1e, - DXGI_FORMAT_R8G8B8A8_SNORM = 0x1f, - DXGI_FORMAT_R8G8B8A8_SINT = 0x20, - DXGI_FORMAT_R16G16_TYPELESS = 0x21, - DXGI_FORMAT_R16G16_FLOAT = 0x22, - DXGI_FORMAT_R16G16_UNORM = 0x23, - DXGI_FORMAT_R16G16_UINT = 0x24, - DXGI_FORMAT_R16G16_SNORM = 0x25, - DXGI_FORMAT_R16G16_SINT = 0x26, - DXGI_FORMAT_R32_TYPELESS = 0x27, - DXGI_FORMAT_D32_FLOAT = 0x28, - DXGI_FORMAT_R32_FLOAT = 0x29, - DXGI_FORMAT_R32_UINT = 0x2a, - DXGI_FORMAT_R32_SINT = 0x2b, - DXGI_FORMAT_R24G8_TYPELESS = 0x2c, - DXGI_FORMAT_D24_UNORM_S8_UINT = 0x2d, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 0x2e, - DXGI_FORMAT_X24_TYPELESS_G8_UINT = 0x2f, - DXGI_FORMAT_R8G8_TYPELESS = 0x30, - DXGI_FORMAT_R8G8_UNORM = 0x31, - DXGI_FORMAT_R8G8_UINT = 0x32, - DXGI_FORMAT_R8G8_SNORM = 0x33, - DXGI_FORMAT_R8G8_SINT = 0x34, - DXGI_FORMAT_R16_TYPELESS = 0x35, - DXGI_FORMAT_R16_FLOAT = 0x36, - DXGI_FORMAT_D16_UNORM = 0x37, - DXGI_FORMAT_R16_UNORM = 0x38, - DXGI_FORMAT_R16_UINT = 0x39, - DXGI_FORMAT_R16_SNORM = 0x3a, - DXGI_FORMAT_R16_SINT = 0x3b, - DXGI_FORMAT_R8_TYPELESS = 0x3c, - DXGI_FORMAT_R8_UNORM = 0x3d, - DXGI_FORMAT_R8_UINT = 0x3e, - DXGI_FORMAT_R8_SNORM = 0x3f, - DXGI_FORMAT_R8_SINT = 0x40, - DXGI_FORMAT_A8_UNORM = 0x41, - DXGI_FORMAT_R1_UNORM = 0x42, - DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 0x43, - DXGI_FORMAT_R8G8_B8G8_UNORM = 0x44, - DXGI_FORMAT_G8R8_G8B8_UNORM = 0x45, - DXGI_FORMAT_BC1_TYPELESS = 0x46, - DXGI_FORMAT_BC1_UNORM = 0x47, - DXGI_FORMAT_BC1_UNORM_SRGB = 0x48, - DXGI_FORMAT_BC2_TYPELESS = 0x49, - DXGI_FORMAT_BC2_UNORM = 0x4a, - DXGI_FORMAT_BC2_UNORM_SRGB = 0x4b, - DXGI_FORMAT_BC3_TYPELESS = 0x4c, - DXGI_FORMAT_BC3_UNORM = 0x4d, - DXGI_FORMAT_BC3_UNORM_SRGB = 0x4e, - DXGI_FORMAT_BC4_TYPELESS = 0x4f, - DXGI_FORMAT_BC4_UNORM = 0x50, - DXGI_FORMAT_BC4_SNORM = 0x51, - DXGI_FORMAT_BC5_TYPELESS = 0x52, - DXGI_FORMAT_BC5_UNORM = 0x53, - DXGI_FORMAT_BC5_SNORM = 0x54, - DXGI_FORMAT_B5G6R5_UNORM = 0x55, - DXGI_FORMAT_B5G5R5A1_UNORM = 0x56, - DXGI_FORMAT_B8G8R8A8_UNORM = 0x57, - DXGI_FORMAT_B8G8R8X8_UNORM = 0x58, - DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 0x59, - DXGI_FORMAT_B8G8R8A8_TYPELESS = 0x5a, - DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 0x5b, - DXGI_FORMAT_B8G8R8X8_TYPELESS = 0x5c, - DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 0x5d, - DXGI_FORMAT_BC6H_TYPELESS = 0x5e, - DXGI_FORMAT_BC6H_UF16 = 0x5f, - DXGI_FORMAT_BC6H_SF16 = 0x60, - DXGI_FORMAT_BC7_TYPELESS = 0x61, - DXGI_FORMAT_BC7_UNORM = 0x62, - DXGI_FORMAT_BC7_UNORM_SRGB = 0x63, - DXGI_FORMAT_AYUV = 0x64, - DXGI_FORMAT_Y410 = 0x65, - DXGI_FORMAT_Y416 = 0x66, - DXGI_FORMAT_NV12 = 0x67, - DXGI_FORMAT_P010 = 0x68, - DXGI_FORMAT_P016 = 0x69, - DXGI_FORMAT_420_OPAQUE = 0x6a, - DXGI_FORMAT_YUY2 = 0x6b, - DXGI_FORMAT_Y210 = 0x6c, - DXGI_FORMAT_Y216 = 0x6d, - DXGI_FORMAT_NV11 = 0x6e, - DXGI_FORMAT_AI44 = 0x6f, - DXGI_FORMAT_IA44 = 0x70, - DXGI_FORMAT_P8 = 0x71, - DXGI_FORMAT_A8P8 = 0x72, - DXGI_FORMAT_B4G4R4A4_UNORM = 0x73, + const unsigned int DXGI_FORMAT_DEFINED = 1; + + // This is a redefinition to make this enum available on platforms without DirectX headers + enum DXGI_FORMAT + { + DXGI_FORMAT_UNKNOWN = 0x00, + DXGI_FORMAT_R32G32B32A32_TYPELESS = 0x01, + DXGI_FORMAT_R32G32B32A32_FLOAT = 0x02, + DXGI_FORMAT_R32G32B32A32_UINT = 0x03, + DXGI_FORMAT_R32G32B32A32_SINT = 0x04, + DXGI_FORMAT_R32G32B32_TYPELESS = 0x05, + DXGI_FORMAT_R32G32B32_FLOAT = 0x06, + DXGI_FORMAT_R32G32B32_UINT = 0x07, + DXGI_FORMAT_R32G32B32_SINT = 0x08, + DXGI_FORMAT_R16G16B16A16_TYPELESS = 0x09, + DXGI_FORMAT_R16G16B16A16_FLOAT = 0x0a, + DXGI_FORMAT_R16G16B16A16_UNORM = 0x0b, + DXGI_FORMAT_R16G16B16A16_UINT = 0x0c, + DXGI_FORMAT_R16G16B16A16_SNORM = 0x0d, + DXGI_FORMAT_R16G16B16A16_SINT = 0x0e, + DXGI_FORMAT_R32G32_TYPELESS = 0x0f, + DXGI_FORMAT_R32G32_FLOAT = 0x10, + DXGI_FORMAT_R32G32_UINT = 0x11, + DXGI_FORMAT_R32G32_SINT = 0x12, + DXGI_FORMAT_R32G8X24_TYPELESS = 0x13, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 0x14, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 0x15, + DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 0x16, + DXGI_FORMAT_R10G10B10A2_TYPELESS = 0x17, + DXGI_FORMAT_R10G10B10A2_UNORM = 0x18, + DXGI_FORMAT_R10G10B10A2_UINT = 0x19, + DXGI_FORMAT_R11G11B10_FLOAT = 0x1a, + DXGI_FORMAT_R8G8B8A8_TYPELESS = 0x1b, + DXGI_FORMAT_R8G8B8A8_UNORM = 0x1c, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 0x1d, + DXGI_FORMAT_R8G8B8A8_UINT = 0x1e, + DXGI_FORMAT_R8G8B8A8_SNORM = 0x1f, + DXGI_FORMAT_R8G8B8A8_SINT = 0x20, + DXGI_FORMAT_R16G16_TYPELESS = 0x21, + DXGI_FORMAT_R16G16_FLOAT = 0x22, + DXGI_FORMAT_R16G16_UNORM = 0x23, + DXGI_FORMAT_R16G16_UINT = 0x24, + DXGI_FORMAT_R16G16_SNORM = 0x25, + DXGI_FORMAT_R16G16_SINT = 0x26, + DXGI_FORMAT_R32_TYPELESS = 0x27, + DXGI_FORMAT_D32_FLOAT = 0x28, + DXGI_FORMAT_R32_FLOAT = 0x29, + DXGI_FORMAT_R32_UINT = 0x2a, + DXGI_FORMAT_R32_SINT = 0x2b, + DXGI_FORMAT_R24G8_TYPELESS = 0x2c, + DXGI_FORMAT_D24_UNORM_S8_UINT = 0x2d, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 0x2e, + DXGI_FORMAT_X24_TYPELESS_G8_UINT = 0x2f, + DXGI_FORMAT_R8G8_TYPELESS = 0x30, + DXGI_FORMAT_R8G8_UNORM = 0x31, + DXGI_FORMAT_R8G8_UINT = 0x32, + DXGI_FORMAT_R8G8_SNORM = 0x33, + DXGI_FORMAT_R8G8_SINT = 0x34, + DXGI_FORMAT_R16_TYPELESS = 0x35, + DXGI_FORMAT_R16_FLOAT = 0x36, + DXGI_FORMAT_D16_UNORM = 0x37, + DXGI_FORMAT_R16_UNORM = 0x38, + DXGI_FORMAT_R16_UINT = 0x39, + DXGI_FORMAT_R16_SNORM = 0x3a, + DXGI_FORMAT_R16_SINT = 0x3b, + DXGI_FORMAT_R8_TYPELESS = 0x3c, + DXGI_FORMAT_R8_UNORM = 0x3d, + DXGI_FORMAT_R8_UINT = 0x3e, + DXGI_FORMAT_R8_SNORM = 0x3f, + DXGI_FORMAT_R8_SINT = 0x40, + DXGI_FORMAT_A8_UNORM = 0x41, + DXGI_FORMAT_R1_UNORM = 0x42, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 0x43, + DXGI_FORMAT_R8G8_B8G8_UNORM = 0x44, + DXGI_FORMAT_G8R8_G8B8_UNORM = 0x45, + DXGI_FORMAT_BC1_TYPELESS = 0x46, + DXGI_FORMAT_BC1_UNORM = 0x47, + DXGI_FORMAT_BC1_UNORM_SRGB = 0x48, + DXGI_FORMAT_BC2_TYPELESS = 0x49, + DXGI_FORMAT_BC2_UNORM = 0x4a, + DXGI_FORMAT_BC2_UNORM_SRGB = 0x4b, + DXGI_FORMAT_BC3_TYPELESS = 0x4c, + DXGI_FORMAT_BC3_UNORM = 0x4d, + DXGI_FORMAT_BC3_UNORM_SRGB = 0x4e, + DXGI_FORMAT_BC4_TYPELESS = 0x4f, + DXGI_FORMAT_BC4_UNORM = 0x50, + DXGI_FORMAT_BC4_SNORM = 0x51, + DXGI_FORMAT_BC5_TYPELESS = 0x52, + DXGI_FORMAT_BC5_UNORM = 0x53, + DXGI_FORMAT_BC5_SNORM = 0x54, + DXGI_FORMAT_B5G6R5_UNORM = 0x55, + DXGI_FORMAT_B5G5R5A1_UNORM = 0x56, + DXGI_FORMAT_B8G8R8A8_UNORM = 0x57, + DXGI_FORMAT_B8G8R8X8_UNORM = 0x58, + DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 0x59, + DXGI_FORMAT_B8G8R8A8_TYPELESS = 0x5a, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 0x5b, + DXGI_FORMAT_B8G8R8X8_TYPELESS = 0x5c, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 0x5d, + DXGI_FORMAT_BC6H_TYPELESS = 0x5e, + DXGI_FORMAT_BC6H_UF16 = 0x5f, + DXGI_FORMAT_BC6H_SF16 = 0x60, + DXGI_FORMAT_BC7_TYPELESS = 0x61, + DXGI_FORMAT_BC7_UNORM = 0x62, + DXGI_FORMAT_BC7_UNORM_SRGB = 0x63, + DXGI_FORMAT_AYUV = 0x64, + DXGI_FORMAT_Y410 = 0x65, + DXGI_FORMAT_Y416 = 0x66, + DXGI_FORMAT_NV12 = 0x67, + DXGI_FORMAT_P010 = 0x68, + DXGI_FORMAT_P016 = 0x69, + DXGI_FORMAT_420_OPAQUE = 0x6a, + DXGI_FORMAT_YUY2 = 0x6b, + DXGI_FORMAT_Y210 = 0x6c, + DXGI_FORMAT_Y216 = 0x6d, + DXGI_FORMAT_NV11 = 0x6e, + DXGI_FORMAT_AI44 = 0x6f, + DXGI_FORMAT_IA44 = 0x70, + DXGI_FORMAT_P8 = 0x71, + DXGI_FORMAT_A8P8 = 0x72, + DXGI_FORMAT_B4G4R4A4_UNORM = 0x73, - DXGI_FORMAT_P208 = 0x82, - DXGI_FORMAT_V208 = 0x83, - DXGI_FORMAT_V408 = 0x84, + DXGI_FORMAT_P208 = 0x82, + DXGI_FORMAT_V208 = 0x83, + DXGI_FORMAT_V408 = 0x84, - DXGI_FORMAT_FORCE_UINT = 0xffffffff, -}; + DXGI_FORMAT_FORCE_UINT = 0xffffffff, + }; +} // namespace oat diff --git a/src/Common/Image/ImageFormat.cpp b/src/Common/Image/ImageFormat.cpp index ed043cbea..7581d972c 100644 --- a/src/Common/Image/ImageFormat.cpp +++ b/src/Common/Image/ImageFormat.cpp @@ -1,6 +1,6 @@ #include "ImageFormat.h" -ImageFormat::ImageFormat(const ImageFormatId id, const D3DFORMAT d3dFormat, const DXGI_FORMAT dxgiFormat) +ImageFormat::ImageFormat(const ImageFormatId id, const oat::D3DFORMAT d3dFormat, const oat::DXGI_FORMAT dxgiFormat) : m_id(id), m_d3d_format(d3dFormat), m_dxgi_format(dxgiFormat) @@ -12,19 +12,19 @@ ImageFormatId ImageFormat::GetId() const return m_id; } -D3DFORMAT ImageFormat::GetD3DFormat() const +oat::D3DFORMAT ImageFormat::GetD3DFormat() const { return m_d3d_format; } -DXGI_FORMAT ImageFormat::GetDxgiFormat() const +oat::DXGI_FORMAT ImageFormat::GetDxgiFormat() const { return m_dxgi_format; } ImageFormatUnsigned::ImageFormatUnsigned(const ImageFormatId id, - const D3DFORMAT d3dFormat, - const DXGI_FORMAT dxgiFormat, + const oat::D3DFORMAT d3dFormat, + const oat::DXGI_FORMAT dxgiFormat, const unsigned bitsPerPixel, const unsigned rOffset, const unsigned rSize, @@ -78,7 +78,7 @@ size_t ImageFormatUnsigned::GetSizeOfMipLevel(const unsigned mipLevel, const uns } ImageFormatBlockCompressed::ImageFormatBlockCompressed( - const ImageFormatId id, const D3DFORMAT d3dFormat, const DXGI_FORMAT dxgiFormat, const unsigned blockSize, const unsigned bitsPerBlock) + const ImageFormatId id, const oat::D3DFORMAT d3dFormat, const oat::DXGI_FORMAT dxgiFormat, const unsigned blockSize, const unsigned bitsPerBlock) : ImageFormat(id, d3dFormat, dxgiFormat), m_block_size(blockSize), m_bits_per_block(bitsPerBlock) @@ -140,22 +140,23 @@ bool ImageFormatUnsigned::HasA() const return m_a_size > 0; } -const ImageFormatUnsigned ImageFormat::FORMAT_R8_G8_B8(ImageFormatId::R8_G8_B8, D3DFMT_R8G8B8, DXGI_FORMAT_UNKNOWN, 24, 0, 8, 8, 8, 16, 8, 0, 0); -const ImageFormatUnsigned ImageFormat::FORMAT_B8_G8_R8_X8(ImageFormatId::B8_G8_R8_X8, D3DFMT_X8R8G8B8, DXGI_FORMAT_B8G8R8X8_UNORM, 32, 16, 8, 8, 8, 0, 8, 0, 0); +const ImageFormatUnsigned ImageFormat::FORMAT_R8_G8_B8(ImageFormatId::R8_G8_B8, oat::D3DFMT_R8G8B8, oat::DXGI_FORMAT_UNKNOWN, 24, 0, 8, 8, 8, 16, 8, 0, 0); const ImageFormatUnsigned - ImageFormat::FORMAT_R8_G8_B8_A8(ImageFormatId::R8_G8_B8_A8, D3DFMT_A8B8G8R8, DXGI_FORMAT_R8G8B8A8_UNORM, 32, 0, 8, 8, 8, 16, 8, 24, 8); + ImageFormat::FORMAT_B8_G8_R8_X8(ImageFormatId::B8_G8_R8_X8, oat::D3DFMT_X8R8G8B8, oat::DXGI_FORMAT_B8G8R8X8_UNORM, 32, 16, 8, 8, 8, 0, 8, 0, 0); const ImageFormatUnsigned - ImageFormat::FORMAT_B8_G8_R8_A8(ImageFormatId::B8_G8_R8_A8, D3DFMT_A8R8G8B8, DXGI_FORMAT_B8G8R8A8_UNORM, 32, 16, 8, 8, 8, 0, 8, 24, 8); -const ImageFormatUnsigned ImageFormat::FORMAT_A8(ImageFormatId::A8, D3DFMT_A8, DXGI_FORMAT_A8_UNORM, 8, 0, 0, 0, 0, 0, 0, 0, 8); + ImageFormat::FORMAT_R8_G8_B8_A8(ImageFormatId::R8_G8_B8_A8, oat::D3DFMT_A8B8G8R8, oat::DXGI_FORMAT_R8G8B8A8_UNORM, 32, 0, 8, 8, 8, 16, 8, 24, 8); +const ImageFormatUnsigned + ImageFormat::FORMAT_B8_G8_R8_A8(ImageFormatId::B8_G8_R8_A8, oat::D3DFMT_A8R8G8B8, oat::DXGI_FORMAT_B8G8R8A8_UNORM, 32, 16, 8, 8, 8, 0, 8, 24, 8); +const ImageFormatUnsigned ImageFormat::FORMAT_A8(ImageFormatId::A8, oat::D3DFMT_A8, oat::DXGI_FORMAT_A8_UNORM, 8, 0, 0, 0, 0, 0, 0, 0, 8); const ImageFormatUnsigned ImageFormat::FORMAT_R16_G16_B16_A16_FLOAT( - ImageFormatId::R16_G16_B16_A16_FLOAT, D3DFMT_A16B16G16R16F, DXGI_FORMAT_R16G16B16A16_FLOAT, 128, 0, 0, 0, 0, 0, 0, 0, 8); -const ImageFormatUnsigned ImageFormat::FORMAT_R8(ImageFormatId::R8, D3DFMT_L8, DXGI_FORMAT_R8_UNORM, 8, 0, 8, 0, 0, 0, 0, 0, 0); -const ImageFormatUnsigned ImageFormat::FORMAT_R8_A8(ImageFormatId::R8_A8, D3DFMT_A8L8, DXGI_FORMAT_UNKNOWN, 16, 0, 8, 0, 0, 0, 0, 8, 8); -const ImageFormatBlockCompressed ImageFormat::FORMAT_BC1(ImageFormatId::BC1, D3DFMT_DXT1, DXGI_FORMAT_BC1_UNORM, 4, 64); -const ImageFormatBlockCompressed ImageFormat::FORMAT_BC2(ImageFormatId::BC2, D3DFMT_DXT3, DXGI_FORMAT_BC2_UNORM, 4, 128); -const ImageFormatBlockCompressed ImageFormat::FORMAT_BC3(ImageFormatId::BC3, D3DFMT_DXT5, DXGI_FORMAT_BC3_UNORM, 4, 128); -const ImageFormatBlockCompressed ImageFormat::FORMAT_BC4(ImageFormatId::BC4, D3DFMT_UNKNOWN, DXGI_FORMAT_BC4_UNORM, 4, 64); -const ImageFormatBlockCompressed ImageFormat::FORMAT_BC5(ImageFormatId::BC5, D3DFMT_UNKNOWN, DXGI_FORMAT_BC5_UNORM, 4, 128); + ImageFormatId::R16_G16_B16_A16_FLOAT, oat::D3DFMT_A16B16G16R16F, oat::DXGI_FORMAT_R16G16B16A16_FLOAT, 128, 0, 0, 0, 0, 0, 0, 0, 8); +const ImageFormatUnsigned ImageFormat::FORMAT_R8(ImageFormatId::R8, oat::D3DFMT_L8, oat::DXGI_FORMAT_R8_UNORM, 8, 0, 8, 0, 0, 0, 0, 0, 0); +const ImageFormatUnsigned ImageFormat::FORMAT_R8_A8(ImageFormatId::R8_A8, oat::D3DFMT_A8L8, oat::DXGI_FORMAT_UNKNOWN, 16, 0, 8, 0, 0, 0, 0, 8, 8); +const ImageFormatBlockCompressed ImageFormat::FORMAT_BC1(ImageFormatId::BC1, oat::D3DFMT_DXT1, oat::DXGI_FORMAT_BC1_UNORM, 4, 64); +const ImageFormatBlockCompressed ImageFormat::FORMAT_BC2(ImageFormatId::BC2, oat::D3DFMT_DXT3, oat::DXGI_FORMAT_BC2_UNORM, 4, 128); +const ImageFormatBlockCompressed ImageFormat::FORMAT_BC3(ImageFormatId::BC3, oat::D3DFMT_DXT5, oat::DXGI_FORMAT_BC3_UNORM, 4, 128); +const ImageFormatBlockCompressed ImageFormat::FORMAT_BC4(ImageFormatId::BC4, oat::D3DFMT_UNKNOWN, oat::DXGI_FORMAT_BC4_UNORM, 4, 64); +const ImageFormatBlockCompressed ImageFormat::FORMAT_BC5(ImageFormatId::BC5, oat::D3DFMT_UNKNOWN, oat::DXGI_FORMAT_BC5_UNORM, 4, 128); const ImageFormat* const ImageFormat::ALL_FORMATS[static_cast(ImageFormatId::MAX)]{ &FORMAT_R8_G8_B8, diff --git a/src/Common/Image/ImageFormat.h b/src/Common/Image/ImageFormat.h index 66b0435a4..bcd825c72 100644 --- a/src/Common/Image/ImageFormat.h +++ b/src/Common/Image/ImageFormat.h @@ -39,18 +39,18 @@ class ImageFormatBlockCompressed; class ImageFormat { ImageFormatId m_id; - D3DFORMAT m_d3d_format; - DXGI_FORMAT m_dxgi_format; + oat::D3DFORMAT m_d3d_format; + oat::DXGI_FORMAT m_dxgi_format; protected: - ImageFormat(ImageFormatId id, D3DFORMAT d3dFormat, DXGI_FORMAT dxgiFormat); + ImageFormat(ImageFormatId id, oat::D3DFORMAT d3dFormat, oat::DXGI_FORMAT dxgiFormat); public: virtual ~ImageFormat() = default; ImageFormatId GetId() const; - D3DFORMAT GetD3DFormat() const; - DXGI_FORMAT GetDxgiFormat() const; + oat::D3DFORMAT GetD3DFormat() const; + oat::DXGI_FORMAT GetDxgiFormat() const; virtual ImageFormatType GetType() const = 0; virtual size_t GetPitch(unsigned mipLevel, unsigned width) const = 0; @@ -86,8 +86,8 @@ class ImageFormatUnsigned final : public ImageFormat unsigned m_a_size; ImageFormatUnsigned(ImageFormatId id, - D3DFORMAT d3dFormat, - DXGI_FORMAT dxgiFormat, + oat::D3DFORMAT d3dFormat, + oat::DXGI_FORMAT dxgiFormat, unsigned bitsPerPixel, unsigned rOffset, unsigned rSize, @@ -114,7 +114,7 @@ class ImageFormatBlockCompressed final : public ImageFormat unsigned m_block_size; unsigned m_bits_per_block; - ImageFormatBlockCompressed(ImageFormatId id, D3DFORMAT d3dFormat, DXGI_FORMAT dxgiFormat, unsigned blockSize, unsigned bitsPerBlock); + ImageFormatBlockCompressed(ImageFormatId id, oat::D3DFORMAT d3dFormat, oat::DXGI_FORMAT dxgiFormat, unsigned blockSize, unsigned bitsPerBlock); ImageFormatType GetType() const override; size_t GetPitch(unsigned mipLevel, unsigned width) const override; diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp index 4cafb0faa..ba76c2786 100644 --- a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -88,7 +88,7 @@ void ObjLoader::LoadImageFromLoadDef(GfxImage* image, Zone* zone) else textureLoader.Type(TextureType::T_2D); - textureLoader.Format(static_cast(loadDef->format)); + textureLoader.Format(static_cast(loadDef->format)); textureLoader.HasMipMaps(!(loadDef->flags & iwi6::IMG_FLAG_NOMIPMAPS)); Texture* loadedTexture = textureLoader.LoadTexture(image->texture.loadDef->data); diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index 95ff6fff9..f35df1311 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -130,7 +130,7 @@ void ObjLoader::LoadImageFromLoadDef(GfxImage* image, Zone* zone) else textureLoader.Type(TextureType::T_2D); - textureLoader.Format(static_cast(loadDef->format)); + textureLoader.Format(static_cast(loadDef->format)); textureLoader.HasMipMaps(!(loadDef->flags & iwi8::IMG_FLAG_NOMIPMAPS)); Texture* loadedTexture = textureLoader.LoadTexture(image->texture.loadDef->data); diff --git a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp index c81ebeab1..39cff848d 100644 --- a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp +++ b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp @@ -106,7 +106,7 @@ void ObjLoader::LoadImageFromLoadDef(GfxImage* image, Zone* zone) else textureLoader.Type(TextureType::T_2D); - textureLoader.Format(static_cast(loadDef->format)); + textureLoader.Format(static_cast(loadDef->format)); textureLoader.HasMipMaps(!(loadDef->flags & iwi8::IMG_FLAG_NOMIPMAPS)); Texture* loadedTexture = textureLoader.LoadTexture(image->texture.loadDef->data); diff --git a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp index 01a42adbc..ee43e1a55 100644 --- a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp +++ b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp @@ -95,7 +95,7 @@ void ObjLoader::LoadImageFromLoadDef(GfxImage* image, Zone* zone) else textureLoader.Type(TextureType::T_2D); - textureLoader.Format(static_cast(loadDef->format)); + textureLoader.Format(static_cast(loadDef->format)); textureLoader.HasMipMaps(!(loadDef->flags & iwi13::IMG_FLAG_NOMIPMAPS)); Texture* loadedTexture = textureLoader.LoadTexture(image->texture.loadDef->data); diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 6fca08a8f..431a3ca42 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -351,7 +351,7 @@ namespace T6 else textureLoader.Type(TextureType::T_2D); - textureLoader.Format(static_cast(loadDef->format)); + textureLoader.Format(static_cast(loadDef->format)); textureLoader.HasMipMaps(!(loadDef->flags & iwi27::IMG_FLAG_NOMIPMAPS)); Texture* loadedTexture = textureLoader.LoadTexture(image->texture.loadDef->data); diff --git a/src/ObjLoading/Image/Dx12TextureLoader.cpp b/src/ObjLoading/Image/Dx12TextureLoader.cpp index 76b8cd5f9..880b1c15e 100644 --- a/src/ObjLoading/Image/Dx12TextureLoader.cpp +++ b/src/ObjLoading/Image/Dx12TextureLoader.cpp @@ -4,7 +4,7 @@ Dx12TextureLoader::Dx12TextureLoader(MemoryManager* memoryManager) : m_memory_manager(memoryManager), - m_format(DXGI_FORMAT_UNKNOWN), + m_format(oat::DXGI_FORMAT_UNKNOWN), m_type(TextureType::T_2D), m_has_mip_maps(false), m_width(1u), @@ -24,7 +24,7 @@ const ImageFormat* Dx12TextureLoader::GetFormatForDx12Format() const return nullptr; } -Dx12TextureLoader& Dx12TextureLoader::Format(const DXGI_FORMAT format) +Dx12TextureLoader& Dx12TextureLoader::Format(const oat::DXGI_FORMAT format) { m_format = format; return *this; diff --git a/src/ObjLoading/Image/Dx12TextureLoader.h b/src/ObjLoading/Image/Dx12TextureLoader.h index 5e9c3130b..f86b2ffa7 100644 --- a/src/ObjLoading/Image/Dx12TextureLoader.h +++ b/src/ObjLoading/Image/Dx12TextureLoader.h @@ -12,7 +12,7 @@ class Dx12TextureLoader static std::unordered_map m_conversion_table; MemoryManager* m_memory_manager; - DXGI_FORMAT m_format; + oat::DXGI_FORMAT m_format; TextureType m_type; bool m_has_mip_maps; size_t m_width; @@ -24,7 +24,7 @@ class Dx12TextureLoader public: explicit Dx12TextureLoader(MemoryManager* memoryManager); - Dx12TextureLoader& Format(DXGI_FORMAT format); + Dx12TextureLoader& Format(oat::DXGI_FORMAT format); Dx12TextureLoader& Type(TextureType textureType); Dx12TextureLoader& HasMipMaps(bool hasMipMaps); Dx12TextureLoader& Width(size_t width); diff --git a/src/ObjLoading/Image/Dx9TextureLoader.cpp b/src/ObjLoading/Image/Dx9TextureLoader.cpp index bd4171dfe..1fe4f60d1 100644 --- a/src/ObjLoading/Image/Dx9TextureLoader.cpp +++ b/src/ObjLoading/Image/Dx9TextureLoader.cpp @@ -4,7 +4,7 @@ Dx9TextureLoader::Dx9TextureLoader(MemoryManager* memoryManager) : m_memory_manager(memoryManager), - m_format(D3DFMT_UNKNOWN), + m_format(oat::D3DFMT_UNKNOWN), m_type(TextureType::T_2D), m_has_mip_maps(false), m_width(1u), @@ -24,7 +24,7 @@ const ImageFormat* Dx9TextureLoader::GetFormatForDx9Format() const return nullptr; } -Dx9TextureLoader& Dx9TextureLoader::Format(const D3DFORMAT format) +Dx9TextureLoader& Dx9TextureLoader::Format(const oat::D3DFORMAT format) { m_format = format; return *this; diff --git a/src/ObjLoading/Image/Dx9TextureLoader.h b/src/ObjLoading/Image/Dx9TextureLoader.h index 0ad0dbae2..441317939 100644 --- a/src/ObjLoading/Image/Dx9TextureLoader.h +++ b/src/ObjLoading/Image/Dx9TextureLoader.h @@ -10,7 +10,7 @@ class Dx9TextureLoader { MemoryManager* m_memory_manager; - D3DFORMAT m_format; + oat::D3DFORMAT m_format; TextureType m_type; bool m_has_mip_maps; size_t m_width; @@ -22,7 +22,7 @@ class Dx9TextureLoader public: explicit Dx9TextureLoader(MemoryManager* memoryManager); - Dx9TextureLoader& Format(D3DFORMAT format); + Dx9TextureLoader& Format(oat::D3DFORMAT format); Dx9TextureLoader& Type(TextureType textureType); Dx9TextureLoader& HasMipMaps(bool hasMipMaps); Dx9TextureLoader& Width(size_t width); diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp index d3f301431..63da316ba 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp @@ -9,7 +9,16 @@ using namespace IW4; -size_t MenuDumper::FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition) +// Uncomment this macro to skip interpretative expression dumping +// #define DUMP_NAIVE + +#ifdef DUMP_NAIVE +#define DUMP_FUNC WriteStatementNaive +#else +#define DUMP_FUNC WriteStatementSkipInitialUnnecessaryParenthesis +#endif + +size_t MenuDumper::FindStatementClosingParenthesis(const Statement_s* statement, const size_t openingParenthesisPosition) { assert(statement->numEntries >= 0); assert(openingParenthesisPosition < static_cast(statement->numEntries)); @@ -158,7 +167,7 @@ void MenuDumper::WriteStatementOperandFunction(const Statement_s* statement, con } if (functionIndex >= 0) - m_stream << "FUNC_" << functionIndex << "()"; + m_stream << "FUNC_" << functionIndex; else m_stream << "INVALID_FUNC"; m_stream << "()"; @@ -206,7 +215,7 @@ void MenuDumper::WriteStatementOperand(const Statement_s* statement, size_t& cur spaceNext = true; } -void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, size_t startOffset, size_t endOffset) const +void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, const size_t startOffset, const size_t endOffset) const { assert(startOffset <= endOffset); assert(endOffset <= static_cast(statement->numEntries)); @@ -260,6 +269,91 @@ void MenuDumper::WriteStatementSkipInitialUnnecessaryParenthesis(const Statement } } +void MenuDumper::WriteStatementNaive(const Statement_s* statement) const +{ + const auto entryCount = static_cast(statement->numEntries); + + const auto missingClosingParenthesis = statement->numEntries > 0 && statement->entries[0].type == EET_OPERATOR + && statement->entries[0].data.op == OP_LEFTPAREN + && FindStatementClosingParenthesis(statement, 0) >= static_cast(statement->numEntries); + + for (auto i = 0u; i < entryCount; i++) + { + const auto& entry = statement->entries[i]; + if (entry.type == EET_OPERAND) + { + size_t pos = i; + bool discard = false; + WriteStatementOperand(statement, pos, discard); + } + else if (entry.data.op >= EXP_FUNC_STATIC_DVAR_INT && entry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) + { + switch (entry.data.op) + { + case EXP_FUNC_STATIC_DVAR_INT: + m_stream << "dvarint"; + break; + + case EXP_FUNC_STATIC_DVAR_BOOL: + m_stream << "dvarbool"; + break; + + case EXP_FUNC_STATIC_DVAR_FLOAT: + m_stream << "dvarfloat"; + break; + + case EXP_FUNC_STATIC_DVAR_STRING: + m_stream << "dvarstring"; + break; + + default: + break; + } + + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, i); + m_stream << "("; + + if (closingParenPos - i + 1 >= 1) + { + const auto& staticDvarEntry = statement->entries[i + 1]; + if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + { + if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 + && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) + { + const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; + if (staticDvar && staticDvar->dvarName) + m_stream << staticDvar->dvarName; + } + else + { + m_stream << "#INVALID_DVAR_INDEX"; + } + } + else + { + m_stream << "#INVALID_DVAR_OPERAND"; + } + } + + m_stream << ")"; + i = closingParenPos; + } + else + { + assert(entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v); + if (entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v) + m_stream << g_expFunctionNames[entry.data.op]; + if (entry.data.op >= OP_COUNT) + m_stream << "("; + } + } + + if (missingClosingParenthesis) + m_stream << ")"; +} + void MenuDumper::WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const { if (statementValue == nullptr || statementValue->numEntries < 0) @@ -271,12 +365,12 @@ void MenuDumper::WriteStatementProperty(const std::string& propertyKey, const St if (isBooleanStatement) { m_stream << "when("; - WriteStatementSkipInitialUnnecessaryParenthesis(statementValue); + DUMP_FUNC(statementValue); m_stream << ");\n"; } else { - WriteStatementSkipInitialUnnecessaryParenthesis(statementValue); + DUMP_FUNC(statementValue); m_stream << ";\n"; } } @@ -728,7 +822,6 @@ void MenuDumper::WriteItemData(const itemDef_s* item) WriteItemKeyHandlerProperty(item->onKey); WriteStatementProperty("exp text", item->textExp, false); WriteStatementProperty("exp material", item->materialExp, false); - WriteStatementProperty("exp disabled", item->disabledExp, false); WriteFloatExpressionsProperty(item->floatExpressions, item->floatExpressionCount); WriteIntProperty("gamemsgwindowindex", item->gameMsgWindowIndex, 0); WriteIntProperty("gamemsgwindowmode", item->gameMsgWindowMode, 0); diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h index 89a843490..9baff905c 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h @@ -11,6 +11,8 @@ namespace IW4 { static size_t FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition); + void WriteStatementNaive(const Statement_s* statement) const; + void WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; void WriteStatementOperandFunction(const Statement_s* statement, size_t currentPos) const; void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp index 2c0c93d45..3b36a0043 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp @@ -9,6 +9,15 @@ using namespace IW5; +// Uncomment this macro to skip interpretative expression dumping +// #define DUMP_NAIVE + +#ifdef DUMP_NAIVE +#define DUMP_FUNC WriteStatementNaive +#else +#define DUMP_FUNC WriteStatementSkipInitialUnnecessaryParenthesis +#endif + size_t MenuDumper::FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition) { assert(statement->numEntries >= 0); @@ -158,9 +167,10 @@ void MenuDumper::WriteStatementOperandFunction(const Statement_s* statement, con } if (functionIndex >= 0) - m_stream << "FUNC_" << functionIndex << "()"; + m_stream << "FUNC_" << functionIndex; else m_stream << "INVALID_FUNC"; + m_stream << "()"; } else { @@ -227,6 +237,83 @@ void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, size_t s } } +void MenuDumper::WriteStatementNaive(const Statement_s* statement) const +{ + const auto entryCount = static_cast(statement->numEntries); + for (auto i = 0u; i < entryCount; i++) + { + const auto& entry = statement->entries[i]; + if (entry.type == EET_OPERAND) + { + size_t pos = i; + bool discard = false; + WriteStatementOperand(statement, pos, discard); + } + else if (entry.data.op >= EXP_FUNC_STATIC_DVAR_INT && entry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) + { + switch (entry.data.op) + { + case EXP_FUNC_STATIC_DVAR_INT: + m_stream << "dvarint"; + break; + + case EXP_FUNC_STATIC_DVAR_BOOL: + m_stream << "dvarbool"; + break; + + case EXP_FUNC_STATIC_DVAR_FLOAT: + m_stream << "dvarfloat"; + break; + + case EXP_FUNC_STATIC_DVAR_STRING: + m_stream << "dvarstring"; + break; + + default: + break; + } + + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, i); + m_stream << "("; + + if (closingParenPos - i + 1 >= 1) + { + const auto& staticDvarEntry = statement->entries[i + 1]; + if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + { + if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 + && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) + { + const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; + if (staticDvar && staticDvar->dvarName) + m_stream << staticDvar->dvarName; + } + else + { + m_stream << "#INVALID_DVAR_INDEX"; + } + } + else + { + m_stream << "#INVALID_DVAR_OPERAND"; + } + } + + m_stream << ")"; + i = closingParenPos; + } + else + { + assert(entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v); + if (entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v) + m_stream << g_expFunctionNames[entry.data.op]; + if (entry.data.op >= OP_COUNT) + m_stream << "("; + } + } +} + void MenuDumper::WriteStatement(const Statement_s* statement) const { if (statement == nullptr || statement->numEntries < 0) @@ -270,12 +357,12 @@ void MenuDumper::WriteStatementProperty(const std::string& propertyKey, const St if (isBooleanStatement) { m_stream << "when("; - WriteStatementSkipInitialUnnecessaryParenthesis(statementValue); + DUMP_FUNC(statementValue); m_stream << ");\n"; } else { - WriteStatementSkipInitialUnnecessaryParenthesis(statementValue); + DUMP_FUNC(statementValue); m_stream << ";\n"; } } @@ -730,7 +817,6 @@ void MenuDumper::WriteItemData(const itemDef_s* item) WriteStatementProperty("exp text", item->textExp, false); WriteStatementProperty("exp textaligny", item->textAlignYExp, false); WriteStatementProperty("exp material", item->materialExp, false); - WriteStatementProperty("exp disabled", item->disabledExp, false); WriteFloatExpressionsProperty(item->floatExpressions, item->floatExpressionCount); WriteIntProperty("gamemsgwindowindex", item->gameMsgWindowIndex, 0); WriteIntProperty("gamemsgwindowmode", item->gameMsgWindowMode, 0); diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h index 4879eb6df..9e3e3000a 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h @@ -11,6 +11,8 @@ namespace IW5 { static size_t FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition); + void WriteStatementNaive(const Statement_s* statement) const; + void WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; void WriteStatementOperandFunction(const Statement_s* statement, size_t currentPos) const; void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; diff --git a/src/ObjWriting/Image/DdsWriter.cpp b/src/ObjWriting/Image/DdsWriter.cpp index 9183e1eb5..308499c7e 100644 --- a/src/ObjWriting/Image/DdsWriter.cpp +++ b/src/ObjWriting/Image/DdsWriter.cpp @@ -39,13 +39,13 @@ class DdsWriterInternal // Use standard pixel format for DXT1-5 for maximum compatibility and only otherwise use DX10 extension switch (format->GetDxgiFormat()) { - case DXGI_FORMAT_BC1_UNORM: + case oat::DXGI_FORMAT_BC1_UNORM: pf.dwFourCC = MakeFourCc('D', 'X', 'T', '1'); break; - case DXGI_FORMAT_BC2_UNORM: + case oat::DXGI_FORMAT_BC2_UNORM: pf.dwFourCC = MakeFourCc('D', 'X', 'T', '3'); break; - case DXGI_FORMAT_BC3_UNORM: + case oat::DXGI_FORMAT_BC3_UNORM: pf.dwFourCC = MakeFourCc('D', 'X', 'T', '5'); break; default: