d3d11: fix several OOM end2end test on trybot
BufferTests.CreateBufferOOM/D3D11_Intel_R_UHD_Graphics_630 fails on trybots due to buffer size overflow UINT which is used as size for create ID3D11Buffer. This CL fixes above issue and also uses CheckOutOfMemoryHRESULT() to handle hresult from texture and buffer creation. It makes OOM an allowed error. Bug: dawn:1705 Change-Id: I2c4a4841cac15934fe83b7f7d6e568e9f3c8d210 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128280 Reviewed-by: Austin Eng <enga@chromium.org> Auto-Submit: Peng Huang <penghuang@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Peng Huang <penghuang@chromium.org>
This commit is contained in:
parent
45ff7a8c4a
commit
bd696e91d2
|
@ -162,7 +162,8 @@ MaybeError Buffer::Initialize(bool mappedAtCreation) {
|
|||
// Allocate at least 4 bytes so clamped accesses are always in bounds.
|
||||
uint64_t size = std::max(GetSize(), uint64_t(4u));
|
||||
size_t alignment = D3D11BufferSizeAlignment(GetUsage());
|
||||
if (size > std::numeric_limits<uint64_t>::max() - alignment) {
|
||||
// Check for overflow, bufferDescriptor.ByteWidth is a UINT.
|
||||
if (size > std::numeric_limits<UINT>::max() - alignment) {
|
||||
// Alignment would overlow.
|
||||
return DAWN_OUT_OF_MEMORY_ERROR("Buffer allocation is too large");
|
||||
}
|
||||
|
@ -177,10 +178,10 @@ MaybeError Buffer::Initialize(bool mappedAtCreation) {
|
|||
bufferDescriptor.MiscFlags = D3D11BufferMiscFlags(GetUsage());
|
||||
bufferDescriptor.StructureByteStride = 0;
|
||||
|
||||
DAWN_TRY(CheckHRESULT(ToBackend(GetDevice())
|
||||
->GetD3D11Device()
|
||||
->CreateBuffer(&bufferDescriptor, nullptr, &mD3d11Buffer),
|
||||
"ID3D11Device::CreateBuffer"));
|
||||
DAWN_TRY(CheckOutOfMemoryHRESULT(ToBackend(GetDevice())
|
||||
->GetD3D11Device()
|
||||
->CreateBuffer(&bufferDescriptor, nullptr, &mD3d11Buffer),
|
||||
"ID3D11Device::CreateBuffer"));
|
||||
|
||||
SetLabelImpl();
|
||||
return {};
|
||||
|
|
|
@ -85,9 +85,9 @@ MaybeError Texture::InitializeAsInternalTexture() {
|
|||
textureDescriptor.CPUAccessFlags = 0;
|
||||
textureDescriptor.MiscFlags = 0;
|
||||
ComPtr<ID3D11Texture1D> d3d11Texture1D;
|
||||
DAWN_TRY(CheckHRESULT(device->GetD3D11Device()->CreateTexture1D(
|
||||
&textureDescriptor, nullptr, &d3d11Texture1D),
|
||||
"D3D11 create texture1d"));
|
||||
DAWN_TRY(CheckOutOfMemoryHRESULT(device->GetD3D11Device()->CreateTexture1D(
|
||||
&textureDescriptor, nullptr, &d3d11Texture1D),
|
||||
"D3D11 create texture1d"));
|
||||
mD3d11Resource = std::move(d3d11Texture1D);
|
||||
break;
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ MaybeError Texture::InitializeAsInternalTexture() {
|
|||
textureDescriptor.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||
}
|
||||
ComPtr<ID3D11Texture2D> d3d11Texture2D;
|
||||
DAWN_TRY(CheckHRESULT(device->GetD3D11Device()->CreateTexture2D(
|
||||
&textureDescriptor, nullptr, &d3d11Texture2D),
|
||||
"D3D11 create texture2d"));
|
||||
DAWN_TRY(CheckOutOfMemoryHRESULT(device->GetD3D11Device()->CreateTexture2D(
|
||||
&textureDescriptor, nullptr, &d3d11Texture2D),
|
||||
"D3D11 create texture2d"));
|
||||
mD3d11Resource = std::move(d3d11Texture2D);
|
||||
break;
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ MaybeError Texture::InitializeAsInternalTexture() {
|
|||
textureDescriptor.CPUAccessFlags = 0;
|
||||
textureDescriptor.MiscFlags = 0;
|
||||
ComPtr<ID3D11Texture3D> d3d11Texture3D;
|
||||
DAWN_TRY(CheckHRESULT(device->GetD3D11Device()->CreateTexture3D(
|
||||
&textureDescriptor, nullptr, &d3d11Texture3D),
|
||||
"D3D11 create texture3d"));
|
||||
DAWN_TRY(CheckOutOfMemoryHRESULT(device->GetD3D11Device()->CreateTexture3D(
|
||||
&textureDescriptor, nullptr, &d3d11Texture3D),
|
||||
"D3D11 create texture3d"));
|
||||
mD3d11Resource = std::move(d3d11Texture3D);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue