Repository: libsdl-org/SDL
File: src/render/SDL_render.c (C)

Code before:
                    SDL_strstr(renderer, "LG100"))) {
                    has_lg100_or_lg110 = SDL_TRUE;
                }
            }
            SDL_GL_DeleteContext(context);
        }
        SDL_DestroyWindow(window);
    }
    return has_lg100_or_lg110;
}
#endif

SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
{
#ifndef SDL_RENDER_DISABLED
    SDL_Renderer *renderer = NULL;
    int n = SDL_GetNumRenderDrivers();
    SDL_bool batching = SDL_TRUE;
    const char *hint;
    int rc = -1;

#if defined(__ANDROID__)
    Android_ActivityMutex_Lock_Running();
#endif

/*CPU acceleration runs faster than integrated graphichs on Loongson at pressent.*/
#if defined(__linux__) && defined(__loongarch__)
    if (SDL_CheckIntegratedGraphics()) {
        SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
        flags = SDL_RENDERER_SOFTWARE;
    }
#endif

    if (!window) {
        SDL_InvalidParamError("window");
        goto error;
    }

    if (SDL_HasWindowSurface(window)) {
        SDL_SetError("Surface already associated with window");
        goto error;
    }

    if (SDL_GetRenderer(window)) {
        SDL_SetError("Renderer already associated with window");
        goto error;
    }

    renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
    if (!renderer) {
        SDL_OutOfMemory();

Review comment (suggestion):
```suggestion
/* CPU acceleration runs faster than integrated graphics on Loongson at present. */
```

Code after:

    if (SDL_GetRenderer(window)) {
        SDL_SetError("Renderer already associated with window");
        goto error;
    }

    renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
    if (!renderer) {
        SDL_OutOfMemory();
        goto error;
    }

    renderer->magic = &renderer_magic;

    hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
    if (hint && *hint) {
        if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) {
            flags |= SDL_RENDERER_PRESENTVSYNC;
        } else {
            flags &= ~SDL_RENDERER_PRESENTVSYNC;
        }
    }

    if (index < 0) {
        hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
        if (hint) {
            for (index = 0; index < n; ++index) {
                const SDL_RenderDriver *driver = render_drivers[index];

                if (SDL_strcasecmp(hint, driver->info.name) == 0) {
                    /* Create a new renderer instance */
                    rc = driver->CreateRenderer(renderer, window, flags);
                    if (rc == 0) {
                        batching = SDL_FALSE;
                    } else {
                        SDL_zerop(renderer);  /* make sure we don't leave function pointers from a previous CreateRenderer() in this struct. */
                        renderer->magic = &renderer_magic;
                    }
                    break;
                }
            }
        }

        if (rc == -1) {
            for (index = 0; index < n; ++index) {
                const SDL_RenderDriver *driver = render_drivers[index];

                if ((driver->info.flags & flags) == flags) {
                    /* Create a new renderer instance */
                    rc = driver->CreateRenderer(renderer, window, flags);
                    if (rc == 0) {