Commit f97fb9df by Alexis Hetu Committed by Alexis Hétu

Enable B10G11R11_UFLOAT blending

B10G11R11_UFLOAT blending is required in order for SwANGLE to expose GL_EXT_color_buffer_float. In this cl: - I added a minor readability improvement by storing "*Pointer<Int>(data + OFFSET(DrawData, colorPitchB[index]))" in a variable, "pitchB" since it's used in every case. - Added a constant for B10G11R11 masking - Added clamping in the floating point blending code for unsigned floating point formats - Fixed the VK_FORMAT_B10G11R11_UFLOAT_PACK32 output format which now takes the coverage mask into account - Included a minor followup cleanup in ShaderCore Bug: b/146223877 Tests: dEQP-VK.*b10g11r11* Change-Id: Ifb95f34a10cdbee9d185bc25feba0aeaca0d9e70 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39929Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent c45e066f
...@@ -238,6 +238,7 @@ Constants::Constants() ...@@ -238,6 +238,7 @@ Constants::Constants()
for(int i = 0; i < 8; i++) for(int i = 0; i < 8; i++)
{ {
mask565Q[i] = word4((i & 0x1 ? 0x001F : 0) | (i & 0x2 ? 0x07E0 : 0) | (i & 0x4 ? 0xF800 : 0)); mask565Q[i] = word4((i & 0x1 ? 0x001F : 0) | (i & 0x2 ? 0x07E0 : 0) | (i & 0x4 ? 0xF800 : 0));
mask11X[i] = dword4((i & 0x1 ? 0x000007FFu : 0) | (i & 0x2 ? 0x003FF800u : 0) | (i & 0x4 ? 0xFFC00000u : 0));
} }
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
......
...@@ -70,6 +70,7 @@ struct Constants ...@@ -70,6 +70,7 @@ struct Constants
word4 mask565Q[8]; word4 mask565Q[8];
dword2 mask10Q[16]; // 4 bit writemask -> A2B10G10R10 bit patterns, replicated 2x dword2 mask10Q[16]; // 4 bit writemask -> A2B10G10R10 bit patterns, replicated 2x
word4 mask5551Q[16]; // 4 bit writemask -> A1R5G5B5 bit patterns, replicated 4x word4 mask5551Q[16]; // 4 bit writemask -> A1R5G5B5 bit patterns, replicated 4x
dword4 mask11X[8]; // 3 bit writemask -> B10G11R11 bit patterns, replicated 4x
unsigned short sRGBtoLinear8_16[256]; unsigned short sRGBtoLinear8_16[256];
......
...@@ -594,7 +594,7 @@ SIMD::UInt floatToHalfBits(SIMD::UInt floatBits, bool storeInUpperBits) ...@@ -594,7 +594,7 @@ SIMD::UInt floatToHalfBits(SIMD::UInt floatBits, bool storeInUpperBits)
return storeInUpperBits ? ((joined << 16) | justsign) : joined | (justsign >> 16); return storeInUpperBits ? ((joined << 16) | justsign) : joined | (justsign >> 16);
} }
sw::SIMD::Float r11g11b10Unpack(UInt r11g11b10bits) Float4 r11g11b10Unpack(UInt r11g11b10bits)
{ {
// 10 (or 11) bit float formats are unsigned formats with a 5 bit exponent and a 5 (or 6) bit mantissa. // 10 (or 11) bit float formats are unsigned formats with a 5 bit exponent and a 5 (or 6) bit mantissa.
// Since the Half float format also has a 5 bit exponent, we can convert these formats to half by // Since the Half float format also has a 5 bit exponent, we can convert these formats to half by
...@@ -606,7 +606,7 @@ sw::SIMD::Float r11g11b10Unpack(UInt r11g11b10bits) ...@@ -606,7 +606,7 @@ sw::SIMD::Float r11g11b10Unpack(UInt r11g11b10bits)
halfBits = Insert(halfBits, (r11g11b10bits & UInt(0x003FF800u)) >> 7, 1); halfBits = Insert(halfBits, (r11g11b10bits & UInt(0x003FF800u)) >> 7, 1);
halfBits = Insert(halfBits, (r11g11b10bits & UInt(0xFFC00000u)) >> 17, 2); halfBits = Insert(halfBits, (r11g11b10bits & UInt(0xFFC00000u)) >> 17, 2);
halfBits = Insert(halfBits, UInt(0x00003C00u), 3); halfBits = Insert(halfBits, UInt(0x00003C00u), 3);
return As<sw::SIMD::Float>(halfToFloatBits(halfBits)); return As<Float4>(halfToFloatBits(halfBits));
} }
UInt r11g11b10Pack(sw::SIMD::Float &value) UInt r11g11b10Pack(sw::SIMD::Float &value)
......
...@@ -616,6 +616,7 @@ void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFor ...@@ -616,6 +616,7 @@ void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFor
case VK_FORMAT_R32_SFLOAT: case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT: case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT: case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
pFormatProperties->optimalTilingFeatures |= pFormatProperties->optimalTilingFeatures |=
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
// Fall through // Fall through
...@@ -640,7 +641,6 @@ void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFor ...@@ -640,7 +641,6 @@ void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFor
case VK_FORMAT_R32G32_SINT: case VK_FORMAT_R32G32_SINT:
case VK_FORMAT_R32G32B32A32_UINT: case VK_FORMAT_R32G32B32A32_UINT:
case VK_FORMAT_R32G32B32A32_SINT: case VK_FORMAT_R32G32B32A32_SINT:
case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
pFormatProperties->optimalTilingFeatures |= pFormatProperties->optimalTilingFeatures |=
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
VK_FORMAT_FEATURE_BLIT_DST_BIT; VK_FORMAT_FEATURE_BLIT_DST_BIT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment