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