mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +01:00
st/dri: simplify dri_get_egl_image by reusing dri2_format_table
this makes dri2_get_mapping_by_fourcc accessible from dri_helpers.h and does a direct lookup on the fourcc id to match the pipe format Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
7404833c2e
commit
c47af8b95f
3 changed files with 25 additions and 42 deletions
|
|
@ -65,21 +65,6 @@ dri2_buffer(__DRIbuffer * driBufferPriv)
|
||||||
return (struct dri2_buffer *) driBufferPriv;
|
return (struct dri2_buffer *) driBufferPriv;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dri2_format_mapping {
|
|
||||||
int dri_fourcc;
|
|
||||||
int dri_format; /* image format */
|
|
||||||
int dri_components;
|
|
||||||
enum pipe_format pipe_format;
|
|
||||||
int nplanes;
|
|
||||||
struct {
|
|
||||||
int buffer_index;
|
|
||||||
int width_shift;
|
|
||||||
int height_shift;
|
|
||||||
uint32_t dri_format; /* plane format */
|
|
||||||
int cpp;
|
|
||||||
} planes[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct dri2_format_mapping dri2_format_table[] = {
|
static const struct dri2_format_mapping dri2_format_table[] = {
|
||||||
{ __DRI_IMAGE_FOURCC_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010,
|
{ __DRI_IMAGE_FOURCC_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010,
|
||||||
__DRI_IMAGE_COMPONENTS_RGBA, PIPE_FORMAT_B10G10R10A2_UNORM, 1,
|
__DRI_IMAGE_COMPONENTS_RGBA, PIPE_FORMAT_B10G10R10A2_UNORM, 1,
|
||||||
|
|
@ -227,7 +212,7 @@ static const struct dri2_format_mapping dri2_format_table[] = {
|
||||||
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR8888, 4 } } }
|
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR8888, 4 } } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct dri2_format_mapping *
|
const struct dri2_format_mapping *
|
||||||
dri2_get_mapping_by_fourcc(int fourcc)
|
dri2_get_mapping_by_fourcc(int fourcc)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(dri2_format_table); i++) {
|
for (unsigned i = 0; i < ARRAY_SIZE(dri2_format_table); i++) {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,27 @@
|
||||||
#include "dri_context.h"
|
#include "dri_context.h"
|
||||||
#include "dri_screen.h"
|
#include "dri_screen.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct dri2_format_mapping {
|
||||||
|
int dri_fourcc;
|
||||||
|
int dri_format; /* image format */
|
||||||
|
int dri_components;
|
||||||
|
enum pipe_format pipe_format;
|
||||||
|
int nplanes;
|
||||||
|
struct {
|
||||||
|
int buffer_index;
|
||||||
|
int width_shift;
|
||||||
|
int height_shift;
|
||||||
|
uint32_t dri_format; /* plane format */
|
||||||
|
int cpp;
|
||||||
|
} planes[3];
|
||||||
|
};
|
||||||
|
|
||||||
extern const __DRI2fenceExtension dri2FenceExtension;
|
extern const __DRI2fenceExtension dri2FenceExtension;
|
||||||
|
|
||||||
|
const struct dri2_format_mapping *
|
||||||
|
dri2_get_mapping_by_fourcc(int fourcc);
|
||||||
|
|
||||||
__DRIimage *
|
__DRIimage *
|
||||||
dri2_lookup_egl_image(struct dri_screen *screen, void *handle);
|
dri2_lookup_egl_image(struct dri_screen *screen, void *handle);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "dri_screen.h"
|
#include "dri_screen.h"
|
||||||
#include "dri_context.h"
|
#include "dri_context.h"
|
||||||
|
#include "dri_helpers.h"
|
||||||
|
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
#include "pipe/p_screen.h"
|
#include "pipe/p_screen.h"
|
||||||
|
|
@ -423,6 +424,7 @@ dri_get_egl_image(struct st_manager *smapi,
|
||||||
{
|
{
|
||||||
struct dri_screen *screen = (struct dri_screen *)smapi;
|
struct dri_screen *screen = (struct dri_screen *)smapi;
|
||||||
__DRIimage *img = NULL;
|
__DRIimage *img = NULL;
|
||||||
|
const struct dri2_format_mapping *map;
|
||||||
|
|
||||||
if (screen->lookup_egl_image) {
|
if (screen->lookup_egl_image) {
|
||||||
img = screen->lookup_egl_image(screen, egl_image);
|
img = screen->lookup_egl_image(screen, egl_image);
|
||||||
|
|
@ -433,32 +435,9 @@ dri_get_egl_image(struct st_manager *smapi,
|
||||||
|
|
||||||
stimg->texture = NULL;
|
stimg->texture = NULL;
|
||||||
pipe_resource_reference(&stimg->texture, img->texture);
|
pipe_resource_reference(&stimg->texture, img->texture);
|
||||||
switch (img->dri_components) {
|
map = dri2_get_mapping_by_fourcc(img->dri_fourcc);
|
||||||
case __DRI_IMAGE_COMPONENTS_Y_U_V:
|
assert(map);
|
||||||
stimg->format = PIPE_FORMAT_IYUV;
|
stimg->format = map->pipe_format;
|
||||||
break;
|
|
||||||
case __DRI_IMAGE_COMPONENTS_Y_UV:
|
|
||||||
if (img->texture->format == PIPE_FORMAT_R8_UNORM)
|
|
||||||
stimg->format = PIPE_FORMAT_NV12;
|
|
||||||
else /* P0XX uses R16 for first texture */
|
|
||||||
stimg->format = PIPE_FORMAT_P016;
|
|
||||||
break;
|
|
||||||
case __DRI_IMAGE_COMPONENTS_AYUV:
|
|
||||||
stimg->format = PIPE_FORMAT_RGBA8888_UNORM;
|
|
||||||
break;
|
|
||||||
case __DRI_IMAGE_COMPONENTS_XYUV:
|
|
||||||
stimg->format = PIPE_FORMAT_RGBX8888_UNORM;
|
|
||||||
break;
|
|
||||||
case __DRI_IMAGE_COMPONENTS_Y_XUXV:
|
|
||||||
stimg->format = PIPE_FORMAT_YUYV;
|
|
||||||
break;
|
|
||||||
case __DRI_IMAGE_COMPONENTS_Y_UXVX:
|
|
||||||
stimg->format = PIPE_FORMAT_UYVY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
stimg->format = img->texture->format;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
stimg->level = img->level;
|
stimg->level = img->level;
|
||||||
stimg->layer = img->layer;
|
stimg->layer = img->layer;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue