ac: do not crash when the buffer data format is invalid
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 29 Jul 2019 10:03:46 +0000 (12:03 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 29 Jul 2019 11:19:32 +0000 (13:19 +0200)
This might happen when a pipeline doesn't define the vertex input
state, so the buffer data format is 0 (aka INVALID).

This fixes crashes when compiling some shaders on GFX10.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_llvm_build.c

index 250bfc5229ec55e0560eacc6f4462504a7af65a1..278f889343211750009fb278ab95b06dbdea4951 100644 (file)
@@ -1508,6 +1508,7 @@ ac_get_tbuffer_format(struct ac_llvm_context *ctx,
                unsigned format;
                switch (dfmt) {
                default: unreachable("bad dfmt");
+               case V_008F0C_BUF_DATA_FORMAT_INVALID: format = V_008F0C_IMG_FORMAT_INVALID; break;
                case V_008F0C_BUF_DATA_FORMAT_8: format = V_008F0C_IMG_FORMAT_8_UINT; break;
                case V_008F0C_BUF_DATA_FORMAT_8_8: format = V_008F0C_IMG_FORMAT_8_8_UINT; break;
                case V_008F0C_BUF_DATA_FORMAT_8_8_8_8: format = V_008F0C_IMG_FORMAT_8_8_8_8_UINT; break;