From f094d582ece128eb66157d1058f6093bef743054 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Tue, 25 Apr 2017 18:53:18 -0500 Subject: [PATCH] swr/rast: add support for DX1_RGB{_SRGB} formats Reviewed-by: Bruce Cherniak --- .../drivers/swr/rasterizer/common/formats.cpp | 80 +++++++++++-------- .../drivers/swr/rasterizer/common/formats.h | 4 +- .../swr/rasterizer/core/format_traits.h | 46 ++++++++++- 3 files changed, 93 insertions(+), 37 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.cpp b/src/gallium/drivers/swr/rasterizer/common/formats.cpp index 72020ee1936..263dec649a4 100644 --- a/src/gallium/drivers/swr/rasterizer/common/formats.cpp +++ b/src/gallium/drivers/swr/rasterizer/common/formats.cpp @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * -* @file gen_formats.cpp +* @file formats.cpp * * @brief auto-generated file * @@ -2729,26 +2729,16 @@ const SWR_FORMAT_INFO gFormatInfo[] = { { 0.0f, 0.0f, 0.0f, 0.0f }, 1, 1 }, - // R10G10B10_FLOAT_A2_UNORM (0xD5) + // padding (0xD5) { - "R10G10B10_FLOAT_A2_UNORM", - { SWR_TYPE_FLOAT, SWR_TYPE_FLOAT, SWR_TYPE_FLOAT, SWR_TYPE_FLOAT }, - { 0, 0, 0, 0x3f800000 }, // Defaults for missing components - { 0, 1, 2, 3 }, // Swizzle - { 10, 10, 10, 2 }, // Bits per component - 32, // Bits per element - 4, // Bytes per element - 4, // Num components - false, // isSRGB - false, // isBC - false, // isSubsampled - false, // isLuminance - { false, false, false, false }, // Is normalized? - { 1.0f, 1.0f, 1.0f, 1.0f }, // To float scale factor - 1, // bcWidth - 1, // bcHeight + nullptr, + { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN }, + { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, + 0, 0, 0, false, false, false, false, + { false, false, false, false }, + { 0.0f, 0.0f, 0.0f, 0.0f }, + 1, 1 }, - // R32_SINT (0xD6) { "R32_SINT", @@ -5179,16 +5169,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = { { 0.0f, 0.0f, 0.0f, 0.0f }, 1, 1 }, - // padding (0x180) + // DXT1_RGB_SRGB (0x180) { - nullptr, - { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN }, - { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, - 0, 0, 0, false, false, false, false, - { false, false, false, false }, - { 0.0f, 0.0f, 0.0f, 0.0f }, - 1, 1 + "DXT1_RGB_SRGB", + { SWR_TYPE_UNORM, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN }, + { 0, 0, 0, 0x3f800000 }, // Defaults for missing components + { 0, 1, 2, 3 }, // Swizzle + { 8, 8, 8, 8 }, // Bits per component + 64, // Bits per element + 8, // Bytes per element + 1, // Num components + false, // isSRGB + true, // isBC + false, // isSubsampled + false, // isLuminance + { true, false, false, false }, // Is normalized? + { 1.0f / 255.0f, 0, 0, 0 }, // To float scale factor + 4, // bcWidth + 4, // bcHeight }, + // padding (0x181) { nullptr, @@ -5449,16 +5449,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = { { 0.0f, 0.0f, 0.0f, 0.0f }, 1, 1 }, - // padding (0x191) + // DXT1_RGB (0x191) { - nullptr, - { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN }, - { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, - 0, 0, 0, false, false, false, false, - { false, false, false, false }, - { 0.0f, 0.0f, 0.0f, 0.0f }, - 1, 1 + "DXT1_RGB", + { SWR_TYPE_UNORM, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN }, + { 0, 0, 0, 0x3f800000 }, // Defaults for missing components + { 0, 1, 2, 3 }, // Swizzle + { 8, 8, 8, 8 }, // Bits per component + 64, // Bits per element + 8, // Bytes per element + 1, // Num components + false, // isSRGB + true, // isBC + false, // isSubsampled + false, // isLuminance + { true, false, false, false }, // Is normalized? + { 1.0f / 255.0f, 0, 0, 0 }, // To float scale factor + 4, // bcWidth + 4, // bcHeight }, + // padding (0x192) { nullptr, diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.h b/src/gallium/drivers/swr/rasterizer/common/formats.h index 0056a56f829..f13f338f8b1 100644 --- a/src/gallium/drivers/swr/rasterizer/common/formats.h +++ b/src/gallium/drivers/swr/rasterizer/common/formats.h @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * -* @file gen_formats.h +* @file formats.h * * @brief auto-generated file * @@ -181,6 +181,7 @@ enum SWR_FORMAT L8_SINT = 0x153, I8_UINT = 0x154, I8_SINT = 0x155, + DXT1_RGB_SRGB = 0x180, YCRCB_SWAPUVY = 0x183, BC1_UNORM = 0x186, BC2_UNORM = 0x187, @@ -191,6 +192,7 @@ enum SWR_FORMAT BC2_UNORM_SRGB = 0x18C, BC3_UNORM_SRGB = 0x18D, YCRCB_SWAPUV = 0x18F, + DXT1_RGB = 0x191, R8G8B8_UNORM = 0x193, R8G8B8_SNORM = 0x194, R8G8B8_SSCALED = 0x195, diff --git a/src/gallium/drivers/swr/rasterizer/core/format_traits.h b/src/gallium/drivers/swr/rasterizer/core/format_traits.h index 6c428043878..478fe3e4f2a 100644 --- a/src/gallium/drivers/swr/rasterizer/core/format_traits.h +++ b/src/gallium/drivers/swr/rasterizer/core/format_traits.h @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * -* @file gen_format_traits.h +* @file format_traits.h * * @brief Format Traits. auto-generated file * @@ -2861,6 +2861,28 @@ template<> struct FormatTraits : typedef Format1<8> FormatT; }; +////////////////////////////////////////////////////////////////////////// +/// FormatTraits - Format traits specialization for DXT1_RGB_SRGB +////////////////////////////////////////////////////////////////////////// +template<> struct FormatTraits : + ComponentTraits, + FormatSwizzle<0>, + Defaults<0, 0, 0, 0x3f800000> +{ + static const uint32_t bpp{ 64 }; + static const uint32_t numComps{ 1 }; + static const bool hasAlpha{ true }; + static const uint32_t alphaComp{ 3 }; + static const bool isSRGB{ false }; + static const bool isBC{ true }; + static const bool isSubsampled{ false }; + static const uint32_t bcWidth{ 4 }; + static const uint32_t bcHeight{ 4 }; + + typedef TransposeSingleComponent<8> TransposeT; + typedef Format1<8> FormatT; +}; + ////////////////////////////////////////////////////////////////////////// /// FormatTraits - Format traits specialization for YCRCB_SWAPUVY ////////////////////////////////////////////////////////////////////////// @@ -3081,6 +3103,28 @@ template<> struct FormatTraits : typedef Format4<8, 8, 8, 8> FormatT; }; +////////////////////////////////////////////////////////////////////////// +/// FormatTraits - Format traits specialization for DXT1_RGB +////////////////////////////////////////////////////////////////////////// +template<> struct FormatTraits : + ComponentTraits, + FormatSwizzle<0>, + Defaults<0, 0, 0, 0x3f800000> +{ + static const uint32_t bpp{ 64 }; + static const uint32_t numComps{ 1 }; + static const bool hasAlpha{ true }; + static const uint32_t alphaComp{ 3 }; + static const bool isSRGB{ false }; + static const bool isBC{ true }; + static const bool isSubsampled{ false }; + static const uint32_t bcWidth{ 4 }; + static const uint32_t bcHeight{ 4 }; + + typedef TransposeSingleComponent<8> TransposeT; + typedef Format1<8> FormatT; +}; + ////////////////////////////////////////////////////////////////////////// /// FormatTraits - Format traits specialization for R8G8B8_UNORM ////////////////////////////////////////////////////////////////////////// -- 2.30.2