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 "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
// The helper struct to configure the copies between buffers and textures.
|
// The helper struct to configure the copies between buffers and textures.
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
// For MinimumBufferSpec bytesPerRow and rowsPerImage, compute a default from the copy extent.
|
// For MinimumBufferSpec bytesPerRow and rowsPerImage, compute a default from the copy extent.
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr static unsigned int kRTSize = 2;
|
constexpr static unsigned int kRTSize = 2;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class DepthStencilCopyTests : public DawnTest {
|
class DepthStencilCopyTests : public DawnTest {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class QueueTests : public DawnTest {};
|
class QueueTests : public DawnTest {};
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -481,20 +481,6 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
||||||
return device.CreateBuffer(&descriptor);
|
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(
|
wgpu::Texture CreateTextureWithTestData(
|
||||||
const std::vector<uint8_t>& initialTextureData,
|
const std::vector<uint8_t>& initialTextureData,
|
||||||
wgpu::TextureFormat format,
|
wgpu::TextureFormat format,
|
||||||
|
@ -527,7 +513,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
||||||
|
|
||||||
wgpu::Texture outputTexture =
|
wgpu::Texture outputTexture =
|
||||||
CreateTexture(format, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopyDst, kWidth,
|
CreateTexture(format, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopyDst, kWidth,
|
||||||
kHeight, sliceCount, ViewDimensionToTextureDimension(dimension));
|
kHeight, sliceCount, utils::ViewDimensionToTextureDimension(dimension));
|
||||||
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
|
@ -1025,9 +1011,9 @@ TEST_P(StorageTextureTests, Writeonly2DArrayOr3DStorageTexture) {
|
||||||
|
|
||||||
// Prepare the write-only storage texture.
|
// Prepare the write-only storage texture.
|
||||||
for (wgpu::TextureViewDimension dimension : dimensions) {
|
for (wgpu::TextureViewDimension dimension : dimensions) {
|
||||||
wgpu::Texture writeonlyStorageTexture =
|
wgpu::Texture writeonlyStorageTexture = CreateTexture(
|
||||||
CreateTexture(kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc,
|
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, kWidth,
|
||||||
kWidth, kHeight, kSliceCount, ViewDimensionToTextureDimension(dimension));
|
kHeight, kSliceCount, utils::ViewDimensionToTextureDimension(dimension));
|
||||||
|
|
||||||
// Write the expected pixel values into the write-only storage texture.
|
// Write the expected pixel values into the write-only storage texture.
|
||||||
const std::string computeShader =
|
const std::string computeShader =
|
||||||
|
@ -1060,9 +1046,9 @@ TEST_P(StorageTextureTests, ReadWrite2DArrayOr3DStorageTexture) {
|
||||||
wgpu::Texture readonlyStorageTexture =
|
wgpu::Texture readonlyStorageTexture =
|
||||||
CreateTextureWithTestData(initialTextureData, kTextureFormat, dimension);
|
CreateTextureWithTestData(initialTextureData, kTextureFormat, dimension);
|
||||||
// Prepare the write-only storage texture.
|
// Prepare the write-only storage texture.
|
||||||
wgpu::Texture writeonlyStorageTexture =
|
wgpu::Texture writeonlyStorageTexture = CreateTexture(
|
||||||
CreateTexture(kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc,
|
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, kWidth,
|
||||||
kWidth, kHeight, kSliceCount, ViewDimensionToTextureDimension(dimension));
|
kHeight, kSliceCount, utils::ViewDimensionToTextureDimension(dimension));
|
||||||
|
|
||||||
// Read values from read-only storage texture and write into the write-only storage texture.
|
// Read values from read-only storage texture and write into the write-only storage texture.
|
||||||
const std::string computeShader = CommonReadWriteTestCode(kTextureFormat, dimension);
|
const std::string computeShader = CommonReadWriteTestCode(kTextureFormat, dimension);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CopyCommandTest : public ValidationTest {
|
class CopyCommandTest : public ValidationTest {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CopyTextureForBrowserTest : public ValidationTest {
|
class CopyTextureForBrowserTest : public ValidationTest {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/TestUtils.h"
|
#include "utils/TestUtils.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class StorageTextureValidationTests : public ValidationTest {
|
class StorageTextureValidationTests : public ValidationTest {
|
||||||
|
@ -718,13 +718,9 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
|
||||||
|
|
||||||
for (wgpu::TextureViewDimension dimensionOfTextureView : kSupportedDimensions) {
|
for (wgpu::TextureViewDimension dimensionOfTextureView : kSupportedDimensions) {
|
||||||
// Create a texture view with given texture view dimension.
|
// Create a texture view with given texture view dimension.
|
||||||
wgpu::TextureDimension dimension = wgpu::TextureDimension::e2D;
|
wgpu::Texture texture = CreateTexture(
|
||||||
if (dimensionOfTextureView == wgpu::TextureViewDimension::e3D) {
|
wgpu::TextureUsage::Storage, kStorageTextureFormat, 1, kDepthOrArrayLayers,
|
||||||
dimension = wgpu::TextureDimension::e3D;
|
utils::ViewDimensionToTextureDimension(dimensionOfTextureView));
|
||||||
}
|
|
||||||
wgpu::Texture texture =
|
|
||||||
CreateTexture(wgpu::TextureUsage::Storage, kStorageTextureFormat, 1,
|
|
||||||
kDepthOrArrayLayers, dimension);
|
|
||||||
|
|
||||||
wgpu::TextureViewDescriptor textureViewDescriptor = kDefaultTextureViewDescriptor;
|
wgpu::TextureViewDescriptor textureViewDescriptor = kDefaultTextureViewDescriptor;
|
||||||
textureViewDescriptor.dimension = dimensionOfTextureView;
|
textureViewDescriptor.dimension = dimensionOfTextureView;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -78,8 +78,8 @@ static_library("dawn_utils") {
|
||||||
"TerribleCommandBuffer.h",
|
"TerribleCommandBuffer.h",
|
||||||
"TestUtils.cpp",
|
"TestUtils.cpp",
|
||||||
"TestUtils.h",
|
"TestUtils.h",
|
||||||
"TextureFormatUtils.cpp",
|
"TextureUtils.cpp",
|
||||||
"TextureFormatUtils.h",
|
"TextureUtils.h",
|
||||||
"Timer.h",
|
"Timer.h",
|
||||||
"WGPUHelpers.cpp",
|
"WGPUHelpers.cpp",
|
||||||
"WGPUHelpers.h",
|
"WGPUHelpers.h",
|
||||||
|
|
|
@ -27,8 +27,8 @@ target_sources(dawn_utils PRIVATE
|
||||||
"TerribleCommandBuffer.h"
|
"TerribleCommandBuffer.h"
|
||||||
"TestUtils.cpp"
|
"TestUtils.cpp"
|
||||||
"TestUtils.h"
|
"TestUtils.h"
|
||||||
"TextureFormatUtils.cpp"
|
"TextureUtils.cpp"
|
||||||
"TextureFormatUtils.h"
|
"TextureUtils.h"
|
||||||
"Timer.h"
|
"Timer.h"
|
||||||
"WGPUHelpers.cpp"
|
"WGPUHelpers.cpp"
|
||||||
"WGPUHelpers.h"
|
"WGPUHelpers.h"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "TextureFormatUtils.h"
|
#include "TextureUtils.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format) {
|
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
|
} // namespace utils
|
|
@ -12,8 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef UTILS_TEXTURE_FORMAT_UTILS_H_
|
#ifndef UTILS_TEXTURE_UTILS_H_
|
||||||
#define UTILS_TEXTURE_FORMAT_UTILS_H_
|
#define UTILS_TEXTURE_UTILS_H_
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -95,6 +95,9 @@ namespace utils {
|
||||||
|
|
||||||
const char* GetWGSLColorTextureComponentType(wgpu::TextureFormat textureFormat);
|
const char* GetWGSLColorTextureComponentType(wgpu::TextureFormat textureFormat);
|
||||||
const char* GetWGSLImageFormatQualifier(wgpu::TextureFormat textureFormat);
|
const char* GetWGSLImageFormatQualifier(wgpu::TextureFormat textureFormat);
|
||||||
|
|
||||||
|
wgpu::TextureDimension ViewDimensionToTextureDimension(
|
||||||
|
const wgpu::TextureViewDimension dimension);
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -22,7 +22,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/TextureFormatUtils.h"
|
#include "utils/TextureUtils.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue