Commit 831b1953 by Geoff Lang

Move the IndexRangeCache and Range types to the gl namespace.

BUG=angleproject:881 Change-Id: Ib05149facee9fcc7714cb957ca8647b3498a36b6 Reviewed-on: https://chromium-review.googlesource.com/269254Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent 94b3a078
...@@ -501,11 +501,6 @@ inline unsigned int averageFloat10(unsigned int a, unsigned int b) ...@@ -501,11 +501,6 @@ inline unsigned int averageFloat10(unsigned int a, unsigned int b)
return float32ToFloat10((float10ToFloat32(static_cast<unsigned short>(a)) + float10ToFloat32(static_cast<unsigned short>(b))) * 0.5f); return float32ToFloat10((float10ToFloat32(static_cast<unsigned short>(a)) + float10ToFloat32(static_cast<unsigned short>(b))) * 0.5f);
} }
}
namespace rx
{
// Represents intervals of the type [a, b) // Represents intervals of the type [a, b)
template <typename T> template <typename T>
struct Range struct Range
...@@ -534,6 +529,11 @@ struct Range ...@@ -534,6 +529,11 @@ struct Range
typedef Range<int> RangeI; typedef Range<int> RangeI;
typedef Range<unsigned int> RangeUI; typedef Range<unsigned int> RangeUI;
}
namespace rx
{
template <typename T> template <typename T>
T roundUp(const T value, const T alignment) T roundUp(const T value, const T alignment)
{ {
......
...@@ -366,6 +366,33 @@ GLenum LayerIndexToCubeMapTextureTarget(size_t index) ...@@ -366,6 +366,33 @@ GLenum LayerIndexToCubeMapTextureTarget(size_t index)
return FirstCubeMapTextureTarget + static_cast<GLenum>(index); return FirstCubeMapTextureTarget + static_cast<GLenum>(index);
} }
template <class IndexType>
static RangeUI ComputeTypedIndexRange(const IndexType *indices, GLsizei count)
{
ASSERT(count > 0);
IndexType minIndex = indices[0];
IndexType maxIndex = indices[0];
for (GLsizei i = 1; i < count; i++)
{
if (minIndex > indices[i]) minIndex = indices[i];
if (maxIndex < indices[i]) maxIndex = indices[i];
}
return RangeUI(static_cast<GLuint>(minIndex), static_cast<GLuint>(maxIndex));
}
RangeUI ComputeIndexRange(GLenum indexType, const GLvoid *indices, GLsizei count)
{
switch (indexType)
{
case GL_UNSIGNED_BYTE: return ComputeTypedIndexRange(static_cast<const GLubyte*>(indices), count);
case GL_UNSIGNED_SHORT: return ComputeTypedIndexRange(static_cast<const GLushort*>(indices), count);
case GL_UNSIGNED_INT: return ComputeTypedIndexRange(static_cast<const GLuint*>(indices), count);
default: UNREACHABLE(); return RangeUI(0, 0);
}
}
bool IsTriangleMode(GLenum drawMode) bool IsTriangleMode(GLenum drawMode)
{ {
switch (drawMode) switch (drawMode)
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <string> #include <string>
#include <math.h> #include <math.h>
#include "common/mathutil.h"
namespace gl namespace gl
{ {
...@@ -44,6 +46,8 @@ GLenum LayerIndexToCubeMapTextureTarget(size_t index); ...@@ -44,6 +46,8 @@ GLenum LayerIndexToCubeMapTextureTarget(size_t index);
// set to GL_INVALID_INDEX if the provided name is not an array or the array index is invalid. // set to GL_INVALID_INDEX if the provided name is not an array or the array index is invalid.
std::string ParseUniformName(const std::string &name, size_t *outSubscript); std::string ParseUniformName(const std::string &name, size_t *outSubscript);
RangeUI ComputeIndexRange(GLenum indexType, const GLvoid *indices, GLsizei count);
bool IsTriangleMode(GLenum drawMode); bool IsTriangleMode(GLenum drawMode);
// [OpenGL ES 3.0.2] Section 2.3.1 page 14 // [OpenGL ES 3.0.2] Section 2.3.1 page 14
......
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
#ifndef LIBANGLE_BUFFER_H_ #ifndef LIBANGLE_BUFFER_H_
#define LIBANGLE_BUFFER_H_ #define LIBANGLE_BUFFER_H_
#include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/IndexRangeCache.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
#include "libANGLE/renderer/IndexRangeCache.h"
#include "common/angleutils.h"
namespace rx namespace rx
{ {
...@@ -50,8 +49,8 @@ class Buffer : public RefCountObject ...@@ -50,8 +49,8 @@ class Buffer : public RefCountObject
rx::BufferImpl *getImplementation() const { return mBuffer; } rx::BufferImpl *getImplementation() const { return mBuffer; }
rx::IndexRangeCache *getIndexRangeCache() { return &mIndexRangeCache; } IndexRangeCache *getIndexRangeCache() { return &mIndexRangeCache; }
const rx::IndexRangeCache *getIndexRangeCache() const { return &mIndexRangeCache; } const IndexRangeCache *getIndexRangeCache() const { return &mIndexRangeCache; }
private: private:
rx::BufferImpl *mBuffer; rx::BufferImpl *mBuffer;
...@@ -65,7 +64,7 @@ class Buffer : public RefCountObject ...@@ -65,7 +64,7 @@ class Buffer : public RefCountObject
GLint64 mMapOffset; GLint64 mMapOffset;
GLint64 mMapLength; GLint64 mMapLength;
rx::IndexRangeCache mIndexRangeCache; IndexRangeCache mIndexRangeCache;
}; };
} }
......
...@@ -1224,7 +1224,7 @@ Error Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei insta ...@@ -1224,7 +1224,7 @@ Error Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei insta
Error Context::drawElements(GLenum mode, GLsizei count, GLenum type, Error Context::drawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const rx::RangeUI &indexRange) const RangeUI &indexRange)
{ {
return mRenderer->drawElements(getData(), mode, count, type, indices, instances, indexRange); return mRenderer->drawElements(getData(), mode, count, type, indices, instances, indexRange);
} }
......
...@@ -167,7 +167,7 @@ class Context final : angle::NonCopyable ...@@ -167,7 +167,7 @@ class Context final : angle::NonCopyable
Error drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances); Error drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
Error drawElements(GLenum mode, GLsizei count, GLenum type, Error drawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const rx::RangeUI &indexRange); const RangeUI &indexRange);
Error flush(); Error flush();
Error finish(); Error finish();
......
...@@ -83,30 +83,30 @@ ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn) ...@@ -83,30 +83,30 @@ ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip) ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip)
{ {
return ImageIndexIterator(GL_TEXTURE_2D, rx::Range<GLint>(minMip, maxMip), return ImageIndexIterator(GL_TEXTURE_2D, Range<GLint>(minMip, maxMip),
rx::Range<GLint>(ImageIndex::ENTIRE_LEVEL, ImageIndex::ENTIRE_LEVEL), NULL); Range<GLint>(ImageIndex::ENTIRE_LEVEL, ImageIndex::ENTIRE_LEVEL), NULL);
} }
ImageIndexIterator ImageIndexIterator::MakeCube(GLint minMip, GLint maxMip) ImageIndexIterator ImageIndexIterator::MakeCube(GLint minMip, GLint maxMip)
{ {
return ImageIndexIterator(GL_TEXTURE_CUBE_MAP, rx::Range<GLint>(minMip, maxMip), rx::Range<GLint>(0, 6), NULL); return ImageIndexIterator(GL_TEXTURE_CUBE_MAP, Range<GLint>(minMip, maxMip), Range<GLint>(0, 6), NULL);
} }
ImageIndexIterator ImageIndexIterator::Make3D(GLint minMip, GLint maxMip, ImageIndexIterator ImageIndexIterator::Make3D(GLint minMip, GLint maxMip,
GLint minLayer, GLint maxLayer) GLint minLayer, GLint maxLayer)
{ {
return ImageIndexIterator(GL_TEXTURE_3D, rx::Range<GLint>(minMip, maxMip), rx::Range<GLint>(minLayer, maxLayer), NULL); return ImageIndexIterator(GL_TEXTURE_3D, Range<GLint>(minMip, maxMip), Range<GLint>(minLayer, maxLayer), NULL);
} }
ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip, ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip,
const GLsizei *layerCounts) const GLsizei *layerCounts)
{ {
return ImageIndexIterator(GL_TEXTURE_2D_ARRAY, rx::Range<GLint>(minMip, maxMip), return ImageIndexIterator(GL_TEXTURE_2D_ARRAY, Range<GLint>(minMip, maxMip),
rx::Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS), layerCounts); Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS), layerCounts);
} }
ImageIndexIterator::ImageIndexIterator(GLenum type, const rx::Range<GLint> &mipRange, ImageIndexIterator::ImageIndexIterator(GLenum type, const Range<GLint> &mipRange,
const rx::Range<GLint> &layerRange, const GLsizei *layerCounts) const Range<GLint> &layerRange, const GLsizei *layerCounts)
: mType(type), : mType(type),
mMipRange(mipRange), mMipRange(mipRange),
mLayerRange(layerRange), mLayerRange(layerRange),
......
...@@ -61,14 +61,14 @@ class ImageIndexIterator ...@@ -61,14 +61,14 @@ class ImageIndexIterator
private: private:
ImageIndexIterator(GLenum type, const rx::Range<GLint> &mipRange, ImageIndexIterator(GLenum type, const Range<GLint> &mipRange,
const rx::Range<GLint> &layerRange, const GLsizei *layerCounts); const Range<GLint> &layerRange, const GLsizei *layerCounts);
GLint maxLayer() const; GLint maxLayer() const;
GLenum mType; GLenum mType;
rx::Range<GLint> mMipRange; Range<GLint> mMipRange;
rx::Range<GLint> mLayerRange; Range<GLint> mLayerRange;
const GLsizei *mLayerCounts; const GLsizei *mLayerCounts;
GLint mCurrentMip; GLint mCurrentMip;
GLint mCurrentLayer; GLint mCurrentLayer;
......
...@@ -4,47 +4,16 @@ ...@@ -4,47 +4,16 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// IndexRangeCache.cpp: Defines the rx::IndexRangeCache class which stores information about // IndexRangeCache.cpp: Defines the gl::IndexRangeCache class which stores information about
// ranges of indices. // ranges of indices.
#include "libANGLE/renderer/IndexRangeCache.h" #include "libANGLE/IndexRangeCache.h"
#include "libANGLE/formatutils.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/formatutils.h"
namespace rx namespace gl
{
template <class IndexType>
static RangeUI ComputeTypedRange(const IndexType *indices, GLsizei count)
{
unsigned int minIndex = indices[0];
unsigned int maxIndex = indices[0];
for (GLsizei i = 1; i < count; i++)
{
if (minIndex > indices[i]) minIndex = indices[i];
if (maxIndex < indices[i]) maxIndex = indices[i];
}
return RangeUI(minIndex, maxIndex);
}
RangeUI IndexRangeCache::ComputeRange(GLenum type, const GLvoid *indices, GLsizei count)
{ {
switch (type)
{
case GL_UNSIGNED_BYTE:
return ComputeTypedRange(static_cast<const GLubyte*>(indices), count);
case GL_UNSIGNED_INT:
return ComputeTypedRange(static_cast<const GLuint*>(indices), count);
case GL_UNSIGNED_SHORT:
return ComputeTypedRange(static_cast<const GLushort*>(indices), count);
default:
UNREACHABLE();
return RangeUI();
}
}
void IndexRangeCache::addRange(GLenum type, unsigned int offset, GLsizei count, const RangeUI &range) void IndexRangeCache::addRange(GLenum type, unsigned int offset, GLsizei count, const RangeUI &range)
{ {
...@@ -60,7 +29,7 @@ void IndexRangeCache::invalidateRange(unsigned int offset, unsigned int size) ...@@ -60,7 +29,7 @@ void IndexRangeCache::invalidateRange(unsigned int offset, unsigned int size)
while (i != mIndexRangeCache.end()) while (i != mIndexRangeCache.end())
{ {
unsigned int rangeStart = i->first.offset; unsigned int rangeStart = i->first.offset;
unsigned int rangeEnd = i->first.offset + (gl::GetTypeInfo(i->first.type).bytes * i->first.count); unsigned int rangeEnd = i->first.offset + (GetTypeInfo(i->first.type).bytes * i->first.count);
if (invalidateEnd < rangeStart || invalidateStart > rangeEnd) if (invalidateEnd < rangeStart || invalidateStart > rangeEnd)
{ {
...@@ -79,12 +48,18 @@ bool IndexRangeCache::findRange(GLenum type, unsigned int offset, GLsizei count, ...@@ -79,12 +48,18 @@ bool IndexRangeCache::findRange(GLenum type, unsigned int offset, GLsizei count,
IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count)); IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count));
if (i != mIndexRangeCache.end()) if (i != mIndexRangeCache.end())
{ {
if (outRange) *outRange = i->second; if (outRange)
{
*outRange = i->second;
}
return true; return true;
} }
else else
{ {
if (outRange) *outRange = RangeUI(0, 0); if (outRange)
{
*outRange = RangeUI(0, 0);
}
return false; return false;
} }
} }
...@@ -95,12 +70,14 @@ void IndexRangeCache::clear() ...@@ -95,12 +70,14 @@ void IndexRangeCache::clear()
} }
IndexRangeCache::IndexRange::IndexRange() IndexRangeCache::IndexRange::IndexRange()
: type(GL_NONE), offset(0), count(0) : IndexRangeCache::IndexRange(GL_NONE, 0, 0)
{ {
} }
IndexRangeCache::IndexRange::IndexRange(GLenum typ, intptr_t off, GLsizei c) IndexRangeCache::IndexRange::IndexRange(GLenum typ, intptr_t off, GLsizei c)
: type(typ), offset(static_cast<unsigned int>(off)), count(c) : type(typ),
offset(static_cast<unsigned int>(off)),
count(c)
{ {
} }
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// IndexRangeCache.h: Defines the rx::IndexRangeCache class which stores information about // IndexRangeCache.h: Defines the gl::IndexRangeCache class which stores information about
// ranges of indices. // ranges of indices.
#ifndef LIBANGLE_RENDERER_INDEXRANGECACHE_H_ #ifndef LIBANGLE_INDEXRANGECACHE_H_
#define LIBANGLE_RENDERER_INDEXRANGECACHE_H_ #define LIBANGLE_INDEXRANGECACHE_H_
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/mathutil.h" #include "common/mathutil.h"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <map> #include <map>
namespace rx namespace gl
{ {
class IndexRangeCache class IndexRangeCache
...@@ -29,8 +29,6 @@ class IndexRangeCache ...@@ -29,8 +29,6 @@ class IndexRangeCache
void invalidateRange(unsigned int offset, unsigned int size); void invalidateRange(unsigned int offset, unsigned int size);
void clear(); void clear();
static RangeUI ComputeRange(GLenum type, const GLvoid *indices, GLsizei count);
private: private:
struct IndexRange struct IndexRange
{ {
...@@ -50,4 +48,4 @@ class IndexRangeCache ...@@ -50,4 +48,4 @@ class IndexRangeCache
} }
#endif // LIBANGLE_RENDERER_INDEXRANGECACHE_H_ #endif // LIBANGLE_INDEXRANGECACHE_H_
...@@ -55,7 +55,7 @@ class Renderer : public ImplFactory ...@@ -55,7 +55,7 @@ class Renderer : public ImplFactory
GLint first, GLsizei count, GLsizei instances) = 0; GLint first, GLsizei count, GLsizei instances) = 0;
virtual gl::Error drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type, virtual gl::Error drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) = 0; const gl::RangeUI &indexRange) = 0;
// lost device // lost device
//TODO(jmadill): investigate if this stuff is necessary in GL //TODO(jmadill): investigate if this stuff is necessary in GL
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/renderer/IndexRangeCache.h"
namespace rx namespace rx
{ {
......
...@@ -38,7 +38,7 @@ class RendererD3D; ...@@ -38,7 +38,7 @@ class RendererD3D;
struct TranslatedIndexData struct TranslatedIndexData
{ {
RangeUI indexRange; gl::RangeUI indexRange;
unsigned int startIndex; unsigned int startIndex;
unsigned int startOffset; // In bytes unsigned int startOffset; // In bytes
......
...@@ -57,7 +57,7 @@ void RendererD3D::cleanup() ...@@ -57,7 +57,7 @@ void RendererD3D::cleanup()
gl::Error RendererD3D::drawElements(const gl::Data &data, gl::Error RendererD3D::drawElements(const gl::Data &data,
GLenum mode, GLsizei count, GLenum type, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) const gl::RangeUI &indexRange)
{ {
if (data.state->isPrimitiveRestartEnabled()) if (data.state->isPrimitiveRestartEnabled())
{ {
......
...@@ -86,7 +86,7 @@ class RendererD3D : public Renderer, public BufferFactoryD3D ...@@ -86,7 +86,7 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
gl::Error drawElements(const gl::Data &data, gl::Error drawElements(const gl::Data &data,
GLenum mode, GLsizei count, GLenum type, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) override; const gl::RangeUI &indexRange) override;
bool isDeviceLost() const override; bool isDeviceLost() const override;
std::string getVendorString() const override; std::string getVendorString() const override;
......
...@@ -94,7 +94,7 @@ static bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER ...@@ -94,7 +94,7 @@ static bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER
unsigned mipMin = index.mipIndex; unsigned mipMin = index.mipIndex;
unsigned mipMax = (layerIndex == -1) ? INT_MAX : layerIndex; unsigned mipMax = (layerIndex == -1) ? INT_MAX : layerIndex;
return type == GL_TEXTURE_2D && RangeUI(mipMin, mipMax).intersects(RangeUI(desc.Texture2D.MostDetailedMip, maxSrvMip)); return type == GL_TEXTURE_2D && gl::RangeUI(mipMin, mipMax).intersects(gl::RangeUI(desc.Texture2D.MostDetailedMip, maxSrvMip));
} }
case D3D11_SRV_DIMENSION_TEXTURE2DARRAY: case D3D11_SRV_DIMENSION_TEXTURE2DARRAY:
......
...@@ -129,7 +129,7 @@ gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode, ...@@ -129,7 +129,7 @@ gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode,
gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type, gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) const gl::RangeUI &indexRange)
{ {
if (instances > 0) if (instances > 0)
{ {
......
...@@ -29,7 +29,7 @@ class RendererGL : public Renderer ...@@ -29,7 +29,7 @@ class RendererGL : public Renderer
GLint first, GLsizei count, GLsizei instances) override; GLint first, GLsizei count, GLsizei instances) override;
gl::Error drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type, gl::Error drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) override; const gl::RangeUI &indexRange) override;
// Shader creation // Shader creation
CompilerImpl *createCompiler(const gl::Data &data) override; CompilerImpl *createCompiler(const gl::Data &data) override;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/mathutil.h" #include "common/mathutil.h"
#include "common/utilities.h"
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
...@@ -117,7 +118,7 @@ gl::Error VertexArrayGL::syncDrawState(GLint first, GLsizei count, GLenum type, ...@@ -117,7 +118,7 @@ gl::Error VertexArrayGL::syncDrawState(GLint first, GLsizei count, GLenum type,
bool attributesNeedStreaming = doAttributesNeedStreaming(); bool attributesNeedStreaming = doAttributesNeedStreaming();
// Determine if an index buffer needs to be streamed and the range of vertices that need to be copied // Determine if an index buffer needs to be streamed and the range of vertices that need to be copied
RangeUI indexRange(0, 0); gl::RangeUI indexRange(0, 0);
if (type != GL_NONE) if (type != GL_NONE)
{ {
gl::Error error = syncIndexData(count, type, indices, attributesNeedStreaming, &indexRange, outIndices); gl::Error error = syncIndexData(count, type, indices, attributesNeedStreaming, &indexRange, outIndices);
...@@ -170,7 +171,7 @@ bool VertexArrayGL::doAttributesNeedStreaming() const ...@@ -170,7 +171,7 @@ bool VertexArrayGL::doAttributesNeedStreaming() const
return false; return false;
} }
gl::Error VertexArrayGL::syncAttributeState(bool attributesNeedStreaming, const RangeUI &indexRange, gl::Error VertexArrayGL::syncAttributeState(bool attributesNeedStreaming, const gl::RangeUI &indexRange,
size_t *outStreamingDataSize, size_t *outMaxAttributeDataSize) const size_t *outStreamingDataSize, size_t *outMaxAttributeDataSize) const
{ {
*outStreamingDataSize = 0; *outStreamingDataSize = 0;
...@@ -241,7 +242,7 @@ gl::Error VertexArrayGL::syncAttributeState(bool attributesNeedStreaming, const ...@@ -241,7 +242,7 @@ gl::Error VertexArrayGL::syncAttributeState(bool attributesNeedStreaming, const
} }
gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming, gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming,
RangeUI *outIndexRange, const GLvoid **outIndices) const gl::RangeUI *outIndexRange, const GLvoid **outIndices) const
{ {
ASSERT(outIndices); ASSERT(outIndices);
...@@ -262,7 +263,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid ...@@ -262,7 +263,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid
ptrdiff_t elementArrayBufferOffset = reinterpret_cast<ptrdiff_t>(indices); ptrdiff_t elementArrayBufferOffset = reinterpret_cast<ptrdiff_t>(indices);
// Find the index range in the buffer // Find the index range in the buffer
const IndexRangeCache *rangeCache = mElementArrayBuffer.get()->getIndexRangeCache(); const gl::IndexRangeCache *rangeCache = mElementArrayBuffer.get()->getIndexRangeCache();
if (!rangeCache->findRange(type, static_cast<unsigned int>(elementArrayBufferOffset), count, outIndexRange)) if (!rangeCache->findRange(type, static_cast<unsigned int>(elementArrayBufferOffset), count, outIndexRange))
{ {
...@@ -270,10 +271,10 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid ...@@ -270,10 +271,10 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid
mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBufferID); mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBufferID);
uint8_t *elementArrayBufferPointer = reinterpret_cast<uint8_t*>(mFunctions->mapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY)); uint8_t *elementArrayBufferPointer = reinterpret_cast<uint8_t*>(mFunctions->mapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY));
*outIndexRange = IndexRangeCache::ComputeRange(type, elementArrayBufferPointer + elementArrayBufferOffset, count); *outIndexRange = gl::ComputeIndexRange(type, elementArrayBufferPointer + elementArrayBufferOffset, count);
// TODO: Store the range cache at the impl level since the gl::Buffer object is supposed to remain constant // TODO: Store the range cache at the impl level since the gl::Buffer object is supposed to remain constant
const_cast<IndexRangeCache*>(rangeCache)->addRange(type, static_cast<unsigned int>(elementArrayBufferOffset), count, *outIndexRange); const_cast<gl::IndexRangeCache*>(rangeCache)->addRange(type, static_cast<unsigned int>(elementArrayBufferOffset), count, *outIndexRange);
if (!mFunctions->unmapBuffer(GL_ELEMENT_ARRAY_BUFFER)) if (!mFunctions->unmapBuffer(GL_ELEMENT_ARRAY_BUFFER))
{ {
...@@ -293,7 +294,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid ...@@ -293,7 +294,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid
// Only compute the index range if the attributes also need to be streamed // Only compute the index range if the attributes also need to be streamed
if (attributesNeedStreaming) if (attributesNeedStreaming)
{ {
*outIndexRange = IndexRangeCache::ComputeRange(type, indices, count); *outIndexRange = gl::ComputeIndexRange(type, indices, count);
} }
// Allocate the streaming element array buffer // Allocate the streaming element array buffer
...@@ -328,7 +329,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid ...@@ -328,7 +329,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error VertexArrayGL::streamAttributes(size_t streamingDataSize, size_t maxAttributeDataSize, const RangeUI &indexRange) const gl::Error VertexArrayGL::streamAttributes(size_t streamingDataSize, size_t maxAttributeDataSize, const gl::RangeUI &indexRange) const
{ {
if (mStreamingArrayBuffer == 0) if (mStreamingArrayBuffer == 0)
{ {
......
...@@ -41,15 +41,15 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -41,15 +41,15 @@ class VertexArrayGL : public VertexArrayImpl
// Apply attribute state, returns the amount of space needed to stream all attributes that need streaming // Apply attribute state, returns the amount of space needed to stream all attributes that need streaming
// and the data size of the largest attribute // and the data size of the largest attribute
gl::Error syncAttributeState(bool attributesNeedStreaming, const RangeUI &indexRange, size_t *outStreamingDataSize, gl::Error syncAttributeState(bool attributesNeedStreaming, const gl::RangeUI &indexRange, size_t *outStreamingDataSize,
size_t *outMaxAttributeDataSize) const; size_t *outMaxAttributeDataSize) const;
// Apply index data, only sets outIndexRange if attributesNeedStreaming is true // Apply index data, only sets outIndexRange if attributesNeedStreaming is true
gl::Error syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming, gl::Error syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming,
RangeUI *outIndexRange, const GLvoid **outIndices) const; gl::RangeUI *outIndexRange, const GLvoid **outIndices) const;
// Stream attributes that have client data // Stream attributes that have client data
gl::Error streamAttributes(size_t streamingDataSize, size_t maxAttributeDataSize, const RangeUI &indexRange) const; gl::Error streamAttributes(size_t streamingDataSize, size_t maxAttributeDataSize, const gl::RangeUI &indexRange) const;
const FunctionsGL *mFunctions; const FunctionsGL *mFunctions;
StateManagerGL *mStateManager; StateManagerGL *mStateManager;
......
...@@ -1196,7 +1196,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, ...@@ -1196,7 +1196,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType,
return true; return true;
} }
bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage, bool ValidateCopyTexImageParametersBase(gl::Context *context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height,
GLint border, GLenum *textureFormatOut) GLint border, GLenum *textureFormatOut)
{ {
...@@ -1564,7 +1564,7 @@ bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first ...@@ -1564,7 +1564,7 @@ bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first
} }
bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut) const GLvoid *indices, GLsizei primcount, RangeUI *indexRangeOut)
{ {
switch (type) switch (type)
{ {
...@@ -1656,13 +1656,13 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t ...@@ -1656,13 +1656,13 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t
} }
const uint8_t *offsetPointer = dataPointer + offset; const uint8_t *offsetPointer = dataPointer + offset;
*indexRangeOut = rx::IndexRangeCache::ComputeRange(type, offsetPointer, count); *indexRangeOut = ComputeIndexRange(type, offsetPointer, count);
elementArrayBuffer->getIndexRangeCache()->addRange(type, static_cast<unsigned int>(offset), count, *indexRangeOut); elementArrayBuffer->getIndexRangeCache()->addRange(type, static_cast<unsigned int>(offset), count, *indexRangeOut);
} }
} }
else else
{ {
*indexRangeOut = rx::IndexRangeCache::ComputeRange(type, indices, count); *indexRangeOut = ComputeIndexRange(type, indices, count);
} }
if (!ValidateDrawBase(context, mode, count, static_cast<GLsizei>(indexRangeOut->end), primcount)) if (!ValidateDrawBase(context, mode, count, static_cast<GLsizei>(indexRangeOut->end), primcount))
...@@ -1676,7 +1676,7 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t ...@@ -1676,7 +1676,7 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t
bool ValidateDrawElementsInstanced(Context *context, bool ValidateDrawElementsInstanced(Context *context,
GLenum mode, GLsizei count, GLenum type, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, const GLvoid *indices, GLsizei primcount,
rx::RangeUI *indexRangeOut) RangeUI *indexRangeOut)
{ {
if (primcount < 0) if (primcount < 0)
{ {
...@@ -1694,7 +1694,7 @@ bool ValidateDrawElementsInstanced(Context *context, ...@@ -1694,7 +1694,7 @@ bool ValidateDrawElementsInstanced(Context *context,
} }
bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut) const GLvoid *indices, GLsizei primcount, RangeUI *indexRangeOut)
{ {
if (!ValidateDrawInstancedANGLE(context)) if (!ValidateDrawInstancedANGLE(context))
{ {
......
...@@ -71,12 +71,12 @@ bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLs ...@@ -71,12 +71,12 @@ bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLs
bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut); const GLvoid *indices, GLsizei primcount, RangeUI *indexRangeOut);
bool ValidateDrawElementsInstanced(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElementsInstanced(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut); const GLvoid *indices, GLsizei primcount, RangeUI *indexRangeOut);
bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut); const GLvoid *indices, GLsizei primcount, RangeUI *indexRangeOut);
bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment,
GLuint texture, GLint level); GLuint texture, GLint level);
......
...@@ -80,6 +80,8 @@ ...@@ -80,6 +80,8 @@
'libANGLE/HandleAllocator.h', 'libANGLE/HandleAllocator.h',
'libANGLE/ImageIndex.h', 'libANGLE/ImageIndex.h',
'libANGLE/ImageIndex.cpp', 'libANGLE/ImageIndex.cpp',
'libANGLE/IndexRangeCache.cpp',
'libANGLE/IndexRangeCache.h',
'libANGLE/Platform.cpp', 'libANGLE/Platform.cpp',
'libANGLE/Program.cpp', 'libANGLE/Program.cpp',
'libANGLE/Program.h', 'libANGLE/Program.h',
...@@ -127,8 +129,6 @@ ...@@ -127,8 +129,6 @@
'libANGLE/renderer/FenceSyncImpl.h', 'libANGLE/renderer/FenceSyncImpl.h',
'libANGLE/renderer/FramebufferImpl.h', 'libANGLE/renderer/FramebufferImpl.h',
'libANGLE/renderer/ImplFactory.h', 'libANGLE/renderer/ImplFactory.h',
'libANGLE/renderer/IndexRangeCache.cpp',
'libANGLE/renderer/IndexRangeCache.h',
'libANGLE/renderer/ProgramImpl.cpp', 'libANGLE/renderer/ProgramImpl.cpp',
'libANGLE/renderer/ProgramImpl.h', 'libANGLE/renderer/ProgramImpl.h',
'libANGLE/renderer/QueryImpl.h', 'libANGLE/renderer/QueryImpl.h',
......
...@@ -1236,7 +1236,7 @@ void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const GLv ...@@ -1236,7 +1236,7 @@ void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const GLv
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
rx::RangeUI indexRange; RangeUI indexRange;
if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange)) if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
{ {
return; return;
......
...@@ -117,7 +117,7 @@ void GL_APIENTRY DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t ...@@ -117,7 +117,7 @@ void GL_APIENTRY DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
rx::RangeUI indexRange; RangeUI indexRange;
if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange)) if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
{ {
return; return;
......
...@@ -59,7 +59,7 @@ void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize ...@@ -59,7 +59,7 @@ void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize
return; return;
} }
rx::RangeUI indexRange; RangeUI indexRange;
if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange)) if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
{ {
return; return;
...@@ -2328,7 +2328,7 @@ void GL_APIENTRY DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, ...@@ -2328,7 +2328,7 @@ void GL_APIENTRY DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
return; return;
} }
rx::RangeUI indexRange; RangeUI indexRange;
if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, instanceCount, &indexRange)) if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, instanceCount, &indexRange))
{ {
return; return;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "common/utilities.h"
#include "libANGLE/renderer/d3d/BufferD3D.h" #include "libANGLE/renderer/d3d/BufferD3D.h"
#include "libANGLE/renderer/d3d/IndexBuffer.h" #include "libANGLE/renderer/d3d/IndexBuffer.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h" #include "libANGLE/renderer/d3d/IndexDataManager.h"
...@@ -145,7 +146,7 @@ void IndexDataManagerPerfTest::step(float dt, double totalTime) ...@@ -145,7 +146,7 @@ void IndexDataManagerPerfTest::step(float dt, double totalTime)
{ {
if (!mIndexBuffer.getIndexRangeCache()->findRange(GL_UNSIGNED_SHORT, 0, mIndexCount, &translatedIndexData.indexRange)) if (!mIndexBuffer.getIndexRangeCache()->findRange(GL_UNSIGNED_SHORT, 0, mIndexCount, &translatedIndexData.indexRange))
{ {
translatedIndexData.indexRange = rx::IndexRangeCache::ComputeRange(GL_UNSIGNED_SHORT, &mIndexData[0], mIndexCount); translatedIndexData.indexRange = gl::ComputeIndexRange(GL_UNSIGNED_SHORT, &mIndexData[0], mIndexCount);
mIndexBuffer.getIndexRangeCache()->addRange(GL_UNSIGNED_SHORT, 0, mIndexCount, translatedIndexData.indexRange); mIndexBuffer.getIndexRangeCache()->addRange(GL_UNSIGNED_SHORT, 0, mIndexCount, translatedIndexData.indexRange);
} }
......
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