Fix SamplerFilterAnisotropicTests mipmap

Fix a bug about mipmap level in SamplerFilterAnisotropicTests.
Sizes of the 3 miplevels should be 4,2,1.
The old code allocates 8,4,2 (which don't have a 1x1 level)
Expected rendered pixel values have to change.
The render result now fits the webgl demo at https://jsfiddle.net/t8k7c95o/5/
(Thanks Kai for the enlarged pixelated canvas)

ComputeBoids.cpp and DawnTest.cpp change is due to git cl format

Bug: dawn:568
Change-Id: I9069732208a16be285be13b8cd1ab19b211995a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37380
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
shrekshao 2021-01-12 23:56:54 +00:00 committed by Commit Bot service account
parent e6ca254c72
commit 7faa362ea9
3 changed files with 27 additions and 30 deletions

View File

@ -95,8 +95,7 @@ void initBuffers() {
}
void initRender() {
wgpu::ShaderModule vsModule =
utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<in> a_particlePos : vec2<f32>;
[[location(1)]] var<in> a_particleVel : vec2<f32>;
[[location(2)]] var<in> a_pos : vec2<f32>;
@ -113,8 +112,7 @@ void initRender() {
}
)");
wgpu::ShaderModule fsModule =
utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[stage(fragment)]]
fn main() -> void {

View File

@ -901,7 +901,6 @@ void DawnTestBase::SetUp() {
// upgrade. Violently suppress this whole configuration until we figure out what to do.
// See https://crbug.com/dawn/598
DAWN_SKIP_TEST_IF(IsBackendValidationEnabled() && IsIntel() && IsD3D12());
}
void DawnTestBase::TearDown() {

View File

@ -93,8 +93,8 @@ class SamplerFilterAnisotropicTest : public DawnTest {
void InitTexture() {
const uint32_t mipLevelCount = colors.size();
const uint32_t textureWidthLevel0 = 1 << mipLevelCount;
const uint32_t textureHeightLevel0 = 1 << mipLevelCount;
const uint32_t textureWidthLevel0 = 1 << (mipLevelCount - 1);
const uint32_t textureHeightLevel0 = 1 << (mipLevelCount - 1);
wgpu::TextureDescriptor descriptor;
descriptor.dimension = wgpu::TextureDimension::e2D;
@ -197,18 +197,18 @@ class SamplerFilterAnisotropicTest : public DawnTest {
queue.Submit(1, &commands);
// https://jsfiddle.net/t8k7c95o/5/
// (x, y) -> (8, [0,15)) full readpixels result on Mac metal backend Intel GPU
// (x, y) -> (8, [0,15)) full readpixels result on Win10 Nvidia D3D12 GPU
// maxAnisotropy: 1
// 0 - 00 00 00
// 1 - 00 00 ff
// 2 - 00 00 ff
// 3 - 00 00 ff
// 4 - 00 00 ff
// 5 - 00 00 ff
// 6 - 00 ef 10
// 7 - 00 ef 10
// 8 - a7 58 00
// 9 - a7 58 00
// 4 - 00 f9 06
// 5 - 00 f9 06
// 6 - f2 0d 00
// 7 - f2 0d 00
// 8 - ff 00 00
// 9 - ff 00 00
// 10 - ff 00 00
// 11 - ff 00 00
// 12 - ff 00 00
@ -219,12 +219,12 @@ class SamplerFilterAnisotropicTest : public DawnTest {
// maxAnisotropy: 2
// 0 - 00 00 00
// 1 - 00 00 ff
// 2 - 00 00 ff
// 3 - 00 00 ff
// 4 - 00 f7 08
// 5 - 00 f7 08
// 6 - ed 12 00
// 7 - ed 12 10
// 2 - 00 7e 81
// 3 - 00 7e 81
// 4 - ff 00 00
// 5 - ff 00 00
// 6 - ff 00 00
// 7 - ff 00 00
// 8 - ff 00 00
// 9 - ff 00 00
// 10 - ff 00 00
@ -237,10 +237,10 @@ class SamplerFilterAnisotropicTest : public DawnTest {
// maxAnisotropy: 16
// 0 - 00 00 00
// 1 - 00 00 ff
// 2 - 00 ad 52
// 3 - 00 ad 52
// 4 - 81 7e 00
// 5 - 81 7e 00
// 2 - dd 22 00
// 3 - dd 22 00
// 4 - ff 00 00
// 5 - ff 00 00
// 6 - ff 00 00
// 7 - ff 00 00
// 8 - ff 00 00
@ -253,14 +253,14 @@ class SamplerFilterAnisotropicTest : public DawnTest {
// 15 - ff 00 00
if (maxAnisotropy >= 16) {
EXPECT_PIXEL_RGBA8_BETWEEN(colors[0], colors[1], mRenderPass.color, 8, 4);
EXPECT_PIXEL_RGBA8_EQ(colors[0], mRenderPass.color, 8, 7);
EXPECT_PIXEL_RGBA8_BETWEEN(colors[0], colors[1], mRenderPass.color, 8, 2);
EXPECT_PIXEL_RGBA8_EQ(colors[0], mRenderPass.color, 8, 6);
} else if (maxAnisotropy == 2) {
EXPECT_PIXEL_RGBA8_BETWEEN(colors[1], colors[2], mRenderPass.color, 8, 4);
EXPECT_PIXEL_RGBA8_BETWEEN(colors[0], colors[1], mRenderPass.color, 8, 7);
EXPECT_PIXEL_RGBA8_BETWEEN(colors[1], colors[2], mRenderPass.color, 8, 2);
EXPECT_PIXEL_RGBA8_EQ(colors[0], mRenderPass.color, 8, 6);
} else if (maxAnisotropy <= 1) {
EXPECT_PIXEL_RGBA8_EQ(colors[2], mRenderPass.color, 8, 4);
EXPECT_PIXEL_RGBA8_BETWEEN(colors[1], colors[2], mRenderPass.color, 8, 7);
EXPECT_PIXEL_RGBA8_EQ(colors[2], mRenderPass.color, 8, 2);
EXPECT_PIXEL_RGBA8_BETWEEN(colors[0], colors[1], mRenderPass.color, 8, 6);
}
}