Пример #1
0
static void
generate_130_uniforms(exec_list *instructions,
                      struct _mesa_glsl_parse_state *state)
{
    glsl_symbol_table *const symtab = state->symbols;

    add_builtin_constant(instructions, symtab, "gl_MaxClipDistances",
                         state->Const.MaxClipPlanes);
    add_builtin_constant(instructions, symtab, "gl_MaxVaryingComponents",
                         state->Const.MaxVaryingFloats);
}
Пример #2
0
static void
generate_ARB_draw_buffers_variables(exec_list *instructions,
                                    struct _mesa_glsl_parse_state *state,
                                    bool warn, _mesa_glsl_parser_targets target)
{
    /* gl_MaxDrawBuffers is available in all shader stages.
     */
    ir_variable *const mdb =
        add_builtin_constant(instructions, state->symbols, "gl_MaxDrawBuffers",
                             state->Const.MaxDrawBuffers);

    if (warn)
        mdb->warn_extension = "GL_ARB_draw_buffers";

    /* gl_FragData is only available in the fragment shader.
     * It is not present in GLSL 3.00 ES.
     */
    if (target == fragment_shader && !state->is_version(0, 300)) {
        const glsl_type *const vec4_array_type =
            glsl_type::get_array_instance(glsl_type::vec4_type,
                                          state->Const.MaxDrawBuffers);

        ir_variable *const fd =
            add_variable(instructions, state->symbols,
                         "gl_FragData", vec4_array_type,
                         ir_var_shader_out, FRAG_RESULT_DATA0);

        if (warn)
            fd->warn_extension = "GL_ARB_draw_buffers";
    }
}
Пример #3
0
static void
generate_300ES_uniforms(exec_list *instructions,
                        struct _mesa_glsl_parse_state *state)
{
    generate_common_ES_uniforms(instructions, state);

    glsl_symbol_table *const symtab = state->symbols;

    add_builtin_constant(instructions, symtab, "gl_MaxVertexOutputVectors",
                         state->Const.MaxVaryingFloats / 4);
    add_builtin_constant(instructions, symtab, "gl_MaxFragmentInputVectors",
                         state->Const.MaxVaryingFloats / 4);
    add_builtin_constant(instructions, symtab, "gl_MinProgramTexelOffset",
                         state->Const.MinProgramTexelOffset);
    add_builtin_constant(instructions, symtab, "gl_MaxProgramTexelOffset",
                         state->Const.MaxProgramTexelOffset);
}
Пример #4
0
static void
generate_100ES_uniforms(exec_list *instructions,
                        struct _mesa_glsl_parse_state *state)
{
    generate_common_ES_uniforms(instructions, state);

    glsl_symbol_table *const symtab = state->symbols;

    add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors",
                         state->Const.MaxVaryingFloats / 4);
}
Пример #5
0
/* Several constants in GLSL ES have different names than normal desktop GLSL.
 * Therefore, this function should only be called on the ES path.
 */
static void
generate_100ES_uniforms(exec_list *instructions,
                        struct _mesa_glsl_parse_state *state)
{
    glsl_symbol_table *const symtab = state->symbols;

    add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs",
                         state->Const.MaxVertexAttribs);
    add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformVectors",
                         state->Const.MaxVertexUniformComponents);
    add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors",
                         state->Const.MaxVaryingFloats / 4);
    add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits",
                         state->Const.MaxVertexTextureImageUnits);
    add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits",
                         state->Const.MaxCombinedTextureImageUnits);
    add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits",
                         state->Const.MaxTextureImageUnits);
    add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformVectors",
                         state->Const.MaxFragmentUniformComponents);

    add_uniform(instructions, symtab, "gl_DepthRange",
                state->symbols->get_type("gl_DepthRangeParameters"));
}
Пример #6
0
static void
generate_110_uniforms(exec_list *instructions,
                      struct _mesa_glsl_parse_state *state,
                      bool add_deprecated)
{
    glsl_symbol_table *const symtab = state->symbols;

    if (add_deprecated) {
        for (unsigned i = 0
                          ; i < Elements(builtin_110_deprecated_uniforms)
                ; i++) {
            add_builtin_variable(instructions, symtab,
                                 & builtin_110_deprecated_uniforms[i]);
        }
    }

    if (add_deprecated) {
        add_builtin_constant(instructions, symtab, "gl_MaxLights",
                             state->Const.MaxLights);
        add_builtin_constant(instructions, symtab, "gl_MaxClipPlanes",
                             state->Const.MaxClipPlanes);
        add_builtin_constant(instructions, symtab, "gl_MaxTextureUnits",
                             state->Const.MaxTextureUnits);
        add_builtin_constant(instructions, symtab, "gl_MaxTextureCoords",
                             state->Const.MaxTextureCoords);
    }
    add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs",
                         state->Const.MaxVertexAttribs);
    add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformComponents",
                         state->Const.MaxVertexUniformComponents);
    add_builtin_constant(instructions, symtab, "gl_MaxVaryingFloats",
                         state->Const.MaxVaryingFloats);
    add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits",
                         state->Const.MaxVertexTextureImageUnits);
    add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits",
                         state->Const.MaxCombinedTextureImageUnits);
    add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits",
                         state->Const.MaxTextureImageUnits);
    add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformComponents",
                         state->Const.MaxFragmentUniformComponents);

    if (add_deprecated) {
        const glsl_type *const mat4_array_type =
            glsl_type::get_array_instance(glsl_type::mat4_type,
                                          state->Const.MaxTextureCoords);

        add_uniform(instructions, symtab, "gl_TextureMatrix", mat4_array_type);
        add_uniform(instructions, symtab, "gl_TextureMatrixInverse", mat4_array_type);
        add_uniform(instructions, symtab, "gl_TextureMatrixTranspose", mat4_array_type);
        add_uniform(instructions, symtab, "gl_TextureMatrixInverseTranspose", mat4_array_type);
    }

    add_uniform(instructions, symtab, "gl_DepthRange",
                symtab->get_type("gl_DepthRangeParameters"));

    if (add_deprecated) {
        add_uniform(instructions, symtab, "gl_ClipPlane",
                    glsl_type::get_array_instance(glsl_type::vec4_type,
                            state->Const.MaxClipPlanes));
        add_uniform(instructions, symtab, "gl_Point",
                    symtab->get_type("gl_PointParameters"));

        const glsl_type *const material_parameters_type =
            symtab->get_type("gl_MaterialParameters");
        add_uniform(instructions, symtab, "gl_FrontMaterial", material_parameters_type);
        add_uniform(instructions, symtab, "gl_BackMaterial", material_parameters_type);

        const glsl_type *const light_source_array_type =
            glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), state->Const.MaxLights);

        add_uniform(instructions, symtab, "gl_LightSource", light_source_array_type);

        const glsl_type *const light_model_products_type =
            symtab->get_type("gl_LightModelProducts");
        add_uniform(instructions, symtab, "gl_FrontLightModelProduct",
                    light_model_products_type);
        add_uniform(instructions, symtab, "gl_BackLightModelProduct",
                    light_model_products_type);

        const glsl_type *const light_products_type =
            glsl_type::get_array_instance(symtab->get_type("gl_LightProducts"),
                                          state->Const.MaxLights);
        add_uniform(instructions, symtab, "gl_FrontLightProduct", light_products_type);
        add_uniform(instructions, symtab, "gl_BackLightProduct", light_products_type);

        add_uniform(instructions, symtab, "gl_TextureEnvColor",
                    glsl_type::get_array_instance(glsl_type::vec4_type,
                            state->Const.MaxTextureUnits));

        const glsl_type *const texcoords_vec4 =
            glsl_type::get_array_instance(glsl_type::vec4_type,
                                          state->Const.MaxTextureCoords);
        add_uniform(instructions, symtab, "gl_EyePlaneS", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_EyePlaneT", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_EyePlaneR", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_EyePlaneQ", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_ObjectPlaneS", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_ObjectPlaneT", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_ObjectPlaneR", texcoords_vec4);
        add_uniform(instructions, symtab, "gl_ObjectPlaneQ", texcoords_vec4);

        add_uniform(instructions, symtab, "gl_Fog",
                    symtab->get_type("gl_FogParameters"));
    }

    /* Mesa-internal current attrib state */
    const glsl_type *const vert_attribs =
        glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX);
    add_uniform(instructions, symtab, "gl_CurrentAttribVertMESA", vert_attribs);
    const glsl_type *const frag_attribs =
        glsl_type::get_array_instance(glsl_type::vec4_type, FRAG_ATTRIB_MAX);
    add_uniform(instructions, symtab, "gl_CurrentAttribFragMESA", frag_attribs);
}