OSDN Git Service

Adding functionality to stencils
authorAlexis Hetu <sugoi@google.com>
Wed, 5 Oct 2016 21:03:30 +0000 (17:03 -0400)
committerAlexis Hétu <sugoi@google.com>
Thu, 6 Oct 2016 14:13:22 +0000 (14:13 +0000)
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/7490
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/D3D9/Direct3DDevice9.cpp
src/OpenGL/common/Image.cpp
src/OpenGL/libGL/Device.cpp
src/OpenGL/libGL/Image.cpp
src/OpenGL/libGLES_CM/Device.cpp
src/OpenGL/libGLESv2/Device.cpp
src/Renderer/Renderer.cpp
src/Renderer/Surface.cpp
src/Renderer/Surface.hpp

index 515ab4b..126b0df 100644 (file)
@@ -6271,8 +6271,8 @@ namespace D3D9
 
                        if(source->hasStencil())
                        {
-                               byte *sourceBuffer = (byte*)source->lockStencil(0, sw::PUBLIC);
-                               byte *destBuffer = (byte*)dest->lockStencil(0, sw::PUBLIC);
+                               byte *sourceBuffer = (byte*)source->lockStencil(0, 0, 0, sw::PUBLIC);
+                               byte *destBuffer = (byte*)dest->lockStencil(0, 0, 0, sw::PUBLIC);
 
                                unsigned int width = source->getWidth();
                                unsigned int height = source->getHeight();
index b7362d8..c734ba2 100644 (file)
@@ -1627,7 +1627,7 @@ namespace egl
        {
                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)
                {
@@ -1641,7 +1641,7 @@ namespace egl
        {
                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)
                {
index 57c669f..86d01b9 100644 (file)
@@ -570,8 +570,8 @@ namespace gl
 
                        if(source->hasStencil())
                        {
-                               sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
-                               sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
+                               sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, 0, 0, PUBLIC);
+                               sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, 0, 0, PUBLIC);
 
                                unsigned int width = source->getWidth();
                                unsigned int height = source->getHeight();
index 49204f5..6a8c01d 100644 (file)
@@ -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)
                {
index 6587d36..b66c323 100644 (file)
@@ -455,8 +455,8 @@ namespace es1
 
                        if(source->hasStencil())
                        {
-                               sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
-                               sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
+                               sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, 0, 0, PUBLIC);
+                               sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, 0, 0, PUBLIC);
 
                                unsigned int width = source->getWidth();
                                unsigned int height = source->getHeight();
index 3307f45..225ceeb 100644 (file)
@@ -621,8 +621,8 @@ namespace es2
 
                        if(source->hasStencil())
                        {
-                               sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, PUBLIC);
-                               sw::byte *destBuffer = (sw::byte*)dest->lockStencil(0, PUBLIC);
+                               sw::byte *sourceBuffer = (sw::byte*)source->lockStencil(0, 0, 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);
 
index fe6c7f9..0700a88 100644 (file)
@@ -634,7 +634,7 @@ namespace sw
 
                                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->stencilSliceB = context->stencilBuffer->getStencilSliceB();
                                }
index 5ddea4a..d972574 100644 (file)
@@ -1426,7 +1426,7 @@ namespace sw
                internal.unlockRect();
        }
 
-       void *Surface::lockStencil(int front, Accessor client)
+       void *Surface::lockStencil(int x, int y, int front, Accessor client)
        {
                resource->lock(client);
 
@@ -1435,7 +1435,7 @@ namespace sw
                        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()
@@ -3258,7 +3258,7 @@ namespace sw
                unsigned int fill = maskedS;
                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
                for(int z = 0; z < stencil.depth; z++)
index cd89d74..dd96ffd 100644 (file)
@@ -283,8 +283,9 @@ namespace sw
                inline int getInternalSliceB() const;
                inline int getInternalSliceP() const;
 
-               void *lockStencil(int front, Accessor client);
+               void *lockStencil(int x, int y, int front, Accessor client);
                void unlockStencil();
+               inline Format getStencilFormat() const;
                inline int getStencilPitchB() const;
                inline int getStencilSliceB() const;
 
@@ -573,6 +574,11 @@ namespace sw
                return internal.sliceP;
        }
 
+       Format Surface::getStencilFormat() const
+       {
+               return stencil.format;
+       }
+
        int Surface::getStencilPitchB() const
        {
                return stencil.pitchB;