Make TextureComponentType an internal enum

Fixed: dawn:1682
Change-Id: Iadbe7e2829805fed9a7f7e3bb0925544f4318380
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130440
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Austin Eng 2023-05-02 04:34:55 +00:00 committed by Dawn LUCI CQ
parent ba242e53cc
commit 7b82609894
15 changed files with 136 additions and 138 deletions

View File

@ -2671,16 +2671,6 @@
{"value": 4, "name": "plane 1 only", "tags": ["dawn"]} {"value": 4, "name": "plane 1 only", "tags": ["dawn"]}
] ]
}, },
"texture component type": {
"category": "enum",
"tags": ["dawn"],
"values": [
{"value": 0, "name": "float"},
{"value": 1, "name": "sint"},
{"value": 2, "name": "uint"},
{"value": 3, "name": "depth comparison"}
]
},
"texture data layout": { "texture data layout": {
"category": "structure", "category": "structure",
"extensible": "in", "extensible": "in",

View File

@ -51,13 +51,11 @@ const char* GetTextureComponentTypeString(DeviceBase* device, wgpu::TextureForma
const Format& formatInfo = device->GetValidInternalFormat(format); const Format& formatInfo = device->GetValidInternalFormat(format);
switch (formatInfo.GetAspectInfo(Aspect::Color).baseType) { switch (formatInfo.GetAspectInfo(Aspect::Color).baseType) {
case wgpu::TextureComponentType::Sint: case TextureComponentType::Sint:
return "i32"; return "i32";
case wgpu::TextureComponentType::Uint: case TextureComponentType::Uint:
return "u32"; return "u32";
case wgpu::TextureComponentType::Float: case TextureComponentType::Float:
case wgpu::TextureComponentType::DepthComparison:
default:
UNREACHABLE(); UNREACHABLE();
return ""; return "";
} }
@ -178,12 +176,12 @@ ResultOrError<Ref<BufferBase>> CreateUniformBufferWithClearValues(
uint32_t offset = 0; uint32_t offset = 0;
for (uint32_t i : IterateBitSet(key.colorTargetsToApplyClearColorValue)) { for (uint32_t i : IterateBitSet(key.colorTargetsToApplyClearColorValue)) {
const Format& format = renderPassDescriptor->colorAttachments[i].view->GetFormat(); const Format& format = renderPassDescriptor->colorAttachments[i].view->GetFormat();
wgpu::TextureComponentType baseType = format.GetAspectInfo(Aspect::Color).baseType; TextureComponentType baseType = format.GetAspectInfo(Aspect::Color).baseType;
Color initialClearValue = GetClearColorValue(renderPassDescriptor->colorAttachments[i]); Color initialClearValue = GetClearColorValue(renderPassDescriptor->colorAttachments[i]);
Color clearValue = ClampClearColorValueToLegalRange(initialClearValue, format); Color clearValue = ClampClearColorValueToLegalRange(initialClearValue, format);
switch (baseType) { switch (baseType) {
case wgpu::TextureComponentType::Uint: { case TextureComponentType::Uint: {
uint32_t* clearValuePtr = reinterpret_cast<uint32_t*>(clearValues.data() + offset); uint32_t* clearValuePtr = reinterpret_cast<uint32_t*>(clearValues.data() + offset);
clearValuePtr[0] = static_cast<uint32_t>(clearValue.r); clearValuePtr[0] = static_cast<uint32_t>(clearValue.r);
clearValuePtr[1] = static_cast<uint32_t>(clearValue.g); clearValuePtr[1] = static_cast<uint32_t>(clearValue.g);
@ -191,7 +189,7 @@ ResultOrError<Ref<BufferBase>> CreateUniformBufferWithClearValues(
clearValuePtr[3] = static_cast<uint32_t>(clearValue.a); clearValuePtr[3] = static_cast<uint32_t>(clearValue.a);
break; break;
} }
case wgpu::TextureComponentType::Sint: { case TextureComponentType::Sint: {
int32_t* clearValuePtr = reinterpret_cast<int32_t*>(clearValues.data() + offset); int32_t* clearValuePtr = reinterpret_cast<int32_t*>(clearValues.data() + offset);
clearValuePtr[0] = static_cast<int32_t>(clearValue.r); clearValuePtr[0] = static_cast<int32_t>(clearValue.r);
clearValuePtr[1] = static_cast<int32_t>(clearValue.g); clearValuePtr[1] = static_cast<int32_t>(clearValue.g);
@ -199,7 +197,7 @@ ResultOrError<Ref<BufferBase>> CreateUniformBufferWithClearValues(
clearValuePtr[3] = static_cast<int32_t>(clearValue.a); clearValuePtr[3] = static_cast<int32_t>(clearValue.a);
break; break;
} }
case wgpu::TextureComponentType::Float: { case TextureComponentType::Float: {
float* clearValuePtr = reinterpret_cast<float*>(clearValues.data() + offset); float* clearValuePtr = reinterpret_cast<float*>(clearValues.data() + offset);
clearValuePtr[0] = static_cast<float>(clearValue.r); clearValuePtr[0] = static_cast<float>(clearValue.r);
clearValuePtr[1] = static_cast<float>(clearValue.g); clearValuePtr[1] = static_cast<float>(clearValue.g);
@ -207,11 +205,6 @@ ResultOrError<Ref<BufferBase>> CreateUniformBufferWithClearValues(
clearValuePtr[3] = static_cast<float>(clearValue.a); clearValuePtr[3] = static_cast<float>(clearValue.a);
break; break;
} }
case wgpu::TextureComponentType::DepthComparison:
default:
UNREACHABLE();
break;
} }
offset += sizeof(uint32_t) * 4; offset += sizeof(uint32_t) * 4;
} }
@ -255,7 +248,7 @@ bool ShouldApplyClearBigIntegerColorValueWithDraw(
// TODO(dawn:537): only check the color channels that are available in the current color format. // TODO(dawn:537): only check the color channels that are available in the current color format.
Color clearValue = GetClearColorValue(colorAttachmentInfo); Color clearValue = GetClearColorValue(colorAttachmentInfo);
switch (format.GetAspectInfo(Aspect::Color).baseType) { switch (format.GetAspectInfo(Aspect::Color).baseType) {
case wgpu::TextureComponentType::Uint: { case TextureComponentType::Uint: {
constexpr double kMaxUintRepresentableInFloat = 1 << std::numeric_limits<float>::digits; constexpr double kMaxUintRepresentableInFloat = 1 << std::numeric_limits<float>::digits;
if (clearValue.r <= kMaxUintRepresentableInFloat && if (clearValue.r <= kMaxUintRepresentableInFloat &&
clearValue.g <= kMaxUintRepresentableInFloat && clearValue.g <= kMaxUintRepresentableInFloat &&
@ -265,7 +258,7 @@ bool ShouldApplyClearBigIntegerColorValueWithDraw(
} }
break; break;
} }
case wgpu::TextureComponentType::Sint: { case TextureComponentType::Sint: {
constexpr double kMaxSintRepresentableInFloat = 1 << std::numeric_limits<float>::digits; constexpr double kMaxSintRepresentableInFloat = 1 << std::numeric_limits<float>::digits;
constexpr double kMinSintRepresentableInFloat = -kMaxSintRepresentableInFloat; constexpr double kMinSintRepresentableInFloat = -kMaxSintRepresentableInFloat;
if (clearValue.r <= kMaxSintRepresentableInFloat && if (clearValue.r <= kMaxSintRepresentableInFloat &&
@ -280,9 +273,7 @@ bool ShouldApplyClearBigIntegerColorValueWithDraw(
} }
break; break;
} }
case wgpu::TextureComponentType::Float: case TextureComponentType::Float:
case wgpu::TextureComponentType::DepthComparison:
default:
UNREACHABLE(); UNREACHABLE();
return false; return false;
} }

View File

@ -636,10 +636,10 @@ Color ClampClearColorValueToLegalRange(const Color& originalColor, const Format&
double minValue = 0; double minValue = 0;
double maxValue = 0; double maxValue = 0;
switch (aspectInfo.baseType) { switch (aspectInfo.baseType) {
case wgpu::TextureComponentType::Float: { case TextureComponentType::Float: {
return originalColor; return originalColor;
} }
case wgpu::TextureComponentType::Sint: { case TextureComponentType::Sint: {
const uint32_t bitsPerComponent = const uint32_t bitsPerComponent =
(aspectInfo.block.byteSize * 8 / format.componentCount); (aspectInfo.block.byteSize * 8 / format.componentCount);
maxValue = maxValue =
@ -647,16 +647,12 @@ Color ClampClearColorValueToLegalRange(const Color& originalColor, const Format&
minValue = -static_cast<double>(static_cast<uint64_t>(1) << (bitsPerComponent - 1)); minValue = -static_cast<double>(static_cast<uint64_t>(1) << (bitsPerComponent - 1));
break; break;
} }
case wgpu::TextureComponentType::Uint: { case TextureComponentType::Uint: {
const uint32_t bitsPerComponent = const uint32_t bitsPerComponent =
(aspectInfo.block.byteSize * 8 / format.componentCount); (aspectInfo.block.byteSize * 8 / format.componentCount);
maxValue = static_cast<double>((static_cast<uint64_t>(1) << bitsPerComponent) - 1); maxValue = static_cast<double>((static_cast<uint64_t>(1) << bitsPerComponent) - 1);
break; break;
} }
case wgpu::TextureComponentType::DepthComparison:
default:
UNREACHABLE();
break;
} }
return {std::clamp(originalColor.r, minValue, maxValue), return {std::clamp(originalColor.r, minValue, maxValue),

View File

@ -205,20 +205,20 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
switch (sampleTypes) { switch (sampleTypes) {
case SampleTypeBit::Float: case SampleTypeBit::Float:
case SampleTypeBit::UnfilterableFloat: case SampleTypeBit::UnfilterableFloat:
firstAspect->baseType = wgpu::TextureComponentType::Float; firstAspect->baseType = TextureComponentType::Float;
break; break;
case SampleTypeBit::Sint: case SampleTypeBit::Sint:
firstAspect->baseType = wgpu::TextureComponentType::Sint; firstAspect->baseType = TextureComponentType::Sint;
break; break;
case SampleTypeBit::Uint: case SampleTypeBit::Uint:
firstAspect->baseType = wgpu::TextureComponentType::Uint; firstAspect->baseType = TextureComponentType::Uint;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} else { } else {
ASSERT(sampleTypes & SampleTypeBit::Float); ASSERT(sampleTypes & SampleTypeBit::Float);
firstAspect->baseType = wgpu::TextureComponentType::Float; firstAspect->baseType = TextureComponentType::Float;
} }
firstAspect->supportedSampleTypes = sampleTypes; firstAspect->supportedSampleTypes = sampleTypes;
firstAspect->format = format; firstAspect->format = format;
@ -243,7 +243,7 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
firstAspect->block.byteSize = byteSize; firstAspect->block.byteSize = byteSize;
firstAspect->block.width = 1; firstAspect->block.width = 1;
firstAspect->block.height = 1; firstAspect->block.height = 1;
firstAspect->baseType = wgpu::TextureComponentType::Float; firstAspect->baseType = TextureComponentType::Float;
firstAspect->supportedSampleTypes = SampleTypeBit::Depth | SampleTypeBit::UnfilterableFloat; firstAspect->supportedSampleTypes = SampleTypeBit::Depth | SampleTypeBit::UnfilterableFloat;
firstAspect->format = format; firstAspect->format = format;
AddFormat(internalFormat); AddFormat(internalFormat);
@ -272,7 +272,7 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
internalFormat.aspectInfo[0].block.byteSize = 1; internalFormat.aspectInfo[0].block.byteSize = 1;
internalFormat.aspectInfo[0].block.width = 1; internalFormat.aspectInfo[0].block.width = 1;
internalFormat.aspectInfo[0].block.height = 1; internalFormat.aspectInfo[0].block.height = 1;
internalFormat.aspectInfo[0].baseType = wgpu::TextureComponentType::Uint; internalFormat.aspectInfo[0].baseType = TextureComponentType::Uint;
internalFormat.aspectInfo[0].supportedSampleTypes = SampleTypeBit::Uint; internalFormat.aspectInfo[0].supportedSampleTypes = SampleTypeBit::Uint;
internalFormat.aspectInfo[0].format = format; internalFormat.aspectInfo[0].format = format;
@ -307,7 +307,7 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
firstAspect->block.byteSize = byteSize; firstAspect->block.byteSize = byteSize;
firstAspect->block.width = width; firstAspect->block.width = width;
firstAspect->block.height = height; firstAspect->block.height = height;
firstAspect->baseType = wgpu::TextureComponentType::Float; firstAspect->baseType = TextureComponentType::Float;
firstAspect->supportedSampleTypes = kAnyFloat; firstAspect->supportedSampleTypes = kAnyFloat;
firstAspect->format = format; firstAspect->format = format;
AddFormat(internalFormat); AddFormat(internalFormat);

View File

@ -66,11 +66,15 @@ struct TexelBlockInfo {
uint32_t height; uint32_t height;
}; };
enum class TextureComponentType {
Float,
Sint,
Uint,
};
struct AspectInfo { struct AspectInfo {
TexelBlockInfo block; TexelBlockInfo block;
// TODO(crbug.com/dawn/367): Replace TextureComponentType with TextureSampleType, or make it TextureComponentType baseType{};
// an internal Dawn enum.
wgpu::TextureComponentType baseType{};
SampleTypeBit supportedSampleTypes{}; SampleTypeBit supportedSampleTypes{};
wgpu::TextureFormat format = wgpu::TextureFormat::Undefined; wgpu::TextureFormat format = wgpu::TextureFormat::Undefined;
}; };

View File

@ -156,16 +156,16 @@ SampleTypeBit TintSampledKindToSampleTypeBit(tint::inspector::ResourceBinding::S
UNREACHABLE(); UNREACHABLE();
} }
ResultOrError<wgpu::TextureComponentType> TintComponentTypeToTextureComponentType( ResultOrError<TextureComponentType> TintComponentTypeToTextureComponentType(
tint::inspector::ComponentType type) { tint::inspector::ComponentType type) {
switch (type) { switch (type) {
case tint::inspector::ComponentType::kF32: case tint::inspector::ComponentType::kF32:
case tint::inspector::ComponentType::kF16: case tint::inspector::ComponentType::kF16:
return wgpu::TextureComponentType::Float; return TextureComponentType::Float;
case tint::inspector::ComponentType::kI32: case tint::inspector::ComponentType::kI32:
return wgpu::TextureComponentType::Sint; return TextureComponentType::Sint;
case tint::inspector::ComponentType::kU32: case tint::inspector::ComponentType::kU32:
return wgpu::TextureComponentType::Uint; return TextureComponentType::Uint;
case tint::inspector::ComponentType::kUnknown: case tint::inspector::ComponentType::kUnknown:
return DAWN_VALIDATION_ERROR("Attempted to convert 'Unknown' component type from Tint"); return DAWN_VALIDATION_ERROR("Attempted to convert 'Unknown' component type from Tint");
} }

View File

@ -194,7 +194,7 @@ struct EntryPointMetadata {
// An array to record the basic types (float, int and uint) of the fragment shader outputs. // An array to record the basic types (float, int and uint) of the fragment shader outputs.
struct FragmentOutputVariableInfo { struct FragmentOutputVariableInfo {
wgpu::TextureComponentType baseType; TextureComponentType baseType;
uint8_t componentCount; uint8_t componentCount;
}; };
ityp::array<ColorAttachmentIndex, FragmentOutputVariableInfo, kMaxColorAttachments> ityp::array<ColorAttachmentIndex, FragmentOutputVariableInfo, kMaxColorAttachments>

View File

@ -69,7 +69,7 @@ D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS D3D12EndingAccessResolveParam
// RESOLVE_MODE_AVERAGE is only valid for non-integer formats. // RESOLVE_MODE_AVERAGE is only valid for non-integer formats.
ASSERT(resolveDestination->GetFormat().GetAspectInfo(Aspect::Color).baseType == ASSERT(resolveDestination->GetFormat().GetAspectInfo(Aspect::Color).baseType ==
wgpu::TextureComponentType::Float); TextureComponentType::Float);
resolveParameters.ResolveMode = D3D12_RESOLVE_MODE_AVERAGE; resolveParameters.ResolveMode = D3D12_RESOLVE_MODE_AVERAGE;
resolveParameters.SubresourceCount = 1; resolveParameters.SubresourceCount = 1;

View File

@ -934,30 +934,27 @@ MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass) {
if (attachmentInfo->loadOp == wgpu::LoadOp::Clear) { if (attachmentInfo->loadOp == wgpu::LoadOp::Clear) {
gl.ColorMask(true, true, true, true); gl.ColorMask(true, true, true, true);
wgpu::TextureComponentType baseType = TextureComponentType baseType =
attachmentInfo->view->GetFormat().GetAspectInfo(Aspect::Color).baseType; attachmentInfo->view->GetFormat().GetAspectInfo(Aspect::Color).baseType;
switch (baseType) { switch (baseType) {
case wgpu::TextureComponentType::Float: { case TextureComponentType::Float: {
const std::array<float, 4> appliedClearColor = const std::array<float, 4> appliedClearColor =
ConvertToFloatColor(attachmentInfo->clearColor); ConvertToFloatColor(attachmentInfo->clearColor);
gl.ClearBufferfv(GL_COLOR, i, appliedClearColor.data()); gl.ClearBufferfv(GL_COLOR, i, appliedClearColor.data());
break; break;
} }
case wgpu::TextureComponentType::Uint: { case TextureComponentType::Uint: {
const std::array<uint32_t, 4> appliedClearColor = const std::array<uint32_t, 4> appliedClearColor =
ConvertToUnsignedIntegerColor(attachmentInfo->clearColor); ConvertToUnsignedIntegerColor(attachmentInfo->clearColor);
gl.ClearBufferuiv(GL_COLOR, i, appliedClearColor.data()); gl.ClearBufferuiv(GL_COLOR, i, appliedClearColor.data());
break; break;
} }
case wgpu::TextureComponentType::Sint: { case TextureComponentType::Sint: {
const std::array<int32_t, 4> appliedClearColor = const std::array<int32_t, 4> appliedClearColor =
ConvertToSignedIntegerColor(attachmentInfo->clearColor); ConvertToSignedIntegerColor(attachmentInfo->clearColor);
gl.ClearBufferiv(GL_COLOR, i, appliedClearColor.data()); gl.ClearBufferiv(GL_COLOR, i, appliedClearColor.data());
break; break;
} }
case wgpu::TextureComponentType::DepthComparison:
UNREACHABLE();
} }
} }

View File

@ -372,7 +372,7 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
constexpr std::array<GLbyte, MAX_TEXEL_SIZE> kClearColorDataBytes255 = { constexpr std::array<GLbyte, MAX_TEXEL_SIZE> kClearColorDataBytes255 = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
wgpu::TextureComponentType baseType = GetFormat().GetAspectInfo(Aspect::Color).baseType; TextureComponentType baseType = GetFormat().GetAspectInfo(Aspect::Color).baseType;
const GLFormat& glFormat = GetGLFormat(); const GLFormat& glFormat = GetGLFormat();
for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount; for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
@ -409,21 +409,21 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
auto DoClear = [&]() { auto DoClear = [&]() {
switch (baseType) { switch (baseType) {
case wgpu::TextureComponentType::Float: { case TextureComponentType::Float: {
gl.ClearBufferfv(GL_COLOR, 0, gl.ClearBufferfv(GL_COLOR, 0,
clearValue == TextureBase::ClearValue::Zero clearValue == TextureBase::ClearValue::Zero
? kClearColorDataFloat0.data() ? kClearColorDataFloat0.data()
: kClearColorDataFloat1.data()); : kClearColorDataFloat1.data());
break; break;
} }
case wgpu::TextureComponentType::Uint: { case TextureComponentType::Uint: {
gl.ClearBufferuiv(GL_COLOR, 0, gl.ClearBufferuiv(GL_COLOR, 0,
clearValue == TextureBase::ClearValue::Zero clearValue == TextureBase::ClearValue::Zero
? kClearColorDataUint0.data() ? kClearColorDataUint0.data()
: kClearColorDataUint1.data()); : kClearColorDataUint1.data());
break; break;
} }
case wgpu::TextureComponentType::Sint: { case TextureComponentType::Sint: {
gl.ClearBufferiv(GL_COLOR, 0, gl.ClearBufferiv(GL_COLOR, 0,
reinterpret_cast<const GLint*>( reinterpret_cast<const GLint*>(
clearValue == TextureBase::ClearValue::Zero clearValue == TextureBase::ClearValue::Zero
@ -431,9 +431,6 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
: kClearColorDataUint1.data())); : kClearColorDataUint1.data()));
break; break;
} }
case wgpu::TextureComponentType::DepthComparison:
UNREACHABLE();
} }
}; };

View File

@ -252,7 +252,7 @@ MaybeError RecordBeginRenderPass(CommandRecordingContext* recordingContext,
attachments[attachmentCount] = view->GetHandle(); attachments[attachmentCount] = view->GetHandle();
switch (view->GetFormat().GetAspectInfo(Aspect::Color).baseType) { switch (view->GetFormat().GetAspectInfo(Aspect::Color).baseType) {
case wgpu::TextureComponentType::Float: { case TextureComponentType::Float: {
const std::array<float, 4> appliedClearColor = const std::array<float, 4> appliedClearColor =
ConvertToFloatColor(attachmentInfo.clearColor); ConvertToFloatColor(attachmentInfo.clearColor);
for (uint32_t i = 0; i < 4; ++i) { for (uint32_t i = 0; i < 4; ++i) {
@ -260,7 +260,7 @@ MaybeError RecordBeginRenderPass(CommandRecordingContext* recordingContext,
} }
break; break;
} }
case wgpu::TextureComponentType::Uint: { case TextureComponentType::Uint: {
const std::array<uint32_t, 4> appliedClearColor = const std::array<uint32_t, 4> appliedClearColor =
ConvertToUnsignedIntegerColor(attachmentInfo.clearColor); ConvertToUnsignedIntegerColor(attachmentInfo.clearColor);
for (uint32_t i = 0; i < 4; ++i) { for (uint32_t i = 0; i < 4; ++i) {
@ -268,7 +268,7 @@ MaybeError RecordBeginRenderPass(CommandRecordingContext* recordingContext,
} }
break; break;
} }
case wgpu::TextureComponentType::Sint: { case TextureComponentType::Sint: {
const std::array<int32_t, 4> appliedClearColor = const std::array<int32_t, 4> appliedClearColor =
ConvertToSignedIntegerColor(attachmentInfo.clearColor); ConvertToSignedIntegerColor(attachmentInfo.clearColor);
for (uint32_t i = 0; i < 4; ++i) { for (uint32_t i = 0; i < 4; ++i) {
@ -276,9 +276,6 @@ MaybeError RecordBeginRenderPass(CommandRecordingContext* recordingContext,
} }
break; break;
} }
case wgpu::TextureComponentType::DepthComparison:
UNREACHABLE();
} }
attachmentCount++; attachmentCount++;
} }

View File

@ -1341,26 +1341,24 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* recordingContext,
ASSERT(aspects == Aspect::Color); ASSERT(aspects == Aspect::Color);
VkClearColorValue clearColorValue; VkClearColorValue clearColorValue;
switch (GetFormat().GetAspectInfo(Aspect::Color).baseType) { switch (GetFormat().GetAspectInfo(Aspect::Color).baseType) {
case wgpu::TextureComponentType::Float: case TextureComponentType::Float:
clearColorValue.float32[0] = fClearColor; clearColorValue.float32[0] = fClearColor;
clearColorValue.float32[1] = fClearColor; clearColorValue.float32[1] = fClearColor;
clearColorValue.float32[2] = fClearColor; clearColorValue.float32[2] = fClearColor;
clearColorValue.float32[3] = fClearColor; clearColorValue.float32[3] = fClearColor;
break; break;
case wgpu::TextureComponentType::Sint: case TextureComponentType::Sint:
clearColorValue.int32[0] = sClearColor; clearColorValue.int32[0] = sClearColor;
clearColorValue.int32[1] = sClearColor; clearColorValue.int32[1] = sClearColor;
clearColorValue.int32[2] = sClearColor; clearColorValue.int32[2] = sClearColor;
clearColorValue.int32[3] = sClearColor; clearColorValue.int32[3] = sClearColor;
break; break;
case wgpu::TextureComponentType::Uint: case TextureComponentType::Uint:
clearColorValue.uint32[0] = uClearColor; clearColorValue.uint32[0] = uClearColor;
clearColorValue.uint32[1] = uClearColor; clearColorValue.uint32[1] = uClearColor;
clearColorValue.uint32[2] = uClearColor; clearColorValue.uint32[2] = uClearColor;
clearColorValue.uint32[3] = uClearColor; clearColorValue.uint32[3] = uClearColor;
break; break;
case wgpu::TextureComponentType::DepthComparison:
UNREACHABLE();
} }
device->fn.CmdClearColorImage(recordingContext->commandBuffer, GetHandle(), device->fn.CmdClearColorImage(recordingContext->commandBuffer, GetHandle(),
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,

View File

@ -436,4 +436,22 @@ absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConv
return {true}; return {true};
} }
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
TextureComponentType value,
const absl::FormatConversionSpec& spec,
absl::FormatSink* s) {
switch (value) {
case TextureComponentType::Float:
s->Append("Float");
break;
case TextureComponentType::Sint:
s->Append("Sint");
break;
case TextureComponentType::Uint:
s->Append("Uint");
break;
}
return {true};
}
} // namespace dawn::native } // namespace dawn::native

View File

@ -129,6 +129,12 @@ absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConv
const absl::FormatConversionSpec& spec, const absl::FormatConversionSpec& spec,
absl::FormatSink* s); absl::FormatSink* s);
enum class TextureComponentType;
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
TextureComponentType value,
const absl::FormatConversionSpec& spec,
absl::FormatSink* s);
} // namespace dawn::native } // namespace dawn::native
#endif // SRC_DAWN_NATIVE_WEBGPU_ABSL_FORMAT_H_ #endif // SRC_DAWN_NATIVE_WEBGPU_ABSL_FORMAT_H_

View File

@ -25,6 +25,16 @@
#include "dawn/utils/TextureUtils.h" #include "dawn/utils/TextureUtils.h"
#include "dawn/utils/WGPUHelpers.h" #include "dawn/utils/WGPUHelpers.h"
namespace {
enum class TextureComponentType {
Float,
Sint,
Uint,
};
}
// An expectation for float buffer content that can correctly compare different NaN values and // An expectation for float buffer content that can correctly compare different NaN values and
// supports a basic tolerance for comparison of finite values. // supports a basic tolerance for comparison of finite values.
class ExpectFloatWithTolerance : public detail::Expectation { class ExpectFloatWithTolerance : public detail::Expectation {
@ -194,7 +204,7 @@ class TextureFormatTest : public DawnTest {
struct FormatTestInfo { struct FormatTestInfo {
wgpu::TextureFormat format; wgpu::TextureFormat format;
uint32_t texelByteSize; uint32_t texelByteSize;
wgpu::TextureComponentType type; TextureComponentType type;
uint32_t componentCount; uint32_t componentCount;
}; };
@ -202,11 +212,11 @@ class TextureFormatTest : public DawnTest {
// of the format. That the equivalent format with all channels 32bit-sized. // of the format. That the equivalent format with all channels 32bit-sized.
FormatTestInfo GetUncompressedFormatInfo(FormatTestInfo formatInfo) { FormatTestInfo GetUncompressedFormatInfo(FormatTestInfo formatInfo) {
switch (formatInfo.type) { switch (formatInfo.type) {
case wgpu::TextureComponentType::Float: case TextureComponentType::Float:
return {wgpu::TextureFormat::RGBA32Float, 16, formatInfo.type, 4}; return {wgpu::TextureFormat::RGBA32Float, 16, formatInfo.type, 4};
case wgpu::TextureComponentType::Sint: case TextureComponentType::Sint:
return {wgpu::TextureFormat::RGBA32Sint, 16, formatInfo.type, 4}; return {wgpu::TextureFormat::RGBA32Sint, 16, formatInfo.type, 4};
case wgpu::TextureComponentType::Uint: case TextureComponentType::Uint:
return {wgpu::TextureFormat::RGBA32Uint, 16, formatInfo.type, 4}; return {wgpu::TextureFormat::RGBA32Uint, 16, formatInfo.type, 4};
default: default:
UNREACHABLE(); UNREACHABLE();
@ -429,7 +439,7 @@ class TextureFormatTest : public DawnTest {
void DoUnormTest(FormatTestInfo formatInfo) { void DoUnormTest(FormatTestInfo formatInfo) {
static_assert(!std::is_signed<T>::value && std::is_integral<T>::value); static_assert(!std::is_signed<T>::value && std::is_integral<T>::value);
ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize); ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Float); ASSERT(formatInfo.type == TextureComponentType::Float);
T maxValue = std::numeric_limits<T>::max(); T maxValue = std::numeric_limits<T>::max();
std::vector<T> textureData = {0, 1, maxValue, maxValue}; std::vector<T> textureData = {0, 1, maxValue, maxValue};
@ -443,7 +453,7 @@ class TextureFormatTest : public DawnTest {
void DoSnormTest(FormatTestInfo formatInfo) { void DoSnormTest(FormatTestInfo formatInfo) {
static_assert(std::is_signed<T>::value && std::is_integral<T>::value); static_assert(std::is_signed<T>::value && std::is_integral<T>::value);
ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize); ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Float); ASSERT(formatInfo.type == TextureComponentType::Float);
T maxValue = std::numeric_limits<T>::max(); T maxValue = std::numeric_limits<T>::max();
T minValue = std::numeric_limits<T>::min(); T minValue = std::numeric_limits<T>::min();
@ -459,7 +469,7 @@ class TextureFormatTest : public DawnTest {
void DoUintTest(FormatTestInfo formatInfo) { void DoUintTest(FormatTestInfo formatInfo) {
static_assert(!std::is_signed<T>::value && std::is_integral<T>::value); static_assert(!std::is_signed<T>::value && std::is_integral<T>::value);
ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize); ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Uint); ASSERT(formatInfo.type == TextureComponentType::Uint);
T maxValue = std::numeric_limits<T>::max(); T maxValue = std::numeric_limits<T>::max();
std::vector<T> textureData = {0, 1, maxValue, maxValue}; std::vector<T> textureData = {0, 1, maxValue, maxValue};
@ -473,7 +483,7 @@ class TextureFormatTest : public DawnTest {
void DoSintTest(FormatTestInfo formatInfo) { void DoSintTest(FormatTestInfo formatInfo) {
static_assert(std::is_signed<T>::value && std::is_integral<T>::value); static_assert(std::is_signed<T>::value && std::is_integral<T>::value);
ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize); ASSERT(sizeof(T) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Sint); ASSERT(formatInfo.type == TextureComponentType::Sint);
T maxValue = std::numeric_limits<T>::max(); T maxValue = std::numeric_limits<T>::max();
T minValue = std::numeric_limits<T>::min(); T minValue = std::numeric_limits<T>::min();
@ -486,7 +496,7 @@ class TextureFormatTest : public DawnTest {
void DoFloat32Test(FormatTestInfo formatInfo) { void DoFloat32Test(FormatTestInfo formatInfo) {
ASSERT(sizeof(float) * formatInfo.componentCount == formatInfo.texelByteSize); ASSERT(sizeof(float) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Float); ASSERT(formatInfo.type == TextureComponentType::Float);
std::vector<float> textureData = {+0.0f, -0.0f, 1.0f, 1.0e-29f, std::vector<float> textureData = {+0.0f, -0.0f, 1.0f, 1.0e-29f,
1.0e29f, NAN, INFINITY, -INFINITY}; 1.0e29f, NAN, INFINITY, -INFINITY};
@ -498,7 +508,7 @@ class TextureFormatTest : public DawnTest {
void DoFloat16Test(FormatTestInfo formatInfo) { void DoFloat16Test(FormatTestInfo formatInfo) {
ASSERT(sizeof(int16_t) * formatInfo.componentCount == formatInfo.texelByteSize); ASSERT(sizeof(int16_t) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Float); ASSERT(formatInfo.type == TextureComponentType::Float);
std::vector<float> uncompressedData = {+0.0f, -0.0f, 1.0f, 1.01e-4f, std::vector<float> uncompressedData = {+0.0f, -0.0f, 1.0f, 1.01e-4f,
1.0e4f, NAN, INFINITY, -INFINITY}; 1.0e4f, NAN, INFINITY, -INFINITY};
@ -533,18 +543,17 @@ class TextureFormatTest : public DawnTest {
// Test the R8Unorm format // Test the R8Unorm format
TEST_P(TextureFormatTest, R8Unorm) { TEST_P(TextureFormatTest, R8Unorm) {
DoUnormTest<uint8_t>({wgpu::TextureFormat::R8Unorm, 1, wgpu::TextureComponentType::Float, 1}); DoUnormTest<uint8_t>({wgpu::TextureFormat::R8Unorm, 1, TextureComponentType::Float, 1});
} }
// Test the RG8Unorm format // Test the RG8Unorm format
TEST_P(TextureFormatTest, RG8Unorm) { TEST_P(TextureFormatTest, RG8Unorm) {
DoUnormTest<uint8_t>({wgpu::TextureFormat::RG8Unorm, 2, wgpu::TextureComponentType::Float, 2}); DoUnormTest<uint8_t>({wgpu::TextureFormat::RG8Unorm, 2, TextureComponentType::Float, 2});
} }
// Test the RGBA8Unorm format // Test the RGBA8Unorm format
TEST_P(TextureFormatTest, RGBA8Unorm) { TEST_P(TextureFormatTest, RGBA8Unorm) {
DoUnormTest<uint8_t>( DoUnormTest<uint8_t>({wgpu::TextureFormat::RGBA8Unorm, 4, TextureComponentType::Float, 4});
{wgpu::TextureFormat::RGBA8Unorm, 4, wgpu::TextureComponentType::Float, 4});
} }
// Test the BGRA8Unorm format // Test the BGRA8Unorm format
@ -558,132 +567,130 @@ TEST_P(TextureFormatTest, BGRA8Unorm) {
uint8_t maxValue = std::numeric_limits<uint8_t>::max(); uint8_t maxValue = std::numeric_limits<uint8_t>::max();
std::vector<uint8_t> textureData = {maxValue, 1, 0, maxValue}; std::vector<uint8_t> textureData = {maxValue, 1, 0, maxValue};
std::vector<float> uncompressedData = {0.0f, 1.0f / maxValue, 1.0f, 1.0f}; std::vector<float> uncompressedData = {0.0f, 1.0f / maxValue, 1.0f, 1.0f};
DoFormatSamplingTest({wgpu::TextureFormat::BGRA8Unorm, 4, wgpu::TextureComponentType::Float, 4}, DoFormatSamplingTest({wgpu::TextureFormat::BGRA8Unorm, 4, TextureComponentType::Float, 4},
textureData, uncompressedData); textureData, uncompressedData);
DoFormatRenderingTest( DoFormatRenderingTest({wgpu::TextureFormat::BGRA8Unorm, 4, TextureComponentType::Float, 4},
{wgpu::TextureFormat::BGRA8Unorm, 4, wgpu::TextureComponentType::Float, 4},
uncompressedData, textureData); uncompressedData, textureData);
} }
// Test the R8Snorm format // Test the R8Snorm format
TEST_P(TextureFormatTest, R8Snorm) { TEST_P(TextureFormatTest, R8Snorm) {
DoSnormTest<int8_t>({wgpu::TextureFormat::R8Snorm, 1, wgpu::TextureComponentType::Float, 1}); DoSnormTest<int8_t>({wgpu::TextureFormat::R8Snorm, 1, TextureComponentType::Float, 1});
} }
// Test the RG8Snorm format // Test the RG8Snorm format
TEST_P(TextureFormatTest, RG8Snorm) { TEST_P(TextureFormatTest, RG8Snorm) {
DoSnormTest<int8_t>({wgpu::TextureFormat::RG8Snorm, 2, wgpu::TextureComponentType::Float, 2}); DoSnormTest<int8_t>({wgpu::TextureFormat::RG8Snorm, 2, TextureComponentType::Float, 2});
} }
// Test the RGBA8Snorm format // Test the RGBA8Snorm format
TEST_P(TextureFormatTest, RGBA8Snorm) { TEST_P(TextureFormatTest, RGBA8Snorm) {
DoSnormTest<int8_t>({wgpu::TextureFormat::RGBA8Snorm, 4, wgpu::TextureComponentType::Float, 4}); DoSnormTest<int8_t>({wgpu::TextureFormat::RGBA8Snorm, 4, TextureComponentType::Float, 4});
} }
// Test the R8Uint format // Test the R8Uint format
TEST_P(TextureFormatTest, R8Uint) { TEST_P(TextureFormatTest, R8Uint) {
DoUintTest<uint8_t>({wgpu::TextureFormat::R8Uint, 1, wgpu::TextureComponentType::Uint, 1}); DoUintTest<uint8_t>({wgpu::TextureFormat::R8Uint, 1, TextureComponentType::Uint, 1});
} }
// Test the RG8Uint format // Test the RG8Uint format
TEST_P(TextureFormatTest, RG8Uint) { TEST_P(TextureFormatTest, RG8Uint) {
DoUintTest<uint8_t>({wgpu::TextureFormat::RG8Uint, 2, wgpu::TextureComponentType::Uint, 2}); DoUintTest<uint8_t>({wgpu::TextureFormat::RG8Uint, 2, TextureComponentType::Uint, 2});
} }
// Test the RGBA8Uint format // Test the RGBA8Uint format
TEST_P(TextureFormatTest, RGBA8Uint) { TEST_P(TextureFormatTest, RGBA8Uint) {
DoUintTest<uint8_t>({wgpu::TextureFormat::RGBA8Uint, 4, wgpu::TextureComponentType::Uint, 4}); DoUintTest<uint8_t>({wgpu::TextureFormat::RGBA8Uint, 4, TextureComponentType::Uint, 4});
} }
// Test the R16Uint format // Test the R16Uint format
TEST_P(TextureFormatTest, R16Uint) { TEST_P(TextureFormatTest, R16Uint) {
DoUintTest<uint16_t>({wgpu::TextureFormat::R16Uint, 2, wgpu::TextureComponentType::Uint, 1}); DoUintTest<uint16_t>({wgpu::TextureFormat::R16Uint, 2, TextureComponentType::Uint, 1});
} }
// Test the RG16Uint format // Test the RG16Uint format
TEST_P(TextureFormatTest, RG16Uint) { TEST_P(TextureFormatTest, RG16Uint) {
DoUintTest<uint16_t>({wgpu::TextureFormat::RG16Uint, 4, wgpu::TextureComponentType::Uint, 2}); DoUintTest<uint16_t>({wgpu::TextureFormat::RG16Uint, 4, TextureComponentType::Uint, 2});
} }
// Test the RGBA16Uint format // Test the RGBA16Uint format
TEST_P(TextureFormatTest, RGBA16Uint) { TEST_P(TextureFormatTest, RGBA16Uint) {
DoUintTest<uint16_t>({wgpu::TextureFormat::RGBA16Uint, 8, wgpu::TextureComponentType::Uint, 4}); DoUintTest<uint16_t>({wgpu::TextureFormat::RGBA16Uint, 8, TextureComponentType::Uint, 4});
} }
// Test the R32Uint format // Test the R32Uint format
TEST_P(TextureFormatTest, R32Uint) { TEST_P(TextureFormatTest, R32Uint) {
DoUintTest<uint32_t>({wgpu::TextureFormat::R32Uint, 4, wgpu::TextureComponentType::Uint, 1}); DoUintTest<uint32_t>({wgpu::TextureFormat::R32Uint, 4, TextureComponentType::Uint, 1});
} }
// Test the RG32Uint format // Test the RG32Uint format
TEST_P(TextureFormatTest, RG32Uint) { TEST_P(TextureFormatTest, RG32Uint) {
DoUintTest<uint32_t>({wgpu::TextureFormat::RG32Uint, 8, wgpu::TextureComponentType::Uint, 2}); DoUintTest<uint32_t>({wgpu::TextureFormat::RG32Uint, 8, TextureComponentType::Uint, 2});
} }
// Test the RGBA32Uint format // Test the RGBA32Uint format
TEST_P(TextureFormatTest, RGBA32Uint) { TEST_P(TextureFormatTest, RGBA32Uint) {
DoUintTest<uint32_t>( DoUintTest<uint32_t>({wgpu::TextureFormat::RGBA32Uint, 16, TextureComponentType::Uint, 4});
{wgpu::TextureFormat::RGBA32Uint, 16, wgpu::TextureComponentType::Uint, 4});
} }
// Test the R8Sint format // Test the R8Sint format
TEST_P(TextureFormatTest, R8Sint) { TEST_P(TextureFormatTest, R8Sint) {
DoSintTest<int8_t>({wgpu::TextureFormat::R8Sint, 1, wgpu::TextureComponentType::Sint, 1}); DoSintTest<int8_t>({wgpu::TextureFormat::R8Sint, 1, TextureComponentType::Sint, 1});
} }
// Test the RG8Sint format // Test the RG8Sint format
TEST_P(TextureFormatTest, RG8Sint) { TEST_P(TextureFormatTest, RG8Sint) {
DoSintTest<int8_t>({wgpu::TextureFormat::RG8Sint, 2, wgpu::TextureComponentType::Sint, 2}); DoSintTest<int8_t>({wgpu::TextureFormat::RG8Sint, 2, TextureComponentType::Sint, 2});
} }
// Test the RGBA8Sint format // Test the RGBA8Sint format
TEST_P(TextureFormatTest, RGBA8Sint) { TEST_P(TextureFormatTest, RGBA8Sint) {
DoSintTest<int8_t>({wgpu::TextureFormat::RGBA8Sint, 4, wgpu::TextureComponentType::Sint, 4}); DoSintTest<int8_t>({wgpu::TextureFormat::RGBA8Sint, 4, TextureComponentType::Sint, 4});
} }
// Test the R16Sint format // Test the R16Sint format
TEST_P(TextureFormatTest, R16Sint) { TEST_P(TextureFormatTest, R16Sint) {
DoSintTest<int16_t>({wgpu::TextureFormat::R16Sint, 2, wgpu::TextureComponentType::Sint, 1}); DoSintTest<int16_t>({wgpu::TextureFormat::R16Sint, 2, TextureComponentType::Sint, 1});
} }
// Test the RG16Sint format // Test the RG16Sint format
TEST_P(TextureFormatTest, RG16Sint) { TEST_P(TextureFormatTest, RG16Sint) {
DoSintTest<int16_t>({wgpu::TextureFormat::RG16Sint, 4, wgpu::TextureComponentType::Sint, 2}); DoSintTest<int16_t>({wgpu::TextureFormat::RG16Sint, 4, TextureComponentType::Sint, 2});
} }
// Test the RGBA16Sint format // Test the RGBA16Sint format
TEST_P(TextureFormatTest, RGBA16Sint) { TEST_P(TextureFormatTest, RGBA16Sint) {
DoSintTest<int16_t>({wgpu::TextureFormat::RGBA16Sint, 8, wgpu::TextureComponentType::Sint, 4}); DoSintTest<int16_t>({wgpu::TextureFormat::RGBA16Sint, 8, TextureComponentType::Sint, 4});
} }
// Test the R32Sint format // Test the R32Sint format
TEST_P(TextureFormatTest, R32Sint) { TEST_P(TextureFormatTest, R32Sint) {
DoSintTest<int32_t>({wgpu::TextureFormat::R32Sint, 4, wgpu::TextureComponentType::Sint, 1}); DoSintTest<int32_t>({wgpu::TextureFormat::R32Sint, 4, TextureComponentType::Sint, 1});
} }
// Test the RG32Sint format // Test the RG32Sint format
TEST_P(TextureFormatTest, RG32Sint) { TEST_P(TextureFormatTest, RG32Sint) {
DoSintTest<int32_t>({wgpu::TextureFormat::RG32Sint, 8, wgpu::TextureComponentType::Sint, 2}); DoSintTest<int32_t>({wgpu::TextureFormat::RG32Sint, 8, TextureComponentType::Sint, 2});
} }
// Test the RGBA32Sint format // Test the RGBA32Sint format
TEST_P(TextureFormatTest, RGBA32Sint) { TEST_P(TextureFormatTest, RGBA32Sint) {
DoSintTest<int32_t>({wgpu::TextureFormat::RGBA32Sint, 16, wgpu::TextureComponentType::Sint, 4}); DoSintTest<int32_t>({wgpu::TextureFormat::RGBA32Sint, 16, TextureComponentType::Sint, 4});
} }
// Test the R32Float format // Test the R32Float format
TEST_P(TextureFormatTest, R32Float) { TEST_P(TextureFormatTest, R32Float) {
DoFloat32Test({wgpu::TextureFormat::R32Float, 4, wgpu::TextureComponentType::Float, 1}); DoFloat32Test({wgpu::TextureFormat::R32Float, 4, TextureComponentType::Float, 1});
} }
// Test the RG32Float format // Test the RG32Float format
TEST_P(TextureFormatTest, RG32Float) { TEST_P(TextureFormatTest, RG32Float) {
DoFloat32Test({wgpu::TextureFormat::RG32Float, 8, wgpu::TextureComponentType::Float, 2}); DoFloat32Test({wgpu::TextureFormat::RG32Float, 8, TextureComponentType::Float, 2});
} }
// Test the RGBA32Float format // Test the RGBA32Float format
TEST_P(TextureFormatTest, RGBA32Float) { TEST_P(TextureFormatTest, RGBA32Float) {
DoFloat32Test({wgpu::TextureFormat::RGBA32Float, 16, wgpu::TextureComponentType::Float, 4}); DoFloat32Test({wgpu::TextureFormat::RGBA32Float, 16, TextureComponentType::Float, 4});
} }
// Test the R16Float format // Test the R16Float format
@ -692,7 +699,7 @@ TEST_P(TextureFormatTest, R16Float) {
// swiftshader // swiftshader
DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsSwiftshader() || IsANGLE()); DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsSwiftshader() || IsANGLE());
DoFloat16Test({wgpu::TextureFormat::R16Float, 2, wgpu::TextureComponentType::Float, 1}); DoFloat16Test({wgpu::TextureFormat::R16Float, 2, TextureComponentType::Float, 1});
} }
// Test the RG16Float format // Test the RG16Float format
@ -701,7 +708,7 @@ TEST_P(TextureFormatTest, RG16Float) {
// swiftshader // swiftshader
DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsSwiftshader() || IsANGLE()); DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsSwiftshader() || IsANGLE());
DoFloat16Test({wgpu::TextureFormat::RG16Float, 4, wgpu::TextureComponentType::Float, 2}); DoFloat16Test({wgpu::TextureFormat::RG16Float, 4, TextureComponentType::Float, 2});
} }
// Test the RGBA16Float format // Test the RGBA16Float format
@ -710,7 +717,7 @@ TEST_P(TextureFormatTest, RGBA16Float) {
// swiftshader // swiftshader
DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsSwiftshader() || IsANGLE()); DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsSwiftshader() || IsANGLE());
DoFloat16Test({wgpu::TextureFormat::RGBA16Float, 8, wgpu::TextureComponentType::Float, 4}); DoFloat16Test({wgpu::TextureFormat::RGBA16Float, 8, TextureComponentType::Float, 4});
} }
// Test the RGBA8Unorm format // Test the RGBA8Unorm format
@ -728,10 +735,9 @@ TEST_P(TextureFormatTest, RGBA8UnormSrgb) {
} }
DoFloatFormatSamplingTest( DoFloatFormatSamplingTest(
{wgpu::TextureFormat::RGBA8UnormSrgb, 4, wgpu::TextureComponentType::Float, 4}, textureData, {wgpu::TextureFormat::RGBA8UnormSrgb, 4, TextureComponentType::Float, 4}, textureData,
uncompressedData, 1.0e-3); uncompressedData, 1.0e-3);
DoFormatRenderingTest( DoFormatRenderingTest({wgpu::TextureFormat::RGBA8UnormSrgb, 4, TextureComponentType::Float, 4},
{wgpu::TextureFormat::RGBA8UnormSrgb, 4, wgpu::TextureComponentType::Float, 4},
uncompressedData, textureData); uncompressedData, textureData);
} }
@ -755,10 +761,9 @@ TEST_P(TextureFormatTest, BGRA8UnormSrgb) {
} }
DoFloatFormatSamplingTest( DoFloatFormatSamplingTest(
{wgpu::TextureFormat::BGRA8UnormSrgb, 4, wgpu::TextureComponentType::Float, 4}, textureData, {wgpu::TextureFormat::BGRA8UnormSrgb, 4, TextureComponentType::Float, 4}, textureData,
uncompressedData, 1.0e-3); uncompressedData, 1.0e-3);
DoFormatRenderingTest( DoFormatRenderingTest({wgpu::TextureFormat::BGRA8UnormSrgb, 4, TextureComponentType::Float, 4},
{wgpu::TextureFormat::BGRA8UnormSrgb, 4, wgpu::TextureComponentType::Float, 4},
uncompressedData, textureData); uncompressedData, textureData);
} }
@ -784,10 +789,9 @@ TEST_P(TextureFormatTest, RGB10A2Unorm) {
// clang-format on // clang-format on
DoFloatFormatSamplingTest( DoFloatFormatSamplingTest(
{wgpu::TextureFormat::RGB10A2Unorm, 4, wgpu::TextureComponentType::Float, 4}, textureData, {wgpu::TextureFormat::RGB10A2Unorm, 4, TextureComponentType::Float, 4}, textureData,
uncompressedData, 1.0e-5); uncompressedData, 1.0e-5);
DoFormatRenderingTest( DoFormatRenderingTest({wgpu::TextureFormat::RGB10A2Unorm, 4, TextureComponentType::Float, 4},
{wgpu::TextureFormat::RGB10A2Unorm, 4, wgpu::TextureComponentType::Float, 4},
uncompressedData, textureData); uncompressedData, textureData);
} }
@ -831,7 +835,7 @@ TEST_P(TextureFormatTest, RG11B10Ufloat) {
// clang-format on // clang-format on
DoFloatFormatSamplingTest( DoFloatFormatSamplingTest(
{wgpu::TextureFormat::RG11B10Ufloat, 4, wgpu::TextureComponentType::Float, 4}, textureData, {wgpu::TextureFormat::RG11B10Ufloat, 4, TextureComponentType::Float, 4}, textureData,
uncompressedData); uncompressedData);
// This format is renderable if "rg11b10ufloat-renderable" feature is enabled // This format is renderable if "rg11b10ufloat-renderable" feature is enabled
@ -843,7 +847,7 @@ TEST_P(TextureFormatTest, RG11B10Ufloat) {
"and NaN correctly for RG11B10Ufloat texture format."; "and NaN correctly for RG11B10Ufloat texture format.";
} else { } else {
DoFormatRenderingTest( DoFormatRenderingTest(
{wgpu::TextureFormat::RG11B10Ufloat, 4, wgpu::TextureComponentType::Float, 4}, {wgpu::TextureFormat::RG11B10Ufloat, 4, TextureComponentType::Float, 4},
uncompressedData, textureData, new ExpectRG11B10Ufloat(textureData)); uncompressedData, textureData, new ExpectRG11B10Ufloat(textureData));
} }
} }
@ -891,7 +895,7 @@ TEST_P(TextureFormatTest, RGB9E5Ufloat) {
// clang-format on // clang-format on
DoFloatFormatSamplingTest( DoFloatFormatSamplingTest(
{wgpu::TextureFormat::RGB9E5Ufloat, 4, wgpu::TextureComponentType::Float, 4}, textureData, {wgpu::TextureFormat::RGB9E5Ufloat, 4, TextureComponentType::Float, 4}, textureData,
uncompressedData); uncompressedData);
// This format is not renderable. // This format is not renderable.
} }