Move a function to TextureFormatUtils.h|.cpp and rename these two util files
This change moves function ViewDimensionToTextureDimension() to TextureFormatUtils.h|.cpp. This change also renames TextureFormatUtils.h|.cpp to TextureUtils.h|.cpp because the new name makes more sense now. Bug: dawn:547 Change-Id: I183c68d26365a6cda722be55b8ba3556c1b4c82b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57482 Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
3185d9ce1f
commit
9749f5a9f5
|
@ -19,7 +19,7 @@
|
|||
#include "common/Math.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
// The helper struct to configure the copies between buffers and textures.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "common/Constants.h"
|
||||
#include "common/Math.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
// For MinimumBufferSpec bytesPerRow and rowsPerImage, compute a default from the copy extent.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "common/Math.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "common/Math.h"
|
||||
#include "tests/DawnTest.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
constexpr static unsigned int kRTSize = 2;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "common/Math.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class DepthStencilCopyTests : public DawnTest {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "common/Math.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class QueueTests : public DawnTest {};
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "common/Constants.h"
|
||||
#include "common/Math.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
namespace {
|
||||
|
@ -481,20 +481,6 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
|||
return device.CreateBuffer(&descriptor);
|
||||
}
|
||||
|
||||
wgpu::TextureDimension ViewDimensionToTextureDimension(
|
||||
const wgpu::TextureViewDimension dimension) {
|
||||
switch (dimension) {
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
return wgpu::TextureDimension::e2D;
|
||||
case wgpu::TextureViewDimension::e3D:
|
||||
return wgpu::TextureDimension::e3D;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wgpu::Texture CreateTextureWithTestData(
|
||||
const std::vector<uint8_t>& initialTextureData,
|
||||
wgpu::TextureFormat format,
|
||||
|
@ -527,7 +513,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
|||
|
||||
wgpu::Texture outputTexture =
|
||||
CreateTexture(format, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopyDst, kWidth,
|
||||
kHeight, sliceCount, ViewDimensionToTextureDimension(dimension));
|
||||
kHeight, sliceCount, utils::ViewDimensionToTextureDimension(dimension));
|
||||
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
|
@ -1025,9 +1011,9 @@ TEST_P(StorageTextureTests, Writeonly2DArrayOr3DStorageTexture) {
|
|||
|
||||
// Prepare the write-only storage texture.
|
||||
for (wgpu::TextureViewDimension dimension : dimensions) {
|
||||
wgpu::Texture writeonlyStorageTexture =
|
||||
CreateTexture(kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc,
|
||||
kWidth, kHeight, kSliceCount, ViewDimensionToTextureDimension(dimension));
|
||||
wgpu::Texture writeonlyStorageTexture = CreateTexture(
|
||||
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, kWidth,
|
||||
kHeight, kSliceCount, utils::ViewDimensionToTextureDimension(dimension));
|
||||
|
||||
// Write the expected pixel values into the write-only storage texture.
|
||||
const std::string computeShader =
|
||||
|
@ -1060,9 +1046,9 @@ TEST_P(StorageTextureTests, ReadWrite2DArrayOr3DStorageTexture) {
|
|||
wgpu::Texture readonlyStorageTexture =
|
||||
CreateTextureWithTestData(initialTextureData, kTextureFormat, dimension);
|
||||
// Prepare the write-only storage texture.
|
||||
wgpu::Texture writeonlyStorageTexture =
|
||||
CreateTexture(kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc,
|
||||
kWidth, kHeight, kSliceCount, ViewDimensionToTextureDimension(dimension));
|
||||
wgpu::Texture writeonlyStorageTexture = CreateTexture(
|
||||
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, kWidth,
|
||||
kHeight, kSliceCount, utils::ViewDimensionToTextureDimension(dimension));
|
||||
|
||||
// Read values from read-only storage texture and write into the write-only storage texture.
|
||||
const std::string computeShader = CommonReadWriteTestCode(kTextureFormat, dimension);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "common/Assert.h"
|
||||
#include "common/Math.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
#include <cmath>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "common/Math.h"
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class CopyCommandTest : public ValidationTest {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "common/Math.h"
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class CopyTextureForBrowserTest : public ValidationTest {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "common/Math.h"
|
||||
#include "utils/TestUtils.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "common/Assert.h"
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class StorageTextureValidationTests : public ValidationTest {
|
||||
|
@ -718,13 +718,9 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
|
|||
|
||||
for (wgpu::TextureViewDimension dimensionOfTextureView : kSupportedDimensions) {
|
||||
// Create a texture view with given texture view dimension.
|
||||
wgpu::TextureDimension dimension = wgpu::TextureDimension::e2D;
|
||||
if (dimensionOfTextureView == wgpu::TextureViewDimension::e3D) {
|
||||
dimension = wgpu::TextureDimension::e3D;
|
||||
}
|
||||
wgpu::Texture texture =
|
||||
CreateTexture(wgpu::TextureUsage::Storage, kStorageTextureFormat, 1,
|
||||
kDepthOrArrayLayers, dimension);
|
||||
wgpu::Texture texture = CreateTexture(
|
||||
wgpu::TextureUsage::Storage, kStorageTextureFormat, 1, kDepthOrArrayLayers,
|
||||
utils::ViewDimensionToTextureDimension(dimensionOfTextureView));
|
||||
|
||||
wgpu::TextureViewDescriptor textureViewDescriptor = kDefaultTextureViewDescriptor;
|
||||
textureViewDescriptor.dimension = dimensionOfTextureView;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "common/Constants.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -78,8 +78,8 @@ static_library("dawn_utils") {
|
|||
"TerribleCommandBuffer.h",
|
||||
"TestUtils.cpp",
|
||||
"TestUtils.h",
|
||||
"TextureFormatUtils.cpp",
|
||||
"TextureFormatUtils.h",
|
||||
"TextureUtils.cpp",
|
||||
"TextureUtils.h",
|
||||
"Timer.h",
|
||||
"WGPUHelpers.cpp",
|
||||
"WGPUHelpers.h",
|
||||
|
|
|
@ -27,8 +27,8 @@ target_sources(dawn_utils PRIVATE
|
|||
"TerribleCommandBuffer.h"
|
||||
"TestUtils.cpp"
|
||||
"TestUtils.h"
|
||||
"TextureFormatUtils.cpp"
|
||||
"TextureFormatUtils.h"
|
||||
"TextureUtils.cpp"
|
||||
"TextureUtils.h"
|
||||
"Timer.h"
|
||||
"WGPUHelpers.cpp"
|
||||
"WGPUHelpers.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
#include "common/Math.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "TextureFormatUtils.h"
|
||||
#include "TextureUtils.h"
|
||||
|
||||
namespace utils {
|
||||
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format) {
|
||||
|
@ -379,4 +379,22 @@ namespace utils {
|
|||
}
|
||||
}
|
||||
|
||||
wgpu::TextureDimension ViewDimensionToTextureDimension(
|
||||
const wgpu::TextureViewDimension dimension) {
|
||||
switch (dimension) {
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return wgpu::TextureDimension::e2D;
|
||||
case wgpu::TextureViewDimension::e3D:
|
||||
return wgpu::TextureDimension::e3D;
|
||||
// TODO(crbug.com/dawn/814): Implement for 1D texture.
|
||||
case wgpu::TextureViewDimension::e1D:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace utils
|
|
@ -12,8 +12,8 @@
|
|||
// 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_
|
||||
#ifndef UTILS_TEXTURE_UTILS_H_
|
||||
#define UTILS_TEXTURE_UTILS_H_
|
||||
|
||||
#include <array>
|
||||
|
||||
|
@ -95,6 +95,9 @@ namespace utils {
|
|||
|
||||
const char* GetWGSLColorTextureComponentType(wgpu::TextureFormat textureFormat);
|
||||
const char* GetWGSLImageFormatQualifier(wgpu::TextureFormat textureFormat);
|
||||
|
||||
wgpu::TextureDimension ViewDimensionToTextureDimension(
|
||||
const wgpu::TextureViewDimension dimension);
|
||||
} // namespace utils
|
||||
|
||||
#endif
|
|
@ -22,7 +22,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "common/Constants.h"
|
||||
#include "utils/TextureFormatUtils.h"
|
||||
#include "utils/TextureUtils.h"
|
||||
|
||||
namespace utils {
|
||||
|
||||
|
|
Loading…
Reference in New Issue