BufferUploadPerf: Measure various buffer sizes.
Upload perf depends on buffer size. Try small and large buffers to ensure allocation tuning is more accurate. BUG=dawn:208 Change-Id: I1ee23454e86a31cf0a316946bc87550dad51e5c2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11961 Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
8bde031abe
commit
3b05a6e031
|
@ -20,19 +20,32 @@
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr unsigned int kNumIterations = 50;
|
constexpr unsigned int kNumIterations = 50;
|
||||||
constexpr uint32_t kBufferSize = 1024 * 1024;
|
|
||||||
|
|
||||||
enum class UploadMethod {
|
enum class UploadMethod {
|
||||||
SetSubData,
|
SetSubData,
|
||||||
CreateBufferMapped,
|
CreateBufferMapped,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Perf delta exists between ranges [0, 1MB] vs [1MB, MAX_SIZE).
|
||||||
|
// These are sample buffer sizes within each range.
|
||||||
|
enum class UploadSize {
|
||||||
|
BufferSize_1KB = 1 * 1024,
|
||||||
|
BufferSize_64KB = 64 * 1024,
|
||||||
|
BufferSize_1MB = 1 * 1024 * 1024,
|
||||||
|
|
||||||
|
BufferSize_4MB = 4 * 1024 * 1024,
|
||||||
|
BufferSize_16MB = 16 * 1024 * 1024,
|
||||||
|
};
|
||||||
|
|
||||||
struct BufferUploadParams : DawnTestParam {
|
struct BufferUploadParams : DawnTestParam {
|
||||||
BufferUploadParams(const DawnTestParam& param, UploadMethod uploadMethod)
|
BufferUploadParams(const DawnTestParam& param,
|
||||||
: DawnTestParam(param), uploadMethod(uploadMethod) {
|
UploadMethod uploadMethod,
|
||||||
|
UploadSize uploadSize)
|
||||||
|
: DawnTestParam(param), uploadMethod(uploadMethod), uploadSize(uploadSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadMethod uploadMethod;
|
UploadMethod uploadMethod;
|
||||||
|
UploadSize uploadSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& ostream, const BufferUploadParams& param) {
|
std::ostream& operator<<(std::ostream& ostream, const BufferUploadParams& param) {
|
||||||
|
@ -46,6 +59,25 @@ namespace {
|
||||||
ostream << "_CreateBufferMapped";
|
ostream << "_CreateBufferMapped";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (param.uploadSize) {
|
||||||
|
case UploadSize::BufferSize_1KB:
|
||||||
|
ostream << "_BufferSize_1KB";
|
||||||
|
break;
|
||||||
|
case UploadSize::BufferSize_64KB:
|
||||||
|
ostream << "_BufferSize_64KB";
|
||||||
|
break;
|
||||||
|
case UploadSize::BufferSize_1MB:
|
||||||
|
ostream << "_BufferSize_1MB";
|
||||||
|
break;
|
||||||
|
case UploadSize::BufferSize_4MB:
|
||||||
|
ostream << "_BufferSize_4MB";
|
||||||
|
break;
|
||||||
|
case UploadSize::BufferSize_16MB:
|
||||||
|
ostream << "_BufferSize_16MB";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return ostream;
|
return ostream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +86,8 @@ namespace {
|
||||||
// Test uploading |kBufferSize| bytes of data |kNumIterations| times.
|
// Test uploading |kBufferSize| bytes of data |kNumIterations| times.
|
||||||
class BufferUploadPerf : public DawnPerfTestWithParams<BufferUploadParams> {
|
class BufferUploadPerf : public DawnPerfTestWithParams<BufferUploadParams> {
|
||||||
public:
|
public:
|
||||||
BufferUploadPerf() : DawnPerfTestWithParams(kNumIterations), data(kBufferSize) {
|
BufferUploadPerf()
|
||||||
|
: DawnPerfTestWithParams(kNumIterations), data(static_cast<size_t>(GetParam().uploadSize)) {
|
||||||
}
|
}
|
||||||
~BufferUploadPerf() override = default;
|
~BufferUploadPerf() override = default;
|
||||||
|
|
||||||
|
@ -71,7 +104,7 @@ void BufferUploadPerf::TestSetUp() {
|
||||||
DawnPerfTestWithParams<BufferUploadParams>::TestSetUp();
|
DawnPerfTestWithParams<BufferUploadParams>::TestSetUp();
|
||||||
|
|
||||||
dawn::BufferDescriptor desc = {};
|
dawn::BufferDescriptor desc = {};
|
||||||
desc.size = kBufferSize;
|
desc.size = data.size();
|
||||||
desc.usage = dawn::BufferUsage::CopyDst;
|
desc.usage = dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
dst = device.CreateBuffer(&desc);
|
dst = device.CreateBuffer(&desc);
|
||||||
|
@ -81,7 +114,7 @@ void BufferUploadPerf::Step() {
|
||||||
switch (GetParam().uploadMethod) {
|
switch (GetParam().uploadMethod) {
|
||||||
case UploadMethod::SetSubData: {
|
case UploadMethod::SetSubData: {
|
||||||
for (unsigned int i = 0; i < kNumIterations; ++i) {
|
for (unsigned int i = 0; i < kNumIterations; ++i) {
|
||||||
dst.SetSubData(0, kBufferSize, data.data());
|
dst.SetSubData(0, data.size(), data.data());
|
||||||
}
|
}
|
||||||
// Make sure all SetSubData's are flushed.
|
// Make sure all SetSubData's are flushed.
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
@ -89,16 +122,16 @@ void BufferUploadPerf::Step() {
|
||||||
|
|
||||||
case UploadMethod::CreateBufferMapped: {
|
case UploadMethod::CreateBufferMapped: {
|
||||||
dawn::BufferDescriptor desc = {};
|
dawn::BufferDescriptor desc = {};
|
||||||
desc.size = kBufferSize;
|
desc.size = data.size();
|
||||||
desc.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite;
|
desc.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite;
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < kNumIterations; ++i) {
|
for (unsigned int i = 0; i < kNumIterations; ++i) {
|
||||||
auto result = device.CreateBufferMapped(&desc);
|
auto result = device.CreateBufferMapped(&desc);
|
||||||
memcpy(result.data, data.data(), kBufferSize);
|
memcpy(result.data, data.data(), data.size());
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
encoder.CopyBufferToBuffer(result.buffer, 0, dst, 0, kBufferSize);
|
encoder.CopyBufferToBuffer(result.buffer, 0, dst, 0, data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
|
@ -114,9 +147,16 @@ void BufferUploadPerf::Step() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BufferUploadPerf, Run) {
|
TEST_P(BufferUploadPerf, Run) {
|
||||||
|
// TODO(crbug.com/dawn/239): Investigate why large buffer uploads via SetSubData fail on Metal.
|
||||||
|
DAWN_SKIP_TEST_IF(IsMetal() && GetParam().uploadMethod == UploadMethod::SetSubData &&
|
||||||
|
GetParam().uploadSize == UploadSize::BufferSize_16MB);
|
||||||
|
|
||||||
RunTest();
|
RunTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_PERF_TEST_SUITE_P(BufferUploadPerf,
|
DAWN_INSTANTIATE_PERF_TEST_SUITE_P(BufferUploadPerf,
|
||||||
{D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend},
|
{D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend},
|
||||||
{UploadMethod::SetSubData, UploadMethod::CreateBufferMapped});
|
{UploadMethod::SetSubData, UploadMethod::CreateBufferMapped},
|
||||||
|
{UploadSize::BufferSize_1KB, UploadSize::BufferSize_64KB,
|
||||||
|
UploadSize::BufferSize_1MB, UploadSize::BufferSize_4MB,
|
||||||
|
UploadSize::BufferSize_16MB});
|
||||||
|
|
Loading…
Reference in New Issue