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 ...@@ -149,9 +149,14 @@ Context::Context(egl::Display *const display, const Context *shareContext, const
mTextureExternalZero = new TextureExternal(0); mTextureExternalZero = new TextureExternal(0);
mState.activeSampler = 0; mState.activeSampler = 0;
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
bindTexture((TextureType)type, 0);
}
bindArrayBuffer(0); bindArrayBuffer(0);
bindElementArrayBuffer(0); bindElementArrayBuffer(0);
bindTexture2D(0);
bindFramebuffer(0); bindFramebuffer(0);
bindRenderbuffer(0); bindRenderbuffer(0);
...@@ -1012,18 +1017,11 @@ void Context::bindElementArrayBuffer(unsigned int buffer) ...@@ -1012,18 +1017,11 @@ void Context::bindElementArrayBuffer(unsigned int buffer)
mState.elementArrayBuffer = getBuffer(buffer); mState.elementArrayBuffer = getBuffer(buffer);
} }
void Context::bindTexture2D(GLuint texture) void Context::bindTexture(TextureType type, GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_2D);
mState.samplerTexture[TEXTURE_2D][mState.activeSampler] = getTexture(texture);
}
void Context::bindTextureExternal(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) void Context::bindFramebuffer(GLuint framebuffer)
...@@ -1368,7 +1366,6 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1368,7 +1366,6 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
} }
break; break;
case GL_TEXTURE_BINDING_2D: *params = mState.samplerTexture[TEXTURE_2D][mState.activeSampler].name(); 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_TEXTURE_BINDING_EXTERNAL_OES: *params = mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler].name(); break;
case GL_MAX_LIGHTS: *params = MAX_LIGHTS; break; case GL_MAX_LIGHTS: *params = MAX_LIGHTS; break;
case GL_MAX_MODELVIEW_STACK_DEPTH: *params = MAX_MODELVIEW_STACK_DEPTH; break; case GL_MAX_MODELVIEW_STACK_DEPTH: *params = MAX_MODELVIEW_STACK_DEPTH; break;
......
...@@ -454,7 +454,7 @@ public: ...@@ -454,7 +454,7 @@ public:
void bindArrayBuffer(GLuint buffer); void bindArrayBuffer(GLuint buffer);
void bindElementArrayBuffer(GLuint buffer); void bindElementArrayBuffer(GLuint buffer);
void bindTexture2D(GLuint texture); void bindTexture(TextureType type, GLuint texture);
void bindTextureExternal(GLuint texture); void bindTextureExternal(GLuint texture);
void bindFramebuffer(GLuint framebuffer); void bindFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer); void bindRenderbuffer(GLuint renderbuffer);
......
...@@ -33,7 +33,6 @@ class Renderbuffer; ...@@ -33,7 +33,6 @@ class Renderbuffer;
enum TextureType enum TextureType
{ {
TEXTURE_2D, TEXTURE_2D,
TEXTURE_CUBE,
TEXTURE_EXTERNAL, TEXTURE_EXTERNAL,
TEXTURE_TYPE_COUNT, TEXTURE_TYPE_COUNT,
......
...@@ -191,11 +191,11 @@ void BindTexture(GLenum target, GLuint texture) ...@@ -191,11 +191,11 @@ void BindTexture(GLenum target, GLuint texture)
switch(target) switch(target)
{ {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
context->bindTexture2D(texture); context->bindTexture(TEXTURE_2D, texture);
return; break;
case GL_TEXTURE_EXTERNAL_OES: case GL_TEXTURE_EXTERNAL_OES:
context->bindTextureExternal(texture); context->bindTexture(TEXTURE_EXTERNAL, texture);
return; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
......
...@@ -146,11 +146,15 @@ Context::Context(egl::Display *display, const Context *shareContext, EGLint clie ...@@ -146,11 +146,15 @@ Context::Context(egl::Display *display, const Context *shareContext, EGLint clie
mTextureExternalZero = new TextureExternal(0); mTextureExternalZero = new TextureExternal(0);
mState.activeSampler = 0; mState.activeSampler = 0;
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
bindTexture((TextureType)type, 0);
}
bindVertexArray(0); bindVertexArray(0);
bindArrayBuffer(0); bindArrayBuffer(0);
bindElementArrayBuffer(0); bindElementArrayBuffer(0);
bindTextureCubeMap(0);
bindTexture2D(0);
bindReadFramebuffer(0); bindReadFramebuffer(0);
bindDrawFramebuffer(0); bindDrawFramebuffer(0);
bindRenderbuffer(0); bindRenderbuffer(0);
...@@ -1153,46 +1157,11 @@ void Context::bindTransformFeedbackBuffer(GLuint buffer) ...@@ -1153,46 +1157,11 @@ void Context::bindTransformFeedbackBuffer(GLuint buffer)
} }
} }
void Context::bindTexture2D(GLuint texture) void Context::bindTexture(TextureType type, 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)
{ {
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) void Context::bindReadFramebuffer(GLuint framebuffer)
......
...@@ -585,12 +585,7 @@ public: ...@@ -585,12 +585,7 @@ public:
void bindPixelPackBuffer(GLuint buffer); void bindPixelPackBuffer(GLuint buffer);
void bindPixelUnpackBuffer(GLuint buffer); void bindPixelUnpackBuffer(GLuint buffer);
void bindTransformFeedbackBuffer(GLuint buffer); void bindTransformFeedbackBuffer(GLuint buffer);
void bindTexture2D(GLuint texture); void bindTexture(TextureType type, GLuint texture);
void bindTextureCubeMap(GLuint texture);
void bindTextureExternal(GLuint texture);
void bindTexture3D(GLuint texture);
void bindTexture2DArray(GLuint texture);
void bindTexture2DRect(GLuint texture);
void bindReadFramebuffer(GLuint framebuffer); void bindReadFramebuffer(GLuint framebuffer);
void bindDrawFramebuffer(GLuint framebuffer); void bindDrawFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer); void bindRenderbuffer(GLuint renderbuffer);
......
...@@ -307,26 +307,26 @@ void BindTexture(GLenum target, GLuint texture) ...@@ -307,26 +307,26 @@ void BindTexture(GLenum target, GLuint texture)
switch(target) switch(target)
{ {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
context->bindTexture2D(texture); context->bindTexture(TEXTURE_2D, texture);
break; break;
case GL_TEXTURE_CUBE_MAP: case GL_TEXTURE_CUBE_MAP:
context->bindTextureCubeMap(texture); context->bindTexture(TEXTURE_CUBE, texture);
break; break;
case GL_TEXTURE_EXTERNAL_OES: case GL_TEXTURE_EXTERNAL_OES:
context->bindTextureExternal(texture); context->bindTexture(TEXTURE_EXTERNAL, texture);
break; break;
case GL_TEXTURE_2D_ARRAY: case GL_TEXTURE_2D_ARRAY:
if(clientVersion < 3) if(clientVersion < 3)
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
context->bindTexture2DArray(texture); context->bindTexture(TEXTURE_2D_ARRAY, texture);
break; break;
case GL_TEXTURE_3D: case GL_TEXTURE_3D:
context->bindTexture3D(texture); context->bindTexture(TEXTURE_3D, texture);
break; break;
case GL_TEXTURE_RECTANGLE_ARB: case GL_TEXTURE_RECTANGLE_ARB:
context->bindTexture2DRect(texture); context->bindTexture(TEXTURE_2D_RECT, texture);
break; break;
default: default:
return error(GL_INVALID_ENUM); 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