mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 10:25:28 +00:00
Validate the declaration of storage texture format in shader
This patch adds the validation on the storage texture format declared in shaders when we create a rendering or compute pipeline with read-only or write-only storage textures. This patch also fixes a typo in the TextureValidationTest. BUG=dawn:267 TEST=dawn_unittests Change-Id: Id302b4b7803d7e03b57c61de1290cc71ba940e2c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16940 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
2550e96724
commit
971a6233c2
@@ -26,6 +26,8 @@ target_sources(dawn_utils PRIVATE
|
||||
"SystemUtils.h"
|
||||
"TerribleCommandBuffer.cpp"
|
||||
"TerribleCommandBuffer.h"
|
||||
"TextureFormatUtils.cpp"
|
||||
"TextureFormatUtils.h"
|
||||
"Timer.h"
|
||||
"WGPUHelpers.cpp"
|
||||
"WGPUHelpers.h"
|
||||
|
||||
89
src/utils/TextureFormatUtils.cpp
Normal file
89
src/utils/TextureFormatUtils.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 2020 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "TextureFormatUtils.h"
|
||||
|
||||
namespace utils {
|
||||
const char* GetColorTextureComponentTypePrefix(wgpu::TextureFormat textureFormat) {
|
||||
switch (textureFormat) {
|
||||
case wgpu::TextureFormat::R8Unorm:
|
||||
case wgpu::TextureFormat::R8Snorm:
|
||||
case wgpu::TextureFormat::R16Float:
|
||||
case wgpu::TextureFormat::RG8Unorm:
|
||||
case wgpu::TextureFormat::RG8Snorm:
|
||||
case wgpu::TextureFormat::R32Float:
|
||||
case wgpu::TextureFormat::RG16Float:
|
||||
case wgpu::TextureFormat::RGBA8Unorm:
|
||||
case wgpu::TextureFormat::RGBA8Snorm:
|
||||
case wgpu::TextureFormat::RGB10A2Unorm:
|
||||
case wgpu::TextureFormat::RG11B10Float:
|
||||
case wgpu::TextureFormat::RG32Float:
|
||||
case wgpu::TextureFormat::RGBA16Float:
|
||||
case wgpu::TextureFormat::RGBA32Float:
|
||||
case wgpu::TextureFormat::BGRA8Unorm:
|
||||
case wgpu::TextureFormat::BGRA8UnormSrgb:
|
||||
case wgpu::TextureFormat::RGBA8UnormSrgb:
|
||||
return "";
|
||||
|
||||
case wgpu::TextureFormat::R8Uint:
|
||||
case wgpu::TextureFormat::R16Uint:
|
||||
case wgpu::TextureFormat::RG8Uint:
|
||||
case wgpu::TextureFormat::R32Uint:
|
||||
case wgpu::TextureFormat::RG16Uint:
|
||||
case wgpu::TextureFormat::RGBA8Uint:
|
||||
case wgpu::TextureFormat::RG32Uint:
|
||||
case wgpu::TextureFormat::RGBA16Uint:
|
||||
case wgpu::TextureFormat::RGBA32Uint:
|
||||
return "u";
|
||||
|
||||
case wgpu::TextureFormat::R8Sint:
|
||||
case wgpu::TextureFormat::R16Sint:
|
||||
case wgpu::TextureFormat::RG8Sint:
|
||||
case wgpu::TextureFormat::R32Sint:
|
||||
case wgpu::TextureFormat::RG16Sint:
|
||||
case wgpu::TextureFormat::RGBA8Sint:
|
||||
case wgpu::TextureFormat::RG32Sint:
|
||||
case wgpu::TextureFormat::RGBA16Sint:
|
||||
case wgpu::TextureFormat::RGBA32Sint:
|
||||
return "i";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format) {
|
||||
switch (format) {
|
||||
case wgpu::TextureFormat::R32Uint:
|
||||
case wgpu::TextureFormat::R32Sint:
|
||||
case wgpu::TextureFormat::R32Float:
|
||||
case wgpu::TextureFormat::RGBA8Unorm:
|
||||
case wgpu::TextureFormat::RGBA8Snorm:
|
||||
case wgpu::TextureFormat::RGBA8Uint:
|
||||
case wgpu::TextureFormat::RGBA8Sint:
|
||||
case wgpu::TextureFormat::RG32Uint:
|
||||
case wgpu::TextureFormat::RG32Sint:
|
||||
case wgpu::TextureFormat::RG32Float:
|
||||
case wgpu::TextureFormat::RGBA16Uint:
|
||||
case wgpu::TextureFormat::RGBA16Sint:
|
||||
case wgpu::TextureFormat::RGBA16Float:
|
||||
case wgpu::TextureFormat::RGBA32Uint:
|
||||
case wgpu::TextureFormat::RGBA32Sint:
|
||||
case wgpu::TextureFormat::RGBA32Float:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
58
src/utils/TextureFormatUtils.h
Normal file
58
src/utils/TextureFormatUtils.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright 2020 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef UTILS_TEXTURE_FORMAT_UTILS_H_
|
||||
#define UTILS_TEXTURE_FORMAT_UTILS_H_
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <dawn/webgpu_cpp.h>
|
||||
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace utils {
|
||||
static constexpr std::array<wgpu::TextureFormat, 52> kAllTextureFormats = {
|
||||
wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::R8Snorm,
|
||||
wgpu::TextureFormat::R8Uint, wgpu::TextureFormat::R8Sint,
|
||||
wgpu::TextureFormat::R16Uint, wgpu::TextureFormat::R16Sint,
|
||||
wgpu::TextureFormat::R16Float, wgpu::TextureFormat::RG8Unorm,
|
||||
wgpu::TextureFormat::RG8Snorm, wgpu::TextureFormat::RG8Uint,
|
||||
wgpu::TextureFormat::RG8Sint, wgpu::TextureFormat::R32Float,
|
||||
wgpu::TextureFormat::R32Uint, wgpu::TextureFormat::R32Sint,
|
||||
wgpu::TextureFormat::RG16Uint, wgpu::TextureFormat::RG16Sint,
|
||||
wgpu::TextureFormat::RG16Float, wgpu::TextureFormat::RGBA8Unorm,
|
||||
wgpu::TextureFormat::RGBA8UnormSrgb, wgpu::TextureFormat::RGBA8Snorm,
|
||||
wgpu::TextureFormat::RGBA8Uint, wgpu::TextureFormat::RGBA8Sint,
|
||||
wgpu::TextureFormat::BGRA8Unorm, wgpu::TextureFormat::BGRA8UnormSrgb,
|
||||
wgpu::TextureFormat::RGB10A2Unorm, wgpu::TextureFormat::RG11B10Float,
|
||||
wgpu::TextureFormat::RG32Float, wgpu::TextureFormat::RG32Uint,
|
||||
wgpu::TextureFormat::RG32Sint, wgpu::TextureFormat::RGBA16Uint,
|
||||
wgpu::TextureFormat::RGBA16Sint, wgpu::TextureFormat::RGBA16Float,
|
||||
wgpu::TextureFormat::RGBA32Float, wgpu::TextureFormat::RGBA32Uint,
|
||||
wgpu::TextureFormat::RGBA32Sint, wgpu::TextureFormat::Depth32Float,
|
||||
wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
wgpu::TextureFormat::BC1RGBAUnorm, wgpu::TextureFormat::BC1RGBAUnormSrgb,
|
||||
wgpu::TextureFormat::BC2RGBAUnorm, wgpu::TextureFormat::BC2RGBAUnormSrgb,
|
||||
wgpu::TextureFormat::BC3RGBAUnorm, wgpu::TextureFormat::BC3RGBAUnormSrgb,
|
||||
wgpu::TextureFormat::BC4RUnorm, wgpu::TextureFormat::BC4RSnorm,
|
||||
wgpu::TextureFormat::BC5RGUnorm, wgpu::TextureFormat::BC5RGSnorm,
|
||||
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBSfloat,
|
||||
wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb,
|
||||
};
|
||||
|
||||
const char* GetColorTextureComponentTypePrefix(wgpu::TextureFormat textureFormat);
|
||||
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format);
|
||||
} // namespace utils
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user