Commit cdf22f94 by Geoff Lang

Don't apply textures that are currently bound to the framebuffer.

parent 89bf4bff
...@@ -2374,6 +2374,8 @@ void Context::applyTextures(SamplerType type) ...@@ -2374,6 +2374,8 @@ void Context::applyTextures(SamplerType type)
{ {
ProgramBinary *programBinary = getCurrentProgramBinary(); ProgramBinary *programBinary = getCurrentProgramBinary();
FramebufferTextureSerialSet boundFramebufferTextures = getBoundFramebufferTextureSerials();
// Range of Direct3D samplers of given sampler type // Range of Direct3D samplers of given sampler type
int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : mRenderer->getMaxVertexTextureImageUnits(); int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : mRenderer->getMaxVertexTextureImageUnits();
int samplerRange = programBinary->getUsedSamplerRange(type); int samplerRange = programBinary->getUsedSamplerRange(type);
...@@ -2390,7 +2392,8 @@ void Context::applyTextures(SamplerType type) ...@@ -2390,7 +2392,8 @@ void Context::applyTextures(SamplerType type)
SamplerState samplerState; SamplerState samplerState;
texture->getSamplerState(&samplerState); texture->getSamplerState(&samplerState);
if (mState.samplers[textureUnit] != 0) if (texture->isSamplerComplete(samplerState) &&
boundFramebufferTextures.find(texture->getTextureSerial()) == boundFramebufferTextures.end())
{ {
Sampler *samplerObject = getSampler(mState.samplers[textureUnit]); Sampler *samplerObject = getSampler(mState.samplers[textureUnit]);
samplerObject->getState(&samplerState); samplerObject->getState(&samplerState);
...@@ -3659,6 +3662,29 @@ const char *Context::getRendererString() const ...@@ -3659,6 +3662,29 @@ const char *Context::getRendererString() const
return mRendererString; return mRendererString;
} }
Context::FramebufferTextureSerialSet Context::getBoundFramebufferTextureSerials()
{
FramebufferTextureSerialSet set;
Framebuffer *drawFramebuffer = getDrawFramebuffer();
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
{
Renderbuffer *renderBuffer = drawFramebuffer->getColorbuffer(i);
if (renderBuffer && renderBuffer->getTextureSerial() != 0)
{
set.insert(renderBuffer->getTextureSerial());
}
}
Renderbuffer *depthStencilBuffer = drawFramebuffer->getDepthOrStencilbuffer();
if (depthStencilBuffer && depthStencilBuffer->getTextureSerial() != 0)
{
set.insert(depthStencilBuffer->getTextureSerial());
}
return set;
}
void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter) GLbitfield mask, GLenum filter)
{ {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <string> #include <string>
#include <set>
#include <map> #include <map>
#include <unordered_map> #include <unordered_map>
...@@ -465,6 +466,9 @@ class Context ...@@ -465,6 +466,9 @@ class Context
void initExtensionString(); void initExtensionString();
void initRendererString(); void initRendererString();
typedef std::set<unsigned> FramebufferTextureSerialSet;
FramebufferTextureSerialSet getBoundFramebufferTextureSerials();
rx::Renderer *const mRenderer; rx::Renderer *const mRenderer;
int mClientVersion; int mClientVersion;
......
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