Commit 73e18c1b by Nicolas Capens Committed by Nicolas Capens

Update cube texture borders when dirty.

Change-Id: Ic259645ab7950b0b2800964bbfd14f3294de50b1 Reviewed-on: https://swiftshader-review.googlesource.com/14288Reviewed-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 a76a1bfd
......@@ -191,7 +191,7 @@ namespace D3D9
for(unsigned int face = 0; face < 6; face++)
{
if(!surfaceLevel[face][0]->hasDirtyMipmaps())
if(!surfaceLevel[face][0]->hasDirtyContents())
{
continue;
}
......@@ -201,7 +201,7 @@ namespace D3D9
device->stretchRect(surfaceLevel[face][i], 0, surfaceLevel[face][i + 1], 0, GetAutoGenFilterType());
}
surfaceLevel[face][0]->cleanMipmaps();
surfaceLevel[face][0]->markContentsClean();
}
resource->unlock();
......
......@@ -173,7 +173,7 @@ namespace D3D9
TRACE("");
if(!(usage & D3DUSAGE_AUTOGENMIPMAP) || !surfaceLevel[0]->hasDirtyMipmaps())
if(!(usage & D3DUSAGE_AUTOGENMIPMAP) || !surfaceLevel[0]->hasDirtyContents())
{
return;
}
......@@ -185,7 +185,7 @@ namespace D3D9
device->stretchRect(surfaceLevel[i], 0, surfaceLevel[i + 1], 0, GetAutoGenFilterType());
}
surfaceLevel[0]->cleanMipmaps();
surfaceLevel[0]->markContentsClean();
resource->unlock();
}
......
......@@ -174,7 +174,7 @@ namespace D3D9
TRACE("");
if(!(usage & D3DUSAGE_AUTOGENMIPMAP) || !volumeLevel[0]->hasDirtyMipmaps())
if(!(usage & D3DUSAGE_AUTOGENMIPMAP) || !volumeLevel[0]->hasDirtyContents())
{
return;
}
......@@ -230,7 +230,7 @@ namespace D3D9
dest->unlockInternal();
}
volumeLevel[0]->cleanMipmaps();
volumeLevel[0]->markContentsClean();
resource->unlock();
}
......
......@@ -720,10 +720,10 @@ void Texture2D::generateMipmaps()
void Texture2D::autoGenerateMipmaps()
{
if(generateMipmap && image[0]->hasDirtyMipmaps())
if(generateMipmap && image[0]->hasDirtyContents())
{
generateMipmaps();
image[0]->cleanMipmaps();
image[0]->markContentsClean();
}
}
......
......@@ -3233,11 +3233,13 @@ void Context::applyTexture(sw::SamplerType type, int index, Texture *baseTexture
}
else if(baseTexture->getTarget() == GL_TEXTURE_CUBE_MAP)
{
for(int face = 0; face < 6; face++)
TextureCubeMap *cubeTexture = static_cast<TextureCubeMap*>(baseTexture);
for(int mipmapLevel = 0; mipmapLevel < sw::MIPMAP_LEVELS; mipmapLevel++)
{
TextureCubeMap *cubeTexture = static_cast<TextureCubeMap*>(baseTexture);
cubeTexture->updateBorders(mipmapLevel);
for(int mipmapLevel = 0; mipmapLevel < sw::MIPMAP_LEVELS; mipmapLevel++)
for(int face = 0; face < 6; face++)
{
int surfaceLevel = mipmapLevel;
......
......@@ -1260,6 +1260,16 @@ void TextureCubeMap::updateBorders(int level)
return;
}
if(posX->getBorder() == 0) // Non-seamless cube map.
{
return;
}
if(!posX->hasDirtyContents() || !posY->hasDirtyContents() || !posZ->hasDirtyContents() || !negX->hasDirtyContents() || !negY->hasDirtyContents() || !negY->hasDirtyContents())
{
return;
}
// Copy top / bottom first.
posX->copyCubeEdge(sw::Surface::BOTTOM, negY, sw::Surface::RIGHT);
posY->copyCubeEdge(sw::Surface::BOTTOM, posZ, sw::Surface::TOP);
......@@ -1290,6 +1300,13 @@ void TextureCubeMap::updateBorders(int level)
negX->copyCubeEdge(sw::Surface::LEFT, negZ, sw::Surface::RIGHT);
negY->copyCubeEdge(sw::Surface::LEFT, negX, sw::Surface::BOTTOM);
negZ->copyCubeEdge(sw::Surface::LEFT, posX, sw::Surface::RIGHT);
posX->markContentsClean();
posY->markContentsClean();
posZ->markContentsClean();
negX->markContentsClean();
negY->markContentsClean();
negY->markContentsClean();
}
bool TextureCubeMap::isCompressed(GLenum target, GLint level) const
......
......@@ -1249,7 +1249,7 @@ namespace sw
stencil.lock = LOCK_UNLOCKED;
stencil.dirty = false;
dirtyMipmaps = true;
dirtyContents = true;
paletteUsed = 0;
}
......@@ -1302,7 +1302,7 @@ namespace sw
stencil.lock = LOCK_UNLOCKED;
stencil.dirty = false;
dirtyMipmaps = true;
dirtyContents = true;
paletteUsed = 0;
}
......@@ -1367,7 +1367,7 @@ namespace sw
case LOCK_WRITEONLY:
case LOCK_READWRITE:
case LOCK_DISCARD:
dirtyMipmaps = true;
dirtyContents = true;
break;
default:
ASSERT(false);
......@@ -1446,7 +1446,7 @@ namespace sw
case LOCK_WRITEONLY:
case LOCK_READWRITE:
case LOCK_DISCARD:
dirtyMipmaps = true;
dirtyContents = true;
break;
default:
ASSERT(false);
......@@ -3649,14 +3649,14 @@ namespace sw
return renderTarget;
}
bool Surface::hasDirtyMipmaps() const
bool Surface::hasDirtyContents() const
{
return dirtyMipmaps;
return dirtyContents;
}
void Surface::cleanMipmaps()
void Surface::markContentsClean()
{
dirtyMipmaps = false;
dirtyContents = false;
}
Resource *Surface::getResource()
......
......@@ -248,7 +248,7 @@ namespace sw
Format format;
AtomicInt lock;
bool dirty;
bool dirty; // Sibling internal/external buffer doesn't match.
};
protected:
......@@ -326,8 +326,8 @@ namespace sw
bool hasPalette() const;
bool isRenderTarget() const;
bool hasDirtyMipmaps() const;
void cleanMipmaps();
bool hasDirtyContents() const;
void markContentsClean();
inline bool isExternalDirty() const;
Resource *getResource();
......@@ -474,7 +474,7 @@ namespace sw
const bool lockable;
const bool renderTarget;
bool dirtyMipmaps;
bool dirtyContents; // Sibling surfaces need updating (mipmaps / cube borders).
unsigned int paletteUsed;
static unsigned int *palette; // FIXME: Not multi-device safe
......
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