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
cursor = cursorImage->lockExternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);
cursorImage->unlockExternal();
cursorWidth = cursorImage->getExternalWidth();
cursorHeight = cursorImage->getExternalHeight();
cursorWidth = cursorImage->getWidth();
cursorHeight = cursorImage->getHeight();
}
else
{
......
......@@ -185,8 +185,8 @@ namespace gl
int x0 = 0;
int y0 = 0;
int width = renderTarget->getExternalWidth();
int height = renderTarget->getExternalHeight();
int width = renderTarget->getWidth();
int height = renderTarget->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -211,8 +211,8 @@ namespace gl
int x0 = 0;
int y0 = 0;
int width = depthStencil->getExternalWidth();
int height = depthStencil->getExternalHeight();
int width = depthStencil->getWidth();
int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -234,8 +234,8 @@ namespace gl
int x0 = 0;
int y0 = 0;
int width = depthStencil->getExternalWidth();
int height = depthStencil->getExternalHeight();
int width = depthStencil->getWidth();
int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -496,10 +496,10 @@ namespace gl
return false;
}
int sWidth = source->getExternalWidth();
int sHeight = source->getExternalHeight();
int dWidth = dest->getExternalWidth();
int dHeight = dest->getExternalHeight();
int sWidth = source->getWidth();
int sHeight = source->getHeight();
int dWidth = dest->getWidth();
int dHeight = dest->getHeight();
SliceRect sRect;
SliceRect dRect;
......@@ -547,8 +547,8 @@ namespace gl
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);
unsigned int width = source->getInternalWidth();
unsigned int height = source->getInternalHeight();
unsigned int width = source->getWidth();
unsigned int height = source->getHeight();
unsigned int pitch = source->getInternalPitchB();
for(unsigned int y = 0; y < height; y++)
......@@ -568,8 +568,8 @@ namespace gl
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
unsigned int width = source->getInternalWidth();
unsigned int height = source->getInternalHeight();
unsigned int width = source->getWidth();
unsigned int height = source->getHeight();
unsigned int pitch = source->getStencilPitchB();
for(unsigned int y = 0; y < height; y++)
......@@ -710,17 +710,17 @@ namespace gl
if(renderTarget)
{
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.y1 = min(scissor.y1, renderTarget->getExternalHeight());
scissor.y1 = min(scissor.y1, renderTarget->getHeight());
}
if(depthStencil)
{
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.y1 = min(scissor.y1, depthStencil->getExternalHeight());
scissor.y1 = min(scissor.y1, depthStencil->getHeight());
}
setScissor(scissor);
......
......@@ -144,8 +144,8 @@ namespace es1
int x0 = 0;
int y0 = 0;
int width = renderTarget->getExternalWidth();
int height = renderTarget->getExternalHeight();
int width = renderTarget->getWidth();
int height = renderTarget->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -170,8 +170,8 @@ namespace es1
int x0 = 0;
int y0 = 0;
int width = depthStencil->getExternalWidth();
int height = depthStencil->getExternalHeight();
int width = depthStencil->getWidth();
int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -193,8 +193,8 @@ namespace es1
int x0 = 0;
int y0 = 0;
int width = depthStencil->getExternalWidth();
int height = depthStencil->getExternalHeight();
int width = depthStencil->getWidth();
int height = depthStencil->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -414,10 +414,10 @@ namespace es1
return false;
}
int sWidth = source->getExternalWidth();
int sHeight = source->getExternalHeight();
int dWidth = dest->getExternalWidth();
int dHeight = dest->getExternalHeight();
int sWidth = source->getWidth();
int sHeight = source->getHeight();
int dWidth = dest->getWidth();
int dHeight = dest->getHeight();
SliceRect sRect;
SliceRect dRect;
......@@ -465,8 +465,8 @@ namespace es1
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);
unsigned int width = source->getInternalWidth();
unsigned int height = source->getInternalHeight();
unsigned int width = source->getWidth();
unsigned int height = source->getHeight();
unsigned int pitch = source->getInternalPitchB();
for(unsigned int y = 0; y < height; y++)
......@@ -486,8 +486,8 @@ namespace es1
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
unsigned int width = source->getInternalWidth();
unsigned int height = source->getInternalHeight();
unsigned int width = source->getWidth();
unsigned int height = source->getHeight();
unsigned int pitch = source->getStencilPitchB();
for(unsigned int y = 0; y < height; y++)
......@@ -583,17 +583,17 @@ namespace es1
if(renderTarget)
{
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.y1 = min(scissor.y1, renderTarget->getExternalHeight());
scissor.y1 = min(scissor.y1, renderTarget->getHeight());
}
if(depthStencil)
{
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.y1 = min(scissor.y1, depthStencil->getExternalHeight());
scissor.y1 = min(scissor.y1, depthStencil->getHeight());
}
setScissor(scissor);
......
......@@ -161,8 +161,8 @@ namespace es2
{
x0 = 0;
y0 = 0;
width = sourceSurface->getExternalWidth();
height = sourceSurface->getExternalHeight();
width = sourceSurface->getWidth();
height = sourceSurface->getHeight();
if(scissorEnable) // Clamp against scissor rectangle
{
......@@ -511,10 +511,10 @@ namespace es2
return false;
}
int sWidth = source->getExternalWidth();
int sHeight = source->getExternalHeight();
int dWidth = dest->getExternalWidth();
int dHeight = dest->getExternalHeight();
int sWidth = source->getWidth();
int sHeight = source->getHeight();
int dWidth = dest->getWidth();
int dHeight = dest->getHeight();
bool flipX = false;
bool flipY = false;
......@@ -606,7 +606,7 @@ namespace es2
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);
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();
dest->unlockInternal();
......@@ -617,7 +617,7 @@ namespace es2
sw::byte *sourceBuffer = (sw::byte*)source->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();
dest->unlockStencil();
......@@ -673,12 +673,12 @@ namespace es2
return false;
}
int sWidth = source->getExternalWidth();
int sHeight = source->getExternalHeight();
int sDepth = source->getExternalDepth();
int dWidth = dest->getExternalWidth();
int dHeight = dest->getExternalHeight();
int dDepth = dest->getExternalDepth();
int sWidth = source->getWidth();
int sHeight = source->getHeight();
int sDepth = source->getDepth();
int dWidth = dest->getWidth();
int dHeight = dest->getHeight();
int dDepth = dest->getDepth();
bool scaling = (sWidth != dWidth) || (sHeight != dHeight) || (sDepth != dDepth);
bool equalFormats = source->getInternalFormat() == dest->getInternalFormat();
......@@ -817,17 +817,17 @@ namespace es2
if(renderTarget)
{
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.y1 = min(scissor.y1, renderTarget->getExternalHeight());
scissor.y1 = min(scissor.y1, renderTarget->getHeight());
}
if(depthStencil)
{
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.y1 = min(scissor.y1, depthStencil->getExternalHeight());
scissor.y1 = min(scissor.y1, depthStencil->getHeight());
}
setScissor(scissor);
......
......@@ -95,18 +95,18 @@ namespace sw
source->lockInternal(0, 0, 0, sw::LOCK_READONLY, 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 h = static_cast<float>(source->getExternalHeight()) / static_cast<float>(dest->getExternalHeight());
float d = static_cast<float>(source->getExternalDepth()) / static_cast<float>(dest->getExternalDepth());
float w = static_cast<float>(source->getWidth()) / static_cast<float>(dest->getWidth());
float h = static_cast<float>(source->getHeight()) / static_cast<float>(dest->getHeight());
float d = static_cast<float>(source->getDepth()) / static_cast<float>(dest->getDepth());
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;
for(int j = 0; j < dest->getExternalHeight(); ++j)
for(int j = 0; j < dest->getHeight(); ++j)
{
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));
x += w;
......@@ -271,7 +271,7 @@ namespace sw
unscale = vector(1.0f, 1.0f, 1.0f, 1.0f);
break;
default:
return false;
return nullptr;
}
float4 scale;
......@@ -296,7 +296,7 @@ namespace sw
scale = vector(1.0f, 1.0f, 1.0f, 1.0f);
break;
default:
return false;
return nullptr;
}
if(unscale != scale)
......@@ -309,9 +309,9 @@ namespace sw
color = Min(color, Float4(1.0f, 1.0f, 1.0f, 1.0f));
color = Max(color, Float4(Surface::isUnsignedComponent(state.destFormat, 0) ? 0.0f : -1.0f,
Surface::isUnsignedComponent(state.destFormat, 1) ? 0.0f : -1.0f,
Surface::isUnsignedComponent(state.destFormat, 2) ? 0.0f : -1.0f,
Surface::isUnsignedComponent(state.destFormat, 3) ? 0.0f : -1.0f));
Surface::isUnsignedComponent(state.destFormat, 1) ? 0.0f : -1.0f,
Surface::isUnsignedComponent(state.destFormat, 2) ? 0.0f : -1.0f,
Surface::isUnsignedComponent(state.destFormat, 3) ? 0.0f : -1.0f));
}
Pointer<Byte> d = destLine + i * Surface::bytes(state.destFormat);
......@@ -368,7 +368,7 @@ namespace sw
*Pointer<Float>(d) = color.x;
break;
default:
return false;
return nullptr;
}
x += w;
......@@ -439,8 +439,8 @@ namespace sw
data.y0d = dRect.y0;
data.y1d = dRect.y1;
data.sWidth = source->getInternalWidth();
data.sHeight = source->getInternalHeight();
data.sWidth = source->getWidth();
data.sHeight = source->getHeight();
blitFunction(&data);
......
......@@ -109,9 +109,9 @@ namespace sw
externalTextureFormat = surface->getExternalFormat();
internalTextureFormat = surface->getInternalFormat();
int width = surface->getInternalWidth();
int height = surface->getInternalHeight();
int depth = surface->getInternalDepth();
int width = surface->getWidth();
int height = surface->getHeight();
int depth = surface->getDepth();
int pitchP = surface->getInternalPitchP();
int sliceP = surface->getInternalSliceP();
......
......@@ -165,11 +165,12 @@ namespace sw
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 unlockExternal();
inline int getExternalWidth() const;
inline int getExternalHeight() const;
inline int getExternalDepth() const;
inline Format getExternalFormat() const;
inline int getExternalPitchB() const;
inline int getExternalPitchP() const;
......@@ -178,9 +179,6 @@ namespace sw
virtual void *lockInternal(int x, int y, int z, Lock lock, Accessor client);
virtual void unlockInternal();
inline int getInternalWidth() const;
inline int getInternalHeight() const;
inline int getInternalDepth() const;
inline Format getInternalFormat() const;
inline int getInternalPitchB() const;
inline int getInternalPitchP() const;
......@@ -377,17 +375,17 @@ namespace sw
namespace sw
{
int Surface::getExternalWidth() const
int Surface::getWidth() const
{
return external.width;
}
int Surface::getExternalHeight() const
int Surface::getHeight() const
{
return external.height;
}
int Surface::getExternalDepth() const
int Surface::getDepth() const
{
return external.depth;
}
......@@ -417,21 +415,6 @@ namespace sw
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
{
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