Commit ff7b8867 by Alexis Hetu Committed by Alexis Hétu

Added OpenGL ES 3.0 parameters to buffers and textures

Added parameters to support: - Mapping a subset of a buffer - New texture features like swizzling, min/max LOD, texture comparison modes, etc. Change-Id: Iffd961a3aeab33cb95892f93d78d3888ce60e401 Reviewed-on: https://swiftshader-review.googlesource.com/2780Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent d45d14a5
......@@ -27,6 +27,10 @@ Buffer::Buffer(GLuint name) : Object(name)
mContents = 0;
mSize = 0;
mUsage = GL_DYNAMIC_DRAW;
mIsMapped = false;
mOffset = 0;
mLength = 0;
mAccess = 0;
}
Buffer::~Buffer()
......@@ -75,6 +79,33 @@ void Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset)
}
}
void* Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
{
if(mContents)
{
char* buffer = (char*)mContents->lock(sw::PUBLIC);
mIsMapped = true;
mOffset = offset;
mLength = length;
mAccess = access;
return buffer + offset;
}
return nullptr;
}
bool Buffer::unmap()
{
if(mContents)
{
mContents->unlock();
}
mIsMapped = false;
mOffset = 0;
mLength = 0;
mAccess = 0;
return true;
}
sw::Resource *Buffer::getResource()
{
return mContents;
......
......@@ -40,6 +40,14 @@ class Buffer : public gl::Object
const void *data() { return mContents ? mContents->data() : 0; }
size_t size() const { return mSize; }
GLenum usage() const { return mUsage; }
bool isMapped() const { return mIsMapped; }
GLintptr offset() const { return mOffset; }
GLsizeiptr length() const { return mLength; }
GLbitfield access() const { return mAccess; }
void* mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
bool unmap();
void flushMappedRange(GLintptr offset, GLsizeiptr length) {}
sw::Resource *getResource();
......@@ -47,6 +55,10 @@ class Buffer : public gl::Object
sw::Resource *mContents;
size_t mSize;
GLenum mUsage;
bool mIsMapped;
GLintptr mOffset;
GLsizeiptr mLength;
GLbitfield mAccess;
};
}
......
......@@ -36,6 +36,17 @@ Texture::Texture(GLuint name) : egl::Texture(name)
mWrapT = GL_REPEAT;
mWrapR = GL_REPEAT;
mMaxAnisotropy = 1.0f;
mBaseLevel = 0;
mCompareFunc = GL_LEQUAL;
mCompareMode = GL_NONE;
mImmutableFormat = GL_FALSE;
mMaxLevel = 1000;
mMaxLOD = 1000;
mMinLOD = -1000;
mSwizzleR = GL_RED;
mSwizzleG = GL_GREEN;
mSwizzleB = GL_BLUE;
mSwizzleA = GL_ALPHA;
resource = new sw::Resource(0);
}
......@@ -165,6 +176,136 @@ bool Texture::setMaxAnisotropy(float textureMaxAnisotropy)
return true;
}
bool Texture::setBaseLevel(GLint baseLevel)
{
mBaseLevel = baseLevel;
return true;
}
bool Texture::setCompareFunc(GLenum compareFunc)
{
switch(compareFunc)
{
case GL_LEQUAL:
case GL_GEQUAL:
case GL_LESS:
case GL_GREATER:
case GL_EQUAL:
case GL_NOTEQUAL:
case GL_ALWAYS:
case GL_NEVER:
mCompareFunc = compareFunc;
return true;
default:
return false;
}
}
bool Texture::setCompareMode(GLenum compareMode)
{
switch(compareMode)
{
case GL_COMPARE_REF_TO_TEXTURE:
case GL_NONE:
mCompareMode = compareMode;
return true;
default:
return false;
}
}
bool Texture::setImmutableFormat(GLboolean immutableFormat)
{
mImmutableFormat = immutableFormat;
return true;
}
bool Texture::setMaxLevel(GLint maxLevel)
{
mMaxLevel = maxLevel;
return true;
}
bool Texture::setMaxLOD(GLfloat maxLOD)
{
mMaxLOD = maxLOD;
return true;
}
bool Texture::setMinLOD(GLfloat minLOD)
{
mMinLOD = minLOD;
return true;
}
bool Texture::setSwizzleR(GLenum swizzleR)
{
switch(swizzleR)
{
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_ZERO:
case GL_ONE:
mSwizzleR = swizzleR;
return true;
default:
return false;
}
}
bool Texture::setSwizzleG(GLenum swizzleG)
{
switch(swizzleG)
{
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_ZERO:
case GL_ONE:
mSwizzleG = swizzleG;
return true;
default:
return false;
}
}
bool Texture::setSwizzleB(GLenum swizzleB)
{
switch(swizzleB)
{
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_ZERO:
case GL_ONE:
mSwizzleB = swizzleB;
return true;
default:
return false;
}
}
bool Texture::setSwizzleA(GLenum swizzleA)
{
switch(swizzleA)
{
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_ZERO:
case GL_ONE:
mSwizzleA = swizzleA;
return true;
default:
return false;
}
}
GLenum Texture::getMinFilter() const
{
return mMinFilter;
......@@ -195,6 +336,51 @@ GLfloat Texture::getMaxAnisotropy() const
return mMaxAnisotropy;
}
GLint Texture::getBaseLevel() const
{
return mBaseLevel;
}
GLenum Texture::getCompareFunc() const
{
return mCompareFunc;
}
GLenum Texture::getCompareMode() const
{
return mCompareMode;
}
GLboolean Texture::getImmutableFormat() const
{
return mImmutableFormat;
}
GLint Texture::getMaxLevel() const
{
return mMaxLevel;
}
GLfloat Texture::getMaxLOD() const
{
return mMaxLOD;
}
GLfloat Texture::getMinLOD() const
{
return mMinLOD;
}
GLenum Texture::getSwizzleR() const
{
return mSwizzleR;
}
GLenum Texture::getSwizzleG() const
{
return mSwizzleG;
}
GLenum Texture::getSwizzleB() const
{
return mSwizzleB;
}
GLenum Texture::getSwizzleA() const
{
return mSwizzleA;
}
GLsizei Texture::getDepth(GLenum target, GLint level) const
{
return 1;
......
......@@ -71,6 +71,17 @@ public:
bool setWrapT(GLenum wrap);
bool setWrapR(GLenum wrap);
bool setMaxAnisotropy(GLfloat textureMaxAnisotropy);
bool setBaseLevel(GLint baseLevel);
bool setCompareFunc(GLenum compareFunc);
bool setCompareMode(GLenum compareMode);
bool setImmutableFormat(GLboolean immutableFormat);
bool setMaxLevel(GLint maxLevel);
bool setMaxLOD(GLfloat maxLOD);
bool setMinLOD(GLfloat minLOD);
bool setSwizzleR(GLenum swizzleR);
bool setSwizzleG(GLenum swizzleG);
bool setSwizzleB(GLenum swizzleB);
bool setSwizzleA(GLenum swizzleA);
GLenum getMinFilter() const;
GLenum getMagFilter() const;
......@@ -78,6 +89,17 @@ public:
GLenum getWrapT() const;
GLenum getWrapR() const;
GLfloat getMaxAnisotropy() const;
GLint getBaseLevel() const;
GLenum getCompareFunc() const;
GLenum getCompareMode() const;
GLboolean getImmutableFormat() const;
GLint getMaxLevel() const;
GLfloat getMaxLOD() const;
GLfloat getMinLOD() const;
GLenum getSwizzleR() const;
GLenum getSwizzleG() const;
GLenum getSwizzleB() const;
GLenum getSwizzleA() const;
virtual GLsizei getWidth(GLenum target, GLint level) const = 0;
virtual GLsizei getHeight(GLenum target, GLint level) const = 0;
......@@ -115,6 +137,17 @@ protected:
GLenum mWrapT;
GLenum mWrapR;
GLfloat mMaxAnisotropy;
GLint mBaseLevel;
GLenum mCompareFunc;
GLenum mCompareMode;
GLboolean mImmutableFormat;
GLint mMaxLevel;
GLfloat mMaxLOD;
GLfloat mMinLOD;
GLenum mSwizzleR;
GLenum mSwizzleG;
GLenum mSwizzleB;
GLenum mSwizzleA;
sw::Resource *resource;
};
......
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