Query API: Record used query index in command encoder

- There are some methods need to know which query indexes are used in
encoders: endOcclusionQuery, endPipelineStatisticsQuery, resolveQuerySet.
- On Vulkan, we also need to use the used query indexes to reset each
queries between uses. And because the reset command must be called
outside render pass, we need to check whether a query index is writen
twice on command encoder and render/compute encoders.
- Add validation on writeTimestamp for duplicate writes at same index.

Bug: dawn:434
Change-Id: I6d00dd91e565d960246b6d01ad434d2d5c095deb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27561
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
This commit is contained in:
Hao Li
2020-10-21 08:38:31 +00:00
committed by Commit Bot service account
parent 3f6bb08d00
commit e2cbcc9565
7 changed files with 101 additions and 5 deletions

View File

@@ -185,6 +185,14 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnCommandEncoder) {
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to write timestamp to the same index twice on command encoder
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
encoder.WriteTimestamp(timestampQuerySet, 0);
encoder.WriteTimestamp(timestampQuerySet, 0);
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to submit timestamp query with a destroyed query set
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
@@ -241,6 +249,26 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnComputePassEncoder) {
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to write timestamp to the same index twice on compute encoder
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.WriteTimestamp(timestampQuerySet, 0);
pass.WriteTimestamp(timestampQuerySet, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to write timestamp to the same index twice on command encoder and compute encoder
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
encoder.WriteTimestamp(timestampQuerySet, 0);
wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.WriteTimestamp(timestampQuerySet, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to submit timestamp query with a destroyed query set
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
@@ -301,6 +329,26 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnRenderPassEncoder) {
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to write timestamp to the same index twice on command encoder and render encoder
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.WriteTimestamp(timestampQuerySet, 0);
pass.WriteTimestamp(timestampQuerySet, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to write timestamp to the same index twice on command encoder and render encoder
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();
encoder.WriteTimestamp(timestampQuerySet, 0);
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.WriteTimestamp(timestampQuerySet, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Fail to submit timestamp query with a destroyed query set
{
wgpu::CommandEncoder encoder = deviceWithTimestamp.CreateCommandEncoder();