diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp index bbeb2cbefd..e6bf540137 100644 --- a/src/dawn/native/d3d11/BufferD3D11.cpp +++ b/src/dawn/native/d3d11/BufferD3D11.cpp @@ -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::max() - alignment) { + // Check for overflow, bufferDescriptor.ByteWidth is a UINT. + if (size > std::numeric_limits::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 {}; diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp index 6f7a85a916..ecdba76e5c 100644 --- a/src/dawn/native/d3d11/TextureD3D11.cpp +++ b/src/dawn/native/d3d11/TextureD3D11.cpp @@ -85,9 +85,9 @@ MaybeError Texture::InitializeAsInternalTexture() { textureDescriptor.CPUAccessFlags = 0; textureDescriptor.MiscFlags = 0; ComPtr 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 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 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; }