Removes d3d9 device usage from IndexDataManager and subjugate classes.

TRAC #21816 Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1341 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent b7386999
......@@ -63,7 +63,7 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
if (usage == GL_STATIC_DRAW)
{
mStaticVertexBuffer = new StaticVertexBuffer(mRenderer);
mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
mStaticIndexBuffer = new StaticIndexBuffer(mRenderer);
}
}
......@@ -110,7 +110,7 @@ void Buffer::promoteStaticUsage(int dataSize)
if (mUnmodifiedDataUse > 3 * mSize)
{
mStaticVertexBuffer = new StaticVertexBuffer(mRenderer);
mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
mStaticIndexBuffer = new StaticIndexBuffer(mRenderer);
}
}
}
......
......@@ -261,7 +261,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
if (!mHasBeenCurrent)
{
mVertexDataManager = new VertexDataManager(this, mRenderer);
mIndexDataManager = new IndexDataManager(this, mDevice);
mIndexDataManager = new IndexDataManager(this, mRenderer);
mBlit = new Blit(mRenderer);
mSupportsShaderModel3 = mRenderer->getShaderModel3Support();
......@@ -3213,7 +3213,7 @@ void Context::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, in
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
mLineLoopIB = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
}
if (mLineLoopIB)
......@@ -3270,7 +3270,7 @@ void Context::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, in
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
mLineLoopIB = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
}
if (mLineLoopIB)
......
......@@ -19,13 +19,13 @@ namespace gl
{
unsigned int IndexBuffer::mCurrentSerial = 1;
IndexDataManager::IndexDataManager(Context *context, IDirect3DDevice9 *device) : mDevice(device)
IndexDataManager::IndexDataManager(Context *context, renderer::Renderer *renderer) : mRenderer(renderer)
{
mStreamingBufferShort = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
mStreamingBufferShort = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
if (context->supports32bitIndices())
{
mStreamingBufferInt = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
mStreamingBufferInt = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
if (!mStreamingBufferInt)
{
......@@ -235,7 +235,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count)
if (!mCountingBuffer || mCountingBuffer->size() < spaceNeeded)
{
delete mCountingBuffer;
mCountingBuffer = new StaticIndexBuffer(mDevice);
mCountingBuffer = new StaticIndexBuffer(mRenderer);
mCountingBuffer->reserveSpace(spaceNeeded, GL_UNSIGNED_SHORT);
UINT offset;
......@@ -259,7 +259,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count)
if (!mCountingBuffer || mCountingBuffer->size() < spaceNeeded)
{
delete mCountingBuffer;
mCountingBuffer = new StaticIndexBuffer(mDevice);
mCountingBuffer = new StaticIndexBuffer(mRenderer);
mCountingBuffer->reserveSpace(spaceNeeded, GL_UNSIGNED_INT);
UINT offset;
......@@ -281,13 +281,13 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count)
return mCountingBuffer;
}
IndexBuffer::IndexBuffer(IDirect3DDevice9 *device, UINT size, D3DFORMAT format) : mDevice(device), mBufferSize(size), mIndexBuffer(NULL)
IndexBuffer::IndexBuffer(renderer::Renderer *renderer, UINT size, D3DFORMAT format) : mRenderer(renderer), mBufferSize(size), mIndexBuffer(NULL)
{
if (size > 0)
{
// D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = device->CreateIndexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, format, pool, &mIndexBuffer, NULL);
D3DPOOL pool = mRenderer->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = mRenderer->getDevice()->CreateIndexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, format, pool, &mIndexBuffer, NULL);
mSerial = issueSerial();
if (FAILED(result))
......@@ -328,7 +328,7 @@ void IndexBuffer::unmap()
}
}
StreamingIndexBuffer::StreamingIndexBuffer(IDirect3DDevice9 *device, UINT initialSize, D3DFORMAT format) : IndexBuffer(device, initialSize, format)
StreamingIndexBuffer::StreamingIndexBuffer(renderer::Renderer *renderer, UINT initialSize, D3DFORMAT format) : IndexBuffer(renderer, initialSize, format)
{
mWritePosition = 0;
}
......@@ -371,8 +371,8 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
mBufferSize = std::max(requiredSpace, 2 * mBufferSize);
// D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = mDevice->CreateIndexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
D3DPOOL pool = mRenderer->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = mRenderer->getDevice()->CreateIndexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
mSerial = issueSerial();
if (FAILED(result))
......@@ -392,7 +392,7 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
}
}
StaticIndexBuffer::StaticIndexBuffer(IDirect3DDevice9 *device) : IndexBuffer(device, 0, D3DFMT_UNKNOWN)
StaticIndexBuffer::StaticIndexBuffer(renderer::Renderer *renderer) : IndexBuffer(renderer, 0, D3DFMT_UNKNOWN)
{
mCacheType = GL_NONE;
}
......@@ -426,8 +426,8 @@ void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
if (!mIndexBuffer && mBufferSize == 0)
{
// D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_WRITEONLY);
HRESULT result = mDevice->CreateIndexBuffer(requiredSpace, D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
D3DPOOL pool = mRenderer->getBufferPool(D3DUSAGE_WRITEONLY);
HRESULT result = mRenderer->getDevice()->CreateIndexBuffer(requiredSpace, D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
mSerial = issueSerial();
if (FAILED(result))
......
......@@ -39,7 +39,7 @@ struct TranslatedIndexData
class IndexBuffer
{
public:
IndexBuffer(IDirect3DDevice9 *device, UINT size, D3DFORMAT format);
IndexBuffer(renderer::Renderer *renderer, UINT size, D3DFORMAT format);
virtual ~IndexBuffer();
UINT size() const { return mBufferSize; }
......@@ -51,7 +51,7 @@ class IndexBuffer
unsigned int getSerial() const;
protected:
IDirect3DDevice9 *const mDevice;
renderer::Renderer *const mRenderer;
IDirect3DIndexBuffer9 *mIndexBuffer;
UINT mBufferSize;
......@@ -67,7 +67,7 @@ class IndexBuffer
class StreamingIndexBuffer : public IndexBuffer
{
public:
StreamingIndexBuffer(IDirect3DDevice9 *device, UINT initialSize, D3DFORMAT format);
StreamingIndexBuffer(renderer::Renderer *renderer, UINT initialSize, D3DFORMAT format);
~StreamingIndexBuffer();
virtual void *map(UINT requiredSpace, UINT *offset);
......@@ -80,7 +80,7 @@ class StreamingIndexBuffer : public IndexBuffer
class StaticIndexBuffer : public IndexBuffer
{
public:
explicit StaticIndexBuffer(IDirect3DDevice9 *device);
explicit StaticIndexBuffer(renderer::Renderer *renderer);
~StaticIndexBuffer();
virtual void *map(UINT requiredSpace, UINT *offset);
......@@ -125,7 +125,7 @@ class StaticIndexBuffer : public IndexBuffer
class IndexDataManager
{
public:
IndexDataManager(Context *context, IDirect3DDevice9 *evice);
IndexDataManager(Context *context, renderer::Renderer *renderer);
virtual ~IndexDataManager();
GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated);
......@@ -137,7 +137,7 @@ class IndexDataManager
std::size_t typeSize(GLenum type) const;
std::size_t indexSize(D3DFORMAT format) const;
IDirect3DDevice9 *const mDevice;
renderer::Renderer *const mRenderer;
StreamingIndexBuffer *mStreamingBufferShort;
StreamingIndexBuffer *mStreamingBufferInt;
......
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