Revert "Fix dynamic buffer offset issues on D3D12 backend"

This reverts commit 421584173c.

Reason for revert: Some of the newly added tests are failing on Windows NVIDIA GTX 1660

https://ci.chromium.org/p/chromium/builders/ci/Win10%20FYI%20x64%20Release%20%28NVIDIA%20GeForce%20GTX%201660%29/21

Original change's description:
> Fix dynamic buffer offset issues on D3D12 backend
> 
> This patch fixes
> 1. Inherit dynamic buffer offsets : dawn chooses vulkan
> like inherit behaviour, so dynamic offsets need to be inherited.
> This patch adds inherit dynamic offsets between pipelines support and
> adds tests to cover it.
> 
> 2. Dynamic offsets are skipped when groups have been set : in D3D12
> backend, when invoke SetBindGroup, dawn will check whether this group
> has already been set and skip updating root signature if the answer is
> yes. However, this behaviour will affect dynamic offsets update. With
> the latest patch, we always update dynamic offsets, even if they didn't
> change and adds tests to cover it.
> 
> This patch also hit a dawn's issue about storage buffer validation in compute pass.
> Currently the validation is a workaround to avoid access conflicts but will impact
> using dynamic buffer offset in compute pipeline. Fix this issue is hard so disable
> related test for now and will enable it after the issue been fixed. File dawn bug
> 198 to track this
> 
> BUG=dawn:55
> 
> Change-Id: I2b0f179b3555d37d5b350292eb729767b0d60ab6
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9621
> Commit-Queue: Austin Eng <enga@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

TBR=kainino@chromium.org,shaobo.yan@intel.com,enga@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: dawn:55
Change-Id: I018e6fa9b4b0905de602ab4ba3294ef537c53759
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9900
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2019-08-08 22:41:00 +00:00 committed by Commit Bot service account
parent ab8b768d27
commit 42e1bba480
4 changed files with 43 additions and 270 deletions

View File

