Skip to content

Commit

Permalink
d3d11: Rename UnApplyBindGroup
Browse files Browse the repository at this point in the history
The method is only used in compute passes, so rename it to
UnapplyComputeBindings to reflect that.

Change-Id: Ib7ef43ac3dc0dc02d30e1f50c42f56b89deb1549
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/204577
Reviewed-by: Quyen Le <[email protected]>
Reviewed-by: Corentin Wallez <[email protected]>
Commit-Queue: Jie A Chen <[email protected]>
  • Loading branch information
jchen10 authored and Dawn LUCI CQ committed Sep 3, 2024
1 parent 30c9e45 commit 13696cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 70 deletions.
84 changes: 15 additions & 69 deletions src/dawn/native/d3d11/BindGroupTrackerD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ BindGroupTracker::~BindGroupTracker() {
} else {
for (BindGroupIndex index :
IterateBitSet(mLastAppliedPipelineLayout->GetBindGroupLayoutsMask())) {
UnApplyBindGroup(index);
UnapplyComputeBindings(index);
}
}
// All slots should be unbound here.
Expand Down Expand Up @@ -271,7 +271,7 @@ MaybeError BindGroupTracker::Apply() {
// render pass. So we don't need to do this inside render passes.
BindGroupMask groupsToUnset = previousGroups & (~inheritedGroups | mDirtyBindGroups);
for (BindGroupIndex index : IterateBitSet(groupsToUnset)) {
UnApplyBindGroup(index);
UnapplyComputeBindings(index);
}
}

Expand Down Expand Up @@ -456,7 +456,8 @@ MaybeError BindGroupTracker::ApplyBindGroup(BindGroupIndex index) {
return {};
}

void BindGroupTracker::UnApplyBindGroup(BindGroupIndex index) {
void BindGroupTracker::UnapplyComputeBindings(BindGroupIndex index) {
DAWN_ASSERT(!mIsRenderPass);
auto* deviceContext = mCommandContext->GetD3D11DeviceContext4();
BindGroupLayoutInternalBase* groupLayout =
mLastAppliedPipelineLayout->GetBindGroupLayout(index);
Expand All @@ -466,25 +467,18 @@ void BindGroupTracker::UnApplyBindGroup(BindGroupIndex index) {
const BindingInfo& bindingInfo = groupLayout->GetBindingInfo(bindingIndex);
const uint32_t bindingSlot = indices[bindingIndex];
const auto bindingVisibility = bindingInfo.visibility & mVisibleStages;
if (!(bindingVisibility & wgpu::ShaderStage::Compute)) {
continue;
}

MatchVariant(
bindingInfo.bindingLayout,
[&](const BufferBindingInfo& layout) {
switch (layout.type) {
case wgpu::BufferBindingType::Uniform: {
ID3D11Buffer* nullBuffer = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
deviceContext->VSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
nullptr, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->PSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
nullptr, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
nullptr, nullptr);
}
deviceContext->CSSetConstantBuffers1(bindingSlot, 1, &nullBuffer, nullptr,
nullptr);
break;
}
case wgpu::BufferBindingType::Storage:
Expand All @@ -493,28 +487,12 @@ void BindGroupTracker::UnApplyBindGroup(BindGroupIndex index) {
IsSubset(bindingInfo.visibility,
wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute));
ID3D11UnorderedAccessView* nullUAV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, nullptr, nullptr,
bindingSlot, 1, &nullUAV, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV,
nullptr);
}
deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV, nullptr);
break;
}
case wgpu::BufferBindingType::ReadOnlyStorage: {
ID3D11ShaderResourceView* nullSRV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
deviceContext->VSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->PSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
}
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
break;
}
case wgpu::BufferBindingType::Undefined:
Expand All @@ -528,55 +506,23 @@ void BindGroupTracker::UnApplyBindGroup(BindGroupIndex index) {
},
[&](const SamplerBindingInfo&) {
ID3D11SamplerState* nullSampler = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
deviceContext->VSSetSamplers(bindingSlot, 1, &nullSampler);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->PSSetSamplers(bindingSlot, 1, &nullSampler);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetSamplers(bindingSlot, 1, &nullSampler);
}
deviceContext->CSSetSamplers(bindingSlot, 1, &nullSampler);
},
[&](const TextureBindingInfo&) {
ID3D11ShaderResourceView* nullSRV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
deviceContext->VSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->PSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
}
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
},
[&](const StorageTextureBindingInfo& layout) {
switch (layout.access) {
case wgpu::StorageTextureAccess::WriteOnly:
case wgpu::StorageTextureAccess::ReadWrite: {
ID3D11UnorderedAccessView* nullUAV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, nullptr, nullptr,
bindingSlot, 1, &nullUAV, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV,
nullptr);
}
deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV, nullptr);
break;
}
case wgpu::StorageTextureAccess::ReadOnly: {
ID3D11ShaderResourceView* nullSRV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
deviceContext->VSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
deviceContext->PSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
}
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
break;
}
default:
Expand Down
2 changes: 1 addition & 1 deletion src/dawn/native/d3d11/BindGroupTrackerD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BindGroupTracker : public BindGroupTrackerBase</*CanInheritBindGroups=*/tr

private:
MaybeError ApplyBindGroup(BindGroupIndex index);
void UnApplyBindGroup(BindGroupIndex index);
void UnapplyComputeBindings(BindGroupIndex index);

raw_ptr<const ScopedSwapStateCommandRecordingContext> mCommandContext;
const bool mIsRenderPass;
Expand Down

0 comments on commit 13696cc

Please sign in to comment.