Refactors RenderPassLoadOpTests to adhere to new limit.
Bug: dawn:1522 Change-Id: I856bad3d2930d276f1b8b281a7692d38dc82cf21 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113900 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Loko Kung <lokokung@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
fbb339ff97
commit
5646acbd71
|
@ -13,8 +13,11 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "dawn/tests/DawnTest.h"
|
#include "dawn/tests/DawnTest.h"
|
||||||
|
|
||||||
|
@ -464,109 +467,13 @@ TEST_P(RenderPassLoadOpTests, LoadOpClearNormalizedFormatsOutOfBound) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test clearing multiple color attachments with different big integers can still work correctly.
|
// Test clearing multiple color attachments with different big signed and unsigned integers can
|
||||||
// TODO(dawn:1522) Refactor and fix this test to avoid deprecation warnings.
|
// still work correctly.
|
||||||
TEST_P(RenderPassLoadOpTests, LoadOpClearWithBigInt32ValuesOnMultipleColorAttachments) {
|
TEST_P(RenderPassLoadOpTests, LoadOpClearWithBig32BitIntegralValuesOnMultipleColorAttachments) {
|
||||||
constexpr int32_t kMaxInt32RepresentableInFloat = 1 << std::numeric_limits<float>::digits;
|
constexpr int32_t kMaxInt32RepresentableInFloat = 1 << std::numeric_limits<float>::digits;
|
||||||
constexpr int32_t kMinInt32RepresentableInFloat = -kMaxInt32RepresentableInFloat;
|
constexpr int32_t kMinInt32RepresentableInFloat = -kMaxInt32RepresentableInFloat;
|
||||||
|
|
||||||
using TestCase = std::tuple<wgpu::TextureFormat, wgpu::Color, std::array<int32_t, 4>>;
|
constexpr uint32_t kMaxUInt32RepresentableInFloat = 1 << std::numeric_limits<float>::digits;
|
||||||
|
|
||||||
constexpr std::array<TestCase, kMaxColorAttachments> kTestCases = {{
|
|
||||||
{wgpu::TextureFormat::R32Sint,
|
|
||||||
{kMaxInt32RepresentableInFloat, 0, 0, 0},
|
|
||||||
{kMaxInt32RepresentableInFloat, 0, 0, 0}},
|
|
||||||
{wgpu::TextureFormat::R32Sint,
|
|
||||||
{kMaxInt32RepresentableInFloat + 1, 0, 0, 0},
|
|
||||||
{kMaxInt32RepresentableInFloat + 1, 0, 0, 0}},
|
|
||||||
{wgpu::TextureFormat::R32Sint,
|
|
||||||
{kMinInt32RepresentableInFloat, 0, 0, 0},
|
|
||||||
{kMinInt32RepresentableInFloat, 0, 0, 0}},
|
|
||||||
{wgpu::TextureFormat::R32Sint,
|
|
||||||
{kMinInt32RepresentableInFloat - 1, 0, 0, 0},
|
|
||||||
{kMinInt32RepresentableInFloat - 1, 0, 0, 0}},
|
|
||||||
{wgpu::TextureFormat::RG32Sint,
|
|
||||||
{kMaxInt32RepresentableInFloat, kMaxInt32RepresentableInFloat + 1, 0, 0},
|
|
||||||
{kMaxInt32RepresentableInFloat, kMaxInt32RepresentableInFloat + 1, 0, 0}},
|
|
||||||
{wgpu::TextureFormat::RG32Sint,
|
|
||||||
{kMinInt32RepresentableInFloat, kMinInt32RepresentableInFloat - 1, 0, 0},
|
|
||||||
{kMinInt32RepresentableInFloat, kMinInt32RepresentableInFloat - 1, 0, 0}},
|
|
||||||
{wgpu::TextureFormat::RGBA32Sint,
|
|
||||||
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
|
||||||
kMaxInt32RepresentableInFloat + 1, kMinInt32RepresentableInFloat - 1},
|
|
||||||
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
|
||||||
kMaxInt32RepresentableInFloat + 1, kMinInt32RepresentableInFloat - 1}},
|
|
||||||
{wgpu::TextureFormat::RGBA32Sint,
|
|
||||||
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
|
||||||
kMaxInt32RepresentableInFloat - 1, kMinInt32RepresentableInFloat + 1},
|
|
||||||
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
|
||||||
kMaxInt32RepresentableInFloat - 1, kMinInt32RepresentableInFloat + 1}},
|
|
||||||
}};
|
|
||||||
|
|
||||||
std::array<wgpu::Texture, kMaxColorAttachments> textures;
|
|
||||||
|
|
||||||
wgpu::TextureDescriptor textureDescriptor = {};
|
|
||||||
textureDescriptor.size = {1, 1, 1};
|
|
||||||
textureDescriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment;
|
|
||||||
|
|
||||||
std::array<wgpu::RenderPassColorAttachment, kMaxColorAttachments> colorAttachmentsInfo;
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
|
||||||
textureDescriptor.format = std::get<0>(kTestCases[i]);
|
|
||||||
textures[i] = device.CreateTexture(&textureDescriptor);
|
|
||||||
|
|
||||||
colorAttachmentsInfo[i].view = textures[i].CreateView();
|
|
||||||
colorAttachmentsInfo[i].loadOp = wgpu::LoadOp::Clear;
|
|
||||||
colorAttachmentsInfo[i].storeOp = wgpu::StoreOp::Store;
|
|
||||||
colorAttachmentsInfo[i].clearValue = std::get<1>(kTestCases[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
wgpu::RenderPassDescriptor renderPassDescriptor = {};
|
|
||||||
renderPassDescriptor.colorAttachmentCount = kMaxColorAttachments;
|
|
||||||
renderPassDescriptor.colorAttachments = colorAttachmentsInfo.data();
|
|
||||||
wgpu::RenderPassEncoder renderPass;
|
|
||||||
if (HasToggleEnabled("apply_clear_big_integer_color_value_with_draw")) {
|
|
||||||
// When the toggle is enabled, an extra internal pipeline is created which will hit the same
|
|
||||||
// deprecation issue again, hence we need to check for 2 warnings instead of 1.
|
|
||||||
EXPECT_DEPRECATION_WARNINGS(renderPass = encoder.BeginRenderPass(&renderPassDescriptor), 2);
|
|
||||||
} else {
|
|
||||||
EXPECT_DEPRECATION_WARNING(renderPass = encoder.BeginRenderPass(&renderPassDescriptor));
|
|
||||||
}
|
|
||||||
renderPass.End();
|
|
||||||
|
|
||||||
std::array<wgpu::Buffer, kMaxColorAttachments> outputBuffers;
|
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
|
||||||
wgpu::BufferDescriptor bufferDescriptor = {};
|
|
||||||
bufferDescriptor.size = sizeof(int32_t) * 4;
|
|
||||||
bufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
|
||||||
outputBuffers[i] = device.CreateBuffer(&bufferDescriptor);
|
|
||||||
|
|
||||||
wgpu::ImageCopyTexture imageCopyTexture =
|
|
||||||
utils::CreateImageCopyTexture(textures[i], 0, {0, 0, 0});
|
|
||||||
wgpu::ImageCopyBuffer imageCopyBuffer =
|
|
||||||
utils::CreateImageCopyBuffer(outputBuffers[i], 0, kTextureBytesPerRowAlignment);
|
|
||||||
encoder.CopyTextureToBuffer(&imageCopyTexture, &imageCopyBuffer, &textureDescriptor.size);
|
|
||||||
}
|
|
||||||
|
|
||||||
wgpu::CommandBuffer commandBuffer = encoder.Finish();
|
|
||||||
queue.Submit(1, &commandBuffer);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
|
||||||
const uint8_t* expected =
|
|
||||||
reinterpret_cast<const uint8_t*>(std::get<2>(kTestCases[i]).data());
|
|
||||||
EXPECT_BUFFER_U8_RANGE_EQ(expected, outputBuffers[i], 0,
|
|
||||||
sizeof(std::get<2>(kTestCases[i])));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test clearing multiple color attachments with different big unsigned integers can still work
|
|
||||||
// correctly.
|
|
||||||
// TODO(dawn:1522) Refactor and fix this test to avoid deprecation warnings.
|
|
||||||
TEST_P(RenderPassLoadOpTests, LoadOpClearWithBigUInt32ValuesOnMultipleColorAttachments) {
|
|
||||||
constexpr int32_t kMaxUInt32RepresentableInFloat = 1 << std::numeric_limits<float>::digits;
|
|
||||||
|
|
||||||
using TestCase = std::tuple<wgpu::TextureFormat, wgpu::Color, std::array<uint32_t, 4>>;
|
|
||||||
|
|
||||||
std::array<float, 4> testColorForRGBA32Float = {
|
std::array<float, 4> testColorForRGBA32Float = {
|
||||||
kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat - 1,
|
kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat - 1,
|
||||||
kMaxUInt32RepresentableInFloat - 2, kMaxUInt32RepresentableInFloat - 3};
|
kMaxUInt32RepresentableInFloat - 2, kMaxUInt32RepresentableInFloat - 3};
|
||||||
|
@ -575,105 +482,166 @@ TEST_P(RenderPassLoadOpTests, LoadOpClearWithBigUInt32ValuesOnMultipleColorAttac
|
||||||
expectedDataForRGBA32Float[i] = *(reinterpret_cast<uint32_t*>(&testColorForRGBA32Float[i]));
|
expectedDataForRGBA32Float[i] = *(reinterpret_cast<uint32_t*>(&testColorForRGBA32Float[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::array<TestCase, kMaxColorAttachments> kTestCases = {{
|
struct AttachmentCase {
|
||||||
{wgpu::TextureFormat::R32Uint,
|
static AttachmentCase Int(wgpu::TextureFormat format,
|
||||||
|
wgpu::Color clearValue,
|
||||||
|
const std::array<int32_t, 4> expData) {
|
||||||
|
AttachmentCase attachmentCase;
|
||||||
|
static_assert(sizeof(int32_t) * expData.size() == sizeof(attachmentCase.mExpData));
|
||||||
|
attachmentCase.mFormat = format;
|
||||||
|
attachmentCase.mClearValue = clearValue;
|
||||||
|
memcpy(attachmentCase.mExpData, reinterpret_cast<const uint8_t*>(expData.data()),
|
||||||
|
sizeof(attachmentCase.mExpData));
|
||||||
|
return attachmentCase;
|
||||||
|
}
|
||||||
|
static AttachmentCase Uint(wgpu::TextureFormat format,
|
||||||
|
wgpu::Color clearValue,
|
||||||
|
const std::array<uint32_t, 4> expData) {
|
||||||
|
AttachmentCase attachmentCase;
|
||||||
|
static_assert(sizeof(uint32_t) * expData.size() == sizeof(attachmentCase.mExpData));
|
||||||
|
attachmentCase.mFormat = format;
|
||||||
|
attachmentCase.mClearValue = clearValue;
|
||||||
|
memcpy(attachmentCase.mExpData, reinterpret_cast<const uint8_t*>(expData.data()),
|
||||||
|
sizeof(attachmentCase.mExpData));
|
||||||
|
return attachmentCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
wgpu::TextureFormat mFormat;
|
||||||
|
wgpu::Color mClearValue;
|
||||||
|
uint8_t mExpData[16];
|
||||||
|
};
|
||||||
|
using TestCase = std::vector<AttachmentCase>;
|
||||||
|
// Test cases are split so that the attachments in each case do not exceed the default
|
||||||
|
// maxColorAttachmentBytesPerSample.
|
||||||
|
static std::vector<TestCase> kTestCases = {
|
||||||
|
// Full 8 attachment case (Signed 1 and 2 components).
|
||||||
|
{AttachmentCase::Int(wgpu::TextureFormat::R32Sint, {kMaxInt32RepresentableInFloat, 0, 0, 0},
|
||||||
|
{kMaxInt32RepresentableInFloat, 0, 0, 0}),
|
||||||
|
AttachmentCase::Int(wgpu::TextureFormat::R32Sint,
|
||||||
|
{kMaxInt32RepresentableInFloat + 1, 0, 0, 0},
|
||||||
|
{kMaxInt32RepresentableInFloat + 1, 0, 0, 0}),
|
||||||
|
AttachmentCase::Int(wgpu::TextureFormat::R32Sint, {kMinInt32RepresentableInFloat, 0, 0, 0},
|
||||||
|
{kMinInt32RepresentableInFloat, 0, 0, 0}),
|
||||||
|
AttachmentCase::Int(wgpu::TextureFormat::R32Sint,
|
||||||
|
{kMinInt32RepresentableInFloat - 1, 0, 0, 0},
|
||||||
|
{kMinInt32RepresentableInFloat - 1, 0, 0, 0}),
|
||||||
|
AttachmentCase::Int(
|
||||||
|
wgpu::TextureFormat::RG32Sint,
|
||||||
|
{kMaxInt32RepresentableInFloat, kMaxInt32RepresentableInFloat + 1, 0, 0},
|
||||||
|
{kMaxInt32RepresentableInFloat, kMaxInt32RepresentableInFloat + 1, 0, 0}),
|
||||||
|
AttachmentCase::Int(
|
||||||
|
wgpu::TextureFormat::RG32Sint,
|
||||||
|
{kMinInt32RepresentableInFloat, kMinInt32RepresentableInFloat - 1, 0, 0},
|
||||||
|
{kMinInt32RepresentableInFloat, kMinInt32RepresentableInFloat - 1, 0, 0})},
|
||||||
|
|
||||||
|
// Signed 4 components.
|
||||||
|
{AttachmentCase::Int(
|
||||||
|
wgpu::TextureFormat::RGBA32Sint,
|
||||||
|
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
||||||
|
kMaxInt32RepresentableInFloat + 1, kMinInt32RepresentableInFloat - 1},
|
||||||
|
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
||||||
|
kMaxInt32RepresentableInFloat + 1, kMinInt32RepresentableInFloat - 1}),
|
||||||
|
AttachmentCase::Int(
|
||||||
|
wgpu::TextureFormat::RGBA32Sint,
|
||||||
|
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
||||||
|
kMaxInt32RepresentableInFloat - 1, kMinInt32RepresentableInFloat + 1},
|
||||||
|
{kMaxInt32RepresentableInFloat, kMinInt32RepresentableInFloat,
|
||||||
|
kMaxInt32RepresentableInFloat - 1, kMinInt32RepresentableInFloat + 1})},
|
||||||
|
|
||||||
|
// Unsigned 1 components.
|
||||||
|
{AttachmentCase::Uint(wgpu::TextureFormat::R32Uint,
|
||||||
{kMaxUInt32RepresentableInFloat, 0, 0, 0},
|
{kMaxUInt32RepresentableInFloat, 0, 0, 0},
|
||||||
{kMaxUInt32RepresentableInFloat, 0, 0, 0}},
|
{kMaxUInt32RepresentableInFloat, 0, 0, 0}),
|
||||||
{wgpu::TextureFormat::R32Uint,
|
AttachmentCase::Uint(wgpu::TextureFormat::R32Uint,
|
||||||
{kMaxUInt32RepresentableInFloat + 1, 0, 0, 0},
|
{kMaxUInt32RepresentableInFloat + 1, 0, 0, 0},
|
||||||
{kMaxUInt32RepresentableInFloat + 1, 0, 0, 0}},
|
{kMaxUInt32RepresentableInFloat + 1, 0, 0, 0})},
|
||||||
{wgpu::TextureFormat::RG32Uint,
|
|
||||||
|
// Unsigned 2 components.
|
||||||
|
{AttachmentCase::Uint(
|
||||||
|
wgpu::TextureFormat::RG32Uint,
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat, 0, 0},
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat, 0, 0},
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat, 0, 0}},
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat, 0, 0}),
|
||||||
{wgpu::TextureFormat::RG32Uint,
|
AttachmentCase::Uint(
|
||||||
|
wgpu::TextureFormat::RG32Uint,
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1, 0, 0},
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1, 0, 0},
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1, 0, 0}},
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1, 0, 0})},
|
||||||
{wgpu::TextureFormat::RGBA32Uint,
|
|
||||||
|
// Unsigned 4 component expectations (with use of signed inputs).
|
||||||
|
{AttachmentCase::Uint(
|
||||||
|
wgpu::TextureFormat::RGBA32Uint,
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1,
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1,
|
||||||
kMaxUInt32RepresentableInFloat - 1, kMaxUInt32RepresentableInFloat - 2},
|
kMaxUInt32RepresentableInFloat - 1, kMaxUInt32RepresentableInFloat - 2},
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1,
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat + 1,
|
||||||
kMaxUInt32RepresentableInFloat - 1, kMaxUInt32RepresentableInFloat - 2}},
|
kMaxUInt32RepresentableInFloat - 1, kMaxUInt32RepresentableInFloat - 2}),
|
||||||
{wgpu::TextureFormat::RGBA32Sint,
|
AttachmentCase::Uint(
|
||||||
|
wgpu::TextureFormat::RGBA32Sint,
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat - 1,
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat - 1,
|
||||||
kMaxUInt32RepresentableInFloat - 2, kMaxUInt32RepresentableInFloat - 3},
|
kMaxUInt32RepresentableInFloat - 2, kMaxUInt32RepresentableInFloat - 3},
|
||||||
{static_cast<int32_t>(kMaxUInt32RepresentableInFloat),
|
{static_cast<int32_t>(kMaxUInt32RepresentableInFloat),
|
||||||
static_cast<int32_t>(kMaxUInt32RepresentableInFloat - 1),
|
static_cast<int32_t>(kMaxUInt32RepresentableInFloat - 1),
|
||||||
static_cast<int32_t>(kMaxUInt32RepresentableInFloat - 2),
|
static_cast<int32_t>(kMaxUInt32RepresentableInFloat - 2),
|
||||||
static_cast<int32_t>(kMaxUInt32RepresentableInFloat - 3)}},
|
static_cast<int32_t>(kMaxUInt32RepresentableInFloat - 3)})},
|
||||||
{wgpu::TextureFormat::RGBA32Float,
|
|
||||||
|
// Unsigned 4 component expectations from float.
|
||||||
|
{AttachmentCase::Uint(
|
||||||
|
wgpu::TextureFormat::RGBA32Float,
|
||||||
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat - 1,
|
{kMaxUInt32RepresentableInFloat, kMaxUInt32RepresentableInFloat - 1,
|
||||||
kMaxUInt32RepresentableInFloat - 2, kMaxUInt32RepresentableInFloat - 3},
|
kMaxUInt32RepresentableInFloat - 2, kMaxUInt32RepresentableInFloat - 3},
|
||||||
expectedDataForRGBA32Float},
|
expectedDataForRGBA32Float)}};
|
||||||
{wgpu::TextureFormat::Undefined,
|
|
||||||
{kMaxUInt32RepresentableInFloat + 1, kMaxUInt32RepresentableInFloat + 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}},
|
|
||||||
}};
|
|
||||||
|
|
||||||
std::array<wgpu::Texture, kMaxColorAttachments> textures;
|
for (const TestCase& testCase : kTestCases) {
|
||||||
|
std::vector<wgpu::Texture> textures;
|
||||||
|
std::vector<wgpu::RenderPassColorAttachment> colorAttachmentsInfo;
|
||||||
|
std::vector<wgpu::Buffer> outputBuffers;
|
||||||
|
|
||||||
|
// Initialize the default values for the textures.
|
||||||
wgpu::TextureDescriptor textureDescriptor = {};
|
wgpu::TextureDescriptor textureDescriptor = {};
|
||||||
textureDescriptor.size = {1, 1, 1};
|
textureDescriptor.size = {1, 1, 1};
|
||||||
textureDescriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment;
|
textureDescriptor.usage =
|
||||||
|
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment;
|
||||||
|
|
||||||
std::array<wgpu::RenderPassColorAttachment, kMaxColorAttachments> colorAttachmentsInfo;
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
for (const AttachmentCase& attachmentCase : testCase) {
|
||||||
wgpu::TextureFormat format = std::get<0>(kTestCases[i]);
|
textureDescriptor.format = attachmentCase.mFormat;
|
||||||
if (format == wgpu::TextureFormat::Undefined) {
|
textures.push_back(device.CreateTexture(&textureDescriptor));
|
||||||
textures[i] = nullptr;
|
|
||||||
colorAttachmentsInfo[i].view = nullptr;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
textureDescriptor.format = format;
|
wgpu::RenderPassColorAttachment colorAttachmentInfo = {};
|
||||||
textures[i] = device.CreateTexture(&textureDescriptor);
|
colorAttachmentInfo.view = textures.back().CreateView();
|
||||||
|
colorAttachmentInfo.loadOp = wgpu::LoadOp::Clear;
|
||||||
|
colorAttachmentInfo.storeOp = wgpu::StoreOp::Store;
|
||||||
|
colorAttachmentInfo.clearValue = attachmentCase.mClearValue;
|
||||||
|
colorAttachmentsInfo.push_back(colorAttachmentInfo);
|
||||||
|
|
||||||
colorAttachmentsInfo[i].view = textures[i].CreateView();
|
// Create the output buffer to compare values against.
|
||||||
colorAttachmentsInfo[i].loadOp = wgpu::LoadOp::Clear;
|
wgpu::BufferDescriptor bufferDescriptor = {};
|
||||||
colorAttachmentsInfo[i].storeOp = wgpu::StoreOp::Store;
|
bufferDescriptor.size = sizeof(attachmentCase.mExpData);
|
||||||
colorAttachmentsInfo[i].clearValue = std::get<1>(kTestCases[i]);
|
bufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||||
|
outputBuffers.push_back(device.CreateBuffer(&bufferDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::RenderPassDescriptor renderPassDescriptor = {};
|
wgpu::RenderPassDescriptor renderPassDescriptor = {};
|
||||||
renderPassDescriptor.colorAttachmentCount = kMaxColorAttachments;
|
renderPassDescriptor.colorAttachmentCount = colorAttachmentsInfo.size();
|
||||||
renderPassDescriptor.colorAttachments = colorAttachmentsInfo.data();
|
renderPassDescriptor.colorAttachments = colorAttachmentsInfo.data();
|
||||||
wgpu::RenderPassEncoder renderPass;
|
wgpu::RenderPassEncoder renderPass;
|
||||||
if (HasToggleEnabled("apply_clear_big_integer_color_value_with_draw")) {
|
renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
|
||||||
// When the toggle is enabled, an extra internal pipeline is created which will hit the same
|
|
||||||
// deprecation issue again, hence we need to check for 2 warnings instead of 1.
|
|
||||||
EXPECT_DEPRECATION_WARNINGS(renderPass = encoder.BeginRenderPass(&renderPassDescriptor), 2);
|
|
||||||
} else {
|
|
||||||
EXPECT_DEPRECATION_WARNING(renderPass = encoder.BeginRenderPass(&renderPassDescriptor));
|
|
||||||
}
|
|
||||||
renderPass.End();
|
renderPass.End();
|
||||||
|
|
||||||
std::array<wgpu::Buffer, kMaxColorAttachments> outputBuffers;
|
for (uint32_t i = 0; i < testCase.size(); ++i) {
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
|
||||||
wgpu::TextureFormat format = std::get<0>(kTestCases[i]);
|
|
||||||
if (format == wgpu::TextureFormat::Undefined) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
wgpu::BufferDescriptor bufferDescriptor = {};
|
|
||||||
bufferDescriptor.size = sizeof(int32_t) * 4;
|
|
||||||
bufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
|
||||||
outputBuffers[i] = device.CreateBuffer(&bufferDescriptor);
|
|
||||||
|
|
||||||
wgpu::ImageCopyTexture imageCopyTexture =
|
wgpu::ImageCopyTexture imageCopyTexture =
|
||||||
utils::CreateImageCopyTexture(textures[i], 0, {0, 0, 0});
|
utils::CreateImageCopyTexture(textures[i], 0, {0, 0, 0});
|
||||||
wgpu::ImageCopyBuffer imageCopyBuffer =
|
wgpu::ImageCopyBuffer imageCopyBuffer =
|
||||||
utils::CreateImageCopyBuffer(outputBuffers[i], 0, kTextureBytesPerRowAlignment);
|
utils::CreateImageCopyBuffer(outputBuffers[i], 0, kTextureBytesPerRowAlignment);
|
||||||
encoder.CopyTextureToBuffer(&imageCopyTexture, &imageCopyBuffer, &textureDescriptor.size);
|
encoder.CopyTextureToBuffer(&imageCopyTexture, &imageCopyBuffer,
|
||||||
|
&textureDescriptor.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::CommandBuffer commandBuffer = encoder.Finish();
|
wgpu::CommandBuffer commandBuffer = encoder.Finish();
|
||||||
queue.Submit(1, &commandBuffer);
|
queue.Submit(1, &commandBuffer);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments - 1; ++i) {
|
for (uint32_t i = 0; i < testCase.size(); ++i) {
|
||||||
const uint8_t* expected =
|
EXPECT_BUFFER_U8_RANGE_EQ(testCase.at(i).mExpData, outputBuffers[i], 0,
|
||||||
reinterpret_cast<const uint8_t*>(std::get<2>(kTestCases[i]).data());
|
sizeof(testCase.at(i).mExpData));
|
||||||
EXPECT_BUFFER_U8_RANGE_EQ(expected, outputBuffers[i], 0,
|
}
|
||||||
sizeof(std::get<2>(kTestCases[i])));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue