summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-06-05 11:13:40 -0700
committerJason Ekstrand <[email protected]>2018-06-07 11:23:34 -0700
commiteeae4851494c16d2a6591550bfa6ef77d887ebe3 (patch)
tree71a1f9f6388254866e3ada901d51c5a9c4d07948 /src/mesa/drivers
parent3b54dd87f707a0fa40a1555bee64aeb06a381c27 (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]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 935711106c0..2c783591202 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1266,22 +1266,23 @@ 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) {
- /* Note, sRGB formats not included. */
- *count = ARRAY_SIZE(intel_image_formats) - 2;
- return true;
- }
+ for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
+ if (intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SARGB8888 ||
+ intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SABGR8888)
+ continue;
- for (i = 0; i < (ARRAY_SIZE(intel_image_formats)) && j < max; i++) {
- if (intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SARGB8888 ||
- intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SABGR8888)
- continue;
- formats[j++] = intel_image_formats[i].fourcc;
+ 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;
}