Commit e18eb970 by Jamie Madill Committed by Commit Bot

D3D: Refactor VertexDataManager attribute storage.

Instead of splitting attributes into 'active enabled' and 'active disabled', split them into static/dynamic/direct/current value, and handle each group invidually. This also will allow the dirty bits code to call in to the VertexDataManager separately for each type of necessary vertex data translation, and skip it entirely for direct buffer storage. Should be a refactoring patch only. BUG=angleproject:1327 Change-Id: I53cb5672054d99ae68e9aa2e5a3c046a002e360d Reviewed-on: https://chromium-review.googlesource.com/330171Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e36b92d4
......@@ -26,7 +26,7 @@ BufferD3D::BufferD3D(BufferFactoryD3D *factory)
mStaticBufferCacheTotalSize(0),
mStaticVertexBufferOutOfDate(false),
mUnmodifiedDataUse(0),
mUsage(D3D_BUFFER_USAGE_STATIC)
mUsage(D3DBufferUsage::STATIC)
{
updateSerial();
}
......@@ -54,7 +54,7 @@ void BufferD3D::updateD3DBufferUsage(GLenum usage)
case GL_STATIC_DRAW:
case GL_STATIC_READ:
case GL_STATIC_COPY:
mUsage = D3D_BUFFER_USAGE_STATIC;
mUsage = D3DBufferUsage::STATIC;
initializeStaticData();
break;
......@@ -64,7 +64,7 @@ void BufferD3D::updateD3DBufferUsage(GLenum usage)
case GL_DYNAMIC_READ:
case GL_DYNAMIC_COPY:
case GL_DYNAMIC_DRAW:
mUsage = D3D_BUFFER_USAGE_DYNAMIC;
mUsage = D3DBufferUsage::DYNAMIC;
break;
default:
UNREACHABLE();
......@@ -150,7 +150,7 @@ void BufferD3D::invalidateStaticData()
// If the buffer was created with a static usage then we recreate the static
// buffers so that they are populated the next time we use this buffer.
if (mUsage == D3D_BUFFER_USAGE_STATIC)
if (mUsage == D3DBufferUsage::STATIC)
{
initializeStaticData();
}
......
......@@ -21,10 +21,10 @@ class BufferFactoryD3D;
class StaticIndexBufferInterface;
class StaticVertexBufferInterface;
enum D3DBufferUsage
enum class D3DBufferUsage
{
D3D_BUFFER_USAGE_STATIC,
D3D_BUFFER_USAGE_DYNAMIC,
STATIC,
DYNAMIC,
};
class BufferD3D : public BufferImpl
......@@ -55,6 +55,7 @@ class BufferD3D : public BufferImpl
gl::IndexRange *outRange) override;
BufferFactoryD3D *getFactory() const { return mFactory; }
D3DBufferUsage getUsage() const { return mUsage; }
protected:
void updateSerial();
......
......@@ -60,6 +60,18 @@ struct TranslatedAttribute
unsigned int divisor;
};
enum class VertexStorageType
{
UNKNOWN,
STATIC, // Translate the vertex data once and re-use it.
DYNAMIC, // Translate the data every frame into a ring buffer.
DIRECT, // Bind a D3D buffer directly without any translation.
CURRENT_VALUE, // Use a single value for the attribute.
};
// Given a vertex attribute, return the type of storage it will use.
VertexStorageType ClassifyAttributeStorage(const gl::VertexAttribute &attrib);
class VertexDataManager : angle::NonCopyable
{
public:
......@@ -72,6 +84,23 @@ class VertexDataManager : angle::NonCopyable
std::vector<TranslatedAttribute> *translatedAttribs,
GLsizei instances);
static void StoreDirectAttrib(TranslatedAttribute *directAttrib, GLint start);
static gl::Error StoreStaticAttrib(TranslatedAttribute *translated,
GLint start,
GLsizei count,
GLsizei instances);
gl::Error storeDynamicAttribs(std::vector<TranslatedAttribute> *translatedAttribs,
const std::vector<size_t> &dynamicAttribIndexes,
GLint start,
GLsizei count,
GLsizei instances);
gl::Error storeCurrentValue(const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
size_t attribIndex);
private:
struct CurrentValueState
{
......@@ -87,14 +116,10 @@ class VertexDataManager : angle::NonCopyable
GLsizei count,
GLsizei instances) const;
gl::Error storeAttribute(TranslatedAttribute *translated,
GLint start,
GLsizei count,
GLsizei instances);
gl::Error storeCurrentValue(const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
CurrentValueState *cachedState);
gl::Error storeDynamicAttrib(TranslatedAttribute *translated,
GLint start,
GLsizei count,
GLsizei instances);
void unmapStreamingBuffer();
......@@ -102,12 +127,9 @@ class VertexDataManager : angle::NonCopyable
StreamingVertexBufferInterface *mStreamingBuffer;
std::vector<CurrentValueState> mCurrentValueCache;
// Cache variables
std::vector<TranslatedAttribute *> mActiveEnabledAttributes;
std::vector<size_t> mActiveDisabledAttributes;
std::vector<size_t> mDynamicAttributeIndexesCache;
};
}
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_VERTEXDATAMANAGER_H_
......@@ -38,9 +38,10 @@ gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage)
memcpy(mMemory.data(), data, size);
}
updateD3DBufferUsage(usage);
invalidateStaticData();
updateD3DBufferUsage(usage);
return gl::Error(GL_NO_ERROR);
}
......
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