VirtualBox

Ignore:
Timestamp:
Mar 15, 2015 5:15:57 PM (10 years ago)
Author:
vboxsync
Message:

VMSVGA3d: Applied patches from trivirt that among other things makes Chrome work on OpenGL hosts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/shaderlib/glsl_shader.c

    r53740 r54765  
    13181318    shader_addline(buffer, "vec4 tmp0;\n");
    13191319    shader_addline(buffer, "vec4 tmp1;\n");
     1320#ifdef VBOX_WITH_VMSVGA
     1321    shader_addline(buffer, "bool p0[4];\n");
     1322#endif
    13201323
    13211324    /* Local constants use a different name so they can be loaded once at shader link time
     
    16301633            break;
    16311634
     1635#ifdef VBOX_WITH_VMSVGA
     1636        case WINED3DSPR_PREDICATE:
     1637            sprintf(register_name, "p0");
     1638            break;
     1639#endif
     1640
    16321641        default:
    16331642            FIXME("Unhandled register name Type(%d)\n", reg->type);
     
    16591668    else
    16601669    {
     1670#ifdef VBOX_WITH_VMSVGA
     1671        if (param->reg.type == WINED3DSPR_PREDICATE)
     1672        {
     1673            *write_mask++ = '[';
     1674            if (mask & WINED3DSP_WRITEMASK_0) *write_mask++ = '0';
     1675            else
     1676            if (mask & WINED3DSP_WRITEMASK_1) *write_mask++ = '1';
     1677            else
     1678            if (mask & WINED3DSP_WRITEMASK_2) *write_mask++ = '2';
     1679            else
     1680            if (mask & WINED3DSP_WRITEMASK_3) *write_mask++ = '3';
     1681            *write_mask++ = ']';
     1682            *write_mask = '\0';
     1683        }
     1684        else
     1685#endif
    16611686        shader_glsl_write_mask_to_str(mask, write_mask);
    16621687    }
     
    21612186}
    21622187
     2188#ifdef VBOX_WITH_VMSVGA
     2189static void shader_glsl_mov_impl(const struct wined3d_shader_instruction *ins, int p0_idx);
     2190
    21632191/* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */
    21642192static void shader_glsl_mov(const struct wined3d_shader_instruction *ins)
     2193{
     2194    if (ins->predicate)
     2195    {
     2196        int i;
     2197        DWORD dst_mask = ins->dst[0].write_mask;
     2198        struct wined3d_shader_dst_param *dst = (struct wined3d_shader_dst_param *)&ins->dst[0];
     2199
     2200        for (i = 0; i < 4; i++)
     2201        {
     2202            if (dst_mask & RT_BIT(i))
     2203            {
     2204                dst->write_mask = RT_BIT(i);
     2205
     2206                shader_glsl_mov_impl(ins, i);
     2207            }
     2208        }
     2209        dst->write_mask = dst_mask;
     2210    }
     2211    else
     2212        shader_glsl_mov_impl(ins, 0);
     2213}
     2214
     2215/* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */
     2216static void shader_glsl_mov_impl(const struct wined3d_shader_instruction *ins, int p0_idx)
     2217
     2218#else
     2219/* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */
     2220static void shader_glsl_mov(const struct wined3d_shader_instruction *ins)
     2221#endif
    21652222{
    21662223    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     
    21682225    glsl_src_param_t src0_param;
    21692226    DWORD write_mask;
     2227
     2228#ifdef VBOX_WITH_VMSVGA
     2229    if (ins->predicate)
     2230    {
     2231        shader_addline(buffer, "if (p0[%d]) {\n", p0_idx);
     2232    }
     2233#endif
    21702234
    21712235    write_mask = shader_glsl_append_dst(buffer, ins);
     
    22122276        shader_addline(buffer, "%s);\n", src0_param.param_str);
    22132277    }
     2278#ifdef VBOX_WITH_VMSVGA
     2279    if (ins->predicate)
     2280    {
     2281        shader_addline(buffer, "}\n");
     2282    }
     2283#endif
    22142284}
    22152285
     
    24682538    }
    24692539}
     2540
     2541#ifdef VBOX_WITH_VMSVGA
     2542static void shader_glsl_setp(const struct wined3d_shader_instruction *ins)
     2543{
     2544    struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
     2545    glsl_src_param_t src_param1, src_param2;
     2546    DWORD write_mask;
     2547
     2548    int i;
     2549    DWORD dst_mask = ins->dst[0].write_mask;
     2550    struct wined3d_shader_dst_param dst = ins->dst[0];
     2551
     2552    /* Cycle through all source0 channels */
     2553    for (i=0; i<4; i++) {
     2554        if (dst_mask & RT_BIT(i))
     2555        {
     2556            write_mask = WINED3DSP_WRITEMASK_0 << i;
     2557            dst.write_mask = dst_mask & write_mask;
     2558
     2559            write_mask = shader_glsl_append_dst_ext(ins->ctx->buffer, ins, &dst);
     2560            Assert(write_mask);
     2561
     2562            shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src_param1);
     2563            shader_glsl_add_src_param(ins, &ins->src[1], write_mask, &src_param2);
     2564
     2565            shader_addline(buffer, "%s %s %s);\n",
     2566                    src_param1.param_str, shader_get_comp_op(ins->flags), src_param2.param_str);
     2567        }
     2568    }
     2569}
     2570#endif
    24702571
    24712572/** Process signed comparison opcodes in GLSL. */
     
    53145415    /* WINED3DSIH_RET           */ shader_glsl_ret,
    53155416    /* WINED3DSIH_RSQ           */ shader_glsl_rsq,
     5417#ifdef VBOX_WITH_VMSVGA
     5418    /* WINED3DSIH_SETP          */ shader_glsl_setp,
     5419#else
    53165420    /* WINED3DSIH_SETP          */ NULL,
     5421#endif
    53175422    /* WINED3DSIH_SGE           */ shader_glsl_compare,
    53185423    /* WINED3DSIH_SGN           */ shader_glsl_sgn,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette