Skip to content

Commit

Permalink
Fallback to using implicit framebuffer modifiers in all rendering mod…
Browse files Browse the repository at this point in the history
…es if drmModeAddFB2WithModifiers() fails
  • Loading branch information
ehopperdietzel committed Jul 10, 2024
1 parent 1bbde8c commit de106c6
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 25 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
SRM (0.6.3-1)

# Bug Fixes

* Fallback to using implicit framebuffer modifiers in all rendering modes if drmModeAddFB2WithModifiers() fails. Thanks to @RogerDavenport for reporting the issue.

-- Eduardo Hopperdietzel <ehopperdietzel@gmail.com> Wed, 10 Jul 2024 12:44:04 -0400


SRM (0.6.2-1)

# Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="SRM is released under the MIT license." />
</a>
<a href="https://github.com/CuarzoSoftware/SRM">
<img src="https://img.shields.io/badge/version-0.6.2-brightgreen" alt="Current SRM version." />
<img src="https://img.shields.io/badge/version-0.6.3-brightgreen" alt="Current SRM version." />
</a>
</p>

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.2
0.6.3
1 change: 1 addition & 0 deletions src/lib/private/SRMConnectorPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct SRMConnectorStruct
pthread_mutex_t propsMutex;

// Render specific
UInt8 allowModifiers;
struct SRMConnectorRenderInterface renderInterface;
void *renderData;
};
Expand Down
35 changes: 27 additions & 8 deletions src/lib/private/modes/SRMRenderModeCPU.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,16 @@ static UInt8 createEGLSurfaces(SRMConnector *connector)
fbCount = c;
}

while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->connectorGBMSurface) > 0)
do
{
eglSwapBuffers(connector->device->eglDisplay,
data->connectorEGLSurface);
bo = gbm_surface_lock_front_buffer(data->connectorGBMSurface);
srmListAppendData(bos, bo);

if (bo)
srmListAppendData(bos, bo);
}
while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->connectorGBMSurface) > 0 && bo);

data->buffersCount = srmListGetLength(bos);

Expand Down Expand Up @@ -388,13 +391,16 @@ static UInt8 createEGLSurfaces(SRMConnector *connector)
bos = srmListCreate();
bo = NULL;

while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->rendererGBMSurface) > 0)
do
{
eglSwapBuffers(connector->device->rendererDevice->eglDisplay,
data->rendererEGLSurface);
bo = gbm_surface_lock_front_buffer(data->rendererGBMSurface);
srmListAppendData(bos, bo);

if (bo)
srmListAppendData(bos, bo);
}
while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->rendererGBMSurface) > 0 && bo);

data->buffersCount = srmListGetLength(bos);

Expand Down Expand Up @@ -1033,9 +1039,13 @@ static void uninitialize(SRMConnector *connector)

static UInt8 initialize(SRMConnector *connector)
{
connector->allowModifiers = 1;

retry:

if (!eglBindAPI(EGL_OPENGL_ES_API))
{
SRMError("Failed to bind GLES API for device %s connector %d (ITSELF MODE).",
SRMError("Failed to bind GLES API for device %s connector %d (CPU MODE).",
connector->device->name,
connector->id);
goto fail;
Expand Down Expand Up @@ -1068,11 +1078,20 @@ static UInt8 initialize(SRMConnector *connector)
return 1;

fail:
SRMError("Failed to initialize render mode ITSELF for device %s connector %d.",
uninitialize(connector);

if (connector->allowModifiers)
{
SRMError("Failed to initialize device %s connector %d with explicit modifiers, falling back to implicit modifiers (CPU MODE).",
connector->device->name,
connector->id);
connector->allowModifiers = 0;
goto retry;
}

SRMError("Failed to initialize render mode CPU for device %s connector %d.",
connector->device->name,
connector->id);

uninitialize(connector);
return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions src/lib/private/modes/SRMRenderModeCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ Int32 srmRenderModeCommonUpdateMode(SRMConnector *connector, UInt32 fb)

void srmRenderModeCommonUninitialize(SRMConnector *connector)
{
if (connector->state == SRM_CONNECTOR_STATE_INITIALIZING)
return;

Int32 ret;

if (connector->device->clientCapAtomic)
Expand Down Expand Up @@ -1349,8 +1352,7 @@ void srmRenderModeCommonSearchNonLinearModifier(SRMConnector *connector)
connector->currentFormat.format = DRM_FORMAT_XRGB8888;
connector->currentFormat.modifier = DRM_FORMAT_MOD_LINEAR;

/* TODO: Check why this fails
if (!connector->device->capAddFb2Modifiers)
if (!connector->device->capAddFb2Modifiers || !connector->allowModifiers)
return;

SRMListForeach(it, connector->currentPrimaryPlane->inFormats)
Expand All @@ -1365,7 +1367,6 @@ void srmRenderModeCommonSearchNonLinearModifier(SRMConnector *connector)
break;
}
}
*/
}

void srmRenderModeCommonCreateConnectorGBMSurface(SRMConnector *connector, struct gbm_surface **surface)
Expand Down
11 changes: 7 additions & 4 deletions src/lib/private/modes/SRMRenderModeDumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ static UInt8 createEGLSurfaces(SRMConnector *connector)
fbCount = c;
}

while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->rendererGBMSurface) > 0)
do
{
eglSwapBuffers(connector->device->rendererDevice->eglDisplay,
data->rendererEGLSurface);
bo = gbm_surface_lock_front_buffer(data->rendererGBMSurface);
srmListAppendData(bos, bo);

if (bo)
srmListAppendData(bos, bo);
}
while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->rendererGBMSurface) > 0 && bo);

