Renamed IndxBuffer to IndexBufferInterface.

TRAC #22237 Author: Geoff Lang Signed-off-by: Shannon Woods Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1603 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 955377eb
...@@ -62,7 +62,7 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) ...@@ -62,7 +62,7 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
if (usage == GL_STATIC_DRAW) if (usage == GL_STATIC_DRAW)
{ {
mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer); mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer);
mStaticIndexBuffer = new rx::StaticIndexBuffer(mRenderer); mStaticIndexBuffer = new rx::StaticIndexBufferInterface(mRenderer);
} }
} }
...@@ -83,7 +83,7 @@ rx::StaticVertexBufferInterface *Buffer::getStaticVertexBuffer() ...@@ -83,7 +83,7 @@ rx::StaticVertexBufferInterface *Buffer::getStaticVertexBuffer()
return mStaticVertexBuffer; return mStaticVertexBuffer;
} }
rx::StaticIndexBuffer *Buffer::getStaticIndexBuffer() rx::StaticIndexBufferInterface *Buffer::getStaticIndexBuffer()
{ {
return mStaticIndexBuffer; return mStaticIndexBuffer;
} }
...@@ -109,7 +109,7 @@ void Buffer::promoteStaticUsage(int dataSize) ...@@ -109,7 +109,7 @@ void Buffer::promoteStaticUsage(int dataSize)
if (mUnmodifiedDataUse > 3 * mSize) if (mUnmodifiedDataUse > 3 * mSize)
{ {
mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer); mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer);
mStaticIndexBuffer = new rx::StaticIndexBuffer(mRenderer); mStaticIndexBuffer = new rx::StaticIndexBufferInterface(mRenderer);
} }
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
namespace rx namespace rx
{ {
class StaticVertexBufferInterface; class StaticVertexBufferInterface;
class StaticIndexBuffer; class StaticIndexBufferInterface;
} }
namespace gl namespace gl
...@@ -45,7 +45,7 @@ class Buffer : public RefCountObject ...@@ -45,7 +45,7 @@ class Buffer : public RefCountObject
GLenum usage() const { return mUsage; } GLenum usage() const { return mUsage; }
rx::StaticVertexBufferInterface *getStaticVertexBuffer(); rx::StaticVertexBufferInterface *getStaticVertexBuffer();
rx::StaticIndexBuffer *getStaticIndexBuffer(); rx::StaticIndexBufferInterface *getStaticIndexBuffer();
void invalidateStaticData(); void invalidateStaticData();
void promoteStaticUsage(int dataSize); void promoteStaticUsage(int dataSize);
...@@ -58,7 +58,7 @@ class Buffer : public RefCountObject ...@@ -58,7 +58,7 @@ class Buffer : public RefCountObject
GLenum mUsage; GLenum mUsage;
rx::StaticVertexBufferInterface *mStaticVertexBuffer; rx::StaticVertexBufferInterface *mStaticVertexBuffer;
rx::StaticIndexBuffer *mStaticIndexBuffer; rx::StaticIndexBufferInterface *mStaticIndexBuffer;
GLsizeiptr mUnmodifiedDataUse; GLsizeiptr mUnmodifiedDataUse;
}; };
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
namespace rx namespace rx
{ {
unsigned int IndexBuffer::mCurrentSerial = 1; unsigned int IndexBufferInterface::mCurrentSerial = 1;
IndexBuffer::IndexBuffer(rx::Renderer9 *renderer, UINT size, D3DFORMAT format) : mRenderer(renderer), mBufferSize(size), mIndexBuffer(NULL) IndexBufferInterface::IndexBufferInterface(rx::Renderer9 *renderer, UINT size, D3DFORMAT format) : mRenderer(renderer), mBufferSize(size), mIndexBuffer(NULL)
{ {
if (size > 0) if (size > 0)
{ {
...@@ -31,7 +31,7 @@ IndexBuffer::IndexBuffer(rx::Renderer9 *renderer, UINT size, D3DFORMAT format) : ...@@ -31,7 +31,7 @@ IndexBuffer::IndexBuffer(rx::Renderer9 *renderer, UINT size, D3DFORMAT format) :
} }
} }
IndexBuffer::~IndexBuffer() IndexBufferInterface::~IndexBufferInterface()
{ {
if (mIndexBuffer) if (mIndexBuffer)
{ {
...@@ -39,22 +39,22 @@ IndexBuffer::~IndexBuffer() ...@@ -39,22 +39,22 @@ IndexBuffer::~IndexBuffer()
} }
} }
IDirect3DIndexBuffer9 *IndexBuffer::getBuffer() const IDirect3DIndexBuffer9 *IndexBufferInterface::getBuffer() const
{ {
return mIndexBuffer; return mIndexBuffer;
} }
unsigned int IndexBuffer::getSerial() const unsigned int IndexBufferInterface::getSerial() const
{ {
return mSerial; return mSerial;
} }
unsigned int IndexBuffer::issueSerial() unsigned int IndexBufferInterface::issueSerial()
{ {
return mCurrentSerial++; return mCurrentSerial++;
} }
void IndexBuffer::unmap() void IndexBufferInterface::unmap()
{ {
if (mIndexBuffer) if (mIndexBuffer)
{ {
...@@ -62,16 +62,16 @@ void IndexBuffer::unmap() ...@@ -62,16 +62,16 @@ void IndexBuffer::unmap()
} }
} }
StreamingIndexBuffer::StreamingIndexBuffer(rx::Renderer9 *renderer, UINT initialSize, D3DFORMAT format) : IndexBuffer(renderer, initialSize, format) StreamingIndexBufferInterface::StreamingIndexBufferInterface(rx::Renderer9 *renderer, UINT initialSize, D3DFORMAT format) : IndexBufferInterface(renderer, initialSize, format)
{ {
mWritePosition = 0; mWritePosition = 0;
} }
StreamingIndexBuffer::~StreamingIndexBuffer() StreamingIndexBufferInterface::~StreamingIndexBufferInterface()
{ {
} }
void *StreamingIndexBuffer::map(UINT requiredSpace, UINT *offset) void *StreamingIndexBufferInterface::map(UINT requiredSpace, UINT *offset)
{ {
void *mapPtr = NULL; void *mapPtr = NULL;
...@@ -92,7 +92,7 @@ void *StreamingIndexBuffer::map(UINT requiredSpace, UINT *offset) ...@@ -92,7 +92,7 @@ void *StreamingIndexBuffer::map(UINT requiredSpace, UINT *offset)
return mapPtr; return mapPtr;
} }
void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) void StreamingIndexBufferInterface::reserveSpace(UINT requiredSpace, GLenum type)
{ {
if (requiredSpace > mBufferSize) if (requiredSpace > mBufferSize)
{ {
...@@ -125,16 +125,16 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) ...@@ -125,16 +125,16 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
} }
} }
StaticIndexBuffer::StaticIndexBuffer(rx::Renderer9 *renderer) : IndexBuffer(renderer, 0, D3DFMT_UNKNOWN) StaticIndexBufferInterface::StaticIndexBufferInterface(rx::Renderer9 *renderer) : IndexBufferInterface(renderer, 0, D3DFMT_UNKNOWN)
{ {
mCacheType = GL_NONE; mCacheType = GL_NONE;
} }
StaticIndexBuffer::~StaticIndexBuffer() StaticIndexBufferInterface::~StaticIndexBufferInterface()
{ {
} }
void *StaticIndexBuffer::map(UINT requiredSpace, UINT *offset) void *StaticIndexBufferInterface::map(UINT requiredSpace, UINT *offset)
{ {
void *mapPtr = NULL; void *mapPtr = NULL;
...@@ -154,7 +154,7 @@ void *StaticIndexBuffer::map(UINT requiredSpace, UINT *offset) ...@@ -154,7 +154,7 @@ void *StaticIndexBuffer::map(UINT requiredSpace, UINT *offset)
return mapPtr; return mapPtr;
} }
void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) void StaticIndexBufferInterface::reserveSpace(UINT requiredSpace, GLenum type)
{ {
if (!mIndexBuffer && mBufferSize == 0) if (!mIndexBuffer && mBufferSize == 0)
{ {
...@@ -177,12 +177,12 @@ void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) ...@@ -177,12 +177,12 @@ void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
else UNREACHABLE(); // Static index buffers can't be resized else UNREACHABLE(); // Static index buffers can't be resized
} }
bool StaticIndexBuffer::lookupType(GLenum type) bool StaticIndexBufferInterface::lookupType(GLenum type)
{ {
return mCacheType == type; return mCacheType == type;
} }
UINT StaticIndexBuffer::lookupRange(intptr_t offset, GLsizei count, UINT *minIndex, UINT *maxIndex) UINT StaticIndexBufferInterface::lookupRange(intptr_t offset, GLsizei count, UINT *minIndex, UINT *maxIndex)
{ {
IndexRange range = {offset, count}; IndexRange range = {offset, count};
...@@ -198,7 +198,7 @@ UINT StaticIndexBuffer::lookupRange(intptr_t offset, GLsizei count, UINT *minInd ...@@ -198,7 +198,7 @@ UINT StaticIndexBuffer::lookupRange(intptr_t offset, GLsizei count, UINT *minInd
return res->second.streamOffset; return res->second.streamOffset;
} }
void StaticIndexBuffer::addRange(intptr_t offset, GLsizei count, UINT minIndex, UINT maxIndex, UINT streamOffset) void StaticIndexBufferInterface::addRange(intptr_t offset, GLsizei count, UINT minIndex, UINT maxIndex, UINT streamOffset)
{ {
IndexRange indexRange = {offset, count}; IndexRange indexRange = {offset, count};
IndexResult indexResult = {minIndex, maxIndex, streamOffset}; IndexResult indexResult = {minIndex, maxIndex, streamOffset};
......
...@@ -24,11 +24,11 @@ namespace rx ...@@ -24,11 +24,11 @@ namespace rx
class Renderer9; class Renderer9;
class IndexBuffer class IndexBufferInterface
{ {
public: public:
IndexBuffer(rx::Renderer9 *renderer, UINT size, D3DFORMAT format); IndexBufferInterface(rx::Renderer9 *renderer, UINT size, D3DFORMAT format);
virtual ~IndexBuffer(); virtual ~IndexBufferInterface();
UINT size() const { return mBufferSize; } UINT size() const { return mBufferSize; }
virtual void *map(UINT requiredSpace, UINT *offset) = 0; virtual void *map(UINT requiredSpace, UINT *offset) = 0;
...@@ -49,14 +49,14 @@ class IndexBuffer ...@@ -49,14 +49,14 @@ class IndexBuffer
static unsigned int mCurrentSerial; static unsigned int mCurrentSerial;
private: private:
DISALLOW_COPY_AND_ASSIGN(IndexBuffer); DISALLOW_COPY_AND_ASSIGN(IndexBufferInterface);
}; };
class StreamingIndexBuffer : public IndexBuffer class StreamingIndexBufferInterface : public IndexBufferInterface
{ {
public: public:
StreamingIndexBuffer(rx::Renderer9 *renderer, UINT initialSize, D3DFORMAT format); StreamingIndexBufferInterface(rx::Renderer9 *renderer, UINT initialSize, D3DFORMAT format);
~StreamingIndexBuffer(); ~StreamingIndexBufferInterface();
virtual void *map(UINT requiredSpace, UINT *offset); virtual void *map(UINT requiredSpace, UINT *offset);
virtual void reserveSpace(UINT requiredSpace, GLenum type); virtual void reserveSpace(UINT requiredSpace, GLenum type);
...@@ -65,11 +65,11 @@ class StreamingIndexBuffer : public IndexBuffer ...@@ -65,11 +65,11 @@ class StreamingIndexBuffer : public IndexBuffer
UINT mWritePosition; UINT mWritePosition;
}; };
class StaticIndexBuffer : public IndexBuffer class StaticIndexBufferInterface : public IndexBufferInterface
{ {
public: public:
explicit StaticIndexBuffer(rx::Renderer9 *renderer); explicit StaticIndexBufferInterface(rx::Renderer9 *renderer);
~StaticIndexBuffer(); ~StaticIndexBufferInterface();
virtual void *map(UINT requiredSpace, UINT *offset); virtual void *map(UINT requiredSpace, UINT *offset);
virtual void reserveSpace(UINT requiredSpace, GLenum type); virtual void reserveSpace(UINT requiredSpace, GLenum type);
......
...@@ -20,11 +20,11 @@ namespace rx ...@@ -20,11 +20,11 @@ namespace rx
IndexDataManager::IndexDataManager(rx::Renderer9 *renderer) : mRenderer(renderer) IndexDataManager::IndexDataManager(rx::Renderer9 *renderer) : mRenderer(renderer)
{ {
mStreamingBufferShort = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16); mStreamingBufferShort = new StreamingIndexBufferInterface(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
if (renderer->get32BitIndexSupport()) if (renderer->get32BitIndexSupport())
{ {
mStreamingBufferInt = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32); mStreamingBufferInt = new StreamingIndexBufferInterface(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
if (!mStreamingBufferInt) if (!mStreamingBufferInt)
{ {
...@@ -135,10 +135,10 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer ...@@ -135,10 +135,10 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer
indices = static_cast<const GLubyte*>(buffer->data()) + offset; indices = static_cast<const GLubyte*>(buffer->data()) + offset;
} }
StreamingIndexBuffer *streamingBuffer = (type == GL_UNSIGNED_INT) ? mStreamingBufferInt : mStreamingBufferShort; StreamingIndexBufferInterface *streamingBuffer = (type == GL_UNSIGNED_INT) ? mStreamingBufferInt : mStreamingBufferShort;
StaticIndexBuffer *staticBuffer = buffer ? buffer->getStaticIndexBuffer() : NULL; StaticIndexBufferInterface *staticBuffer = buffer ? buffer->getStaticIndexBuffer() : NULL;
IndexBuffer *indexBuffer = streamingBuffer; IndexBufferInterface *indexBuffer = streamingBuffer;
UINT streamOffset = 0; UINT streamOffset = 0;
if (staticBuffer && staticBuffer->lookupType(type) && alignedOffset) if (staticBuffer && staticBuffer->lookupType(type) && alignedOffset)
...@@ -225,7 +225,7 @@ std::size_t IndexDataManager::typeSize(GLenum type) const ...@@ -225,7 +225,7 @@ std::size_t IndexDataManager::typeSize(GLenum type) const
} }
} }
StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count) StaticIndexBufferInterface *IndexDataManager::getCountingIndices(GLsizei count)
{ {
if (count <= 65536) // 16-bit indices if (count <= 65536) // 16-bit indices
{ {
...@@ -234,7 +234,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count) ...@@ -234,7 +234,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count)
if (!mCountingBuffer || mCountingBuffer->size() < spaceNeeded) if (!mCountingBuffer || mCountingBuffer->size() < spaceNeeded)
{ {
delete mCountingBuffer; delete mCountingBuffer;
mCountingBuffer = new StaticIndexBuffer(mRenderer); mCountingBuffer = new StaticIndexBufferInterface(mRenderer);
mCountingBuffer->reserveSpace(spaceNeeded, GL_UNSIGNED_SHORT); mCountingBuffer->reserveSpace(spaceNeeded, GL_UNSIGNED_SHORT);
UINT offset; UINT offset;
...@@ -258,7 +258,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count) ...@@ -258,7 +258,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count)
if (!mCountingBuffer || mCountingBuffer->size() < spaceNeeded) if (!mCountingBuffer || mCountingBuffer->size() < spaceNeeded)
{ {
delete mCountingBuffer; delete mCountingBuffer;
mCountingBuffer = new StaticIndexBuffer(mRenderer); mCountingBuffer = new StaticIndexBufferInterface(mRenderer);
mCountingBuffer->reserveSpace(spaceNeeded, GL_UNSIGNED_INT); mCountingBuffer->reserveSpace(spaceNeeded, GL_UNSIGNED_INT);
UINT offset; UINT offset;
......
...@@ -41,7 +41,7 @@ class IndexDataManager ...@@ -41,7 +41,7 @@ class IndexDataManager
virtual ~IndexDataManager(); virtual ~IndexDataManager();
GLenum prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated, IDirect3DIndexBuffer9 **indexBuffer, unsigned int *serial); GLenum prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated, IDirect3DIndexBuffer9 **indexBuffer, unsigned int *serial);
StaticIndexBuffer *getCountingIndices(GLsizei count); StaticIndexBufferInterface *getCountingIndices(GLsizei count);
private: private:
DISALLOW_COPY_AND_ASSIGN(IndexDataManager); DISALLOW_COPY_AND_ASSIGN(IndexDataManager);
...@@ -51,9 +51,9 @@ class IndexDataManager ...@@ -51,9 +51,9 @@ class IndexDataManager
rx::Renderer9 *const mRenderer; // D3D9_REPLACE rx::Renderer9 *const mRenderer; // D3D9_REPLACE
StreamingIndexBuffer *mStreamingBufferShort; StreamingIndexBufferInterface *mStreamingBufferShort;
StreamingIndexBuffer *mStreamingBufferInt; StreamingIndexBufferInterface *mStreamingBufferInt;
StaticIndexBuffer *mCountingBuffer; StaticIndexBufferInterface *mCountingBuffer;
}; };
} }
......
...@@ -1220,7 +1220,7 @@ void Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances) ...@@ -1220,7 +1220,7 @@ void Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances)
} }
else if (instances > 0) else if (instances > 0)
{ {
StaticIndexBuffer *countingIB = mIndexDataManager->getCountingIndices(count); StaticIndexBufferInterface *countingIB = mIndexDataManager->getCountingIndices(count);
if (countingIB) if (countingIB)
{ {
if (mAppliedIBSerial != countingIB->getSerial()) if (mAppliedIBSerial != countingIB->getSerial())
...@@ -1283,7 +1283,7 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, ...@@ -1283,7 +1283,7 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
if (!mLineLoopIB) if (!mLineLoopIB)
{ {
mLineLoopIB = new StreamingIndexBuffer(this, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32); mLineLoopIB = new StreamingIndexBufferInterface(this, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
} }
if (mLineLoopIB) if (mLineLoopIB)
...@@ -1340,7 +1340,7 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, ...@@ -1340,7 +1340,7 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
if (!mLineLoopIB) if (!mLineLoopIB)
{ {
mLineLoopIB = new StreamingIndexBuffer(this, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16); mLineLoopIB = new StreamingIndexBufferInterface(this, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
} }
if (mLineLoopIB) if (mLineLoopIB)
......
...@@ -33,7 +33,7 @@ namespace rx ...@@ -33,7 +33,7 @@ namespace rx
{ {
class D3DConstantTable; class D3DConstantTable;
class VertexDataManager; class VertexDataManager;
class StreamingIndexBuffer; class StreamingIndexBufferInterface;
struct TranslatedAttribute; struct TranslatedAttribute;
class Renderer9 : public Renderer class Renderer9 : public Renderer
...@@ -283,7 +283,7 @@ class Renderer9 : public Renderer ...@@ -283,7 +283,7 @@ class Renderer9 : public Renderer
VertexDeclarationCache mVertexDeclarationCache; VertexDeclarationCache mVertexDeclarationCache;
IndexDataManager *mIndexDataManager; IndexDataManager *mIndexDataManager;
StreamingIndexBuffer *mLineLoopIB; StreamingIndexBufferInterface *mLineLoopIB;
enum { NUM_NULL_COLORBUFFER_CACHE_ENTRIES = 12 }; enum { NUM_NULL_COLORBUFFER_CACHE_ENTRIES = 12 };
struct NullColorbufferCacheEntry struct NullColorbufferCacheEntry
......
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