Commit 925c2827 by Alexis Hetu Committed by Alexis Hétu

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/4294Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 75b650f0
...@@ -187,6 +187,16 @@ namespace sw ...@@ -187,6 +187,16 @@ namespace sw
c = Float4(*Pointer<Byte4>(element)).zyxw; c = Float4(*Pointer<Byte4>(element)).zyxw;
c.w = float(0xFF); c.w = float(0xFF);
break; 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: case FORMAT_X8B8G8R8I:
c = Float4(*Pointer<SByte4>(element)); c = Float4(*Pointer<SByte4>(element));
c.w = float(0x7F); c.w = float(0x7F);
...@@ -363,6 +373,16 @@ namespace sw ...@@ -363,6 +373,16 @@ namespace sw
if(writeA) { *Pointer<Byte>(element + 3) = Byte(0xFF); } if(writeA) { *Pointer<Byte>(element + 3) = Byte(0xFF); }
} }
break; 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: case FORMAT_A32B32G32R32F:
if(writeRGBA) if(writeRGBA)
{ {
...@@ -825,6 +845,8 @@ namespace sw ...@@ -825,6 +845,8 @@ namespace sw
case FORMAT_X8R8G8B8: case FORMAT_X8R8G8B8:
case FORMAT_R8: case FORMAT_R8:
case FORMAT_G8R8: case FORMAT_G8R8:
case FORMAT_R8G8B8:
case FORMAT_B8G8R8:
case FORMAT_X8B8G8R8: case FORMAT_X8B8G8R8:
case FORMAT_A8B8G8R8: case FORMAT_A8B8G8R8:
scale = vector(0xFF, 0xFF, 0xFF, 0xFF); scale = vector(0xFF, 0xFF, 0xFF, 0xFF);
......
...@@ -2635,6 +2635,8 @@ namespace sw ...@@ -2635,6 +2635,8 @@ namespace sw
switch(format) switch(format)
{ {
case FORMAT_R5G6B5: case FORMAT_R5G6B5:
case FORMAT_R8G8B8:
case FORMAT_B8G8R8:
case FORMAT_X8R8G8B8: case FORMAT_X8R8G8B8:
case FORMAT_X8B8G8R8I: case FORMAT_X8B8G8R8I:
case FORMAT_X8B8G8R8: case FORMAT_X8B8G8R8:
...@@ -2711,6 +2713,8 @@ namespace sw ...@@ -2711,6 +2713,8 @@ namespace sw
{ {
case FORMAT_NULL: case FORMAT_NULL:
case FORMAT_R5G6B5: case FORMAT_R5G6B5:
case FORMAT_R8G8B8:
case FORMAT_B8G8R8:
case FORMAT_X8R8G8B8: case FORMAT_X8R8G8B8:
case FORMAT_X8B8G8R8: case FORMAT_X8B8G8R8:
case FORMAT_A8R8G8B8: case FORMAT_A8R8G8B8:
......
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