Commit 3779ea9c by Nicolas Capens

Use only external surface dimensions.

They should always be identical to the internal ones. Bug 21424351 Change-Id: Iafa18c14cc4d2e16f20238dac0208a8159cbaa6a Reviewed-on: https://swiftshader-review.googlesource.com/3460Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent cce8463e
...@@ -124,8 +124,8 @@ namespace sw ...@@ -124,8 +124,8 @@ namespace sw
cursor = cursorImage->lockExternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC); cursor = cursorImage->lockExternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);
cursorImage->unlockExternal(); cursorImage->unlockExternal();
cursorWidth = cursorImage->getExternalWidth(); cursorWidth = cursorImage->getWidth();
cursorHeight = cursorImage->getExternalHeight(); cursorHeight = cursorImage->getHeight();
} }
else else
{ {
......
...@@ -185,8 +185,8 @@ namespace gl ...@@ -185,8 +185,8 @@ namespace gl
int x0 = 0; int x0 = 0;
int y0 = 0; int y0 = 0;
int width = renderTarget->getExternalWidth(); int width = renderTarget->getWidth();
int height = renderTarget->getExternalHeight(); int height = renderTarget->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -211,8 +211,8 @@ namespace gl ...@@ -211,8 +211,8 @@ namespace gl
int x0 = 0; int x0 = 0;
int y0 = 0; int y0 = 0;
int width = depthStencil->getExternalWidth(); int width = depthStencil->getWidth();
int height = depthStencil->getExternalHeight(); int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -234,8 +234,8 @@ namespace gl ...@@ -234,8 +234,8 @@ namespace gl
int x0 = 0; int x0 = 0;
int y0 = 0; int y0 = 0;
int width = depthStencil->getExternalWidth(); int width = depthStencil->getWidth();
int height = depthStencil->getExternalHeight(); int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -496,10 +496,10 @@ namespace gl ...@@ -496,10 +496,10 @@ namespace gl
return false; return false;
} }
int sWidth = source->getExternalWidth(); int sWidth = source->getWidth();
int sHeight = source->getExternalHeight(); int sHeight = source->getHeight();
int dWidth = dest->getExternalWidth(); int dWidth = dest->getWidth();
int dHeight = dest->getExternalHeight(); int dHeight = dest->getHeight();
SliceRect sRect; SliceRect sRect;
SliceRect dRect; SliceRect dRect;
...@@ -547,8 +547,8 @@ namespace gl ...@@ -547,8 +547,8 @@ namespace gl
sw::byte *sourceBuffer = (sw::byte*)source->lockInternal(0, 0, sRect.slice, LOCK_READONLY, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockInternal(0, 0, sRect.slice, LOCK_READONLY, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockInternal(0, 0, dRect.slice, LOCK_DISCARD, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockInternal(0, 0, dRect.slice, LOCK_DISCARD, PUBLIC);
unsigned int width = source->getInternalWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getInternalHeight(); unsigned int height = source->getHeight();
unsigned int pitch = source->getInternalPitchB(); unsigned int pitch = source->getInternalPitchB();
for(unsigned int y = 0; y < height; y++) for(unsigned int y = 0; y < height; y++)
...@@ -568,8 +568,8 @@ namespace gl ...@@ -568,8 +568,8 @@ namespace gl
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
unsigned int width = source->getInternalWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getInternalHeight(); unsigned int height = source->getHeight();
unsigned int pitch = source->getStencilPitchB(); unsigned int pitch = source->getStencilPitchB();
for(unsigned int y = 0; y < height; y++) for(unsigned int y = 0; y < height; y++)
...@@ -710,17 +710,17 @@ namespace gl ...@@ -710,17 +710,17 @@ namespace gl
if(renderTarget) if(renderTarget)
{ {
scissor.x0 = max(scissor.x0, 0); scissor.x0 = max(scissor.x0, 0);
scissor.x1 = min(scissor.x1, renderTarget->getExternalWidth()); scissor.x1 = min(scissor.x1, renderTarget->getWidth());
scissor.y0 = max(scissor.y0, 0); scissor.y0 = max(scissor.y0, 0);
scissor.y1 = min(scissor.y1, renderTarget->getExternalHeight()); scissor.y1 = min(scissor.y1, renderTarget->getHeight());
} }
if(depthStencil) if(depthStencil)
{ {
scissor.x0 = max(scissor.x0, 0); scissor.x0 = max(scissor.x0, 0);
scissor.x1 = min(scissor.x1, depthStencil->getExternalWidth()); scissor.x1 = min(scissor.x1, depthStencil->getWidth());
scissor.y0 = max(scissor.y0, 0); scissor.y0 = max(scissor.y0, 0);
scissor.y1 = min(scissor.y1, depthStencil->getExternalHeight()); scissor.y1 = min(scissor.y1, depthStencil->getHeight());
} }
setScissor(scissor); setScissor(scissor);
......
...@@ -144,8 +144,8 @@ namespace es1 ...@@ -144,8 +144,8 @@ namespace es1
int x0 = 0; int x0 = 0;
int y0 = 0; int y0 = 0;
int width = renderTarget->getExternalWidth(); int width = renderTarget->getWidth();
int height = renderTarget->getExternalHeight(); int height = renderTarget->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -170,8 +170,8 @@ namespace es1 ...@@ -170,8 +170,8 @@ namespace es1
int x0 = 0; int x0 = 0;
int y0 = 0; int y0 = 0;
int width = depthStencil->getExternalWidth(); int width = depthStencil->getWidth();
int height = depthStencil->getExternalHeight(); int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -193,8 +193,8 @@ namespace es1 ...@@ -193,8 +193,8 @@ namespace es1
int x0 = 0; int x0 = 0;
int y0 = 0; int y0 = 0;
int width = depthStencil->getExternalWidth(); int width = depthStencil->getWidth();
int height = depthStencil->getExternalHeight(); int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -414,10 +414,10 @@ namespace es1 ...@@ -414,10 +414,10 @@ namespace es1
return false; return false;
} }
int sWidth = source->getExternalWidth(); int sWidth = source->getWidth();
int sHeight = source->getExternalHeight(); int sHeight = source->getHeight();
int dWidth = dest->getExternalWidth(); int dWidth = dest->getWidth();
int dHeight = dest->getExternalHeight(); int dHeight = dest->getHeight();
SliceRect sRect; SliceRect sRect;
SliceRect dRect; SliceRect dRect;
...@@ -465,8 +465,8 @@ namespace es1 ...@@ -465,8 +465,8 @@ namespace es1
sw::byte *sourceBuffer = (sw::byte*)source->lockInternal(0, 0, sRect.slice, LOCK_READONLY, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockInternal(0, 0, sRect.slice, LOCK_READONLY, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockInternal(0, 0, dRect.slice, LOCK_DISCARD, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockInternal(0, 0, dRect.slice, LOCK_DISCARD, PUBLIC);
unsigned int width = source->getInternalWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getInternalHeight(); unsigned int height = source->getHeight();
unsigned int pitch = source->getInternalPitchB(); unsigned int pitch = source->getInternalPitchB();
for(unsigned int y = 0; y < height; y++) for(unsigned int y = 0; y < height; y++)
...@@ -486,8 +486,8 @@ namespace es1 ...@@ -486,8 +486,8 @@ namespace es1
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
unsigned int width = source->getInternalWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getInternalHeight(); unsigned int height = source->getHeight();
unsigned int pitch = source->getStencilPitchB(); unsigned int pitch = source->getStencilPitchB();
for(unsigned int y = 0; y < height; y++) for(unsigned int y = 0; y < height; y++)
...@@ -583,17 +583,17 @@ namespace es1 ...@@ -583,17 +583,17 @@ namespace es1
if(renderTarget) if(renderTarget)
{ {
scissor.x0 = max(scissor.x0, 0); scissor.x0 = max(scissor.x0, 0);
scissor.x1 = min(scissor.x1, renderTarget->getExternalWidth()); scissor.x1 = min(scissor.x1, renderTarget->getWidth());
scissor.y0 = max(scissor.y0, 0); scissor.y0 = max(scissor.y0, 0);
scissor.y1 = min(scissor.y1, renderTarget->getExternalHeight()); scissor.y1 = min(scissor.y1, renderTarget->getHeight());
} }
if(depthStencil) if(depthStencil)
{ {
scissor.x0 = max(scissor.x0, 0); scissor.x0 = max(scissor.x0, 0);
scissor.x1 = min(scissor.x1, depthStencil->getExternalWidth()); scissor.x1 = min(scissor.x1, depthStencil->getWidth());
scissor.y0 = max(scissor.y0, 0); scissor.y0 = max(scissor.y0, 0);
scissor.y1 = min(scissor.y1, depthStencil->getExternalHeight()); scissor.y1 = min(scissor.y1, depthStencil->getHeight());
} }
setScissor(scissor); setScissor(scissor);
......
...@@ -161,8 +161,8 @@ namespace es2 ...@@ -161,8 +161,8 @@ namespace es2
{ {
x0 = 0; x0 = 0;
y0 = 0; y0 = 0;
width = sourceSurface->getExternalWidth(); width = sourceSurface->getWidth();
height = sourceSurface->getExternalHeight(); height = sourceSurface->getHeight();
if(scissorEnable) // Clamp against scissor rectangle if(scissorEnable) // Clamp against scissor rectangle
{ {
...@@ -511,10 +511,10 @@ namespace es2 ...@@ -511,10 +511,10 @@ namespace es2
return false; return false;
} }
int sWidth = source->getExternalWidth(); int sWidth = source->getWidth();
int sHeight = source->getExternalHeight(); int sHeight = source->getHeight();
int dWidth = dest->getExternalWidth(); int dWidth = dest->getWidth();
int dHeight = dest->getExternalHeight(); int dHeight = dest->getHeight();
bool flipX = false; bool flipX = false;
bool flipY = false; bool flipY = false;
...@@ -606,7 +606,7 @@ namespace es2 ...@@ -606,7 +606,7 @@ namespace es2
sw::byte *sourceBuffer = (sw::byte*)source->lockInternal(0, 0, sourceRect->slice, LOCK_READONLY, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockInternal(0, 0, sourceRect->slice, LOCK_READONLY, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockInternal(0, 0, destRect->slice, LOCK_DISCARD, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockInternal(0, 0, destRect->slice, LOCK_DISCARD, PUBLIC);
copyBuffer(sourceBuffer, destBuffer, source->getInternalWidth(), source->getInternalHeight(), source->getInternalPitchB(), dest->getInternalPitchB(), egl::Image::bytes(source->getInternalFormat()), flipX, flipY); copyBuffer(sourceBuffer, destBuffer, source->getWidth(), source->getHeight(), source->getInternalPitchB(), dest->getInternalPitchB(), egl::Image::bytes(source->getInternalFormat()), flipX, flipY);
source->unlockInternal(); source->unlockInternal();
dest->unlockInternal(); dest->unlockInternal();
...@@ -617,7 +617,7 @@ namespace es2 ...@@ -617,7 +617,7 @@ namespace es2
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
copyBuffer(sourceBuffer, destBuffer, source->getInternalWidth(), source->getInternalHeight(), source->getInternalPitchB(), dest->getInternalPitchB(), egl::Image::bytes(source->getInternalFormat()), flipX, flipY); copyBuffer(sourceBuffer, destBuffer, source->getWidth(), source->getHeight(), source->getInternalPitchB(), dest->getInternalPitchB(), egl::Image::bytes(source->getInternalFormat()), flipX, flipY);
source->unlockStencil(); source->unlockStencil();
dest->unlockStencil(); dest->unlockStencil();
...@@ -673,12 +673,12 @@ namespace es2 ...@@ -673,12 +673,12 @@ namespace es2
return false; return false;
} }
int sWidth = source->getExternalWidth(); int sWidth = source->getWidth();
int sHeight = source->getExternalHeight(); int sHeight = source->getHeight();
int sDepth = source->getExternalDepth(); int sDepth = source->getDepth();
int dWidth = dest->getExternalWidth(); int dWidth = dest->getWidth();
int dHeight = dest->getExternalHeight(); int dHeight = dest->getHeight();
int dDepth = dest->getExternalDepth(); int dDepth = dest->getDepth();
bool scaling = (sWidth != dWidth) || (sHeight != dHeight) || (sDepth != dDepth); bool scaling = (sWidth != dWidth) || (sHeight != dHeight) || (sDepth != dDepth);
bool equalFormats = source->getInternalFormat() == dest->getInternalFormat(); bool equalFormats = source->getInternalFormat() == dest->getInternalFormat();
...@@ -817,17 +817,17 @@ namespace es2 ...@@ -817,17 +817,17 @@ namespace es2
if(renderTarget) if(renderTarget)
{ {
scissor.x0 = max(scissor.x0, 0); scissor.x0 = max(scissor.x0, 0);
scissor.x1 = min(scissor.x1, renderTarget->getExternalWidth()); scissor.x1 = min(scissor.x1, renderTarget->getWidth());
scissor.y0 = max(scissor.y0, 0); scissor.y0 = max(scissor.y0, 0);
scissor.y1 = min(scissor.y1, renderTarget->getExternalHeight()); scissor.y1 = min(scissor.y1, renderTarget->getHeight());
} }
if(depthStencil) if(depthStencil)
{ {
scissor.x0 = max(scissor.x0, 0); scissor.x0 = max(scissor.x0, 0);
scissor.x1 = min(scissor.x1, depthStencil->getExternalWidth()); scissor.x1 = min(scissor.x1, depthStencil->getWidth());
scissor.y0 = max(scissor.y0, 0); scissor.y0 = max(scissor.y0, 0);
scissor.y1 = min(scissor.y1, depthStencil->getExternalHeight()); scissor.y1 = min(scissor.y1, depthStencil->getHeight());
} }
setScissor(scissor); setScissor(scissor);
......
...@@ -95,18 +95,18 @@ namespace sw ...@@ -95,18 +95,18 @@ namespace sw
source->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC); source->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);
dest->lockInternal(0, 0, 0, sw::LOCK_WRITEONLY, sw::PUBLIC); dest->lockInternal(0, 0, 0, sw::LOCK_WRITEONLY, sw::PUBLIC);
float w = static_cast<float>(source->getExternalWidth()) / static_cast<float>(dest->getExternalWidth()); float w = static_cast<float>(source->getWidth()) / static_cast<float>(dest->getWidth());
float h = static_cast<float>(source->getExternalHeight()) / static_cast<float>(dest->getExternalHeight()); float h = static_cast<float>(source->getHeight()) / static_cast<float>(dest->getHeight());
float d = static_cast<float>(source->getExternalDepth()) / static_cast<float>(dest->getExternalDepth()); float d = static_cast<float>(source->getDepth()) / static_cast<float>(dest->getDepth());
float z = 0.5f * d; float z = 0.5f * d;
for(int k = 0; k < dest->getExternalDepth(); ++k) for(int k = 0; k < dest->getDepth(); ++k)
{ {
float y = 0.5f * h; float y = 0.5f * h;
for(int j = 0; j < dest->getExternalHeight(); ++j) for(int j = 0; j < dest->getHeight(); ++j)
{ {
float x = 0.5f * w; float x = 0.5f * w;
for(int i = 0; i < dest->getExternalWidth(); ++i) for(int i = 0; i < dest->getWidth(); ++i)
{ {
dest->writeInternal(i, j, k, source->sampleInternal(x, y, z)); dest->writeInternal(i, j, k, source->sampleInternal(x, y, z));
x += w; x += w;
...@@ -271,7 +271,7 @@ namespace sw ...@@ -271,7 +271,7 @@ namespace sw
unscale = vector(1.0f, 1.0f, 1.0f, 1.0f); unscale = vector(1.0f, 1.0f, 1.0f, 1.0f);
break; break;
default: default:
return false; return nullptr;
} }
float4 scale; float4 scale;
...@@ -296,7 +296,7 @@ namespace sw ...@@ -296,7 +296,7 @@ namespace sw
scale = vector(1.0f, 1.0f, 1.0f, 1.0f); scale = vector(1.0f, 1.0f, 1.0f, 1.0f);
break; break;
default: default:
return false; return nullptr;
} }
if(unscale != scale) if(unscale != scale)
...@@ -368,7 +368,7 @@ namespace sw ...@@ -368,7 +368,7 @@ namespace sw
*Pointer<Float>(d) = color.x; *Pointer<Float>(d) = color.x;
break; break;
default: default:
return false; return nullptr;
} }
x += w; x += w;
...@@ -439,8 +439,8 @@ namespace sw ...@@ -439,8 +439,8 @@ namespace sw
data.y0d = dRect.y0; data.y0d = dRect.y0;
data.y1d = dRect.y1; data.y1d = dRect.y1;
data.sWidth = source->getInternalWidth(); data.sWidth = source->getWidth();
data.sHeight = source->getInternalHeight(); data.sHeight = source->getHeight();
blitFunction(&data); blitFunction(&data);
......
...@@ -109,9 +109,9 @@ namespace sw ...@@ -109,9 +109,9 @@ namespace sw
externalTextureFormat = surface->getExternalFormat(); externalTextureFormat = surface->getExternalFormat();
internalTextureFormat = surface->getInternalFormat(); internalTextureFormat = surface->getInternalFormat();
int width = surface->getInternalWidth(); int width = surface->getWidth();
int height = surface->getInternalHeight(); int height = surface->getHeight();
int depth = surface->getInternalDepth(); int depth = surface->getDepth();
int pitchP = surface->getInternalPitchP(); int pitchP = surface->getInternalPitchP();
int sliceP = surface->getInternalSliceP(); int sliceP = surface->getInternalSliceP();
......
...@@ -165,11 +165,12 @@ namespace sw ...@@ -165,11 +165,12 @@ namespace sw
virtual ~Surface(); virtual ~Surface();
inline int getWidth() const;
inline int getHeight() const;
inline int getDepth() const;
void *lockExternal(int x, int y, int z, Lock lock, Accessor client); void *lockExternal(int x, int y, int z, Lock lock, Accessor client);
void unlockExternal(); void unlockExternal();
inline int getExternalWidth() const;
inline int getExternalHeight() const;
inline int getExternalDepth() const;
inline Format getExternalFormat() const; inline Format getExternalFormat() const;
inline int getExternalPitchB() const; inline int getExternalPitchB() const;
inline int getExternalPitchP() const; inline int getExternalPitchP() const;
...@@ -178,9 +179,6 @@ namespace sw ...@@ -178,9 +179,6 @@ namespace sw
virtual void *lockInternal(int x, int y, int z, Lock lock, Accessor client); virtual void *lockInternal(int x, int y, int z, Lock lock, Accessor client);
virtual void unlockInternal(); virtual void unlockInternal();
inline int getInternalWidth() const;
inline int getInternalHeight() const;
inline int getInternalDepth() const;
inline Format getInternalFormat() const; inline Format getInternalFormat() const;
inline int getInternalPitchB() const; inline int getInternalPitchB() const;
inline int getInternalPitchP() const; inline int getInternalPitchP() const;
...@@ -377,17 +375,17 @@ namespace sw ...@@ -377,17 +375,17 @@ namespace sw
namespace sw namespace sw
{ {
int Surface::getExternalWidth() const int Surface::getWidth() const
{ {
return external.width; return external.width;
} }
int Surface::getExternalHeight() const int Surface::getHeight() const
{ {
return external.height; return external.height;
} }
int Surface::getExternalDepth() const int Surface::getDepth() const
{ {
return external.depth; return external.depth;
} }
...@@ -417,21 +415,6 @@ namespace sw ...@@ -417,21 +415,6 @@ namespace sw
return external.sliceP; return external.sliceP;
} }
int Surface::getInternalWidth() const
{
return internal.width;
}
int Surface::getInternalHeight() const
{
return internal.height;
}
int Surface::getInternalDepth() const
{
return internal.depth;
}
Format Surface::getInternalFormat() const Format Surface::getInternalFormat() const
{ {
return internal.format; return internal.format;
......
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