Add most WebGPU texture formats on Vulkan

This adds the formats to dawn.json, implements support in the Vulkan
backend and adds tests performing basic sampling checks for all formats.

The R8UnormSrgb and RG8UnormSrgb formats skipped because they are not
required in Vulkan (and RG8UnormSrgb is in fact not supported on the
machine used for developing this CL). A PR will be sent to the WebGPU
repo to remove the from the initial list of formats.

The RG11B10Float and RGB10A2Unorm formats of WebGPU are replaced with
B10GR11Float and A2RGB10Unorm that are the formats exposed by Vulkan. It
is likely that all APIs implement them with components stored in that
order.

Each format except depth-stencil ones is tested by uploading some
interesting texel data and checking that sampling from the texture
produces correct results. The goal is to make sure that backends don't
make a mistake in the giant switch statements. There was no effort made
to check the hardware implementation of the formats.

Tests will later be extended to cover rendering and clearing operations
as well as multisample resolve.

It isn't clear if depth-stencil format will support TRANSFER operations
in WebGPU so these are left untested for now.

BUG=dawn:128

Change-Id: I78ac5bf77b57398155551e6db3de50b478d69452
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8363
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2019-07-01 09:58:07 +00:00
committed by Commit Bot service account
parent b6096db4ab
commit 431d618961
10 changed files with 979 additions and 32 deletions

View File

@@ -17,6 +17,7 @@
#include "common/Assert.h"
#include <algorithm>
#include <cmath>
#if defined(DAWN_COMPILER_MSVC)
# include <intrin.h>
@@ -107,3 +108,19 @@ uint16_t Float32ToFloat16(float fp32) {
13);
}
}
// Based on the Khronos Data Format Specification 1.2 Section 13.3 sRGB transfer functions
float SRGBToLinear(float srgb) {
// sRGB is always used in unsigned normalized formats so clamp to [0.0, 1.0]
if (srgb <= 0.0f) {
return 0.0f;
} else if (srgb > 1.0f) {
return 1.0f;
}
if (srgb < 0.04045f) {
return srgb / 12.92f;
} else {
return std::pow((srgb + 0.055f) / 1.055f, 2.4f);
}
}