Move SetTexture calls to the renderer class

Trac #21727 git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1337 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ba0570ef
......@@ -2415,13 +2415,11 @@ void Context::applyTextures(SamplerType type)
int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF; // Range of Direct3D 9 samplers of given sampler type
unsigned int *appliedTextureSerial = (type == SAMPLER_PIXEL) ? mAppliedTextureSerialPS : mAppliedTextureSerialVS;
int d3dSamplerOffset = (type == SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int samplerRange = programBinary->getUsedSamplerRange(type);
for (int samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
{
int textureUnit = programBinary->getSamplerMapping(type, samplerIndex); // OpenGL texture image unit index
int d3dSampler = samplerIndex + d3dSamplerOffset;
if (textureUnit != -1)
{
......@@ -2432,9 +2430,7 @@ void Context::applyTextures(SamplerType type)
if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyParameters() || texture->hasDirtyImages())
{
IDirect3DBaseTexture9 *d3dTexture = texture->getTexture();
if (d3dTexture)
if (texture->isSamplerComplete())
{
if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyParameters())
{
......@@ -2446,12 +2442,12 @@ void Context::applyTextures(SamplerType type)
if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyImages())
{
mDevice->SetTexture(d3dSampler, d3dTexture);
mRenderer->setTexture(type, samplerIndex, texture);
}
}
else
{
mDevice->SetTexture(d3dSampler, getIncompleteTexture(textureType)->getTexture());
mRenderer->setTexture(type, samplerIndex, getIncompleteTexture(textureType));
}
appliedTextureSerial[samplerIndex] = texSerial;
......@@ -2462,7 +2458,7 @@ void Context::applyTextures(SamplerType type)
{
if (appliedTextureSerial[samplerIndex] != 0)
{
mDevice->SetTexture(d3dSampler, NULL);
mRenderer->setTexture(type, samplerIndex, NULL);
appliedTextureSerial[samplerIndex] = 0;
}
}
......@@ -2472,7 +2468,7 @@ void Context::applyTextures(SamplerType type)
{
if (appliedTextureSerial[samplerIndex] != 0)
{
mDevice->SetTexture(samplerIndex + d3dSamplerOffset, NULL);
mRenderer->setTexture(type, samplerIndex, NULL);
appliedTextureSerial[samplerIndex] = 0;
}
}
......
......@@ -1550,13 +1550,9 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
return true;
}
IDirect3DBaseTexture9 *Texture::getTexture()
// D3D9_REPLACE
IDirect3DBaseTexture9 *Texture::getD3DTexture()
{
if (!isSamplerComplete())
{
return NULL;
}
// ensure the underlying texture is created
if (getStorage(false) == NULL)
{
......
......@@ -206,7 +206,7 @@ class Texture : public RefCountObject
virtual bool isSamplerComplete() const = 0;
IDirect3DBaseTexture9 *getTexture();
IDirect3DBaseTexture9 *getD3DTexture(); // D3D9_REPLACE
virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
virtual void generateMipmaps() = 0;
......
......@@ -381,6 +381,24 @@ void Renderer::setSamplerState(gl::SamplerType type, int index, const gl::Sample
}
}
void Renderer::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
{
int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset;
IDirect3DBaseTexture9 *d3dTexture = NULL;
if (texture)
{
d3dTexture = texture->getD3DTexture();
// If we get NULL back from getTexture here, something went wrong
// in the texture class and we're unexpectedly missing the d3d texture
ASSERT(d3dTexture != NULL);
}
mDevice->SetTexture(d3dSampler, d3dTexture);
}
void Renderer::releaseDeviceResources()
{
while (!mEventQueryPool.empty())
......
......@@ -74,13 +74,13 @@ class Renderer
virtual void *createVertexbuffer();
// state setup
virtual void applyTexture();
virtual void applyShaders();
virtual void applyConstants();
virtual void applyRenderTargets();
virtual void applyState();
#endif
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
// lost device
virtual void markDeviceLost();
......
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