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) ...@@ -26,7 +26,7 @@ BufferD3D::BufferD3D(BufferFactoryD3D *factory)
mStaticBufferCacheTotalSize(0), mStaticBufferCacheTotalSize(0),
mStaticVertexBufferOutOfDate(false), mStaticVertexBufferOutOfDate(false),
mUnmodifiedDataUse(0), mUnmodifiedDataUse(0),
mUsage(D3D_BUFFER_USAGE_STATIC) mUsage(D3DBufferUsage::STATIC)
{ {
updateSerial(); updateSerial();
} }
...@@ -54,7 +54,7 @@ void BufferD3D::updateD3DBufferUsage(GLenum usage) ...@@ -54,7 +54,7 @@ void BufferD3D::updateD3DBufferUsage(GLenum usage)
case GL_STATIC_DRAW: case GL_STATIC_DRAW:
case GL_STATIC_READ: case GL_STATIC_READ:
case GL_STATIC_COPY: case GL_STATIC_COPY:
mUsage = D3D_BUFFER_USAGE_STATIC; mUsage = D3DBufferUsage::STATIC;
initializeStaticData(); initializeStaticData();
break; break;
...@@ -64,7 +64,7 @@ void BufferD3D::updateD3DBufferUsage(GLenum usage) ...@@ -64,7 +64,7 @@ void BufferD3D::updateD3DBufferUsage(GLenum usage)
case GL_DYNAMIC_READ: case GL_DYNAMIC_READ:
case GL_DYNAMIC_COPY: case GL_DYNAMIC_COPY:
case GL_DYNAMIC_DRAW: case GL_DYNAMIC_DRAW:
mUsage = D3D_BUFFER_USAGE_DYNAMIC; mUsage = D3DBufferUsage::DYNAMIC;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -150,7 +150,7 @@ void BufferD3D::invalidateStaticData() ...@@ -150,7 +150,7 @@ void BufferD3D::invalidateStaticData()
// If the buffer was created with a static usage then we recreate the static // 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. // buffers so that they are populated the next time we use this buffer.
if (mUsage == D3D_BUFFER_USAGE_STATIC) if (mUsage == D3DBufferUsage::STATIC)
{ {
initializeStaticData(); initializeStaticData();
} }
......
...@@ -21,10 +21,10 @@ class BufferFactoryD3D; ...@@ -21,10 +21,10 @@ class BufferFactoryD3D;
class StaticIndexBufferInterface; class StaticIndexBufferInterface;
class StaticVertexBufferInterface; class StaticVertexBufferInterface;
enum D3DBufferUsage enum class D3DBufferUsage
{ {
D3D_BUFFER_USAGE_STATIC, STATIC,
D3D_BUFFER_USAGE_DYNAMIC, DYNAMIC,
}; };
class BufferD3D : public BufferImpl class BufferD3D : public BufferImpl
...@@ -55,6 +55,7 @@ class BufferD3D : public BufferImpl ...@@ -55,6 +55,7 @@ class BufferD3D : public BufferImpl
gl::IndexRange *outRange) override; gl::IndexRange *outRange) override;
BufferFactoryD3D *getFactory() const { return mFactory; } BufferFactoryD3D *getFactory() const { return mFactory; }
D3DBufferUsage getUsage() const { return mUsage; }
protected: protected:
void updateSerial(); void updateSerial();
......
...@@ -60,6 +60,18 @@ struct TranslatedAttribute ...@@ -60,6 +60,18 @@ struct TranslatedAttribute
unsigned int divisor; 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 class VertexDataManager : angle::NonCopyable
{ {
public: public:
...@@ -72,6 +84,23 @@ class VertexDataManager : angle::NonCopyable ...@@ -72,6 +84,23 @@ class VertexDataManager : angle::NonCopyable
std::vector<TranslatedAttribute> *translatedAttribs, std::vector<TranslatedAttribute> *translatedAttribs,
GLsizei instances); 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: private:
struct CurrentValueState struct CurrentValueState
{ {
...@@ -87,14 +116,10 @@ class VertexDataManager : angle::NonCopyable ...@@ -87,14 +116,10 @@ class VertexDataManager : angle::NonCopyable
GLsizei count, GLsizei count,
GLsizei instances) const; GLsizei instances) const;
gl::Error storeAttribute(TranslatedAttribute *translated, gl::Error storeDynamicAttrib(TranslatedAttribute *translated,
GLint start, GLint start,
GLsizei count, GLsizei count,
GLsizei instances); GLsizei instances);
gl::Error storeCurrentValue(const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
CurrentValueState *cachedState);
void unmapStreamingBuffer(); void unmapStreamingBuffer();
...@@ -102,12 +127,9 @@ class VertexDataManager : angle::NonCopyable ...@@ -102,12 +127,9 @@ class VertexDataManager : angle::NonCopyable
StreamingVertexBufferInterface *mStreamingBuffer; StreamingVertexBufferInterface *mStreamingBuffer;
std::vector<CurrentValueState> mCurrentValueCache; std::vector<CurrentValueState> mCurrentValueCache;
std::vector<size_t> mDynamicAttributeIndexesCache;
// Cache variables
std::vector<TranslatedAttribute *> mActiveEnabledAttributes;
std::vector<size_t> mActiveDisabledAttributes;
}; };
} } // namespace rx
#endif // LIBANGLE_RENDERER_D3D_VERTEXDATAMANAGER_H_ #endif // LIBANGLE_RENDERER_D3D_VERTEXDATAMANAGER_H_
...@@ -38,9 +38,10 @@ gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage) ...@@ -38,9 +38,10 @@ gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage)
memcpy(mMemory.data(), data, size); memcpy(mMemory.data(), data, size);
} }
updateD3DBufferUsage(usage);
invalidateStaticData(); invalidateStaticData();
updateD3DBufferUsage(usage);
return gl::Error(GL_NO_ERROR); 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