Commit 91382e55 by Geoff Lang

Renderer11 tracks applied textures as SRVs.

Since swizzled textures have multiple SRVs and the same serial, it was possible that the bound SRV would not be updated if the texture became swizzled while already bound. Change-Id: Id06e82f4002aa7f7661c7a69243692aa65a83b48 Reviewed-on: https://chromium-review.googlesource.com/181772Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b8f8b89b
...@@ -594,7 +594,6 @@ void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::Samp ...@@ -594,7 +594,6 @@ void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::Samp
void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture) void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
{ {
ID3D11ShaderResourceView *textureSRV = NULL; ID3D11ShaderResourceView *textureSRV = NULL;
unsigned int serial = 0;
bool forceSetTexture = false; bool forceSetTexture = false;
if (texture) if (texture)
...@@ -611,7 +610,6 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur ...@@ -611,7 +610,6 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur
// missing the shader resource view // missing the shader resource view
ASSERT(textureSRV != NULL); ASSERT(textureSRV != NULL);
serial = texture->getTextureSerial();
forceSetTexture = texture->hasDirtyImages(); forceSetTexture = texture->hasDirtyImages();
} }
...@@ -623,12 +621,12 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur ...@@ -623,12 +621,12 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur
return; return;
} }
if (forceSetTexture || mCurPixelTextureSerials[index] != serial) if (forceSetTexture || mCurPixelSRVs[index] != textureSRV)
{ {
mDeviceContext->PSSetShaderResources(index, 1, &textureSRV); mDeviceContext->PSSetShaderResources(index, 1, &textureSRV);
} }
mCurPixelTextureSerials[index] = serial; mCurPixelSRVs[index] = textureSRV;
} }
else if (type == gl::SAMPLER_VERTEX) else if (type == gl::SAMPLER_VERTEX)
{ {
...@@ -638,12 +636,12 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur ...@@ -638,12 +636,12 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur
return; return;
} }
if (forceSetTexture || mCurVertexTextureSerials[index] != serial) if (forceSetTexture || mCurVertexSRVs[index] != textureSRV)
{ {
mDeviceContext->VSSetShaderResources(index, 1, &textureSRV); mDeviceContext->VSSetShaderResources(index, 1, &textureSRV);
} }
mCurVertexTextureSerials[index] = serial; mCurVertexSRVs[index] = textureSRV;
} }
else UNREACHABLE(); else UNREACHABLE();
} }
...@@ -983,24 +981,8 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -983,24 +981,8 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
missingColorRenderTarget = false; missingColorRenderTarget = false;
} }
#ifdef _DEBUG // TODO: Detect if this color buffer is already bound as a texture and unbind it first to prevent
// Workaround for Debug SETSHADERRESOURCES_HAZARD D3D11 warnings // D3D11 warnings.
for (unsigned int vertexSerialIndex = 0; vertexSerialIndex < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; vertexSerialIndex++)
{
if (colorbuffer->getTextureSerial() != 0 && mCurVertexTextureSerials[vertexSerialIndex] == colorbuffer->getTextureSerial())
{
setTexture(gl::SAMPLER_VERTEX, vertexSerialIndex, NULL);
}
}
for (unsigned int pixelSerialIndex = 0; pixelSerialIndex < gl::MAX_TEXTURE_IMAGE_UNITS; pixelSerialIndex++)
{
if (colorbuffer->getTextureSerial() != 0 && mCurPixelTextureSerials[pixelSerialIndex] == colorbuffer->getTextureSerial())
{
setTexture(gl::SAMPLER_PIXEL, pixelSerialIndex, NULL);
}
}
#endif
} }
} }
...@@ -1627,12 +1609,12 @@ void Renderer11::markAllStateDirty() ...@@ -1627,12 +1609,12 @@ void Renderer11::markAllStateDirty()
for (int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++) for (int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++)
{ {
mForceSetVertexSamplerStates[i] = true; mForceSetVertexSamplerStates[i] = true;
mCurVertexTextureSerials[i] = 0; mCurVertexSRVs[i] = NULL;
} }
for (int i = 0; i < gl::MAX_TEXTURE_IMAGE_UNITS; i++) for (int i = 0; i < gl::MAX_TEXTURE_IMAGE_UNITS; i++)
{ {
mForceSetPixelSamplerStates[i] = true; mForceSetPixelSamplerStates[i] = true;
mCurPixelTextureSerials[i] = 0; mCurPixelSRVs[i] = NULL;
} }
mForceSetBlendState = true; mForceSetBlendState = true;
......
...@@ -304,8 +304,8 @@ class Renderer11 : public Renderer ...@@ -304,8 +304,8 @@ class Renderer11 : public Renderer
gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS]; gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
// Currently applied textures // Currently applied textures
unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; ID3D11ShaderResourceView *mCurVertexSRVs[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS]; ID3D11ShaderResourceView *mCurPixelSRVs[gl::MAX_TEXTURE_IMAGE_UNITS];
// Currently applied blend state // Currently applied blend state
bool mForceSetBlendState; bool mForceSetBlendState;
......
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