Re: [Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
On 07/22/2016 02:14 PM, Ilia Mirkin wrote: You said earlier that pbo-readpixels-small worked with this patch on Fermi :( Oh well. It worked, but maybe an other issue has happened in the meantime :/ On Jul 22, 2016 5:39 AM, "Samuel Pitoiset" mailto:samuel.pitoi...@gmail.com>> wrote: This patch introduces the following regressions: bin/fcc-read-to-pbo-after-clear -auto bin/gl-2.1-pbo -auto -fbo bin/fbo-pbo-readpixels-small -auto bin/pbo-read-argb -auto bin/pbo-readpixels-small -auto bin/mesa_pack_invert-readpixels -auto -fbo Tested on Fermi (GF119). On 07/16/2016 09:09 PM, Ilia Mirkin wrote: This is useful for pbo downloads, which are now accelerated with images. BGRA8 is a moderately common format to do that in. Signed-off-by: Ilia Mirkin mailto:imir...@alum.mit.edu>> --- This needs testing on SM20 and SM30. I've tested it on SM35 and bin/pbo-readpixels-small -auto worked fine. (Didn't until I properly fixed the various items.) src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index 2caebe8..179ad0b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] = { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, + + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, }; void diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h index 41804b6..6d2ee8b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h @@ -412,6 +412,8 @@ enum ImgFormat FMT_R16_SNORM, FMT_R8_SNORM, + FMT_BGRA8, + IMG_FORMAT_COUNT, }; @@ -967,6 +969,7 @@ public: uint8_t components; uint8_t bits[4]; ImgType type; + bool bgra; }; static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 61eb7f5..7dff08a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format) FMT_CASE(R8G8_SNORM, RG8_SNORM); FMT_CASE(R16_SNORM, R16_SNORM); FMT_CASE(R8_SNORM, R8_SNORM); + + FMT_CASE(B8G8R8A8_UNORM, BGRA8); } assert(!"Unexpected format"); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 18955eb..92bc0bb 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); } } + + if (format->bgra) { + std::swap(typedDst[0], typedDst[2]); + } } void diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h index 5d40624..49bf860 100644 --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d #define GK104_IMAGE_FORMAT_RG32_SIN
Re: [Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
You said earlier that pbo-readpixels-small worked with this patch on Fermi :( Oh well. On Jul 22, 2016 5:39 AM, "Samuel Pitoiset" wrote: > This patch introduces the following regressions: > > bin/fcc-read-to-pbo-after-clear -auto > bin/gl-2.1-pbo -auto -fbo > bin/fbo-pbo-readpixels-small -auto > bin/pbo-read-argb -auto > bin/pbo-readpixels-small -auto > bin/mesa_pack_invert-readpixels -auto -fbo > > Tested on Fermi (GF119). > > On 07/16/2016 09:09 PM, Ilia Mirkin wrote: > >> This is useful for pbo downloads, which are now accelerated with images. >> BGRA8 is a moderately common format to do that in. >> >> Signed-off-by: Ilia Mirkin >> --- >> >> This needs testing on SM20 and SM30. I've tested it on SM35 and >> >> bin/pbo-readpixels-small -auto >> >> worked fine. (Didn't until I properly fixed the various items.) >> >> src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ >> src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ >> src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ >> src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 >> src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + >> src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- >> src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ >> 7 files changed, 16 insertions(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> index 2caebe8..179ad0b 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc >> TexInstruction::formatTable[] = >> { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, >> { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, >> { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, >> + >> + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, >> }; >> >> void >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> b/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> index 41804b6..6d2ee8b 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> @@ -412,6 +412,8 @@ enum ImgFormat >> FMT_R16_SNORM, >> FMT_R8_SNORM, >> >> + FMT_BGRA8, >> + >> IMG_FORMAT_COUNT, >> }; >> >> @@ -967,6 +969,7 @@ public: >>uint8_t components; >>uint8_t bits[4]; >>ImgType type; >> + bool bgra; >> }; >> >> static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> index 61eb7f5..7dff08a 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint >> format) >> FMT_CASE(R8G8_SNORM, RG8_SNORM); >> FMT_CASE(R16_SNORM, R16_SNORM); >> FMT_CASE(R8_SNORM, R8_SNORM); >> + >> + FMT_CASE(B8G8R8A8_UNORM, BGRA8); >> } >> >> assert(!"Unexpected format"); >> diff --git >> a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> index 18955eb..92bc0bb 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> @@ -1940,6 +1940,10 @@ >> NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) >> bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); >>} >> } >> + >> + if (format->bgra) { >> + std::swap(typedDst[0], typedDst[2]); >> + } >> } >> >> void >> diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> index 5d40624..49bf860 100644 >> --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE >> SOFTWARE. >> #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d >> #define GK104_IMAGE_FORMAT_RG32_SINT 0x000e >> #define GK104_IMAGE_FORMAT_RG32_UINT 0x000f >> +#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x0011 >> #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x0013 >> #define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x0015 >> #define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x0018 >> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> b/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> index 34d32d1..07c4419 100644 >> --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> +++ b/src/gallium/drivers/nou
Re: [Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
This patch introduces the following regressions: bin/fcc-read-to-pbo-after-clear -auto bin/gl-2.1-pbo -auto -fbo bin/fbo-pbo-readpixels-small -auto bin/pbo-read-argb -auto bin/pbo-readpixels-small -auto bin/mesa_pack_invert-readpixels -auto -fbo Tested on Fermi (GF119). On 07/16/2016 09:09 PM, Ilia Mirkin wrote: This is useful for pbo downloads, which are now accelerated with images. BGRA8 is a moderately common format to do that in. Signed-off-by: Ilia Mirkin --- This needs testing on SM20 and SM30. I've tested it on SM35 and bin/pbo-readpixels-small -auto worked fine. (Didn't until I properly fixed the various items.) src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index 2caebe8..179ad0b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] = { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, + + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, }; void diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h index 41804b6..6d2ee8b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h @@ -412,6 +412,8 @@ enum ImgFormat FMT_R16_SNORM, FMT_R8_SNORM, + FMT_BGRA8, + IMG_FORMAT_COUNT, }; @@ -967,6 +969,7 @@ public: uint8_t components; uint8_t bits[4]; ImgType type; + bool bgra; }; static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 61eb7f5..7dff08a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format) FMT_CASE(R8G8_SNORM, RG8_SNORM); FMT_CASE(R16_SNORM, R16_SNORM); FMT_CASE(R8_SNORM, R8_SNORM); + + FMT_CASE(B8G8R8A8_UNORM, BGRA8); } assert(!"Unexpected format"); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 18955eb..92bc0bb 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); } } + + if (format->bgra) { + std::swap(typedDst[0], typedDst[2]); + } } void diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h index 5d40624..49bf860 100644 --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d #define GK104_IMAGE_FORMAT_RG32_SINT 0x000e #define GK104_IMAGE_FORMAT_RG32_UINT 0x000f +#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x0011 #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x0013 #define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x0015 #define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x0018 diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c index 34d32d1..07c4419 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c @@ -50,6 +50,7 @@ #define U_IB PIPE_BIND_BLENDABLE | U_IR #define U_TD PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB #define U_TZ PIPE_BIND_DEPTH_STENCIL | U_T +#define U_ID U_TD | U_I #if NOUVEAU_DRIVER == 0xc0 # define U_TC U_TB # define U_IC U_IB @@ -122,7 +123,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] = const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] = #endif { - C4(A, B8G8R8
Re: [Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
On 07/18/2016 11:16 PM, Ilia Mirkin wrote: Karol tested it on Kepler1, so we should be good. Reviewed-by: Samuel Pitoiset On Mon, Jul 18, 2016 at 5:15 PM, Samuel Pitoiset wrote: Works fine on Fermi, but still need to test on Kepler1. On 07/16/2016 09:09 PM, Ilia Mirkin wrote: This is useful for pbo downloads, which are now accelerated with images. BGRA8 is a moderately common format to do that in. Signed-off-by: Ilia Mirkin --- This needs testing on SM20 and SM30. I've tested it on SM35 and bin/pbo-readpixels-small -auto worked fine. (Didn't until I properly fixed the various items.) src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index 2caebe8..179ad0b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] = { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, + + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, }; void diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h index 41804b6..6d2ee8b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h @@ -412,6 +412,8 @@ enum ImgFormat FMT_R16_SNORM, FMT_R8_SNORM, + FMT_BGRA8, + IMG_FORMAT_COUNT, }; @@ -967,6 +969,7 @@ public: uint8_t components; uint8_t bits[4]; ImgType type; + bool bgra; }; static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 61eb7f5..7dff08a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format) FMT_CASE(R8G8_SNORM, RG8_SNORM); FMT_CASE(R16_SNORM, R16_SNORM); FMT_CASE(R8_SNORM, R8_SNORM); + + FMT_CASE(B8G8R8A8_UNORM, BGRA8); } assert(!"Unexpected format"); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 18955eb..92bc0bb 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); } } + + if (format->bgra) { + std::swap(typedDst[0], typedDst[2]); + } } void diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h index 5d40624..49bf860 100644 --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d #define GK104_IMAGE_FORMAT_RG32_SINT 0x000e #define GK104_IMAGE_FORMAT_RG32_UINT 0x000f +#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x0011 #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x0013 #define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x0015 #define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x0018 diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c index 34d32d1..07c4419 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c @@ -50,6 +50,7 @@ #define U_IB PIPE_BIND_BLENDABLE | U_IR #define U_TD PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB #define U_TZ PIPE_BIND_DEPTH_STENCIL | U_T +#define U_ID U_TD | U_I #if NOUVEAU_DRIVER == 0xc0 # define U_TC U_TB # define U_IC U_IB @@ -122,7 +123,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] = const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] = #endif { - C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM
Re: [Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
Karol tested it on Kepler1, so we should be good. On Mon, Jul 18, 2016 at 5:15 PM, Samuel Pitoiset wrote: > Works fine on Fermi, but still need to test on Kepler1. > > > On 07/16/2016 09:09 PM, Ilia Mirkin wrote: >> >> This is useful for pbo downloads, which are now accelerated with images. >> BGRA8 is a moderately common format to do that in. >> >> Signed-off-by: Ilia Mirkin >> --- >> >> This needs testing on SM20 and SM30. I've tested it on SM35 and >> >> bin/pbo-readpixels-small -auto >> >> worked fine. (Didn't until I properly fixed the various items.) >> >> src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ >> src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ >> src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ >> src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 >> src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + >> src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- >> src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ >> 7 files changed, 16 insertions(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> index 2caebe8..179ad0b 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp >> @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc >> TexInstruction::formatTable[] = >> { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, >> { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, >> { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, >> + >> + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, >> }; >> >> void >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> b/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> index 41804b6..6d2ee8b 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h >> @@ -412,6 +412,8 @@ enum ImgFormat >> FMT_R16_SNORM, >> FMT_R8_SNORM, >> >> + FMT_BGRA8, >> + >> IMG_FORMAT_COUNT, >> }; >> >> @@ -967,6 +969,7 @@ public: >>uint8_t components; >>uint8_t bits[4]; >>ImgType type; >> + bool bgra; >> }; >> >> static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> index 61eb7f5..7dff08a 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp >> @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint >> format) >> FMT_CASE(R8G8_SNORM, RG8_SNORM); >> FMT_CASE(R16_SNORM, R16_SNORM); >> FMT_CASE(R8_SNORM, R8_SNORM); >> + >> + FMT_CASE(B8G8R8A8_UNORM, BGRA8); >> } >> >> assert(!"Unexpected format"); >> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> index 18955eb..92bc0bb 100644 >> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp >> @@ -1940,6 +1940,10 @@ >> NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) >> bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); >>} >> } >> + >> + if (format->bgra) { >> + std::swap(typedDst[0], typedDst[2]); >> + } >> } >> >> void >> diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> index 5d40624..49bf860 100644 >> --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h >> @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE >> SOFTWARE. >> #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d >> #define GK104_IMAGE_FORMAT_RG32_SINT 0x000e >> #define GK104_IMAGE_FORMAT_RG32_UINT 0x000f >> +#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x0011 >> #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x0013 >> #define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x0015 >> #define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x0018 >> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> b/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> index 34d32d1..07c4419 100644 >> --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c >> @@ -50,6 +50,7 @@ >> #define U_IB PIPE_BIND_BLENDABLE | U_IR >> #define U_TD PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB >> #define U_TZ PIPE_BIND_DEPTH_STENCIL | U_T >> +#define U_ID U_TD | U_I >> #if NOUVEAU_DRIVER == 0xc0
Re: [Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
Works fine on Fermi, but still need to test on Kepler1. On 07/16/2016 09:09 PM, Ilia Mirkin wrote: This is useful for pbo downloads, which are now accelerated with images. BGRA8 is a moderately common format to do that in. Signed-off-by: Ilia Mirkin --- This needs testing on SM20 and SM30. I've tested it on SM35 and bin/pbo-readpixels-small -auto worked fine. (Didn't until I properly fixed the various items.) src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index 2caebe8..179ad0b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] = { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, + + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, }; void diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h index 41804b6..6d2ee8b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h @@ -412,6 +412,8 @@ enum ImgFormat FMT_R16_SNORM, FMT_R8_SNORM, + FMT_BGRA8, + IMG_FORMAT_COUNT, }; @@ -967,6 +969,7 @@ public: uint8_t components; uint8_t bits[4]; ImgType type; + bool bgra; }; static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 61eb7f5..7dff08a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format) FMT_CASE(R8G8_SNORM, RG8_SNORM); FMT_CASE(R16_SNORM, R16_SNORM); FMT_CASE(R8_SNORM, R8_SNORM); + + FMT_CASE(B8G8R8A8_UNORM, BGRA8); } assert(!"Unexpected format"); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 18955eb..92bc0bb 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); } } + + if (format->bgra) { + std::swap(typedDst[0], typedDst[2]); + } } void diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h index 5d40624..49bf860 100644 --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d #define GK104_IMAGE_FORMAT_RG32_SINT 0x000e #define GK104_IMAGE_FORMAT_RG32_UINT 0x000f +#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x0011 #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x0013 #define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x0015 #define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x0018 diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c index 34d32d1..07c4419 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c @@ -50,6 +50,7 @@ #define U_IB PIPE_BIND_BLENDABLE | U_IR #define U_TD PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB #define U_TZ PIPE_BIND_DEPTH_STENCIL | U_T +#define U_ID U_TD | U_I #if NOUVEAU_DRIVER == 0xc0 # define U_TC U_TB # define U_IC U_IB @@ -122,7 +123,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] = const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] = #endif { - C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, TD), + C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, ID), F3(A, B8G8R8X8_UNORM, BGRX8_UNORM, B, G, R, xx, UNORM, A8B8G8R8, TD), C4(A, B8G8R8A
[Mesa-dev] [PATCH] nvc0: add support for BGRA8 images
This is useful for pbo downloads, which are now accelerated with images. BGRA8 is a moderately common format to do that in. Signed-off-by: Ilia Mirkin --- This needs testing on SM20 and SM30. I've tested it on SM35 and bin/pbo-readpixels-small -auto worked fine. (Didn't until I properly fixed the various items.) src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir.h | 3 +++ src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 ++ src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 src/gallium/drivers/nouveau/nv50/g80_defs.xml.h | 1 + src/gallium/drivers/nouveau/nv50/nv50_formats.c | 3 ++- src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index 2caebe8..179ad0b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1012,6 +1012,8 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] = { "RG8_SNORM",2, { 8, 8, 0, 0 }, SNORM }, { "R16_SNORM",1, { 16, 0, 0, 0 }, SNORM }, { "R8_SNORM", 1, { 8, 0, 0, 0 }, SNORM }, + + { "BGRA8",4, { 8, 8, 8, 8 }, UNORM, true }, }; void diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h index 41804b6..6d2ee8b 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h @@ -412,6 +412,8 @@ enum ImgFormat FMT_R16_SNORM, FMT_R8_SNORM, + FMT_BGRA8, + IMG_FORMAT_COUNT, }; @@ -967,6 +969,7 @@ public: uint8_t components; uint8_t bits[4]; ImgType type; + bool bgra; }; static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 61eb7f5..7dff08a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -508,6 +508,8 @@ static nv50_ir::ImgFormat translateImgFormat(uint format) FMT_CASE(R8G8_SNORM, RG8_SNORM); FMT_CASE(R16_SNORM, R16_SNORM); FMT_CASE(R8_SNORM, R8_SNORM); + + FMT_CASE(B8G8R8A8_UNORM, BGRA8); } assert(!"Unexpected format"); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 18955eb..92bc0bb 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -1940,6 +1940,10 @@ NVC0LoweringPass::convertSurfaceFormat(TexInstruction *su) bld.mkCvt(OP_CVT, TYPE_F32, typedDst[i], TYPE_F16, typedDst[i]); } } + + if (format->bgra) { + std::swap(typedDst[0], typedDst[2]); + } } void diff --git a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h index 5d40624..49bf860 100644 --- a/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h +++ b/src/gallium/drivers/nouveau/nv50/g80_defs.xml.h @@ -177,6 +177,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define GK104_IMAGE_FORMAT_RG32_FLOAT 0x000d #define GK104_IMAGE_FORMAT_RG32_SINT 0x000e #define GK104_IMAGE_FORMAT_RG32_UINT 0x000f +#define GK104_IMAGE_FORMAT_BGRA8_UNORM 0x0011 #define GK104_IMAGE_FORMAT_RGB10_A2_UNORM 0x0013 #define GK104_IMAGE_FORMAT_RGB10_A2_UINT 0x0015 #define GK104_IMAGE_FORMAT_RGBA8_UNORM 0x0018 diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c index 34d32d1..07c4419 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c @@ -50,6 +50,7 @@ #define U_IB PIPE_BIND_BLENDABLE | U_IR #define U_TD PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB #define U_TZ PIPE_BIND_DEPTH_STENCIL | U_T +#define U_ID U_TD | U_I #if NOUVEAU_DRIVER == 0xc0 # define U_TC U_TB # define U_IC U_IB @@ -122,7 +123,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] = const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] = #endif { - C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, TD), + C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, ID), F3(A, B8G8R8X8_UNORM, BGRX8_UNORM, B, G, R, xx, UNORM, A8B8G8R8, TD), C4(A, B8G8R8A8_SRGB, BGRA8_SRGB, B, G, R, A, UNORM, A8B8G8R8, TD), F3(A, B8G8R8X8_SRGB, BGRX8_SRGB, B, G,