Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6701fbe5 authored by Duane Sand's avatar Duane Sand Committed by Nikola Veljkovic
Browse files

[MIPS] Further opengl support for mips64 and mipsr6

Combines 4 patches by Dragoslav and Douglas:

Use t9 to hold the address of the called function.
Add support for gl binding.
Fix inline assembly code to be R6 compatible.
Fix some more inline assembly code to be R6 compatible.

Change-Id: I0b899813790b2ba4ca538bb21692014cc1933f66
parent 8f3ade0c
Loading
Loading
Loading
Loading
+37 −4
Original line number Diff line number Diff line
@@ -120,6 +120,38 @@ namespace android {
            : "cc"                                              \
            );

#elif defined(__mips64)

        #define API_ENTRY(_api) __attribute__((noinline)) _api

        #define CALL_GL_EXTENSION_API(_api, ...)                    \
            register unsigned int _t0 asm("t0");                    \
            register unsigned int _fn asm("t1");                    \
            register unsigned int _tls asm("v1");                   \
            asm volatile(                                           \
                ".set  push\n\t"                                    \
                ".set  noreorder\n\t"                               \
                "rdhwr %[tls], $29\n\t"                             \
                "ld    %[t0], %[OPENGL_API](%[tls])\n\t"            \
                "beqz  %[t0], 1f\n\t"                               \
                " move %[fn], $ra\n\t"                              \
                "ld    %[t0], %[API](%[t0])\n\t"                    \
                "beqz  %[t0], 1f\n\t"                               \
                " nop\n\t"                                          \
                "move  %[fn], %[t0]\n\t"                            \
                "1:\n\t"                                            \
                "jalr  $0, %[fn]\n\t"                               \
                " nop\n\t"                                          \
                ".set  pop\n\t"                                     \
                : [fn] "=c"(_fn),                                   \
                  [tls] "=&r"(_tls),                                \
                  [t0] "=&r"(_t0)                                   \
                : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4),          \
                  [API] "I"(__builtin_offsetof(gl_hooks_t,          \
                                          ext.extensions[_api]))    \
                :                                                   \
            );

#elif defined(__mips__)

        #define API_ENTRY(_api) __attribute__((noinline)) _api
@@ -131,15 +163,16 @@ namespace android {
            asm volatile(                                           \
                ".set  push\n\t"                                    \
                ".set  noreorder\n\t"                               \
                ".set  mips32r2\n\t"                                \
                "rdhwr %[tls], $29\n\t"                             \
                "lw    %[t0], %[OPENGL_API](%[tls])\n\t"            \
                "beqz  %[t0], 1f\n\t"                               \
                " move %[fn], $ra\n\t"                              \
                "lw    %[fn], %[API](%[t0])\n\t"                    \
                "movz  %[fn], $ra, %[fn]\n\t"                       \
                "lw    %[t0], %[API](%[t0])\n\t"                    \
                "beqz  %[t0], 1f\n\t"                               \
                " nop\n\t"                                          \
                "move  %[fn], %[t0]\n\t"                            \
                "1:\n\t"                                            \
                "j     %[fn]\n\t"                                   \
                "jalr  $0, %[fn]\n\t"                               \
                " nop\n\t"                                          \
                ".set  pop\n\t"                                     \
                : [fn] "=c"(_fn),                                   \
+39 −5
Original line number Diff line number Diff line
@@ -118,27 +118,61 @@ using namespace android;
            : "cc"                                                  \
            );

#elif defined(__mips64)

    #define API_ENTRY(_api) __attribute__((noinline)) _api

    #define CALL_GL_API(_api, ...)                            \
    register unsigned long _t0 asm("t0");                     \
    register unsigned long _fn asm("t9");                     \
    register unsigned long _tls asm("v1");                    \
    register unsigned long _v0 asm("v0");                     \
    asm volatile(                                             \
        ".set  push\n\t"                                      \
        ".set  noreorder\n\t"                                 \
        "rdhwr %[tls], $29\n\t"                               \
        "ld    %[t0], %[OPENGL_API](%[tls])\n\t"              \
        "beqz  %[t0], 1f\n\t"                                 \
        " move %[fn], $ra\n\t"                                \
        "ld    %[t0], %[API](%[t0])\n\t"                      \
        "beqz  %[t0], 1f\n\t"                                 \
        " nop\n\t"                                            \
        "move  %[fn], %[t0]\n\t"                              \
        "1:\n\t"                                              \
        "jalr  $0, %[fn]\n\t"                                 \
        " move %[v0], $0\n\t"                                 \
        ".set  pop\n\t"                                       \
        : [fn] "=c"(_fn),                                     \
          [tls] "=&r"(_tls),                                  \
          [t0] "=&r"(_t0),                                    \
          [v0] "=&r"(_v0)                                     \
        : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
          [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api))  \
        :                                                     \
        );

#elif defined(__mips__)

    #define API_ENTRY(_api) __attribute__((noinline)) _api

    #define CALL_GL_API(_api, ...)                               \
        register unsigned int _t0 asm("t0");                     \
        register unsigned int _fn asm("t1");                     \
        register unsigned int _fn asm("t9");                     \
        register unsigned int _tls asm("v1");                    \
        register unsigned int _v0 asm("v0");                     \
        asm volatile(                                            \
            ".set  push\n\t"                                     \
            ".set  noreorder\n\t"                                \
            ".set mips32r2\n\t"                                  \
            "rdhwr %[tls], $29\n\t"                              \
            "lw    %[t0], %[OPENGL_API](%[tls])\n\t"             \
            "beqz  %[t0], 1f\n\t"                                \
            " move %[fn],$ra\n\t"                                \
            "lw    %[fn], %[API](%[t0])\n\t"                     \
            "movz  %[fn], $ra, %[fn]\n\t"                        \
            "lw    %[t0], %[API](%[t0])\n\t"                     \
            "beqz  %[t0], 1f\n\t"                                \
            " nop\n\t"                                           \
            "move  %[fn], %[t0]\n\t"                             \
            "1:\n\t"                                             \
            "j     %[fn]\n\t"                                    \
            "jalr  $0, %[fn]\n\t"                                \
            " move %[v0], $0\n\t"                                \
            ".set  pop\n\t"                                      \
            : [fn] "=c"(_fn),                                    \
+39 −5
Original line number Diff line number Diff line
@@ -174,27 +174,61 @@ GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
            : "cc"                                                  \
            );

#elif defined(__mips64)

    #define API_ENTRY(_api) __attribute__((noinline)) _api

    #define CALL_GL_API(_api, ...)                            \
    register unsigned long _t0 asm("t0");                     \
    register unsigned long _fn asm("t9");                     \
    register unsigned long _tls asm("v1");                    \
    register unsigned long _v0 asm("v0");                     \
    asm volatile(                                             \
        ".set  push\n\t"                                      \
        ".set  noreorder\n\t"                                 \
        "rdhwr %[tls], $29\n\t"                               \
        "ld    %[t0], %[OPENGL_API](%[tls])\n\t"              \
        "beqz  %[t0], 1f\n\t"                                 \
        " move %[fn], $ra\n\t"                                \
        "ld    %[t0], %[API](%[t0])\n\t"                      \
        "beqz  %[t0], 1f\n\t"                                 \
        " nop\n\t"                                            \
        "move  %[fn], %[t0]\n\t"                              \
        "1:\n\t"                                              \
        "jalr  $0, %[fn]\n\t"                                 \
        " move %[v0], $0\n\t"                                 \
        ".set  pop\n\t"                                       \
        : [fn] "=c"(_fn),                                     \
          [tls] "=&r"(_tls),                                  \
          [t0] "=&r"(_t0),                                    \
          [v0] "=&r"(_v0)                                     \
        : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
          [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api))  \
        :                                                     \
        );

#elif defined(__mips__)

    #define API_ENTRY(_api) __attribute__((noinline)) _api

    #define CALL_GL_API(_api, ...)                               \
        register unsigned int _t0 asm("t0");                     \
        register unsigned int _fn asm("t1");                     \
        register unsigned int _fn asm("t9");                     \
        register unsigned int _tls asm("v1");                    \
        register unsigned int _v0 asm("v0");                     \
        asm volatile(                                            \
            ".set  push\n\t"                                     \
            ".set  noreorder\n\t"                                \
            ".set  mips32r2\n\t"                                 \
            "rdhwr %[tls], $29\n\t"                              \
            "lw    %[t0], %[OPENGL_API](%[tls])\n\t"             \
            "beqz  %[t0], 1f\n\t"                                \
            " move %[fn], $ra\n\t"                               \
            "lw    %[fn], %[API](%[t0])\n\t"                     \
            "movz  %[fn], $ra, %[fn]\n\t"                        \
            "lw    %[t0], %[API](%[t0])\n\t"                     \
            "beqz  %[t0], 1f\n\t"                                \
            " nop\n\t"                                           \
            "move  %[fn], %[t0]\n\t"                             \
            "1:\n\t"                                             \
            "j     %[fn]\n\t"                                    \
            "jalr  $0, %[fn]\n\t"                                \
            " move %[v0], $0\n\t"                                \
            ".set  pop\n\t"                                      \
            : [fn] "=c"(_fn),                                    \