Skip to content

Commit

Permalink
drivers: pvr: Implement queryDmaBufFormats/queryDmaBufModifiers
Browse files Browse the repository at this point in the history
This is needed for various wayland compositors to tun

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
  • Loading branch information
freemangordon committed Aug 16, 2022
1 parent a5f39c3 commit 87c70d8
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/mesa/drivers/dri/pvr/pvrdrawable.c
Expand Up @@ -215,7 +215,7 @@ static bool PVRImageDrawableGetNativeInfo(PVRDRIDrawable *psPVRDrawable)
assert(psDRIScreen->image.loader != NULL);
assert(psDRIScreen->image.loader->getBuffers);

psFormat = PVRDRIIMGPixelFormatToImageFormat(
psFormat = PVRDRIIMGPixelFormatToImageFormat(psPVRDrawable->psPVRScreen,
psPVRDrawable->ePixelFormat);
if (!psFormat)
{
Expand Down
14 changes: 13 additions & 1 deletion src/mesa/drivers/dri/pvr/pvrdri.c
Expand Up @@ -280,6 +280,7 @@ static void PVRDRIScreenRemoveReference(PVRDRIScreen *psPVRScreen)

PVRDRIEGLFreeResources(psPVRScreen->psImpl);
PVRDRIDestroyFencesImpl(psPVRScreen->psImpl);
PVRDRIDestroyFormatInfo(psPVRScreen);
PVRDRIDestroyScreenImpl(psPVRScreen->psImpl);
PVRMutexDeinit(&psPVRScreen->sMutex);

Expand Down Expand Up @@ -385,11 +386,17 @@ static const __DRIconfig **PVRDRIInitScreen(__DRIscreen *psDRIScreen)
psDRIScreen->extensions = PVRDRIScreenExtensions();

psPVRScreen->psImpl = PVRDRICreateScreenImpl(psDRIScreen->fd);

if (psPVRScreen->psImpl == NULL)
{
goto ErrorScreenMutexDeinit;
}

if (!PVRDRIGetSupportedFormats(psPVRScreen))
{
goto ErrorScreenImplDeinit;
}

if (PVRDRIIsFirstScreen(psPVRScreen->psImpl))
{
psDRIScreen->max_gl_compat_version =
Expand All @@ -401,6 +408,7 @@ static const __DRIconfig **PVRDRIInitScreen(__DRIscreen *psDRIScreen)
PVRDRI_API_SUB_GL_CORE,
psPVRScreen->psImpl);
}

psDRIScreen->max_gl_es1_version =
PVRDRIAPIVersion(PVRDRI_API_GLES1,
PVRDRI_API_SUB_NONE,
Expand All @@ -412,16 +420,20 @@ static const __DRIconfig **PVRDRIInitScreen(__DRIscreen *psDRIScreen)
psPVRScreen->psImpl);

configs = PVRDRICreateConfigs();

if (configs == NULL)
{
__driUtilMessage("%s: No framebuffer configs", __func__);
goto ErrorScreenImplDeinit;
goto ErrorDestroyFormatInfo;
}

PVRScreenPrintExtensions(psDRIScreen);

return configs;

ErrorDestroyFormatInfo:
PVRDRIDestroyFormatInfo(psPVRScreen);

ErrorScreenImplDeinit:
PVRDRIDestroyScreenImpl(psPVRScreen->psImpl);

Expand Down
24 changes: 23 additions & 1 deletion src/mesa/drivers/dri/pvr/pvrdri.h 100644 → 100755
Expand Up @@ -85,6 +85,15 @@ typedef struct PVRDRIScreen_TAG
struct _glapi_table *psOGLES2Dispatch;

PVRDRIScreenImpl *psImpl;

/*
* Number of supported formats:
* 0 -> uninitialised or initialisation failed
*/
int iNumFormats;
/* Indicates which entries in the image format array are supported */
bool *pbHasFormat;

} PVRDRIScreen;

/** Our PVR related context data */
Expand Down Expand Up @@ -279,14 +288,27 @@ const PVRDRIImageFormat *PVRDRIFormatToImageFormat(PVRDRIScreen *psPVRScreen,
int iDRIFormat);
const PVRDRIImageFormat *PVRDRIFourCCToImageFormat(PVRDRIScreen *psPVRScreen,
int iDRIFourCC);
const PVRDRIImageFormat *PVRDRIIMGPixelFormatToImageFormat(IMG_PIXFMT eIMGPixelFormat);
const PVRDRIImageFormat *PVRDRIIMGPixelFormatToImageFormat(PVRDRIScreen *psPVRScreen,
IMG_PIXFMT eIMGPixelFormat);

IMG_YUV_COLORSPACE PVRDRIToIMGColourSpace(const PVRDRIImageFormat *psFormat,
enum __DRIYUVColorSpace eDRIColourSpace,
enum __DRISampleRange eDRISampleRange);
IMG_YUV_CHROMA_INTERP PVRDRIChromaSittingToIMGInterp(const PVRDRIImageFormat *psFormat,
enum __DRIChromaSiting eChromaSitting);

bool PVRDRIGetSupportedFormats(PVRDRIScreen *psPVRScreen);

GLboolean PVRDRIQueryDmaBufFormats(__DRIscreen *screen, int max,
int *formats, int *count);

GLboolean PVRDRIQueryDmaBufModifiers(__DRIscreen *screen, int fourcc,
int max, uint64_t *modifiers,
unsigned int *external_only,
int *count);

void PVRDRIDestroyFormatInfo(PVRDRIScreen *psPVRScreen);

/*************************************************************************/ /*!
pvrdrawable.c
*/ /**************************************************************************/
Expand Down
4 changes: 3 additions & 1 deletion src/mesa/drivers/dri/pvr/pvrext.c
Expand Up @@ -75,7 +75,7 @@
/* Maximum version numbers for each supported extension */
#define PVR_DRI_TEX_BUFFER_VERSION 2
#define PVR_DRI2_FLUSH_VERSION 4
#define PVR_DRI_IMAGE_VERSION 8
#define PVR_DRI_IMAGE_VERSION 15
#define PVR_DRI2_ROBUSTNESS_VERSION 1
#define PVR_DRI2_FENCE_VERSION 2

Expand Down Expand Up @@ -230,6 +230,8 @@ static __DRIimageExtension pvrDRIImage =
#if defined(EGL_IMG_cl_image)
.createImageFromBuffer = PVRDRICreateImageFromBuffer,
#endif
.queryDmaBufFormats = PVRDRIQueryDmaBufFormats,
.queryDmaBufModifiers = PVRDRIQueryDmaBufModifiers,
};

static __DRIrobustnessExtension pvrDRIRobustness =
Expand Down
3 changes: 2 additions & 1 deletion src/mesa/drivers/dri/pvr/pvrimage.c
Expand Up @@ -133,7 +133,8 @@ CreateImageSharedFromEGLImage(__DRIscreen *screen,

PVRDRIEGLImageGetAttribs(psEGLImage, &sAttribs);

psFormat = PVRDRIIMGPixelFormatToImageFormat(sAttribs.ePixFormat);
psFormat = PVRDRIIMGPixelFormatToImageFormat(psPVRScreen,
sAttribs.ePixFormat);
if (!psFormat)
{
return NULL;
Expand Down

0 comments on commit 87c70d8

Please sign in to comment.