mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 08:57:26 +00:00
Deprecate readonly storage textures
Bug: dawn:1025 Change-Id: Ie799507b534d983959d44b573436bb5421162150 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59841 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
b550c143c0
commit
52201303f3
@@ -406,7 +406,7 @@ TEST_F(BindGroupValidationTest, TextureUsage) {
|
||||
// Check that a storage texture binding must have the correct usage
|
||||
TEST_F(BindGroupValidationTest, StorageTextureUsage) {
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly,
|
||||
wgpu::TextureFormat::RGBA8Uint}});
|
||||
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
@@ -932,7 +932,7 @@ TEST_F(BindGroupLayoutValidationTest, PerStageLimits) {
|
||||
wgpu::BindGroupLayoutEntry otherEntry;
|
||||
};
|
||||
|
||||
std::array<TestInfo, 8> kTestInfos = {
|
||||
std::array<TestInfo, 7> kTestInfos = {
|
||||
TestInfo{kMaxSampledTexturesPerShaderStage, BGLEntryType(wgpu::TextureSampleType::Float),
|
||||
BGLEntryType(wgpu::BufferBindingType::Uniform)},
|
||||
TestInfo{kMaxSamplersPerShaderStage, BGLEntryType(wgpu::SamplerBindingType::Filtering),
|
||||
@@ -941,10 +941,6 @@ TEST_F(BindGroupLayoutValidationTest, PerStageLimits) {
|
||||
BGLEntryType(wgpu::BufferBindingType::Uniform)},
|
||||
TestInfo{kMaxStorageBuffersPerShaderStage, BGLEntryType(wgpu::BufferBindingType::Storage),
|
||||
BGLEntryType(wgpu::BufferBindingType::Uniform)},
|
||||
TestInfo{
|
||||
kMaxStorageTexturesPerShaderStage,
|
||||
BGLEntryType(wgpu::StorageTextureAccess::ReadOnly, wgpu::TextureFormat::RGBA8Unorm),
|
||||
BGLEntryType(wgpu::BufferBindingType::Uniform)},
|
||||
TestInfo{
|
||||
kMaxStorageTexturesPerShaderStage,
|
||||
BGLEntryType(wgpu::StorageTextureAccess::WriteOnly, wgpu::TextureFormat::RGBA8Unorm),
|
||||
@@ -1020,6 +1016,78 @@ TEST_F(BindGroupLayoutValidationTest, PerStageLimits) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is the same test as PerStageLimits but for the deprecated ReadOnly storage textures.
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
TEST_F(BindGroupLayoutValidationTest, PerStageLimits_ReadOnlyStorageTexture) {
|
||||
uint32_t maxCount = kMaxStorageTexturesPerShaderStage;
|
||||
wgpu::BindGroupLayoutEntry entry =
|
||||
BGLEntryType(wgpu::StorageTextureAccess::ReadOnly, wgpu::TextureFormat::RGBA8Unorm);
|
||||
wgpu::BindGroupLayoutEntry otherEntry = BGLEntryType(wgpu::BufferBindingType::Uniform);
|
||||
|
||||
wgpu::BindGroupLayout bgl[2];
|
||||
std::vector<utils::BindingLayoutEntryInitializationHelper> maxBindings;
|
||||
|
||||
for (uint32_t i = 0; i < maxCount; ++i) {
|
||||
entry.binding = i;
|
||||
maxBindings.push_back(entry);
|
||||
}
|
||||
|
||||
// Creating with the maxes works.
|
||||
EXPECT_DEPRECATION_WARNINGS(
|
||||
bgl[0] = MakeBindGroupLayout(maxBindings.data(), maxBindings.size()), maxCount);
|
||||
|
||||
// Adding an extra binding of a different type works.
|
||||
{
|
||||
std::vector<utils::BindingLayoutEntryInitializationHelper> bindings = maxBindings;
|
||||
wgpu::BindGroupLayoutEntry newEntry = otherEntry;
|
||||
newEntry.binding = maxCount;
|
||||
bindings.push_back(newEntry);
|
||||
EXPECT_DEPRECATION_WARNINGS(MakeBindGroupLayout(bindings.data(), bindings.size()),
|
||||
maxCount);
|
||||
}
|
||||
|
||||
// Adding an extra binding of the maxed type in a different stage works
|
||||
{
|
||||
std::vector<utils::BindingLayoutEntryInitializationHelper> bindings = maxBindings;
|
||||
wgpu::BindGroupLayoutEntry newEntry = entry;
|
||||
newEntry.binding = maxCount;
|
||||
newEntry.visibility = wgpu::ShaderStage::Fragment;
|
||||
bindings.push_back(newEntry);
|
||||
EXPECT_DEPRECATION_WARNINGS(MakeBindGroupLayout(bindings.data(), bindings.size()),
|
||||
maxCount + 1);
|
||||
}
|
||||
|
||||
// Adding an extra binding of the maxed type and stage exceeds the per stage limit.
|
||||
{
|
||||
std::vector<utils::BindingLayoutEntryInitializationHelper> bindings = maxBindings;
|
||||
wgpu::BindGroupLayoutEntry newEntry = entry;
|
||||
newEntry.binding = maxCount;
|
||||
bindings.push_back(newEntry);
|
||||
EXPECT_DEPRECATION_WARNINGS(
|
||||
ASSERT_DEVICE_ERROR(MakeBindGroupLayout(bindings.data(), bindings.size())),
|
||||
maxCount + 1);
|
||||
}
|
||||
|
||||
// Creating a pipeline layout from the valid BGL works.
|
||||
TestCreatePipelineLayout(bgl, 1, true);
|
||||
|
||||
// Adding an extra binding of a different type in a different BGL works
|
||||
bgl[1] = utils::MakeBindGroupLayout(device, {otherEntry});
|
||||
TestCreatePipelineLayout(bgl, 2, true);
|
||||
|
||||
{
|
||||
// Adding an extra binding of the maxed type in a different stage works
|
||||
wgpu::BindGroupLayoutEntry newEntry = entry;
|
||||
newEntry.visibility = wgpu::ShaderStage::Fragment;
|
||||
EXPECT_DEPRECATION_WARNING(bgl[1] = utils::MakeBindGroupLayout(device, {newEntry}));
|
||||
TestCreatePipelineLayout(bgl, 2, true);
|
||||
}
|
||||
|
||||
// Adding an extra binding of the maxed type in a different BGL exceeds the per stage limit.
|
||||
EXPECT_DEPRECATION_WARNING(bgl[1] = utils::MakeBindGroupLayout(device, {entry}));
|
||||
TestCreatePipelineLayout(bgl, 2, false);
|
||||
}
|
||||
|
||||
// External textures require multiple binding slots (3 sampled texture, 1 uniform buffer, 1
|
||||
// sampler), so ensure that these count towards the limit when combined non-external texture
|
||||
// bindings.
|
||||
|
||||
@@ -822,11 +822,15 @@ namespace {
|
||||
wgpu::TextureView view = texture.CreateView();
|
||||
|
||||
// Create a bind group to use the texture as sampled and readonly storage bindings
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::TextureSampleType::Float},
|
||||
{1, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bgl;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::TextureSampleType::Float},
|
||||
{1, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::StorageTextureAccess::ReadOnly, kFormat}}));
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
|
||||
|
||||
// Test render pass
|
||||
@@ -1100,9 +1104,13 @@ namespace {
|
||||
wgpu::TextureView view = texture.CreateView();
|
||||
|
||||
// Create bind groups to use the texture as readonly and writeonly bindings
|
||||
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
@@ -1133,9 +1141,13 @@ namespace {
|
||||
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
|
||||
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}});
|
||||
|
||||
@@ -1199,9 +1211,13 @@ namespace {
|
||||
// Test compute pass
|
||||
{
|
||||
// Create bind groups to use the texture as readonly and writeonly storage bindings
|
||||
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
@@ -1270,9 +1286,13 @@ namespace {
|
||||
// Test compute pass
|
||||
{
|
||||
// Create the bind group to use the texture as readonly and writeonly storage bindings
|
||||
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
@@ -1401,9 +1421,13 @@ namespace {
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
|
||||
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}}));
|
||||
|
||||
wgpu::BindGroup writeBG0 = utils::MakeBindGroup(device, writeBGL, {{0, view0}});
|
||||
wgpu::BindGroup readBG0 = utils::MakeBindGroup(device, readBGL, {{0, view0}});
|
||||
@@ -1455,10 +1479,15 @@ namespace {
|
||||
// usage doesn't reside in render related stages at all
|
||||
{
|
||||
// Create a bind group whose bindings are not visible in render pass
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::None, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bgl;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bgl = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::None, wgpu::StorageTextureAccess::WriteOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
|
||||
|
||||
// These two bindings are invisible in render pass. But we still track these bindings.
|
||||
@@ -1474,10 +1503,15 @@ namespace {
|
||||
// usage doesn't reside in compute related stage at all
|
||||
{
|
||||
// Create a bind group whose bindings are not visible in compute pass
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::None, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bgl;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat},
|
||||
{1, wgpu::ShaderStage::None, wgpu::StorageTextureAccess::WriteOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
|
||||
|
||||
// Create a no-op compute pipeline.
|
||||
@@ -1508,9 +1542,13 @@ namespace {
|
||||
utils::ComboRenderPassDescriptor renderPass({view});
|
||||
|
||||
// Create a bind group which use the texture as readonly storage in compute stage
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bgl;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
|
||||
|
||||
// Texture usage in compute stage in bind group conflicts with render target. And
|
||||
@@ -1526,10 +1564,15 @@ namespace {
|
||||
// Test compute pass
|
||||
{
|
||||
// Create a bind group which contains both fragment and compute stages
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bgl;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat},
|
||||
{1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly,
|
||||
kFormat}}));
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
|
||||
|
||||
// Create a no-op compute pipeline.
|
||||
@@ -1556,9 +1599,13 @@ namespace {
|
||||
wgpu::TextureView view = texture.CreateView();
|
||||
|
||||
// Create bind groups.
|
||||
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::StorageTextureAccess::ReadOnly, kFormat}});
|
||||
wgpu::BindGroupLayout readBGL;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
readBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::StorageTextureAccess::ReadOnly, kFormat}}));
|
||||
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
|
||||
wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
|
||||
@@ -111,13 +111,26 @@ class StorageTextureValidationTests : public ValidationTest {
|
||||
wgpu::ShaderModule mDefaultFSModule;
|
||||
|
||||
const std::array<wgpu::StorageTextureAccess, 2> kSupportedStorageTextureAccess = {
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is
|
||||
// passed.
|
||||
wgpu::StorageTextureAccess::ReadOnly, wgpu::StorageTextureAccess::WriteOnly};
|
||||
};
|
||||
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
#define WARNING_IF_READONLY(statement, access) \
|
||||
do { \
|
||||
if (access == wgpu::StorageTextureAccess::ReadOnly) { \
|
||||
EXPECT_DEPRECATION_WARNING(statement); \
|
||||
} else { \
|
||||
statement; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Validate read-only storage textures can be declared in vertex and fragment shaders, while
|
||||
// writeonly storage textures cannot be used in vertex shaders.
|
||||
TEST_F(StorageTextureValidationTests, RenderPipeline) {
|
||||
// Readonly storage texture can be declared in a vertex shader.
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
{
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
|
||||
@@ -131,10 +144,11 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
|
||||
descriptor.layout = nullptr;
|
||||
descriptor.vertex.module = vsModule;
|
||||
descriptor.cFragment.module = mDefaultFSModule;
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
|
||||
}
|
||||
|
||||
// Read-only storage textures can be declared in a fragment shader.
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
{
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
|
||||
@@ -148,7 +162,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
|
||||
descriptor.layout = nullptr;
|
||||
descriptor.vertex.module = mDefaultVSModule;
|
||||
descriptor.cFragment.module = fsModule;
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
|
||||
}
|
||||
|
||||
// Write-only storage textures cannot be declared in a vertex shader.
|
||||
@@ -187,6 +201,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
|
||||
// compute shaders.
|
||||
TEST_F(StorageTextureValidationTests, ComputePipeline) {
|
||||
// Read-only storage textures can be declared in a compute shader.
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
{
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
|
||||
@@ -205,7 +220,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
|
||||
descriptor.compute.module = csModule;
|
||||
descriptor.compute.entryPoint = "main";
|
||||
|
||||
device.CreateComputePipeline(&descriptor);
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateComputePipeline(&descriptor));
|
||||
}
|
||||
|
||||
// Write-only storage textures can be declared in a compute shader.
|
||||
@@ -281,9 +296,10 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingTy
|
||||
descriptor.entries = &entry;
|
||||
|
||||
if (testSpec.valid) {
|
||||
device.CreateBindGroupLayout(&descriptor);
|
||||
WARNING_IF_READONLY(device.CreateBindGroupLayout(&descriptor), testSpec.type);
|
||||
} else {
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor));
|
||||
WARNING_IF_READONLY(ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor)),
|
||||
testSpec.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,8 +429,10 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDecla
|
||||
defaultComputePipelineDescriptor;
|
||||
|
||||
// Create bind group layout with different binding types.
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindingLayoutEntry});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindingLayoutEntry}),
|
||||
bindingLayoutEntry.storageTexture.access);
|
||||
computePipelineDescriptor.layout =
|
||||
utils::MakeBasicPipelineLayout(device, &bindGroupLayout);
|
||||
|
||||
@@ -456,7 +474,8 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroupLayout) {
|
||||
bindGroupLayoutBinding.storageTexture.access = bindingType;
|
||||
bindGroupLayoutBinding.storageTexture.format = textureFormat;
|
||||
if (utils::TextureFormatSupportsStorageTexture(textureFormat)) {
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
WARNING_IF_READONLY(utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
bindingType);
|
||||
} else {
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}));
|
||||
}
|
||||
@@ -498,8 +517,10 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches
|
||||
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
|
||||
bindGroupLayoutBinding.storageTexture.format =
|
||||
storageTextureFormatInBindGroupLayout;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
bindingType);
|
||||
|
||||
// Create the compute pipeline with the bind group layout.
|
||||
wgpu::ComputePipelineDescriptor computePipelineDescriptor =
|
||||
@@ -547,8 +568,10 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutViewDimensionMatchesShaderD
|
||||
// Create the bind group layout with the given texture view dimension.
|
||||
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
|
||||
bindGroupLayoutBinding.storageTexture.viewDimension = dimensionInBindGroupLayout;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
bindingType);
|
||||
|
||||
// Create the compute pipeline with the bind group layout.
|
||||
wgpu::ComputePipelineDescriptor computePipelineDescriptor =
|
||||
@@ -579,8 +602,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureBindingTypeInBindGroup) {
|
||||
bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute;
|
||||
bindGroupLayoutBinding.storageTexture.access = storageBindingType;
|
||||
bindGroupLayoutBinding.storageTexture.format = kStorageTextureFormat;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
storageBindingType);
|
||||
|
||||
// Buffers are not allowed to be used as storage textures in a bind group.
|
||||
{
|
||||
@@ -622,8 +647,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureUsageInBindGroup) {
|
||||
bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute;
|
||||
bindGroupLayoutBinding.storageTexture.access = storageBindingType;
|
||||
bindGroupLayoutBinding.storageTexture.format = wgpu::TextureFormat::R32Float;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
storageBindingType);
|
||||
|
||||
for (wgpu::TextureUsage usage : kTextureUsages) {
|
||||
// Create texture views with different texture usages
|
||||
@@ -659,8 +686,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) {
|
||||
// Create a bind group layout with given storage texture format.
|
||||
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
|
||||
bindGroupLayoutBinding.storageTexture.format = formatInBindGroupLayout;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
storageBindingType);
|
||||
|
||||
for (wgpu::TextureFormat textureViewFormat : utils::kAllTextureFormats) {
|
||||
if (!utils::TextureFormatSupportsStorageTexture(textureViewFormat)) {
|
||||
@@ -714,8 +743,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
|
||||
// Create a bind group layout with given texture view dimension.
|
||||
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
|
||||
bindGroupLayoutBinding.storageTexture.viewDimension = dimensionInBindGroupLayout;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}),
|
||||
storageBindingType);
|
||||
|
||||
for (wgpu::TextureViewDimension dimensionOfTextureView : kSupportedDimensions) {
|
||||
// Create a texture view with given texture view dimension.
|
||||
@@ -760,8 +791,11 @@ TEST_F(StorageTextureValidationTests, StorageTextureInRenderPass) {
|
||||
|
||||
for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
|
||||
// Create a bind group that contains a storage texture.
|
||||
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat}});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat}}),
|
||||
storageTextureType);
|
||||
|
||||
wgpu::BindGroup bindGroupWithStorageTexture =
|
||||
utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}});
|
||||
@@ -791,9 +825,12 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneRender
|
||||
for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
|
||||
// Create a bind group that binds the same texture as both storage texture and sampled
|
||||
// texture.
|
||||
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat},
|
||||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat},
|
||||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}}),
|
||||
storageTextureType);
|
||||
wgpu::BindGroup bindGroup = utils::MakeBindGroup(
|
||||
device, bindGroupLayout,
|
||||
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
|
||||
@@ -829,8 +866,11 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndRenderAttachmentInOneRend
|
||||
|
||||
for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
|
||||
// Create a bind group that contains a storage texture.
|
||||
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat}});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat}}),
|
||||
storageTextureType);
|
||||
wgpu::BindGroup bindGroupWithStorageTexture =
|
||||
utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}});
|
||||
|
||||
@@ -852,9 +892,13 @@ TEST_F(StorageTextureValidationTests, ReadOnlyAndWriteOnlyStorageTextureInOneRen
|
||||
|
||||
// Create a bind group that uses the same texture as both read-only and write-only storage
|
||||
// texture.
|
||||
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, kFormat}}));
|
||||
wgpu::BindGroup bindGroup =
|
||||
utils::MakeBindGroup(device, bindGroupLayout,
|
||||
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
|
||||
@@ -880,9 +924,12 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneComput
|
||||
for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
|
||||
// Create a bind group that binds the same texture as both storage texture and sampled
|
||||
// texture.
|
||||
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, storageTextureType, kFormat},
|
||||
{1, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float}});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
WARNING_IF_READONLY(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, storageTextureType, kFormat},
|
||||
{1, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float}}),
|
||||
storageTextureType);
|
||||
wgpu::BindGroup bindGroup = utils::MakeBindGroup(
|
||||
device, bindGroupLayout,
|
||||
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
|
||||
@@ -905,9 +952,13 @@ TEST_F(StorageTextureValidationTests, ReadOnlyAndWriteOnlyStorageTextureInOneCom
|
||||
|
||||
// Create a bind group that uses the same texture as both read-only and write-only storage
|
||||
// texture.
|
||||
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
|
||||
wgpu::BindGroupLayout bindGroupLayout;
|
||||
// TODO(crbug.com/dawn/1025): Remove once ReadOnly storage texture deprecation period is passed.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bindGroupLayout = utils::MakeBindGroupLayout(
|
||||
device,
|
||||
{{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat},
|
||||
{1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}}));
|
||||
wgpu::BindGroup bindGroup =
|
||||
utils::MakeBindGroup(device, bindGroupLayout,
|
||||
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
|
||||
|
||||
@@ -72,9 +72,11 @@ namespace {
|
||||
{
|
||||
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, samplerView}});
|
||||
|
||||
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kFormat}});
|
||||
wgpu::BindGroupLayout bgl1;
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
bgl1 = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment,
|
||||
wgpu::StorageTextureAccess::ReadOnly, kFormat}}));
|
||||
|
||||
wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, bgl1, {{0, samplerView}});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define EXPECT_DEPRECATION_WARNING(statement) \
|
||||
#define EXPECT_DEPRECATION_WARNINGS(statement, n) \
|
||||
do { \
|
||||
FlushWire(); \
|
||||
size_t warningsBefore = dawn_native::GetDeprecationWarningCountForTesting(backendDevice); \
|
||||
@@ -50,9 +50,10 @@
|
||||
statement; \
|
||||
FlushWire(); \
|
||||
size_t warningsAfter = dawn_native::GetDeprecationWarningCountForTesting(backendDevice); \
|
||||
EXPECT_EQ(warningsAfter, warningsBefore + 1); \
|
||||
EXPECT_EQ(warningsAfter, warningsBefore + n); \
|
||||
mLastWarningCount = warningsAfter; \
|
||||
} while (0)
|
||||
#define EXPECT_DEPRECATION_WARNING(statement) EXPECT_DEPRECATION_WARNINGS(statement, 1)
|
||||
|
||||
namespace utils {
|
||||
class WireHelper;
|
||||
|
||||
Reference in New Issue
Block a user