Eliminated the dependency of VertexDataManager and IndexDataManager on Context.

TRAC #21963 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1360 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 113f0eb7
......@@ -253,8 +253,8 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
if (!mHasBeenCurrent)
{
mVertexDataManager = new VertexDataManager(this, mRenderer);
mIndexDataManager = new IndexDataManager(this, mRenderer);
mVertexDataManager = new VertexDataManager(mRenderer);
mIndexDataManager = new IndexDataManager(mRenderer);
mBlit = new Blit(mRenderer);
mSupportsShaderModel3 = mRenderer->getShaderModel3Support();
......@@ -837,11 +837,6 @@ const void *Context::getVertexAttribPointer(unsigned int attribNum) const
return mState.vertexAttribute[attribNum].mPointer;
}
const VertexAttributeArray &Context::getVertexAttributes()
{
return mState.vertexAttribute;
}
void Context::setPackAlignment(GLint alignment)
{
mState.packAlignment = alignment;
......@@ -2302,13 +2297,13 @@ GLenum Context::applyVertexBuffer(GLint first, GLsizei count, GLsizei instances,
{
TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS];
GLenum err = mVertexDataManager->prepareVertexData(first, count, attributes, instances);
ProgramBinary *programBinary = getCurrentProgramBinary();
GLenum err = mVertexDataManager->prepareVertexData(mState.vertexAttribute, programBinary, first, count, attributes, instances);
if (err != GL_NO_ERROR)
{
return err;
}
ProgramBinary *programBinary = getCurrentProgramBinary();
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, repeatDraw);
}
......
......@@ -375,8 +375,6 @@ class Context
bool normalized, GLsizei stride, const void *pointer);
const void *getVertexAttribPointer(unsigned int attribNum) const;
const VertexAttributeArray &getVertexAttributes();
void setUnpackAlignment(GLint alignment);
GLint getUnpackAlignment() const;
......
......@@ -19,11 +19,11 @@ namespace gl
{
unsigned int IndexBuffer::mCurrentSerial = 1;
IndexDataManager::IndexDataManager(Context *context, renderer::Renderer9 *renderer) : mRenderer(renderer)
IndexDataManager::IndexDataManager(renderer::Renderer9 *renderer) : mRenderer(renderer)
{
mStreamingBufferShort = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
if (context->supports32bitIndices())
if (renderer->get32BitIndexSupport())
{
mStreamingBufferInt = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
......
......@@ -125,7 +125,7 @@ class StaticIndexBuffer : public IndexBuffer
class IndexDataManager
{
public:
IndexDataManager(Context *context, renderer::Renderer9 *renderer);
IndexDataManager(renderer::Renderer9 *renderer);
virtual ~IndexDataManager();
GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated);
......
......@@ -37,7 +37,7 @@ int elementsInBuffer(const VertexAttribute &attribute, int size)
return (size - attribute.mOffset % stride + (stride - attribute.typeSize())) / stride;
}
VertexDataManager::VertexDataManager(Context *context, renderer::Renderer9 *renderer) : mContext(context), mRenderer(renderer)
VertexDataManager::VertexDataManager(renderer::Renderer9 *renderer) : mRenderer(renderer)
{
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
......@@ -121,16 +121,13 @@ std::size_t VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffe
return streamOffset;
}
GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *translated, GLsizei instances)
GLenum VertexDataManager::prepareVertexData(const VertexAttributeArray &attribs, ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *translated, GLsizei instances)
{
if (!mStreamingBuffer)
{
return GL_OUT_OF_MEMORY;
}
const VertexAttributeArray &attribs = mContext->getVertexAttributes();
ProgramBinary *programBinary = mContext->getCurrentProgramBinary();
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
translated[attributeIndex].active = (programBinary->getSemanticIndex(attributeIndex) != -1);
......
......@@ -113,12 +113,12 @@ class StaticVertexBuffer : public ArrayVertexBuffer
class VertexDataManager
{
public:
VertexDataManager(Context *context, renderer::Renderer9 *renderer);
VertexDataManager(renderer::Renderer9 *renderer);
virtual ~VertexDataManager();
void dirtyCurrentValue(int index) { mDirtyCurrentValue[index] = true; }
GLenum prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances);
GLenum prepareVertexData(const VertexAttributeArray &attribs, ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances);
private:
DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
......@@ -126,7 +126,6 @@ class VertexDataManager
std::size_t spaceRequired(const VertexAttribute &attrib, std::size_t count, GLsizei instances) const;
std::size_t writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute, GLsizei instances);
Context *const mContext;
renderer::Renderer9 *const mRenderer; // D3D9_REPLACE
StreamingVertexBuffer *mStreamingBuffer;
......
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