Commit 2ce08b14 by Nicolas Capens Committed by Nicolas Capens

Refactor texture binding.

Also remove traces of cube texture support for OpenGL ES 1.1. We don't support the OES_texture_cube_map extension, and it would be non-trivial due to requiring reflective texture coordinate generation. Change-Id: I5c224f925fc9c03053acaf33e126dae4f3ffe4d9 Reviewed-on: https://swiftshader-review.googlesource.com/16750Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 41bcdc78
......@@ -149,9 +149,14 @@ Context::Context(egl::Display *const display, const Context *shareContext, const
mTextureExternalZero = new TextureExternal(0);
mState.activeSampler = 0;
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
bindTexture((TextureType)type, 0);
}
bindArrayBuffer(0);
bindElementArrayBuffer(0);
bindTexture2D(0);
bindFramebuffer(0);
bindRenderbuffer(0);
......@@ -1012,18 +1017,11 @@ void Context::bindElementArrayBuffer(unsigned int buffer)
mState.elementArrayBuffer = getBuffer(buffer);
}
void Context::bindTexture2D(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_2D);
mState.samplerTexture[TEXTURE_2D][mState.activeSampler] = getTexture(texture);
}
void Context::bindTextureExternal(GLuint texture)
void Context::bindTexture(TextureType type, GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_EXTERNAL);
mResourceManager->checkTextureAllocation(texture, type);
mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler] = getTexture(texture);
mState.samplerTexture[type][mState.activeSampler] = getTexture(texture);
}
void Context::bindFramebuffer(GLuint framebuffer)
......@@ -1368,7 +1366,6 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
}
break;
case GL_TEXTURE_BINDING_2D: *params = mState.samplerTexture[TEXTURE_2D][mState.activeSampler].name(); break;
case GL_TEXTURE_BINDING_CUBE_MAP_OES: *params = mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].name(); break;
case GL_TEXTURE_BINDING_EXTERNAL_OES: *params = mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler].name(); break;
case GL_MAX_LIGHTS: *params = MAX_LIGHTS; break;
case GL_MAX_MODELVIEW_STACK_DEPTH: *params = MAX_MODELVIEW_STACK_DEPTH; break;
......
......@@ -454,7 +454,7 @@ public:
void bindArrayBuffer(GLuint buffer);
void bindElementArrayBuffer(GLuint buffer);
void bindTexture2D(GLuint texture);
void bindTexture(TextureType type, GLuint texture);
void bindTextureExternal(GLuint texture);
void bindFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer);
......
......@@ -33,7 +33,6 @@ class Renderbuffer;
enum TextureType
{
TEXTURE_2D,
TEXTURE_CUBE,
TEXTURE_EXTERNAL,
TEXTURE_TYPE_COUNT,
......
......@@ -191,11 +191,11 @@ void BindTexture(GLenum target, GLuint texture)
switch(target)
{
case GL_TEXTURE_2D:
context->bindTexture2D(texture);
return;
context->bindTexture(TEXTURE_2D, texture);
break;
case GL_TEXTURE_EXTERNAL_OES:
context->bindTextureExternal(texture);
return;
context->bindTexture(TEXTURE_EXTERNAL, texture);
break;
default:
return error(GL_INVALID_ENUM);
}
......
......@@ -146,11 +146,15 @@ Context::Context(egl::Display *display, const Context *shareContext, EGLint clie
mTextureExternalZero = new TextureExternal(0);
mState.activeSampler = 0;
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
bindTexture((TextureType)type, 0);
}
bindVertexArray(0);
bindArrayBuffer(0);
bindElementArrayBuffer(0);
bindTextureCubeMap(0);
bindTexture2D(0);
bindReadFramebuffer(0);
bindDrawFramebuffer(0);
bindRenderbuffer(0);
......@@ -1153,46 +1157,11 @@ void Context::bindTransformFeedbackBuffer(GLuint buffer)
}
}
void Context::bindTexture2D(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_2D);
mState.samplerTexture[TEXTURE_2D][mState.activeSampler] = getTexture(texture);
}
void Context::bindTextureCubeMap(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_CUBE);
mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler] = getTexture(texture);
}
void Context::bindTextureExternal(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_EXTERNAL);
mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler] = getTexture(texture);
}
void Context::bindTexture3D(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_3D);
mState.samplerTexture[TEXTURE_3D][mState.activeSampler] = getTexture(texture);
}
void Context::bindTexture2DArray(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_2D_ARRAY);
mState.samplerTexture[TEXTURE_2D_ARRAY][mState.activeSampler] = getTexture(texture);
}
void Context::bindTexture2DRect(GLuint texture)
void Context::bindTexture(TextureType type, GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_2D_RECT);
mResourceManager->checkTextureAllocation(texture, type);
mState.samplerTexture[TEXTURE_2D_RECT][mState.activeSampler] = getTexture(texture);
mState.samplerTexture[type][mState.activeSampler] = getTexture(texture);
}
void Context::bindReadFramebuffer(GLuint framebuffer)
......
......@@ -585,12 +585,7 @@ public:
void bindPixelPackBuffer(GLuint buffer);
void bindPixelUnpackBuffer(GLuint buffer);
void bindTransformFeedbackBuffer(GLuint buffer);
void bindTexture2D(GLuint texture);
void bindTextureCubeMap(GLuint texture);
void bindTextureExternal(GLuint texture);
void bindTexture3D(GLuint texture);
void bindTexture2DArray(GLuint texture);
void bindTexture2DRect(GLuint texture);
void bindTexture(TextureType type, GLuint texture);
void bindReadFramebuffer(GLuint framebuffer);
void bindDrawFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer);
......
......@@ -307,26 +307,26 @@ void BindTexture(GLenum target, GLuint texture)
switch(target)
{
case GL_TEXTURE_2D:
context->bindTexture2D(texture);
context->bindTexture(TEXTURE_2D, texture);
break;
case GL_TEXTURE_CUBE_MAP:
context->bindTextureCubeMap(texture);
context->bindTexture(TEXTURE_CUBE, texture);
break;
case GL_TEXTURE_EXTERNAL_OES:
context->bindTextureExternal(texture);
context->bindTexture(TEXTURE_EXTERNAL, texture);
break;
case GL_TEXTURE_2D_ARRAY:
if(clientVersion < 3)
{
return error(GL_INVALID_ENUM);
}
context->bindTexture2DArray(texture);
context->bindTexture(TEXTURE_2D_ARRAY, texture);
break;
case GL_TEXTURE_3D:
context->bindTexture3D(texture);
context->bindTexture(TEXTURE_3D, texture);
break;
case GL_TEXTURE_RECTANGLE_ARB:
context->bindTexture2DRect(texture);
context->bindTexture(TEXTURE_2D_RECT, texture);
break;
default:
return error(GL_INVALID_ENUM);
......
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