Adding RGB support to the blitter
Added both RGB8 and BGR8 formats to the blitter and related
functions so that these formats may be used with glReadPixels.
Change-Id: I22ee13f837b66af5f2135abc77fe81cc2e995fec
Reviewed-on: https://swiftshader-review.googlesource.com/4294
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Renderer/Blitter.cpp b/src/Renderer/Blitter.cpp
index c6ea00e..c12de26 100644
--- a/src/Renderer/Blitter.cpp
+++ b/src/Renderer/Blitter.cpp
@@ -187,6 +187,16 @@
c = Float4(*Pointer<Byte4>(element)).zyxw;
c.w = float(0xFF);
break;
+ case FORMAT_R8G8B8:
+ c.z = Float(Int(*Pointer<Byte>(element + 0)));
+ c.y = Float(Int(*Pointer<Byte>(element + 1)));
+ c.x = Float(Int(*Pointer<Byte>(element + 2)));
+ break;
+ case FORMAT_B8G8R8:
+ c.x = Float(Int(*Pointer<Byte>(element + 0)));
+ c.y = Float(Int(*Pointer<Byte>(element + 1)));
+ c.z = Float(Int(*Pointer<Byte>(element + 2)));
+ break;
case FORMAT_X8B8G8R8I:
c = Float4(*Pointer<SByte4>(element));
c.w = float(0x7F);
@@ -363,6 +373,16 @@
if(writeA) { *Pointer<Byte>(element + 3) = Byte(0xFF); }
}
break;
+ case FORMAT_R8G8B8:
+ if(writeR) { *Pointer<Byte>(element + 2) = Byte(RoundInt(Float(c.x))); }
+ if(writeG) { *Pointer<Byte>(element + 1) = Byte(RoundInt(Float(c.y))); }
+ if(writeB) { *Pointer<Byte>(element + 0) = Byte(RoundInt(Float(c.z))); }
+ break;
+ case FORMAT_B8G8R8:
+ if(writeR) { *Pointer<Byte>(element + 0) = Byte(RoundInt(Float(c.x))); }
+ if(writeG) { *Pointer<Byte>(element + 1) = Byte(RoundInt(Float(c.y))); }
+ if(writeB) { *Pointer<Byte>(element + 2) = Byte(RoundInt(Float(c.z))); }
+ break;
case FORMAT_A32B32G32R32F:
if(writeRGBA)
{
@@ -825,6 +845,8 @@
case FORMAT_X8R8G8B8:
case FORMAT_R8:
case FORMAT_G8R8:
+ case FORMAT_R8G8B8:
+ case FORMAT_B8G8R8:
case FORMAT_X8B8G8R8:
case FORMAT_A8B8G8R8:
scale = vector(0xFF, 0xFF, 0xFF, 0xFF);
diff --git a/src/Renderer/Surface.cpp b/src/Renderer/Surface.cpp
index 46796f8..05e8959 100644
--- a/src/Renderer/Surface.cpp
+++ b/src/Renderer/Surface.cpp
@@ -2635,6 +2635,8 @@
switch(format)
{
case FORMAT_R5G6B5:
+ case FORMAT_R8G8B8:
+ case FORMAT_B8G8R8:
case FORMAT_X8R8G8B8:
case FORMAT_X8B8G8R8I:
case FORMAT_X8B8G8R8:
@@ -2711,6 +2713,8 @@
{
case FORMAT_NULL:
case FORMAT_R5G6B5:
+ case FORMAT_R8G8B8:
+ case FORMAT_B8G8R8:
case FORMAT_X8R8G8B8:
case FORMAT_X8B8G8R8:
case FORMAT_A8R8G8B8: