Skip to content

Commit 06c9e44

Browse files
shaoboyan091Dawn LUCI CQ
authored andcommitted
[dawn][native] Assert Pipeline Is Set Before Applying Immediates
Replace early return with an assertion to ensure that the pipeline is set before applying immediate constants in D3D11, D3D12, and Vulkan backends. This change helps catch potential issues where immediate constants are attempted to be applied without a valid pipeline. Bug: 366291600 Change-Id: Icf4f988909ac63933056b18031206f6201f9cc75 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/282215 Commit-Queue: Shaobo Yan <shaoboyan@microsoft.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
1 parent 979609b commit 06c9e44

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/dawn/native/d3d11/CommandBufferD3D11.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,9 @@ class ImmediateConstantTracker : public T {
224224
ImmediateConstantTracker() = default;
225225

226226
MaybeError Apply(const ScopedSwapStateCommandRecordingContext* commandContext) {
227-
auto* lastPipeline = this->mLastPipeline;
228-
if (!lastPipeline) {
229-
return {};
230-
}
227+
DAWN_ASSERT(this->mLastPipeline != nullptr);
231228

232-
ImmediateConstantMask pipelineMask = lastPipeline->GetImmediateMask();
229+
ImmediateConstantMask pipelineMask = this->mLastPipeline->GetImmediateMask();
233230
ImmediateConstantMask uploadBits = this->mDirty & pipelineMask;
234231
for (auto&& [offset, size] : IterateRanges(uploadBits)) {
235232
uint32_t immediateContentStartOffset =

src/dawn/native/d3d12/CommandBufferD3D12.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ class ImmediateConstantTracker : public T {
414414

415415
// Calling this after BindGroupTrackerBase::Apply() to update root signature.
416416
void Apply(CommandRecordingContext* commandContext) {
417-
auto* lastPipeline = this->mLastPipeline;
418-
DAWN_ASSERT(lastPipeline != nullptr);
417+
DAWN_ASSERT(this->mLastPipeline != nullptr);
419418

419+
auto* lastPipeline = this->mLastPipeline;
420420
ImmediateConstantMask pipelineMask = lastPipeline->GetImmediateMask();
421421
ImmediateConstantMask uploadBits = this->mDirty & pipelineMask;
422422
for (auto&& [offset, size] : IterateRanges(uploadBits)) {

src/dawn/native/vulkan/CommandBufferVk.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,9 @@ class ImmediateConstantTracker : public T {
231231
ImmediateConstantTracker() = default;
232232

233233
void Apply(Device* device, VkCommandBuffer commandBuffer) {
234-
auto* lastPipeline = this->mLastPipeline;
235-
if (!lastPipeline) {
236-
return;
237-
}
234+
DAWN_ASSERT(this->mLastPipeline != nullptr);
238235

236+
auto* lastPipeline = this->mLastPipeline;
239237
const ImmediateConstantMask& pipelineMask = lastPipeline->GetImmediateMask();
240238
ImmediateConstantMask uploadBits = this->mDirty & lastPipeline->GetImmediateMask();
241239
for (auto&& [offset, size] : IterateRanges(uploadBits)) {

0 commit comments

Comments
 (0)