Commit a52dfbda by Alexis Hetu Committed by Alexis Hétu

Adding functionality to stencils

Two minor features are required for the blitFramebuffer implementation in OpenGL ES 3: - lockStencil with x,y coordinates - getting the stencil format (new getStencilFormat function) Change-Id: I83ccccefe70dbbedd05b5d82bc75d30f689c4abe Reviewed-on: https://swiftshader-review.googlesource.com/7490Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 619c0ab9
...@@ -6271,8 +6271,8 @@ namespace D3D9 ...@@ -6271,8 +6271,8 @@ namespace D3D9
if(source->hasStencil()) if(source->hasStencil())
{ {
byte *sourceBuffer = (byte*)source->lockStencil(0, sw::PUBLIC); byte *sourceBuffer = (byte*)source->lockStencil(0, 0, 0, sw::PUBLIC);
byte *destBuffer = (byte*)dest->lockStencil(0, sw::PUBLIC); byte *destBuffer = (byte*)dest->lockStencil(0, 0, 0, sw::PUBLIC);
unsigned int width = source->getWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getHeight(); unsigned int height = source->getHeight();
......
...@@ -1627,7 +1627,7 @@ namespace egl ...@@ -1627,7 +1627,7 @@ namespace egl
{ {
LoadImageData<D24>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<D24>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, sw::PUBLIC)); unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, 0, 0, sw::PUBLIC));
if(stencil) if(stencil)
{ {
...@@ -1641,7 +1641,7 @@ namespace egl ...@@ -1641,7 +1641,7 @@ namespace egl
{ {
LoadImageData<D32F>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<D32F>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, sw::PUBLIC)); unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, 0, 0, sw::PUBLIC));
if(stencil) if(stencil)
{ {
......
...@@ -570,8 +570,8 @@ namespace gl ...@@ -570,8 +570,8 @@ namespace gl
if(source->hasStencil()) if(source->hasStencil())
{ {
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, 0, 0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, 0, 0, PUBLIC);
unsigned int width = source->getWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getHeight(); unsigned int height = source->getHeight();
......
...@@ -672,7 +672,7 @@ namespace gl ...@@ -672,7 +672,7 @@ namespace gl
} }
} }
unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, sw::PUBLIC)); unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, 0, 0, sw::PUBLIC));
if(stencil) if(stencil)
{ {
......
...@@ -455,8 +455,8 @@ namespace es1 ...@@ -455,8 +455,8 @@ namespace es1
if(source->hasStencil()) if(source->hasStencil())
{ {
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, 0, 0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, 0, 0, PUBLIC);
unsigned int width = source->getWidth(); unsigned int width = source->getWidth();
unsigned int height = source->getHeight(); unsigned int height = source->getHeight();
......
...@@ -621,8 +621,8 @@ namespace es2 ...@@ -621,8 +621,8 @@ namespace es2
if(source->hasStencil()) if(source->hasStencil())
{ {
sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC); sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, 0, 0, PUBLIC);
sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC); sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, 0, 0, PUBLIC);
copyBuffer(sourceBuffer, destBuffer, source->getWidth(), source->getHeight(), 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);
......
...@@ -634,7 +634,7 @@ namespace sw ...@@ -634,7 +634,7 @@ namespace sw
if(draw->stencilBuffer) if(draw->stencilBuffer)
{ {
data->stencilBuffer = (unsigned char*)context->stencilBuffer->lockStencil(q * ms, MANAGED); data->stencilBuffer = (unsigned char*)context->stencilBuffer->lockStencil(0, 0, q * ms, MANAGED);
data->stencilPitchB = context->stencilBuffer->getStencilPitchB(); data->stencilPitchB = context->stencilBuffer->getStencilPitchB();
data->stencilSliceB = context->stencilBuffer->getStencilSliceB(); data->stencilSliceB = context->stencilBuffer->getStencilSliceB();
} }
......
...@@ -1426,7 +1426,7 @@ namespace sw ...@@ -1426,7 +1426,7 @@ namespace sw
internal.unlockRect(); internal.unlockRect();
} }
void *Surface::lockStencil(int front, Accessor client) void *Surface::lockStencil(int x, int y, int front, Accessor client)
{ {
resource->lock(client); resource->lock(client);
...@@ -1435,7 +1435,7 @@ namespace sw ...@@ -1435,7 +1435,7 @@ namespace sw
stencil.buffer = allocateBuffer(stencil.width, stencil.height, stencil.depth, stencil.format); stencil.buffer = allocateBuffer(stencil.width, stencil.height, stencil.depth, stencil.format);
} }
return stencil.lockRect(0, 0, front, LOCK_READWRITE); // FIXME return stencil.lockRect(x, y, front, LOCK_READWRITE); // FIXME
} }
void Surface::unlockStencil() void Surface::unlockStencil()
...@@ -3258,7 +3258,7 @@ namespace sw ...@@ -3258,7 +3258,7 @@ namespace sw
unsigned int fill = maskedS; unsigned int fill = maskedS;
fill = fill | (fill << 8) | (fill << 16) + (fill << 24); fill = fill | (fill << 8) | (fill << 16) + (fill << 24);
char *buffer = (char*)lockStencil(0, PUBLIC); char *buffer = (char*)lockStencil(0, 0, 0, PUBLIC);
// Stencil buffers are assumed to use quad layout // Stencil buffers are assumed to use quad layout
for(int z = 0; z < stencil.depth; z++) for(int z = 0; z < stencil.depth; z++)
......
...@@ -283,8 +283,9 @@ namespace sw ...@@ -283,8 +283,9 @@ namespace sw
inline int getInternalSliceB() const; inline int getInternalSliceB() const;
inline int getInternalSliceP() const; inline int getInternalSliceP() const;
void *lockStencil(int front, Accessor client); void *lockStencil(int x, int y, int front, Accessor client);
void unlockStencil(); void unlockStencil();
inline Format getStencilFormat() const;
inline int getStencilPitchB() const; inline int getStencilPitchB() const;
inline int getStencilSliceB() const; inline int getStencilSliceB() const;
...@@ -573,6 +574,11 @@ namespace sw ...@@ -573,6 +574,11 @@ namespace sw
return internal.sliceP; return internal.sliceP;
} }
Format Surface::getStencilFormat() const
{
return stencil.format;
}
int Surface::getStencilPitchB() const int Surface::getStencilPitchB() const
{ {
return stencil.pitchB; return stencil.pitchB;
......
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