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
void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
{
ID3D11ShaderResourceView *textureSRV = NULL;
unsigned int serial = 0;
bool forceSetTexture = false;
if (texture)
......@@ -611,7 +610,6 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur
// missing the shader resource view
ASSERT(textureSRV != NULL);
serial = texture->getTextureSerial();
forceSetTexture = texture->hasDirtyImages();
}
......@@ -623,12 +621,12 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur
return;
}
if (forceSetTexture || mCurPixelTextureSerials[index] != serial)
if (forceSetTexture || mCurPixelSRVs[index] != textureSRV)
{
mDeviceContext->PSSetShaderResources(index, 1, &textureSRV);
}
mCurPixelTextureSerials[index] = serial;
mCurPixelSRVs[index] = textureSRV;
}
else if (type == gl::SAMPLER_VERTEX)
{
......@@ -638,12 +636,12 @@ void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *textur
return;
}
if (forceSetTexture || mCurVertexTextureSerials[index] != serial)
if (forceSetTexture || mCurVertexSRVs[index] != textureSRV)
{
mDeviceContext->VSSetShaderResources(index, 1, &textureSRV);
}
mCurVertexTextureSerials[index] = serial;
mCurVertexSRVs[index] = textureSRV;
}
else UNREACHABLE();
}
......@@ -983,24 +981,8 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
missingColorRenderTarget = false;
}
#ifdef _DEBUG
// Workaround for Debug SETSHADERRESOURCES_HAZARD 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
// TODO: Detect if this color buffer is already bound as a texture and unbind it first to prevent
// D3D11 warnings.
}
}
......@@ -1627,12 +1609,12 @@ void Renderer11::markAllStateDirty()
for (int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
mForceSetVertexSamplerStates[i] = true;
mCurVertexTextureSerials[i] = 0;
mCurVertexSRVs[i] = NULL;
}
for (int i = 0; i < gl::MAX_TEXTURE_IMAGE_UNITS; i++)
{
mForceSetPixelSamplerStates[i] = true;
mCurPixelTextureSerials[i] = 0;
mCurPixelSRVs[i] = NULL;
}
mForceSetBlendState = true;
......
......@@ -304,8 +304,8 @@ class Renderer11 : public Renderer
gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
// Currently applied textures
unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS];
ID3D11ShaderResourceView *mCurVertexSRVs[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
ID3D11ShaderResourceView *mCurPixelSRVs[gl::MAX_TEXTURE_IMAGE_UNITS];
// Currently applied blend state
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