<p dir="ltr">You said earlier that pbo-readpixels-small worked with this patch on Fermi :( Oh well.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Jul 22, 2016 5:39 AM, "Samuel Pitoiset" <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch introduces the following regressions:<br>
<br>
bin/fcc-read-to-pbo-after-clear -auto<br>
bin/gl-2.1-pbo -auto -fbo<br>
bin/fbo-pbo-readpixels-small -auto<br>
bin/pbo-read-argb8888 -auto<br>
bin/pbo-readpixels-small -auto<br>
bin/mesa_pack_invert-readpixels -auto -fbo<br>
<br>
Tested on Fermi (GF119).<br>
<br>
On 07/16/2016 09:09 PM, Ilia Mirkin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is useful for pbo downloads, which are now accelerated with images.<br>
BGRA8 is a moderately common format to do that in.<br>
<br>
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>><br>
---<br>
<br>
This needs testing on SM20 and SM30. I've tested it on SM35 and<br>
<br>
bin/pbo-readpixels-small -auto<br>
<br>
worked fine. (Didn't until I properly fixed the various items.)<br>
<br>
src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++<br>
src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++<br>
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++<br>
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 ++++<br>
src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 +<br>
src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++-<br>
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++<br>
7 files changed, 16 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp<br>
index 2caebe8..179ad0b 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp<br>
@@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] =<br>
{ "RG8_SNORM", 2, { 8, 8, 0, 0 }, SNORM },<br>
{ "R16_SNORM", 1, { 16, 0, 0, 0 }, SNORM },<br>
{ "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM },<br>
+<br>
+ { "BGRA8", 4, { 8, 8, 8, 8 }, UNORM, true },<br>
};<br>
<br>
void<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h<br>
index 41804b6..6d2ee8b 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h<br>
@@ -412,6 +412,8 @@ enum ImgFormat<br>
FMT_R16_SNORM,<br>
FMT_R8_SNORM,<br>
<br>
+ FMT_BGRA8,<br>
+<br>
IMG_FORMAT_COUNT,<br>
};<br>
<br>
@@ -967,6 +969,7 @@ public:<br>
uint8_t components;<br>
uint8_t bits[4];<br>
ImgType type;<br>
+ bool bgra;<br>
};<br>
<br>
static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT];<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp<br>
index 61eb7f5..7dff08a 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp<br>
@@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format)<br>
FMT_CASE(R8G8_SNORM, RG8_SNORM);<br>
FMT_CASE(R16_SNORM, R16_SNORM);<br>
FMT_CASE(R8_SNORM, R8_SNORM);<br>
+<br>
+ FMT_CASE(B8G8R8A8_UNORM, BGRA8);<br>
}<br>
<br>
assert(!"Unexpected format");<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp<br>
index 18955eb..92bc0bb 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp<br>
@@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su)<br>
bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]);<br>
}<br>
}<br>
+<br>
+ if (format->bgra) {<br>
+ std::swap(typedDst[0], typedDst[2]);<br>
+ }<br>
}<br>
<br>
void<br>
diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h<br>
index 5d40624..49bf860 100644<br>
--- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h<br>
+++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h<br>
@@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
#define GK104_IMAGE_FORMAT_RG32_FLOAT 0x0000000d<br>
#define GK104_IMAGE_FORMAT_RG32_SINT 0x0000000e<br>
#define GK104_IMAGE_FORMAT_RG32_UINT 0x0000000f<br>
+#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x00000011<br>
#define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x00000013<br>
#define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x00000015<br>
#define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x00000018<br>
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c<br>
index 34d32d1..07c4419 100644<br>
--- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c<br>
+++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c<br>
@@ -50,6 +50,7 @@<br>
#define U_IB PIPE_BIND_BLENDABLE | U_IR<br>
#define U_TD PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB<br>
#define U_TZ PIPE_BIND_DEPTH_STENCIL | U_T<br>
+#define U_ID U_TD | U_I<br>
#if NOUVEAU_DRIVER == 0xc0<br>
# define U_TC U_TB<br>
# define U_IC U_IB<br>
@@ -122,7 +123,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =<br>
const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =<br>
#endif<br>
{<br>
- C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, TD),<br>
+ C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, ID),<br>
F3(A, B8G8R8X8_UNORM, BGRX8_UNORM, B, G, R, xx, UNORM, A8B8G8R8, TD),<br>
C4(A, B8G8R8A8_SRGB, BGRA8_SRGB, B, G, R, A, UNORM, A8B8G8R8, TD),<br>
F3(A, B8G8R8X8_SRGB, BGRX8_SRGB, B, G, R, xx, UNORM, A8B8G8R8, TD),<br>
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c b/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c<br>
index 6e9e768..439f0f5 100644<br>
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c<br>
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c<br>
@@ -1162,6 +1162,7 @@ static const uint8_t nve4_su_format_map[PIPE_FORMAT_COUNT] =<br>
[PIPE_FORMAT_R16G16B16A16_SNORM] = GK104_IMAGE_FORMAT_RGBA16_SNORM,<br>
[PIPE_FORMAT_R16G16B16A16_SINT] = GK104_IMAGE_FORMAT_RGBA16_SINT,<br>
[PIPE_FORMAT_R16G16B16A16_UINT] = GK104_IMAGE_FORMAT_RGBA16_UINT,<br>
+ [PIPE_FORMAT_B8G8R8A8_UNORM] = GK104_IMAGE_FORMAT_BGRA8_UNORM,<br>
[PIPE_FORMAT_R8G8B8A8_UNORM] = GK104_IMAGE_FORMAT_RGBA8_UNORM,<br>
[PIPE_FORMAT_R8G8B8A8_SNORM] = GK104_IMAGE_FORMAT_RGBA8_SNORM,<br>
[PIPE_FORMAT_R8G8B8A8_SINT] = GK104_IMAGE_FORMAT_RGBA8_SINT,<br>
@@ -1216,6 +1217,7 @@ static const uint16_t nve4_su_format_aux_map[PIPE_FORMAT_COUNT] =<br>
<br>
[PIPE_FORMAT_R10G10B10A2_UNORM] = 0x2a24,<br>
[PIPE_FORMAT_R10G10B10A2_UINT] = 0x2a24,<br>
+ [PIPE_FORMAT_B8G8R8A8_UNORM] = 0x2a24,<br>
[PIPE_FORMAT_R8G8B8A8_UNORM] = 0x2a24,<br>
[PIPE_FORMAT_R8G8B8A8_SNORM] = 0x2a24,<br>
[PIPE_FORMAT_R8G8B8A8_SINT] = 0x2a24,<br>
<br>
</blockquote>
</blockquote></div></div>