Support sampling depth and stencil of combined d/s formats

This CL adds sampling of depth-only and stencil-only texture
views on all backends. However, Metal on macOS <= 10.11 will
need a workaround to use separate depth/stencil textures for
each aspect since it is impossible to sample the stencil
aspect of a combined depth/stencil texture.

Also fixes sampling of depth24plus on D3D12 which had an
incomplete check for determining if a TYPELESS format is
necessary.

Bug: dawn:439, dawn:553
Change-Id: Id4991c565f822add200054296714e2dcd330119a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30725
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Austin Eng
2020-11-04 15:27:11 +00:00
committed by Commit Bot service account
parent 9d6265bc07
commit a0f1725c4f
9 changed files with 633 additions and 153 deletions

View File

@@ -15,9 +15,23 @@
#include <gtest/gtest.h>
#include "common/Math.h"
#include "dawn/EnumClassBitmasks.h"
#include <cmath>
namespace wgpu {
enum class TestEnum {
A = 0x1,
B = 0x2,
C = 0x4,
};
} // namespace wgpu
template <>
struct wgpu::IsDawnBitmask<wgpu::TestEnum> {
static constexpr bool enable = true;
};
// Tests for ScanForward
TEST(Math, ScanForward) {
// Test extrema
@@ -260,3 +274,32 @@ TEST(Math, RoundUp) {
ASSERT_EQ(RoundUp(0x7FFFFFFFFFFFFFFFull, 0x8000000000000000ull), 0x8000000000000000ull);
ASSERT_EQ(RoundUp(1, 1), 1u);
}
// Tests for IsSubset
TEST(Math, IsSubset) {
// single value is a subset
ASSERT_TRUE(IsSubset(0b100, 0b101));
ASSERT_FALSE(IsSubset(0b010, 0b101));
ASSERT_TRUE(IsSubset(0b001, 0b101));
// empty set is a subset
ASSERT_TRUE(IsSubset(0b000, 0b101));
// equal-to is a subset
ASSERT_TRUE(IsSubset(0b101, 0b101));
// superset is not a subset
ASSERT_FALSE(IsSubset(0b111, 0b101));
// only empty is a subset of empty
ASSERT_FALSE(IsSubset(0b100, 0b000));
ASSERT_FALSE(IsSubset(0b010, 0b000));
ASSERT_FALSE(IsSubset(0b001, 0b000));
ASSERT_TRUE(IsSubset(0b000, 0b000));
// Test with enums
ASSERT_TRUE(IsSubset(wgpu::TestEnum::A, wgpu::TestEnum::A));
ASSERT_TRUE(IsSubset(wgpu::TestEnum::A, wgpu::TestEnum::A | wgpu::TestEnum::B));
ASSERT_FALSE(IsSubset(wgpu::TestEnum::C, wgpu::TestEnum::A | wgpu::TestEnum::B));
ASSERT_FALSE(IsSubset(wgpu::TestEnum::A | wgpu::TestEnum::C, wgpu::TestEnum::A));
}