Rename SamplerType to TextureType (refactoring).

Issue=95 TRAC #16568 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@638 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent af29cac9
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 637
#define BUILD_REVISION 638
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -191,7 +191,7 @@ Context::~Context()
mMultiSampleSupport.erase(mMultiSampleSupport.begin());
}
for (int type = 0; type < SAMPLER_TYPE_COUNT; type++)
for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
for (int sampler = 0; sampler < MAX_TEXTURE_IMAGE_UNITS; sampler++)
{
......@@ -199,7 +199,7 @@ Context::~Context()
}
}
for (int type = 0; type < SAMPLER_TYPE_COUNT; type++)
for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
mIncompleteTextures[type].set(NULL);
}
......@@ -961,16 +961,16 @@ void Context::bindElementArrayBuffer(unsigned int buffer)
void Context::bindTexture2D(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, SAMPLER_2D);
mResourceManager->checkTextureAllocation(texture, TEXTURE_2D);
mState.samplerTexture[SAMPLER_2D][mState.activeSampler].set(getTexture(texture));
mState.samplerTexture[TEXTURE_2D][mState.activeSampler].set(getTexture(texture));
}
void Context::bindTextureCubeMap(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, SAMPLER_CUBE);
mResourceManager->checkTextureAllocation(texture, TEXTURE_CUBE);
mState.samplerTexture[SAMPLER_CUBE][mState.activeSampler].set(getTexture(texture));
mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].set(getTexture(texture));
}
void Context::bindReadFramebuffer(GLuint framebuffer)
......@@ -1079,15 +1079,15 @@ Program *Context::getCurrentProgram()
Texture2D *Context::getTexture2D()
{
return static_cast<Texture2D*>(getSamplerTexture(mState.activeSampler, SAMPLER_2D));
return static_cast<Texture2D*>(getSamplerTexture(mState.activeSampler, TEXTURE_2D));
}
TextureCubeMap *Context::getTextureCubeMap()
{
return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, SAMPLER_CUBE));
return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, TEXTURE_CUBE));
}
Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type)
Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type)
{
GLuint texid = mState.samplerTexture[type][sampler].id();
......@@ -1096,8 +1096,8 @@ Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type)
switch (type)
{
default: UNREACHABLE();
case SAMPLER_2D: return mTexture2DZero.get();
case SAMPLER_CUBE: return mTextureCubeMapZero.get();
case TEXTURE_2D: return mTexture2DZero.get();
case TEXTURE_CUBE: return mTextureCubeMapZero.get();
}
}
......@@ -1384,7 +1384,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
return false;
}
*params = mState.samplerTexture[SAMPLER_2D][mState.activeSampler].id();
*params = mState.samplerTexture[TEXTURE_2D][mState.activeSampler].id();
}
break;
case GL_TEXTURE_BINDING_CUBE_MAP:
......@@ -1395,7 +1395,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
return false;
}
*params = mState.samplerTexture[SAMPLER_CUBE][mState.activeSampler].id();
*params = mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].id();
}
break;
default:
......@@ -2012,7 +2012,7 @@ void Context::applyTextures()
int textureUnit = programObject->getSamplerMapping(sampler);
if (textureUnit != -1)
{
SamplerType textureType = programObject->getSamplerType(sampler);
TextureType textureType = programObject->getSamplerTextureType(sampler);
Texture *texture = getSamplerTexture(textureUnit, textureType);
......@@ -3070,7 +3070,7 @@ void Context::detachTexture(GLuint texture)
// If a texture object is deleted, it is as if all texture units which are bound to that texture object are
// rebound to texture object zero
for (int type = 0; type < SAMPLER_TYPE_COUNT; type++)
for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
for (int sampler = 0; sampler < MAX_TEXTURE_IMAGE_UNITS; sampler++)
{
......@@ -3147,7 +3147,7 @@ void Context::detachRenderbuffer(GLuint renderbuffer)
}
}
Texture *Context::getIncompleteTexture(SamplerType type)
Texture *Context::getIncompleteTexture(TextureType type)
{
Texture *t = mIncompleteTextures[type].get();
......@@ -3159,9 +3159,9 @@ Texture *Context::getIncompleteTexture(SamplerType type)
{
default:
UNREACHABLE();
// default falls through to SAMPLER_2D
// default falls through to TEXTURE_2D
case SAMPLER_2D:
case TEXTURE_2D:
{
Texture2D *incomplete2d = new Texture2D(Texture::INCOMPLETE_TEXTURE_ID);
incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
......@@ -3169,7 +3169,7 @@ Texture *Context::getIncompleteTexture(SamplerType type)
}
break;
case SAMPLER_CUBE:
case TEXTURE_CUBE:
{
TextureCubeMap *incompleteCube = new TextureCubeMap(Texture::INCOMPLETE_TEXTURE_ID);
......
......@@ -215,7 +215,7 @@ struct State
GLuint currentProgram;
VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
BindingPointer<Texture> samplerTexture[SAMPLER_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS];
BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS];
GLint unpackAlignment;
GLint packAlignment;
......@@ -395,7 +395,7 @@ class Context
Program *getCurrentProgram();
Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap();
Texture *getSamplerTexture(unsigned int sampler, SamplerType type);
Texture *getSamplerTexture(unsigned int sampler, TextureType type);
Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer();
......@@ -471,7 +471,7 @@ class Context
void detachFramebuffer(GLuint framebuffer);
void detachRenderbuffer(GLuint renderbuffer);
Texture *getIncompleteTexture(SamplerType type);
Texture *getIncompleteTexture(TextureType type);
bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode);
......@@ -501,7 +501,7 @@ class Context
StreamingIndexBuffer *mClosingIB;
BindingPointer<Texture> mIncompleteTextures[SAMPLER_TYPE_COUNT];
BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT];
// Recorded errors
bool mInvalidEnum;
......
......@@ -212,12 +212,12 @@ GLint Program::getSamplerMapping(unsigned int samplerIndex)
return -1;
}
SamplerType Program::getSamplerType(unsigned int samplerIndex)
TextureType Program::getSamplerTextureType(unsigned int samplerIndex)
{
assert(samplerIndex < sizeof(mSamplers)/sizeof(mSamplers[0]));
assert(mSamplers[samplerIndex].active);
return mSamplers[samplerIndex].type;
return mSamplers[samplerIndex].textureType;
}
GLint Program::getUniformLocation(const char *name, bool decorated)
......@@ -1688,7 +1688,7 @@ bool Program::defineUniform(const D3DXHANDLE &constantHandle, const D3DXCONSTANT
ASSERT(samplerIndex < sizeof(mSamplers)/sizeof(mSamplers[0]));
mSamplers[samplerIndex].active = true;
mSamplers[samplerIndex].type = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? SAMPLER_CUBE : SAMPLER_2D;
mSamplers[samplerIndex].textureType = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D;
mSamplers[samplerIndex].logicalTextureUnit = 0;
}
}
......@@ -2790,19 +2790,19 @@ bool Program::validateSamplers() const
// if any two active samplers in a program are of different types, but refer to the same
// texture image unit, and this is the current program, then ValidateProgram will fail, and
// DrawArrays and DrawElements will issue the INVALID_OPERATION error.
std::map<int, SamplerType> samplerMap;
std::map<int, TextureType> samplerMap;
for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i)
{
if (mSamplers[i].active)
{
if (samplerMap.find(mSamplers[i].logicalTextureUnit) != samplerMap.end())
{
if (mSamplers[i].type != samplerMap[mSamplers[i].logicalTextureUnit])
if (mSamplers[i].textureType != samplerMap[mSamplers[i].logicalTextureUnit])
return false;
}
else
{
samplerMap[mSamplers[i].logicalTextureUnit] = mSamplers[i].type;
samplerMap[mSamplers[i].logicalTextureUnit] = mSamplers[i].textureType;
}
}
}
......
......@@ -73,7 +73,7 @@ class Program
int getSemanticIndex(int attributeIndex);
GLint getSamplerMapping(unsigned int samplerIndex);
SamplerType getSamplerType(unsigned int samplerIndex);
TextureType getSamplerTextureType(unsigned int samplerIndex);
GLint getUniformLocation(const char *name, bool decorated);
bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
......@@ -188,7 +188,7 @@ class Program
{
bool active;
GLint logicalTextureUnit;
SamplerType type;
TextureType textureType;
};
Sampler mSamplers[MAX_TEXTURE_IMAGE_UNITS];
......
......@@ -282,17 +282,17 @@ void ResourceManager::checkBufferAllocation(unsigned int buffer)
}
}
void ResourceManager::checkTextureAllocation(GLuint texture, SamplerType type)
void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type)
{
if (!getTexture(texture) && texture != 0)
{
Texture *textureObject;
if (type == SAMPLER_2D)
if (type == TEXTURE_2D)
{
textureObject = new Texture2D(texture);
}
else if (type == SAMPLER_CUBE)
else if (type == TEXTURE_CUBE)
{
textureObject = new TextureCubeMap(texture);
}
......
......@@ -26,12 +26,12 @@ class Program;
class Texture;
class Renderbuffer;
enum SamplerType
enum TextureType
{
SAMPLER_2D,
SAMPLER_CUBE,
TEXTURE_2D,
TEXTURE_CUBE,
SAMPLER_TYPE_COUNT
TEXTURE_TYPE_COUNT
};
class ResourceManager
......@@ -64,7 +64,7 @@ class ResourceManager
void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer);
void checkBufferAllocation(unsigned int buffer);
void checkTextureAllocation(GLuint texture, SamplerType type);
void checkTextureAllocation(GLuint texture, TextureType type);
void checkRenderbufferAllocation(GLuint renderbuffer);
private:
......
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