OSDN Git Service

Use the source stride for framebuffer blit.
authorNicolas Capens <capn@google.com>
Mon, 28 Dec 2015 16:13:48 +0000 (11:13 -0500)
committerNicolas Capens <nicolascapens@google.com>
Tue, 7 Nov 2017 21:35:43 +0000 (21:35 +0000)
Previously we assumed the source stride (in pixels) to be the width
rounded up to the next multiple of 2. This is currently correct but
may not hold in the future.

Change-Id: I23a79ace66f720398a120b70081d731c2cf1b4c0
Reviewed-on: https://swiftshader-review.googlesource.com/4481
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
src/D3D9/Direct3DDevice9.cpp
src/Main/FrameBuffer.cpp
src/Main/FrameBuffer.hpp

index 4be7955..bc58fdb 100644 (file)
@@ -1831,14 +1831,15 @@ namespace D3D9
 
                        static void (__cdecl *blitFunction)(void *dst, void *src);
                        static sw::Routine *blitRoutine;
-                       static sw::BlitState blitState = {0};
+                       static sw::BlitState blitState = {};
 
                        sw::BlitState update;
                        update.width = sourceDescription.Width;
                        update.height = sourceDescription.Height;
                        update.sourceFormat = sw::FORMAT_A8R8G8B8;
+                       update.sourceStride = source->getExternalPitchB();
                        update.destFormat = sw::FORMAT_A8R8G8B8;
-                       update.stride = dest->getExternalPitchB();
+                       update.destStride = dest->getExternalPitchB();
                        update.cursorHeight = 0;
                        update.cursorWidth = 0;
 
index 29371db..ccf9083 100644 (file)
@@ -119,8 +119,9 @@ namespace sw
                updateState.width = width;
                updateState.height = height;
                updateState.destFormat = format;
+               updateState.destStride = stride;
                updateState.sourceFormat = sourceFormat;
-               updateState.stride = topLeftOrigin ? (int)sourceStride : -(int)sourceStride;
+               updateState.sourceStride = topLeftOrigin ? (int)sourceStride : -(int)sourceStride;
                updateState.cursorWidth = cursor.width;
                updateState.cursorHeight = cursor.height;
 
@@ -169,11 +170,10 @@ namespace sw
        {
                const int width = state.width;
                const int height = state.height;
-               const int width2 = (state.width + 1) & ~1;
                const int dBytes = Surface::bytes(state.destFormat);
-               const int dStride = state.stride;
+               const int dStride = state.destStride;
                const int sBytes = Surface::bytes(state.sourceFormat);
-               const int sStride = topLeftOrigin ? (sBytes * width2) : -(sBytes * width2);
+               const int sStride = state.sourceStride;
 
                Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> function;
                {
index f0e00a4..fbb2a79 100644 (file)
@@ -29,7 +29,8 @@ namespace sw
                int height;
                Format destFormat;
                Format sourceFormat;
-               int stride;
+               int destStride;
+               int sourceStride;
                int cursorWidth;
                int cursorHeight;
        };