Hash :
80b9528d
Author :
Date :
2014-05-06T13:57:43
Handle buffer memory allocation failures gracefully. When we would allocate huge buffers, we would not always gracefully fail and return a GL error back to the application. We should be able to better handle buffer allocation failures with this patch. BUG=angle:634 Change-Id: Ic3edce6d22b731ec52666a2a0e82f9a4fbbb23ae Reviewed-on: https://chromium-review.googlesource.com/197994 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
#include "precompiled.h"
//
// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// BufferStorage9.cpp Defines the BufferStorage9 class.
#include "libGLESv2/renderer/d3d9/BufferStorage9.h"
#include "common/debug.h"
#include "libGLESv2/main.h"
namespace rx
{
BufferStorage9::BufferStorage9()
: mSize(0)
{
}
BufferStorage9::~BufferStorage9()
{
}
BufferStorage9 *BufferStorage9::makeBufferStorage9(BufferStorage *bufferStorage)
{
ASSERT(HAS_DYNAMIC_TYPE(BufferStorage9*, bufferStorage));
return static_cast<BufferStorage9*>(bufferStorage);
}
void *BufferStorage9::getData()
{
return mMemory.data();
}
void BufferStorage9::setData(const void* data, size_t size, size_t offset)
{
if (offset + size > mMemory.size())
{
mMemory.resize(offset + size);
}
mSize = std::max(mSize, offset + size);
if (data)
{
memcpy(mMemory.data() + offset, data, size);
}
}
void BufferStorage9::copyData(BufferStorage* sourceStorage, size_t size, size_t sourceOffset, size_t destOffset)
{
BufferStorage9* source = makeBufferStorage9(sourceStorage);
if (source)
{
memcpy(mMemory.data() + destOffset, source->mMemory.data() + sourceOffset, size);
}
}
void BufferStorage9::clear()
{
mSize = 0;
}
void BufferStorage9::markTransformFeedbackUsage()
{
UNREACHABLE();
}
size_t BufferStorage9::getSize() const
{
return mSize;
}
bool BufferStorage9::supportsDirectBinding() const
{
return false;
}
// We do not suppot buffer mapping facility in D3D9
bool BufferStorage9::isMapped() const
{
UNREACHABLE();
return false;
}
void *BufferStorage9::map(GLbitfield access)
{
UNREACHABLE();
return NULL;
}
void BufferStorage9::unmap()
{
UNREACHABLE();
}
}