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
diff --git a/src/libGLESv2/Buffer.cpp b/src/libGLESv2/Buffer.cpp
index d9c63fe..eb19a44 100644
--- a/src/libGLESv2/Buffer.cpp
+++ b/src/libGLESv2/Buffer.cpp
@@ -63,7 +63,7 @@
if (usage == GL_STATIC_DRAW)
{
mStaticVertexBuffer = new StaticVertexBuffer(mRenderer);
- mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
+ mStaticIndexBuffer = new StaticIndexBuffer(mRenderer);
}
}
@@ -110,7 +110,7 @@
if (mUnmodifiedDataUse > 3 * mSize)
{
mStaticVertexBuffer = new StaticVertexBuffer(mRenderer);
- mStaticIndexBuffer = new StaticIndexBuffer(mRenderer->getDevice()); // D3D9_REPLACE
+ mStaticIndexBuffer = new StaticIndexBuffer(mRenderer);
}
}
}
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 05fe012..620cebe 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -261,7 +261,7 @@
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 @@
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 @@
if (!mLineLoopIB)
{
- mLineLoopIB = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
+ mLineLoopIB = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
}
if (mLineLoopIB)
diff --git a/src/libGLESv2/IndexDataManager.cpp b/src/libGLESv2/IndexDataManager.cpp
index ecf9e45..513512b 100644
--- a/src/libGLESv2/IndexDataManager.cpp
+++ b/src/libGLESv2/IndexDataManager.cpp
@@ -19,13 +19,13 @@
{
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 @@
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 @@
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 @@
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 @@
}
}
-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 @@
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 @@
}
}
-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 @@
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))
diff --git a/src/libGLESv2/IndexDataManager.h b/src/libGLESv2/IndexDataManager.h
index c1d4168..dfe1adb 100644
--- a/src/libGLESv2/IndexDataManager.h
+++ b/src/libGLESv2/IndexDataManager.h
@@ -39,7 +39,7 @@
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 @@
unsigned int getSerial() const;
protected:
- IDirect3DDevice9 *const mDevice;
+ renderer::Renderer *const mRenderer;
IDirect3DIndexBuffer9 *mIndexBuffer;
UINT mBufferSize;
@@ -67,7 +67,7 @@
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 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 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 @@
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;