StorageTextureTests: Use textureNumLayers()
Instead of hardcoding the number of array layers Bug: tint:140 Bug: tint:437 Change-Id: Ic9ea6a0e2853d8dbc29a840deff0e6938ff5e4d4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37849 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
be28fe6d99
commit
8268dc3e43
|
@ -285,12 +285,10 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CommonReadOnlyTestCode(wgpu::TextureFormat format,
|
std::string CommonReadOnlyTestCode(wgpu::TextureFormat format, bool is2DArray = false) {
|
||||||
int layerCount = 1,
|
|
||||||
bool is2DArray = false) {
|
|
||||||
// TODO(bclayton): Dynamically retrieve layerCount
|
|
||||||
std::string componentFmt = utils::GetColorTextureComponentWGSLType(format);
|
std::string componentFmt = utils::GetColorTextureComponentWGSLType(format);
|
||||||
auto texelType = "vec4<" + componentFmt + ">";
|
auto texelType = "vec4<" + componentFmt + ">";
|
||||||
|
auto* layerCount = is2DArray ? "textureNumLayers(storageImage0)" : "1";
|
||||||
auto* textureLoad = is2DArray ? "textureLoad(storageImage0, vec2<i32>(x, y), i32(layer))"
|
auto* textureLoad = is2DArray ? "textureLoad(storageImage0, vec2<i32>(x, y), i32(layer))"
|
||||||
: "textureLoad(storageImage0, vec2<i32>(x, y))";
|
: "textureLoad(storageImage0, vec2<i32>(x, y))";
|
||||||
|
|
||||||
|
@ -321,11 +319,10 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
||||||
|
|
||||||
std::string CommonWriteOnlyTestCode(const char* stage,
|
std::string CommonWriteOnlyTestCode(const char* stage,
|
||||||
wgpu::TextureFormat format,
|
wgpu::TextureFormat format,
|
||||||
int layerCount = 1,
|
|
||||||
bool is2DArray = false) {
|
bool is2DArray = false) {
|
||||||
// TODO(bclayton): Dynamically retrieve layerCount
|
|
||||||
std::string componentFmt = utils::GetColorTextureComponentWGSLType(format);
|
std::string componentFmt = utils::GetColorTextureComponentWGSLType(format);
|
||||||
auto texelType = "vec4<" + componentFmt + ">";
|
auto texelType = "vec4<" + componentFmt + ">";
|
||||||
|
auto* layerCount = is2DArray ? "textureNumLayers(storageImage0)" : "1";
|
||||||
auto* textureStore = is2DArray
|
auto* textureStore = is2DArray
|
||||||
? "textureStore(storageImage0, vec2<i32>(x, y), layer, expected)"
|
? "textureStore(storageImage0, vec2<i32>(x, y), layer, expected)"
|
||||||
: "textureStore(storageImage0, vec2<i32>(x, y), expected)";
|
: "textureStore(storageImage0, vec2<i32>(x, y), expected)";
|
||||||
|
@ -351,10 +348,8 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
||||||
return ostream.str();
|
return ostream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CommonReadWriteTestCode(wgpu::TextureFormat format,
|
std::string CommonReadWriteTestCode(wgpu::TextureFormat format, bool is2DArray = false) {
|
||||||
int layerCount = 1,
|
auto* layerCount = is2DArray ? "textureNumLayers(storageImage0)" : "1";
|
||||||
bool is2DArray = false) {
|
|
||||||
// TODO(bclayton): Dynamically retrieve layerCount
|
|
||||||
auto* textureStore = is2DArray ? "textureStore(storageImage0, texcoord, layer, "
|
auto* textureStore = is2DArray ? "textureStore(storageImage0, texcoord, layer, "
|
||||||
"textureLoad(storageImage1, texcoord, layer))"
|
"textureLoad(storageImage1, texcoord, layer))"
|
||||||
: "textureStore(storageImage0, texcoord, "
|
: "textureStore(storageImage0, texcoord, "
|
||||||
|
@ -923,7 +918,7 @@ TEST_P(StorageTextureTests, Readonly2DArrayStorageTexture) {
|
||||||
};
|
};
|
||||||
|
|
||||||
[[set(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer;
|
[[set(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer;
|
||||||
)" << CommonReadOnlyTestCode(kTextureFormat, kArrayLayerCount, true)
|
)" << CommonReadOnlyTestCode(kTextureFormat, true)
|
||||||
<< R"(
|
<< R"(
|
||||||
[[stage(compute)]] fn main() -> void {
|
[[stage(compute)]] fn main() -> void {
|
||||||
if (doTest()) {
|
if (doTest()) {
|
||||||
|
@ -950,8 +945,7 @@ TEST_P(StorageTextureTests, Writeonly2DArrayStorageTexture) {
|
||||||
kWidth, kHeight, kArrayLayerCount);
|
kWidth, kHeight, kArrayLayerCount);
|
||||||
|
|
||||||
// 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 = CommonWriteOnlyTestCode("compute", kTextureFormat, true);
|
||||||
CommonWriteOnlyTestCode("compute", kTextureFormat, kArrayLayerCount, true);
|
|
||||||
WriteIntoStorageTextureInComputePass(writeonlyStorageTexture, computeShader.c_str());
|
WriteIntoStorageTextureInComputePass(writeonlyStorageTexture, computeShader.c_str());
|
||||||
|
|
||||||
// Verify the pixel data in the write-only storage texture is expected.
|
// Verify the pixel data in the write-only storage texture is expected.
|
||||||
|
|
Loading…
Reference in New Issue