data->buffersCount = srmListGetLength(bos);

Expand Down Expand Up @@ -686,7 +689,7 @@ static UInt8 initialize(SRMConnector *connector)
{
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
SRMError("Failed to bind GLES API for device %s connector %d (ITSELF MODE).",
SRMError("Failed to bind GLES API for device %s connector %d (DUMB MODE).",
connector->device->name,
connector->id);
goto fail;
Expand Down Expand Up @@ -719,7 +722,7 @@ static UInt8 initialize(SRMConnector *connector)
return 1;

fail:
SRMError("Failed to initialize render mode ITSELF for device %s connector %d.",
SRMError("Failed to initialize render mode DUMB for device %s connector %d.",
connector->device->name,
connector->id);

Expand Down
22 changes: 19 additions & 3 deletions src/lib/private/modes/SRMRenderModeItself.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,17 @@ static UInt8 createEGLSurfaces(SRMConnector *connector)
fbCount = c;
}

while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->connectorGBMSurface) > 0)
do
{
eglSwapBuffers(connector->device->rendererDevice->eglDisplay,
data->connectorEGLSurface);

bo = gbm_surface_lock_front_buffer(data->connectorGBMSurface);
srmListAppendData(bos, bo);

if (bo)
srmListAppendData(bos, bo);
}
while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->connectorGBMSurface) > 0 && bo);

data->buffersCount = srmListGetLength(bos);

Expand Down Expand Up @@ -491,6 +494,9 @@ static void uninitialize(SRMConnector *connector)

static UInt8 initialize(SRMConnector *connector)
{
connector->allowModifiers = 1;

retry:
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
SRMError("Failed to bind GLES API for device %s connector %d (ITSELF MODE).",
Expand Down Expand Up @@ -523,11 +529,21 @@ static UInt8 initialize(SRMConnector *connector)
return 1;

fail:
uninitialize(connector);

if (connector->allowModifiers)
{
SRMError("Failed to initialize device %s connector %d with explicit modifiers, falling back to implicit modifiers (ITSELF MODE).",
connector->device->name,
connector->id);
connector->allowModifiers = 0;
goto retry;
}

SRMError("Failed to initialize render mode ITSELF for device %s connector %d.",
connector->device->name,
connector->id);

uninitialize(connector);
return 0;
}

Expand Down
30 changes: 25 additions & 5 deletions src/lib/private/modes/SRMRenderModePrime.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,16 @@ static UInt8 createEGLSurfaces(SRMConnector *connector)
fbCount = c;
}

while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->connectorGBMSurface) > 0)
do
{
eglSwapBuffers(connector->device->eglDisplay,
data->connectorEGLSurface);
bo = gbm_surface_lock_front_buffer(data->connectorGBMSurface);
srmListAppendData(bos, bo);

if (bo)
srmListAppendData(bos, bo);
}
while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->connectorGBMSurface) > 0 && bo);

data->buffersCount = srmListGetLength(bos);

Expand Down Expand Up @@ -369,13 +372,16 @@ static UInt8 createEGLSurfaces(SRMConnector *connector)
bos = srmListCreate();
bo = NULL;

while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->rendererGBMSurface) > 0)
do
{
eglSwapBuffers(connector->device->rendererDevice->eglDisplay,
data->rendererEGLSurface);
bo = gbm_surface_lock_front_buffer(data->rendererGBMSurface);
srmListAppendData(bos, bo);

if (bo)
srmListAppendData(bos, bo);
}
while (srmListGetLength(bos) < fbCount && gbm_surface_has_free_buffers(data->rendererGBMSurface) > 0 && bo);

data->buffersCount = srmListGetLength(bos);

Expand Down Expand Up @@ -801,6 +807,9 @@ static void uninitialize(SRMConnector *connector)

static UInt8 initialize(SRMConnector *connector)
{
connector->allowModifiers = 1;

retry:
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
SRMError("Failed to bind GLES API for device %s connector %d (ITSELF MODE).",
Expand Down Expand Up @@ -836,11 +845,22 @@ static UInt8 initialize(SRMConnector *connector)
return 1;

fail:

uninitialize(connector);

if (connector->allowModifiers)
{
SRMError("Failed to initialize device %s connector %d with explicit modifiers, falling back to implicit modifiers (PRIME MODE).",
connector->device->name,
connector->id);
connector->allowModifiers = 0;
goto retry;
}

SRMError("Failed to initialize render mode PRIME for device %s connector %d.",
connector->device->name,
connector->id);

uninitialize(connector);
return 0;
}

Expand Down

0 comments on commit de106c6

Please sign in to comment.