Commit 5d9e9ab8 by Jamie Madill

D3D11: Use system memory for dynamic buffer updates.

In our current code, we would use a staging texture as the working copy for buffer updates. This would trigger very large memcpy calls in some cases for large buffers with small updates. Instead, use a CPU memory buffer storage, and work with this storage when the user updates data. This plays much nicer with the VertexDataManager. BUG=angle:912 BUG=457338 Change-Id: I8c32d3d9bb321a06534556ce05b4b99dc3d1e961 Reviewed-on: https://chromium-review.googlesource.com/252963Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 15d26493
......@@ -273,6 +273,34 @@ enum VendorID : uint32_t
VENDOR_ID_NVIDIA = 0x10DE,
};
// Downcast a base implementation object (EG TextureImpl to TextureD3D)
template <typename DestT, typename SrcT>
inline DestT *GetAs(SrcT *src)
{
ASSERT(HAS_DYNAMIC_TYPE(DestT*, src));
return static_cast<DestT*>(src);
}
template <typename DestT, typename SrcT>
inline const DestT *GetAs(const SrcT *src)
{
ASSERT(HAS_DYNAMIC_TYPE(const DestT*, src));
return static_cast<const DestT*>(src);
}
// Downcast a GL object to an Impl (EG gl::Texture to rx::TextureD3D)
template <typename DestT, typename SrcT>
inline DestT *GetImplAs(SrcT *src)
{
return GetAs<DestT>(src->getImplementation());
}
template <typename DestT, typename SrcT>
inline const DestT *GetImplAs(const SrcT *src)
{
return GetAs<const DestT>(src->getImplementation());
}
}
#endif // LIBANGLE_ANGLETYPES_H_
......@@ -9,7 +9,6 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D11_BUFFER11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_BUFFER11_H_
#include "common/MemoryBuffer.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/d3d/BufferD3D.h"
......@@ -25,6 +24,7 @@ enum BufferUsage
BUFFER_USAGE_PIXEL_UNPACK,
BUFFER_USAGE_PIXEL_PACK,
BUFFER_USAGE_UNIFORM,
BUFFER_USAGE_SYSTEM_MEMORY,
};
struct PackPixelsParams
......@@ -77,6 +77,7 @@ class Buffer11 : public BufferD3D
class BufferStorage;
class NativeStorage;
class PackStorage;
class SystemMemoryStorage;
Renderer11 *mRenderer;
size_t mSize;
......@@ -88,13 +89,13 @@ class Buffer11 : public BufferD3D
typedef std::pair<ID3D11Buffer *, ID3D11ShaderResourceView *> BufferSRVPair;
std::map<DXGI_FORMAT, BufferSRVPair> mBufferResourceViews;
MemoryBuffer mResolvedData;
DataRevision mResolvedDataRevision;
unsigned int mReadUsageCount;
bool mHasSystemMemoryStorage;
void markBufferUsage();
NativeStorage *getStagingStorage();
PackStorage *getPackStorage();
gl::Error getSystemMemoryStorage(SystemMemoryStorage **storageOut);
BufferStorage *getBufferStorage(BufferUsage usage);
BufferStorage *getLatestBufferStorage() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment