VirtualBox

Ignore:
Timestamp:
Jan 21, 2010 9:26:23 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56794
Message:

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c

    r23571 r25949  
    265265        if (name_loc != -1) {
    266266            DWORD mapped_unit = tex_unit_map[i];
    267             if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < GL_LIMITS(fragment_samplers))
     267            if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < gl_info->limits.fragment_samplers)
    268268            {
    269269                TRACE("Loading %s for texture %d\n", sampler_name, mapped_unit);
     
    290290        if (name_loc != -1) {
    291291            DWORD mapped_unit = tex_unit_map[MAX_FRAGMENT_SAMPLERS + i];
    292             if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < GL_LIMITS(combined_samplers))
     292            if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < gl_info->limits.combined_samplers)
    293293            {
    294294                TRACE("Loading %s for texture %d\n", sampler_name, mapped_unit);
     
    641641        char usePixelShader, char useVertexShader)
    642642{
    643     IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.wineD3DDevice;
     643    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
    644644    const struct wined3d_gl_info *gl_info = context->gl_info;
    645645    IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
     
    805805static unsigned int vec4_varyings(DWORD shader_major, const struct wined3d_gl_info *gl_info)
    806806{
    807     unsigned int ret = GL_LIMITS(glsl_varyings) / 4;
     807    unsigned int ret = gl_info->limits.glsl_varyings / 4;
    808808    /* 4.0 shaders do not write clip coords because d3d10 does not support user clipplanes */
    809809    if(shader_major > 3) return ret;
     
    853853         * 2) The shader uses indirect addressing, less constants than supported, but uses a constant index > #supported consts
    854854         */
    855         if(pshader) {
    856             /* No indirect addressing here */
    857             max_constantsF = GL_LIMITS(pshader_constantsF);
    858         } else {
     855        if (pshader)
     856        {
     857            /* No indirect addressing here. */
     858            max_constantsF = gl_info->limits.glsl_ps_float_constants;
     859        }
     860        else
     861        {
    859862            if(This->baseShader.reg_maps.usesrelconstF) {
    860863                /* Subtract the other potential uniforms from the max available (bools, ints, and 1 row of projection matrix).
     
    863866                 * (Unfortunately the Nvidia driver doesn't store 128 and -128 in one float).
    864867                 *
    865                  * Writing gl_ClipPos requires one uniform for each clipplane as well.
     868                 * Writing gl_ClipVertex requires one uniform for each clipplane as well.
    866869                 */
    867                 max_constantsF = GL_LIMITS(vshader_constantsF) - 3 - GL_LIMITS(clipplanes);
     870                max_constantsF = gl_info->limits.glsl_vs_float_constants - 3;
     871                if(ctx_priv->cur_vs_args->clip_enabled)
     872                {
     873                    max_constantsF -= gl_info->limits.clipplanes;
     874                }
    868875                max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants);
    869876                /* Strictly speaking a bool only uses one scalar, but the nvidia(Linux) compiler doesn't pack them properly,
     
    873880                max_constantsF -= count_bits(This->baseShader.reg_maps.boolean_constants);
    874881                /* Set by driver quirks in directx.c */
    875                 max_constantsF -= GLINFO_LOCATION.reserved_glsl_constants;
    876             } else {
    877                 max_constantsF = GL_LIMITS(vshader_constantsF);
     882                max_constantsF -= gl_info->reserved_glsl_constants;
     883            }
     884            else
     885            {
     886                max_constantsF = gl_info->limits.glsl_vs_float_constants;
    878887            }
    879888        }
     
    933942                    srgb_cmp);
    934943        }
    935         if(reg_maps->vpos || reg_maps->usesdsy) {
    936             if(This->baseShader.limits.constant_float + extra_constants_needed + 1 < GL_LIMITS(pshader_constantsF)) {
     944        if (reg_maps->vpos || reg_maps->usesdsy)
     945        {
     946            if (This->baseShader.limits.constant_float + extra_constants_needed
     947                    + 1 < gl_info->limits.glsl_ps_float_constants)
     948            {
    937949                shader_addline(buffer, "uniform vec4 ycorrection;\n");
    938950                ((IWineD3DPixelShaderImpl *) This)->vpos_uniform = 1;
     
    13191331
    13201332        case WINED3DSPR_COLOROUT:
    1321             if (reg->idx >= GL_LIMITS(buffers))
    1322                 WARN("Write to render target %u, only %d supported\n", reg->idx, GL_LIMITS(buffers));
     1333            if (reg->idx >= gl_info->limits.buffers)
     1334                WARN("Write to render target %u, only %d supported.\n", reg->idx, gl_info->limits.buffers);
    13231335
    13241336            sprintf(register_name, "gl_FragData[%u]", reg->idx);
     
    19671979        case WINED3DSIH_NRM: instruction = "normalize"; break;
    19681980        case WINED3DSIH_EXP: instruction = "exp2"; break;
    1969         case WINED3DSIH_SGN: instruction = "sign"; break;
    19701981        case WINED3DSIH_DSX: instruction = "dFdx"; break;
    19711982        case WINED3DSIH_DSY: instruction = "ycorrection.y * dFdy"; break;
     
    24602471}
    24612472
     2473/* sgn in vs_2_0 has 2 extra parameters(registers for temporary storage) which we don't use
     2474 * here. But those extra parameters require a dedicated function for sgn, since map2gl would
     2475 * generate invalid code
     2476 */
     2477static void shader_glsl_sgn(const struct wined3d_shader_instruction *ins)
     2478{
     2479    glsl_src_param_t src0_param;
     2480    DWORD write_mask;
     2481
     2482    write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
     2483    shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src0_param);
     2484
     2485    shader_addline(ins->ctx->buffer, "sign(%s));\n", src0_param.param_str);
     2486}
     2487
    24622488/** Process the WINED3DSIO_LOOP instruction in GLSL:
    24632489 * Start a for() loop where src1.y is the initial value of aL,
     
    27552781    DWORD swizzle = ins->src[1].swizzle;
    27562782
    2757     if(!GL_SUPPORT(ARB_SHADER_TEXTURE_LOD)) {
     2783    if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD])
     2784    {
    27582785        FIXME("texldd used, but not supported by hardware. Falling back to regular tex\n");
    27592786        return shader_glsl_tex(ins);
     
    35723599         */
    35733600        device = (IWineD3DDeviceImpl *) vs->baseShader.device;
    3574         if (((GLINFO_LOCATION).quirks & WINED3D_QUIRK_SET_TEXCOORD_W)
     3601        if ((gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W)
    35753602                && ps_major == 0 && vs_major > 0 && !device->frag_pipe->ffp_proj_control)
    35763603        {
     
    35903617
    35913618        /* The vertex shader writes to its own varyings, the pixel shader needs them in the builtin ones */
    3592         output_signature = vs->output_signature;
     3619        output_signature = vs->baseShader.output_signature;
    35933620
    35943621        shader_addline(buffer, "void order_ps_input(in vec4 OUT[%u]) {\n", MAX_REG_OUTPUT);
     
    36193646                if (semantic_idx < 8)
    36203647                {
    3621                     if (!((GLINFO_LOCATION).quirks & WINED3D_QUIRK_SET_TEXCOORD_W) || ps_major > 0)
     3648                    if (!(gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W) || ps_major > 0)
    36223649                        write_mask |= WINED3DSP_WRITEMASK_3;
    36233650
     
    36423669        WORD map = vs->baseShader.reg_maps.output_registers;
    36433670
    3644         output_signature = vs->output_signature;
     3671        output_signature = vs->baseShader.output_signature;
    36453672
    36463673        /* This one is tricky: a 3.0 pixel shader reads from a 3.0 vertex shader */
     
    36673694
    36683695        /* Then, fix the pixel shader input */
    3669         handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->input_signature,
     3696        handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->baseShader.input_signature,
    36703697                &ps->baseShader.reg_maps, output_signature, &vs->baseShader.reg_maps);
    36713698
     
    36783705         * read gl_TexCoord and gl_ColorX, otherwise we'll run out of varyings
    36793706         */
    3680         handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->input_signature,
     3707        handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->baseShader.input_signature,
    36813708                &ps->baseShader.reg_maps, NULL, NULL);
    36823709        shader_addline(buffer, "}\n");
     
    37323759    shader_addline(buffer, "#version 120\n");
    37333760
    3734     if(GL_SUPPORT(ARB_SHADER_TEXTURE_LOD) && reg_maps->usestexldd) {
     3761    if (gl_info->supported[ARB_SHADER_TEXTURE_LOD] && reg_maps->usestexldd)
     3762    {
    37353763        shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n");
    37363764    }
    3737     if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) {
     3765    if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
     3766    {
    37383767        /* The spec says that it doesn't have to be explicitly enabled, but the nvidia
    37393768         * drivers write a warning if we don't do so
     
    37483777    if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader)
    37493778    {
    3750         shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer, This->input_signature, reg_maps, args->vp_mode);
     3779        shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer,
     3780                This->baseShader.input_signature, reg_maps, args->vp_mode);
    37513781    }
    37523782
     
    38063836    GL_EXTCALL(glShaderSourceARB(shader_obj, 1, (const char**)&buffer->buffer, NULL));
    38073837    GL_EXTCALL(glCompileShaderARB(shader_obj));
    3808     print_glsl_info_log(&GLINFO_LOCATION, shader_obj);
     3838    print_glsl_info_log(gl_info, shader_obj);
    38093839
    38103840    /* Store the shader object */
     
    38603890    shader_addline(buffer, "gl_Position.y = gl_Position.y * posFixup.y;\n");
    38613891    shader_addline(buffer, "gl_Position.xy += posFixup.zw * gl_Position.ww;\n");
    3862     shader_addline(buffer, "gl_ClipVertex = gl_Position;\n");
     3892    if(args->clip_enabled) {
     3893        shader_addline(buffer, "gl_ClipVertex = gl_Position;\n");
     3894    }
    38633895
    38643896    /* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c
     
    38753907    GL_EXTCALL(glShaderSourceARB(shader_obj, 1, (const char**)&buffer->buffer, NULL));
    38763908    GL_EXTCALL(glCompileShaderARB(shader_obj));
    3877     print_glsl_info_log(&GLINFO_LOCATION, shader_obj);
     3909    print_glsl_info_log(gl_info, shader_obj);
    38783910
    38793911    return shader_obj;
     
    39523984                                 const DWORD use_map) {
    39533985    if((stored->swizzle_map & use_map) != new->swizzle_map) return FALSE;
     3986    if((stored->clip_enabled) != new->clip_enabled) return FALSE;
    39543987    return stored->fog_src == new->fog_src;
    39553988}
     
    41274160    TRACE("Linking GLSL shader program %u\n", programId);
    41284161    GL_EXTCALL(glLinkProgramARB(programId));
    4129     print_glsl_info_log(&GLINFO_LOCATION, programId);
    4130 
    4131     entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * GL_LIMITS(vshader_constantsF));
    4132     for (i = 0; i < GL_LIMITS(vshader_constantsF); ++i) {
     4162    print_glsl_info_log(gl_info, programId);
     4163
     4164    entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0,
     4165            sizeof(GLhandleARB) * gl_info->limits.glsl_vs_float_constants);
     4166    for (i = 0; i < gl_info->limits.glsl_vs_float_constants; ++i)
     4167    {
    41334168        snprintf(glsl_name, sizeof(glsl_name), "VC[%i]", i);
    41344169        entry->vuniformF_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name));
    41354170    }
    4136     for (i = 0; i < MAX_CONST_I; ++i) {
     4171    for (i = 0; i < MAX_CONST_I; ++i)
     4172    {
    41374173        snprintf(glsl_name, sizeof(glsl_name), "VI[%i]", i);
    41384174        entry->vuniformI_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name));
    41394175    }
    4140     entry->puniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * GL_LIMITS(pshader_constantsF));
    4141     for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i) {
     4176    entry->puniformF_locations = HeapAlloc(GetProcessHeap(), 0,
     4177            sizeof(GLhandleARB) * gl_info->limits.glsl_ps_float_constants);
     4178    for (i = 0; i < gl_info->limits.glsl_ps_float_constants; ++i)
     4179    {
    41424180        snprintf(glsl_name, sizeof(glsl_name), "PC[%i]", i);
    41434181        entry->puniformF_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name));
    41444182    }
    4145     for (i = 0; i < MAX_CONST_I; ++i) {
     4183    for (i = 0; i < MAX_CONST_I; ++i)
     4184    {
    41464185        snprintf(glsl_name, sizeof(glsl_name), "PI[%i]", i);
    41474186        entry->puniformI_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name));
     
    42754314    GL_EXTCALL(glLinkProgramARB(program_id));
    42764315
    4277     print_glsl_info_log(&GLINFO_LOCATION, program_id);
     4316    print_glsl_info_log(gl_info, program_id);
    42784317
    42794318    /* Once linked we can mark the shaders for deletion. They will be deleted once the program
     
    42884327static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
    42894328{
    4290     IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.wineD3DDevice;
     4329    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
    42914330    const struct wined3d_gl_info *gl_info = context->gl_info;
    42924331    struct shader_glsl_priv *priv = device->shader_priv;
     
    43014340    current_vertex_color_clamp = priv->glsl_program ? priv->glsl_program->vertex_color_clamp : GL_FIXED_ONLY_ARB;
    43024341
    4303     if (old_vertex_color_clamp != current_vertex_color_clamp) {
    4304         if (GL_SUPPORT(ARB_COLOR_BUFFER_FLOAT)) {
     4342    if (old_vertex_color_clamp != current_vertex_color_clamp)
     4343    {
     4344        if (gl_info->supported[ARB_COLOR_BUFFER_FLOAT])
     4345        {
    43054346            GL_EXTCALL(glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, current_vertex_color_clamp));
    43064347            checkGLcall("glClampColorARB");
    4307         } else {
     4348        }
     4349        else
     4350        {
    43084351            FIXME("vertex color clamp needs to be changed, but extension not supported.\n");
    43094352        }
     
    43614404    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
    43624405    struct shader_glsl_priv *priv = device->shader_priv;
    4363     const struct wined3d_context *context;
    43644406    const struct wined3d_gl_info *gl_info;
    43654407    IWineD3DPixelShaderImpl *ps = NULL;
    43664408    IWineD3DVertexShaderImpl *vs = NULL;
     4409    struct wined3d_context *context;
    43674410
    43684411    /* Note: Do not use QueryInterface here to find out which shader type this is because this code
     
    43824425        }
    43834426
    4384         context = ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
     4427        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    43854428        gl_info = context->gl_info;
    43864429
     
    44024445        }
    44034446
    4404         context = ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
     4447        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    44054448        gl_info = context->gl_info;
    44064449
     
    44614504        vs->baseShader.backend_data = NULL;
    44624505    }
     4506
     4507    context_release(context);
    44634508}
    44644509
     
    45184563    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
    45194564    struct shader_glsl_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_glsl_priv));
    4520     SIZE_T stack_size = wined3d_log2i(max(GL_LIMITS(vshader_constantsF), GL_LIMITS(pshader_constantsF))) + 1;
     4565    SIZE_T stack_size = wined3d_log2i(max(gl_info->limits.glsl_vs_float_constants,
     4566            gl_info->limits.glsl_ps_float_constants)) + 1;
    45214567
    45224568    if (!shader_buffer_init(&priv->shader_buffer))
     
    45334579    }
    45344580
    4535     if (!constant_heap_init(&priv->vconst_heap, GL_LIMITS(vshader_constantsF)))
     4581    if (!constant_heap_init(&priv->vconst_heap, gl_info->limits.glsl_vs_float_constants))
    45364582    {
    45374583        ERR("Failed to initialize vertex shader constant heap\n");
     
    45394585    }
    45404586
    4541     if (!constant_heap_init(&priv->pconst_heap, GL_LIMITS(pshader_constantsF)))
     4587    if (!constant_heap_init(&priv->pconst_heap, gl_info->limits.glsl_ps_float_constants))
    45424588    {
    45434589        ERR("Failed to initialize pixel shader constant heap\n");
     
    45864632    constant_heap_free(&priv->vconst_heap);
    45874633    HeapFree(GetProcessHeap(), 0, priv->stack);
     4634    shader_buffer_free(&priv->shader_buffer);
    45884635
    45894636    HeapFree(GetProcessHeap(), 0, This->shader_priv);
     
    46084655     */
    46094656    if ((gl_info->supported[NV_VERTEX_PROGRAM2] && !gl_info->supported[NV_VERTEX_PROGRAM3])
    4610             || gl_info->ps_arb_max_instructions <= 512)
     4657            || gl_info->limits.arb_ps_instructions <= 512)
    46114658        pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
    46124659    else
    46134660        pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
    46144661    TRACE_(d3d_caps)("Hardware vertex shader version %d.%d enabled (GLSL)\n", (pCaps->VertexShaderVersion >> 8) & 0xff, pCaps->VertexShaderVersion & 0xff);
    4615     pCaps->MaxVertexShaderConst = GL_LIMITS(vshader_constantsF);
     4662    pCaps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants;
    46164663
    46174664    /* Older DX9-class videocards (GeforceFX / Radeon >9500/X*00) only support pixel shader 2.0/2.0a/2.0b.
     
    46274674     */
    46284675    if ((gl_info->supported[NV_FRAGMENT_PROGRAM] && !gl_info->supported[NV_FRAGMENT_PROGRAM2])
    4629             || (gl_info->ps_arb_max_instructions <= 512))
     4676            || gl_info->limits.arb_ps_instructions <= 512)
    46304677        pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
    46314678    else
    46324679        pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
    46334680
    4634     pCaps->MaxPixelShaderConst = GL_LIMITS(pshader_constantsF);
     4681    pCaps->MaxPixelShaderConst = gl_info->limits.glsl_ps_float_constants;
    46354682
    46364683    /* FIXME: The following line is card dependent. -8.0 to 8.0 is the
     
    46844731    /* WINED3DSIH_CND           */ shader_glsl_cnd,
    46854732    /* WINED3DSIH_CRS           */ shader_glsl_cross,
     4733    /* WINED3DSIH_CUT           */ NULL,
    46864734    /* WINED3DSIH_DCL           */ NULL,
    46874735    /* WINED3DSIH_DEF           */ NULL,
     
    46954743    /* WINED3DSIH_DSY           */ shader_glsl_map2gl,
    46964744    /* WINED3DSIH_ELSE          */ shader_glsl_else,
     4745    /* WINED3DSIH_EMIT          */ NULL,
    46974746    /* WINED3DSIH_ENDIF         */ shader_glsl_end,
    46984747    /* WINED3DSIH_ENDLOOP       */ shader_glsl_end,
     
    47014750    /* WINED3DSIH_EXPP          */ shader_glsl_expp,
    47024751    /* WINED3DSIH_FRC           */ shader_glsl_map2gl,
     4752    /* WINED3DSIH_IADD          */ NULL,
    47034753    /* WINED3DSIH_IF            */ shader_glsl_if,
    47044754    /* WINED3DSIH_IFC           */ shader_glsl_ifc,
     4755    /* WINED3DSIH_IGE           */ NULL,
    47054756    /* WINED3DSIH_LABEL         */ shader_glsl_label,
    47064757    /* WINED3DSIH_LIT           */ shader_glsl_lit,
     
    47094760    /* WINED3DSIH_LOOP          */ shader_glsl_loop,
    47104761    /* WINED3DSIH_LRP           */ shader_glsl_lrp,
     4762    /* WINED3DSIH_LT            */ NULL,
    47114763    /* WINED3DSIH_M3x2          */ shader_glsl_mnxn,
    47124764    /* WINED3DSIH_M3x3          */ shader_glsl_mnxn,
     
    47304782    /* WINED3DSIH_SETP          */ NULL,
    47314783    /* WINED3DSIH_SGE           */ shader_glsl_compare,
    4732     /* WINED3DSIH_SGN           */ shader_glsl_map2gl,
     4784    /* WINED3DSIH_SGN           */ shader_glsl_sgn,
    47334785    /* WINED3DSIH_SINCOS        */ shader_glsl_sincos,
    47344786    /* WINED3DSIH_SLT           */ shader_glsl_compare,
Note: See TracChangeset for help on using the changeset viewer.

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