diff options
author | Jason Ekstrand <[email protected]> | 2018-06-05 11:13:40 -0700 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-06-08 10:19:55 -0700 |
commit | 47e22895ebb3e04fe58ffea69e200429d9ece4c1 (patch) | |
tree | 55dbf4573a5e4810985ae3c8a45f4eac9d1cae4e /src | |
parent | c2e44a35407658c5e358d67c5d70e6e87c528678 (diff) |
i965/screen: Refactor query_dma_buf_formats
This reworks it to work like query_dma_buf_modifiers and, in particular,
makes it more flexible so that we can disallow a non-static set of
formats.
Cc: [email protected]
Reviewed-by: Lionel Landwerlin <[email protected]>
(cherry picked from commit 8c4c5a09c076832328b6f926c043dbbf8708d0b8)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 7f3c82fab8d..a4b2c0b6984 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -1259,20 +1259,22 @@ static GLboolean intel_query_dma_buf_formats(__DRIscreen *screen, int max, int *formats, int *count) { - int i, j = 0; + int num_formats = 0, i; - if (max == 0) { - *count = ARRAY_SIZE(intel_image_formats) - 1; /* not SARGB */ - return true; - } - - for (i = 0; i < (ARRAY_SIZE(intel_image_formats)) && j < max; i++) { + for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) { if (intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SARGB8888) - continue; - formats[j++] = intel_image_formats[i].fourcc; + continue; + + num_formats++; + if (max == 0) + continue; + + formats[num_formats - 1] = intel_image_formats[i].fourcc; + if (num_formats >= max) + break; } - *count = j; + *count = num_formats; return true; } |