@ -154,24 +154,21 @@ namespace dawn_native { namespace d3d12 {
uint32_t dynamicOffsetCount,
uint64_t* dynamicOffsets,
bool force = false) {
// Usually, the application won't set the same offsets many times,
// so always try to apply dynamic offsets even if the offsets stay the same
if (dynamicOffsetCount) {
// Update dynamic offsets
const BindGroupLayout::LayoutBindingInfo& layout =
group->GetLayout()->GetBindingInfo();
if (mBindGroups[index] != group || force) {
mBindGroups[index] = group;
uint32_t currentDynamicBufferIndex = 0;
const BindGroupLayout::LayoutBindingInfo& layout =
group->GetLayout()->GetBindingInfo();
for (uint32_t bindingIndex : IterateBitSet(layout.dynamic)) {
ASSERT(dynamicOffsetCount > 0);
uint32_t parameterIndex =
pipelineLayout->GetDynamicRootParameterIndex(index, bindingIndex);
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
// Calculate buffer locations that root descriptors links to. The location
// is (base buffer location + initial offset + dynamic offset)
uint64_t dynamicOffset = dynamicOffsets[currentDynamicBufferIndex];
uint64_t offset = binding.offset + dynamicOffset;
// Calculate buffer locations that root descriptors links to. The location is
// (base buffer location + initial offset + dynamic offset)
uint64_t offset = dynamicOffsets[currentDynamicBufferIndex++] + binding.offset;
D3D12_GPU_VIRTUAL_ADDRESS bufferLocation =
ToBackend(binding.buffer)->GetVA() + offset;
@ -201,15 +198,7 @@ namespace dawn_native { namespace d3d12 {
UNREACHABLE();
break;
}
// Record current dynamic offsets for inheriting
mLastDynamicOffsets[index][currentDynamicBufferIndex] = dynamicOffset;
++currentDynamicBufferIndex;
}
}
if (mBindGroups[index] != group || force) {
mBindGroups[index] = group;
uint32_t cbvUavSrvCount =
ToBackend(group->GetLayout())->GetCbvUavSrvDescriptorCount();
uint32_t samplerCount = ToBackend(group->GetLayout())->GetSamplerDescriptorCount();
@ -255,11 +244,12 @@ namespace dawn_native { namespace d3d12 {
for (uint32_t i = 0; i < inheritUntil; ++i) {
const BindGroupLayout* layout = ToBackend(mBindGroups[i]->GetLayout());
const uint32_t dynamicBufferCount = layout->GetDynamicBufferCount();
// Inherit dynamic offsets
// TODO(shaobo.yan@intel.com) : Need to handle dynamic resources inherited with last
// dynamic offsets.
if (dynamicBufferCount > 0) {
std::vector<uint64_t> zeroOffsets(dynamicBufferCount, 0);
SetBindGroup(commandList, newLayout, mBindGroups[i], i, dynamicBufferCount,
mLastDynamicOffsets[i].data(), true);
zeroOffsets.data(), true);
} else {
SetBindGroup(commandList, newLayout, mBindGroups[i], i, 0, nullptr, true);
}
@ -290,8 +280,6 @@ namespace dawn_native { namespace d3d12 {
uint32_t mSamplerDescriptorHeapSize = 0;
std::array<BindGroup*, kMaxBindGroups> mBindGroups = {};
std::deque<BindGroup*> mBindGroupsList = {};
std::array<std::array<uint64_t, kMaxDynamicBufferCount>, kMaxBindGroups>
mLastDynamicOffsets;
bool mInCompute = false;
DescriptorHeapHandle mCbvSrvUavGPUDescriptorHeap = {};
@ -817,11 +805,9 @@ namespace dawn_native { namespace d3d12 {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
BindGroup* group = ToBackend(cmd->group.Get());
uint64_t* dynamicOffsets = nullptr;
if (cmd->dynamicOffsetCount > 0) {
dynamicOffsets = mCommands.NextData<uint64_t>(cmd->dynamicOffsetCount);
}
bindingTracker->SetBindGroup(commandList, lastLayout, group, cmd->index,
cmd->dynamicOffsetCount, dynamicOffsets);
} break;
@ -1118,7 +1104,6 @@ namespace dawn_native { namespace d3d12 {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
BindGroup* group = ToBackend(cmd->group.Get());
uint64_t* dynamicOffsets = nullptr;
if (cmd->dynamicOffsetCount > 0) {
dynamicOffsets = mCommands.NextData<uint64_t>(cmd->dynamicOffsetCount);
}

View File

@ -165,7 +165,7 @@ namespace dawn_native { namespace d3d12 {
return mSamplerRootParameterInfo[group];
}
ComPtr<ID3D12RootSignature> PipelineLayout::GetRootSignature() const {
ComPtr<ID3D12RootSignature> PipelineLayout::GetRootSignature() {
return mRootSignature;
}

View File

@ -33,7 +33,7 @@ namespace dawn_native { namespace d3d12 {
// Returns the index of the root parameter reserved for a dynamic buffer binding
uint32_t GetDynamicRootParameterIndex(uint32_t group, uint32_t binding) const;
ComPtr<ID3D12RootSignature> GetRootSignature() const;
ComPtr<ID3D12RootSignature> GetRootSignature();
private:
std::array<uint32_t, kMaxBindGroups> mCbvUavSrvRootParameterInfo;

View File

@ -52,7 +52,7 @@ class DynamicBufferOffsetTests : public DawnTest {
mDynamicStorageBuffer = device.CreateBuffer(&storageBufferDescriptor);
mDefaultBindGroupLayout = utils::MakeBindGroupLayout(
mBindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
dawn::BindingType::UniformBuffer},
{1, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
@ -62,9 +62,7 @@ class DynamicBufferOffsetTests : public DawnTest {
{4, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
dawn::BindingType::StorageBuffer, true}});
mDefaultPipelineLayout = utils::MakeBasicPipelineLayout(device, &mDefaultBindGroupLayout);
mBindGroup = utils::MakeBindGroup(device, mDefaultBindGroupLayout,
mBindGroup = utils::MakeBindGroup(device, mBindGroupLayout,
{{0, mUniformBuffer, 0, kBindingSize},
{1, mStorageBuffer, 0, kBindingSize},
{3, mDynamicUniformBuffer, 0, kBindingSize},
@ -73,48 +71,24 @@ class DynamicBufferOffsetTests : public DawnTest {
// Create objects to use as resources inside test bind groups.
dawn::BindGroup mBindGroup;
dawn::BindGroupLayout mDefaultBindGroupLayout;
dawn::PipelineLayout mDefaultPipelineLayout;
dawn::BindGroupLayout mBindGroupLayout;
dawn::Buffer mUniformBuffer;
dawn::Buffer mStorageBuffer;
dawn::Buffer mDynamicUniformBuffer;
dawn::Buffer mDynamicStorageBuffer;
dawn::Texture mColorAttachment;
dawn::ShaderModule CreateDefaultCsModule() {
return utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(std140, set = 0, binding = 0) uniform uBufferNotDynamic {
uvec2 notDynamicValue;
};
layout(std140, set = 0, binding = 1) buffer sBufferNotDynamic {
uvec2 notDynamicResult;
} mid;
layout(std140, set = 0, binding = 3) uniform uBuffer {
uvec2 value;
};
layout(std140, set = 0, binding = 4) buffer SBuffer {
uvec2 result;
} sBuffer;
void main() {
mid.notDynamicResult.xy = notDynamicValue.xy;
sBuffer.result.xy = value.xy + mid.notDynamicResult.xy;
})");
}
dawn::ShaderModule CreateDefaultVsModule() {
return utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
dawn::RenderPipeline CreateRenderPipeline() {
dawn::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, -1.0f), vec2(0.0f, -1.0f));
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
})");
}
dawn::ShaderModule CreateDefaultFsModule() {
return utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
dawn::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(std140, set = 0, binding = 0) uniform uBufferNotDynamic {
uvec2 notDynamicValue;
@ -134,10 +108,21 @@ class DynamicBufferOffsetTests : public DawnTest {
sBuffer.result.xy = value.xy + mid.notDynamicResult.xy;
fragColor = vec4(value.x / 255.0f, value.y / 255.0f, 1.0f, 1.0f);
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.cVertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
pipelineDescriptor.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm;
dawn::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
pipelineDescriptor.layout = pipelineLayout;
return device.CreateRenderPipeline(&pipelineDescriptor);
}
dawn::ShaderModule CreateInheritCsModule() {
return utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
dawn::ComputePipeline CreateComputePipeline() {
dawn::ShaderModule csModule =
utils::CreateShaderModule(device, utils::ShaderStage::Compute, R"(
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(std140, set = 0, binding = 0) uniform uBufferNotDynamic {
@ -152,85 +137,29 @@ class DynamicBufferOffsetTests : public DawnTest {
layout(std140, set = 0, binding = 4) buffer SBuffer {
uvec2 result;
} sBuffer;
layout(std140, set = 1, binding = 0) uniform paddingBlock {
uvec2 padding;
};
void main() {
mid.notDynamicResult.xy = notDynamicValue.xy;
sBuffer.result.xy = 2 * (value.xy + mid.notDynamicResult.xy);
sBuffer.result.xy = value.xy + mid.notDynamicResult.xy;
})");
}
dawn::ShaderModule CreateInheritFsModule() {
return utils::CreateShaderModule(device, utils::ShaderStage::Fragment, R"(
#version 450
layout(std140, set = 0, binding = 0) uniform uBufferNotDynamic {
uvec2 notDynamicValue;
};
layout(std140, set = 0, binding = 1) buffer sBufferNotDynamic {
uvec2 notDynamicResult;
} mid;
layout(std140, set = 0, binding = 3) uniform uBuffer {
uvec2 value;
};
layout(std140, set = 0, binding = 4) buffer SBuffer {
uvec2 result;
} sBuffer;
layout(std140, set = 1, binding = 0) uniform paddingBlock {
uvec2 padding;
};
layout(location = 0) out vec4 fragColor;
void main() {
mid.notDynamicResult.xy = notDynamicValue.xy;
sBuffer.result.xy = 2 * (value.xy + mid.notDynamicResult.xy);
fragColor = vec4(value.x / 255.0f, value.y / 255.0f, 1.0f, 1.0f);
})");
}
dawn::RenderPipeline CreateRenderPipeline(dawn::PipelineLayout layout,
dawn::ShaderModule vs,
dawn::ShaderModule fs) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.cVertexStage.module = vs;
pipelineDescriptor.cFragmentStage.module = fs;
pipelineDescriptor.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm;
pipelineDescriptor.layout = layout;
return device.CreateRenderPipeline(&pipelineDescriptor);
}
dawn::ComputePipeline CreateComputePipeline(dawn::PipelineLayout layout,
dawn::ShaderModule cs) {
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = layout;
dawn::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
csDesc.layout = pipelineLayout;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = cs;
computeStage.module = csModule;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
return device.CreateComputePipeline(&csDesc);
}
dawn::RenderPipeline CreateDefaultRenderPipeline() {
dawn::ShaderModule vs = this->CreateDefaultVsModule();
dawn::ShaderModule fs = this->CreateDefaultFsModule();
return this->CreateRenderPipeline(mDefaultPipelineLayout, vs, fs);
}
dawn::ComputePipeline CreateDefaultComputePipeline() {
dawn::ShaderModule cs = this->CreateDefaultCsModule();
return this->CreateComputePipeline(mDefaultPipelineLayout, cs);
}
};
// Dynamic offsets are all zero and no effect to result.
TEST_P(DynamicBufferOffsetTests, BasicRenderPipeline) {
dawn::RenderPipeline pipeline = CreateDefaultRenderPipeline();
dawn::RenderPipeline pipeline = CreateRenderPipeline();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
@ -251,7 +180,7 @@ TEST_P(DynamicBufferOffsetTests, BasicRenderPipeline) {
// Have non-zero dynamic offsets.
TEST_P(DynamicBufferOffsetTests, SetDynamicOffestsRenderPipeline) {
dawn::RenderPipeline pipeline = CreateDefaultRenderPipeline();
dawn::RenderPipeline pipeline = CreateRenderPipeline();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
@ -274,7 +203,7 @@ TEST_P(DynamicBufferOffsetTests, SetDynamicOffestsRenderPipeline) {
// Dynamic offsets are all zero and no effect to result.
TEST_P(DynamicBufferOffsetTests, BasicComputePipeline) {
dawn::ComputePipeline pipeline = CreateDefaultComputePipeline();
dawn::ComputePipeline pipeline = CreateComputePipeline();
std::array<uint64_t, 2> offsets = {0, 0};
@ -293,7 +222,7 @@ TEST_P(DynamicBufferOffsetTests, BasicComputePipeline) {
// Have non-zero dynamic offsets.
TEST_P(DynamicBufferOffsetTests, SetDynamicOffestsComputePipeline) {
dawn::ComputePipeline pipeline = CreateDefaultComputePipeline();
dawn::ComputePipeline pipeline = CreateComputePipeline();
std::array<uint64_t, 2> offsets = {kMinDynamicBufferOffsetAlignment,
kMinDynamicBufferOffsetAlignment};
@ -312,147 +241,6 @@ TEST_P(DynamicBufferOffsetTests, SetDynamicOffestsComputePipeline) {
kMinDynamicBufferOffsetAlignment, expectedData.size());
}
// Test inherit dynamic offsets on render pipeline
TEST_P(DynamicBufferOffsetTests, InheritDynamicOffestsRenderPipeline) {
// Using default pipeline and setting dynamic offsets
dawn::RenderPipeline pipeline = CreateDefaultRenderPipeline();
dawn::ShaderModule testVs = CreateDefaultVsModule();
dawn::ShaderModule testFs = CreateInheritFsModule();
dawn::BindGroupLayout bgl[2];
bgl[0] = mDefaultBindGroupLayout;
bgl[1] = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}});
dawn::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = 2;
descriptor.bindGroupLayouts = bgl;
dawn::PipelineLayout layout = device.CreatePipelineLayout(&descriptor);
dawn::RenderPipeline testPipeline = CreateRenderPipeline(layout, testVs, testFs);
std::array<uint32_t, kBufferElementsCount> uniformData = {0};
dawn::Buffer uniformBuffer = utils::CreateBufferFromData(
device, uniformData.data(), kBufferSize, dawn::BufferUsageBit::Uniform);
dawn::BindGroup bindGroup =
utils::MakeBindGroup(device, bgl[1], {{0, uniformBuffer, 0, kBindingSize}});
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
std::array<uint64_t, 2> offsets = {kMinDynamicBufferOffsetAlignment,
kMinDynamicBufferOffsetAlignment};
dawn::RenderPassEncoder renderPassEncoder =
commandEncoder.BeginRenderPass(&renderPass.renderPassInfo);
renderPassEncoder.SetPipeline(pipeline);
renderPassEncoder.SetBindGroup(0, mBindGroup, offsets.size(), offsets.data());
renderPassEncoder.Draw(3, 1, 0, 0);
renderPassEncoder.SetPipeline(testPipeline);
renderPassEncoder.SetBindGroup(1, bindGroup, 0, nullptr);
renderPassEncoder.Draw(3, 1, 0, 0);
renderPassEncoder.EndPass();
dawn::CommandBuffer commands = commandEncoder.Finish();
queue.Submit(1, &commands);
std::vector<uint32_t> expectedData = {12, 16};
EXPECT_PIXEL_RGBA8_EQ(RGBA8(5, 6, 255, 255), renderPass.color, 0, 0);
EXPECT_BUFFER_U32_RANGE_EQ(expectedData.data(), mDynamicStorageBuffer,
kMinDynamicBufferOffsetAlignment, expectedData.size());
}
// Test inherit dynamic offsets on compute pipeline
TEST_P(DynamicBufferOffsetTests, InheritDynamicOffestsComputePipeline) {
dawn::ComputePipeline pipeline = CreateDefaultComputePipeline();
dawn::ShaderModule testCs = CreateInheritCsModule();
dawn::BindGroupLayout bgl[2];
bgl[0] = mDefaultBindGroupLayout;
bgl[1] = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStageBit::Compute, dawn::BindingType::UniformBuffer}});
dawn::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = 2;
descriptor.bindGroupLayouts = bgl;
dawn::PipelineLayout layout = device.CreatePipelineLayout(&descriptor);
dawn::ComputePipeline testPipeline = CreateComputePipeline(layout, testCs);
std::array<uint32_t, kBufferElementsCount> uniformData = {0};
dawn::Buffer uniformBuffer = utils::CreateBufferFromData(
device, uniformData.data(), kBufferSize, dawn::BufferUsageBit::Uniform);
dawn::BindGroup bindGroup =
utils::MakeBindGroup(device, bgl[1], {{0, uniformBuffer, 0, kBindingSize}});
std::array<uint64_t, 2> offsets = {kMinDynamicBufferOffsetAlignment,
kMinDynamicBufferOffsetAlignment};
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder computePassEncoder = commandEncoder.BeginComputePass();
computePassEncoder.SetPipeline(pipeline);
computePassEncoder.SetBindGroup(0, mBindGroup, offsets.size(), offsets.data());
computePassEncoder.Dispatch(1, 1, 1);
computePassEncoder.SetPipeline(testPipeline);
computePassEncoder.SetBindGroup(1, bindGroup, 0, nullptr);
computePassEncoder.Dispatch(1, 1, 1);
computePassEncoder.EndPass();
dawn::CommandBuffer commands = commandEncoder.Finish();
queue.Submit(1, &commands);
std::vector<uint32_t> expectedData = {12, 16};
EXPECT_BUFFER_U32_RANGE_EQ(expectedData.data(), mDynamicStorageBuffer,
kMinDynamicBufferOffsetAlignment, expectedData.size());
}
// Setting multiple dynamic offsets for the same bindgroup in one render pass.
TEST_P(DynamicBufferOffsetTests, UpdateDynamicOffestsMultipleTimesRenderPipeline) {
// Using default pipeline and setting dynamic offsets
dawn::RenderPipeline pipeline = CreateDefaultRenderPipeline();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
std::array<uint64_t, 2> offsets = {kMinDynamicBufferOffsetAlignment,
kMinDynamicBufferOffsetAlignment};
std::array<uint64_t, 2> testOffsets = {0, 0};
dawn::RenderPassEncoder renderPassEncoder =
commandEncoder.BeginRenderPass(&renderPass.renderPassInfo);
renderPassEncoder.SetPipeline(pipeline);
renderPassEncoder.SetBindGroup(0, mBindGroup, offsets.size(), offsets.data());
renderPassEncoder.Draw(3, 1, 0, 0);
renderPassEncoder.SetBindGroup(0, mBindGroup, testOffsets.size(), testOffsets.data());
renderPassEncoder.Draw(3, 1, 0, 0);
renderPassEncoder.EndPass();
dawn::CommandBuffer commands = commandEncoder.Finish();
queue.Submit(1, &commands);
std::vector<uint32_t> expectedData = {2, 4};
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 2, 255, 255), renderPass.color, 0, 0);
EXPECT_BUFFER_U32_RANGE_EQ(expectedData.data(), mDynamicStorageBuffer, 0, expectedData.size());
}
// Setting multiple dynamic offsets for the same bindgroup in one compute pass.
// TODO(shaobo.yan@intel.com) : enable this test after resolving dawn issue 198.
TEST_P(DynamicBufferOffsetTests, DISABLED_UpdateDynamicOffestsMultipleTimesComputePipeline) {
dawn::ComputePipeline pipeline = CreateDefaultComputePipeline();
std::array<uint64_t, 2> offsets = {kMinDynamicBufferOffsetAlignment,
kMinDynamicBufferOffsetAlignment};
std::array<uint64_t, 2> testOffsets = {0, 0};
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder computePassEncoder = commandEncoder.BeginComputePass();
computePassEncoder.SetPipeline(pipeline);
computePassEncoder.SetBindGroup(0, mBindGroup, offsets.size(), offsets.data());
computePassEncoder.Dispatch(1, 1, 1);
computePassEncoder.SetBindGroup(0, mBindGroup, testOffsets.size(), testOffsets.data());
computePassEncoder.Dispatch(1, 1, 1);
computePassEncoder.EndPass();
dawn::CommandBuffer commands = commandEncoder.Finish();
queue.Submit(1, &commands);
std::vector<uint32_t> expectedData = {2, 4};
EXPECT_BUFFER_U32_RANGE_EQ(expectedData.data(), mDynamicStorageBuffer, 0, expectedData.size());
}
DAWN_INSTANTIATE_TEST(DynamicBufferOffsetTests,
D3D12Backend,
MetalBackend,