mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Support buffer lazy initialization before CopyTextureToBuffer
BUG=dawn:414 TEST=dawn_end2end_tests Change-Id: I5bdd6333029170d47ea240388e7b7d80750ae5d9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25643 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
361a0d8334
commit
c11a19145f
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "dawn_native/opengl/BufferGL.h"
|
||||
|
||||
#include "dawn_native/CommandBuffer.h"
|
||||
#include "dawn_native/opengl/DeviceGL.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
@@ -77,6 +78,21 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::EnsureDataInitializedAsDestination(const CopyTextureToBufferCmd* copy) {
|
||||
// TODO(jiawei.shao@intel.com): check Toggle::LazyClearResourceOnFirstUse
|
||||
// instead when buffer lazy initialization is completely supported.
|
||||
if (IsDataInitialized() ||
|
||||
!GetDevice()->IsToggleEnabled(Toggle::LazyClearBufferOnFirstUse)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFullBufferOverwrittenInTextureToBufferCopy(copy)) {
|
||||
SetIsDataInitialized();
|
||||
} else {
|
||||
InitializeToZero();
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::InitializeToZero() {
|
||||
ASSERT(GetDevice()->IsToggleEnabled(Toggle::LazyClearBufferOnFirstUse));
|
||||
ASSERT(!IsDataInitialized());
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
void EnsureDataInitialized();
|
||||
void EnsureDataInitializedAsDestination(uint64_t offset, uint64_t size);
|
||||
void EnsureDataInitializedAsDestination(const CopyTextureToBufferCmd* copy);
|
||||
|
||||
private:
|
||||
~Buffer() override;
|
||||
|
||||
@@ -611,6 +611,8 @@ namespace dawn_native { namespace opengl {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
buffer->EnsureDataInitializedAsDestination(copy);
|
||||
|
||||
ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
|
||||
SubresourceRange subresources = {src.mipLevel, 1, src.origin.z,
|
||||
copy->copySize.depth};
|
||||
|
||||
Reference in New Issue
Block a user