bool i915CreateContext(int api, const struct gl_config * mesaVis, __DRIcontext * driContextPriv, unsigned major_version, unsigned minor_version, uint32_t flags, unsigned *error, void *sharedContextPrivate) { struct dd_function_table functions; struct i915_context *i915 = rzalloc(NULL, struct i915_context); struct intel_context *intel = &i915->intel; struct gl_context *ctx = &intel->ctx; if (!i915) { *error = __DRI_CTX_ERROR_NO_MEMORY; return false; } i915InitVtbl(i915); i915InitDriverFunctions(&functions); if (!intelInitContext(intel, api, major_version, minor_version, flags, mesaVis, driContextPriv, sharedContextPrivate, &functions, error)) { ralloc_free(i915); return false; } intel_init_texture_formats(ctx); _math_matrix_ctr(&intel->ViewportMatrix); /* Initialize swrast, tnl driver tables: */ intelInitTriFuncs(ctx); /* Install the customized pipeline: */ _tnl_destroy_pipeline(ctx); _tnl_install_pipeline(ctx, intel_pipeline); if (intel->no_rast) FALLBACK(intel, INTEL_FALLBACK_USER, 1); ctx->Const.MaxTextureUnits = I915_TEX_UNITS; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = I915_TEX_UNITS; ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = I915_TEX_UNITS; ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS; ctx->Const.MaxVarying = I915_TEX_UNITS; ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = ctx->Const.MaxVarying * 4; ctx->Const.MaxCombinedTextureImageUnits = ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; /* Advertise the full hardware capabilities. The new memory * manager should cope much better with overload situations: */ ctx->Const.MaxTextureLevels = 12; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 12; ctx->Const.MaxTextureRectSize = (1 << 11); ctx->Const.MaxTextureUnits = I915_TEX_UNITS; ctx->Const.MaxTextureMaxAnisotropy = 4.0; /* GL_ARB_fragment_program limits - don't think Mesa actually * validates programs against these, and in any case one ARB * instruction can translate to more than one HW instruction, so * we'll still have to check and fallback each time. */ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeTemps = I915_MAX_TEMPORARY; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeParameters = I915_MAX_CONSTANT; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeAluInstructions = I915_MAX_ALU_INSN; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeTexInstructions = I915_MAX_TEX_INSN; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeInstructions = (I915_MAX_ALU_INSN + I915_MAX_TEX_INSN); ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeAddressRegs = 0; /* I don't think we have one */ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxEnvParams = MIN2(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeParameters, ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxEnvParams); /* i915 stores all values in single-precision floats. Values aren't set * for other program targets because software is used for those targets. */ ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat.RangeMin = 127; ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat.RangeMax = 127; ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat.Precision = 23; ctx->Const.Program[MESA_SHADER_FRAGMENT].LowFloat = ctx->Const.Program[MESA_SHADER_FRAGMENT].HighFloat = ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat; ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt.RangeMin = 24; ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt.RangeMax = 24; ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt.Precision = 0; ctx->Const.Program[MESA_SHADER_FRAGMENT].LowInt = ctx->Const.Program[MESA_SHADER_FRAGMENT].HighInt = ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt; ctx->FragmentProgram._MaintainTexEnvProgram = true; /* FINISHME: Are there other options that should be enabled for software * FINISHME: vertex shaders? */ ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoIndirectSampler = true; struct gl_shader_compiler_options *const fs_options = & ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; fs_options->MaxIfDepth = 0; fs_options->EmitNoPow = true; fs_options->EmitNoMainReturn = true; fs_options->EmitNoIndirectInput = true; fs_options->EmitNoIndirectOutput = true; fs_options->EmitNoIndirectUniform = true; fs_options->EmitNoIndirectTemp = true; fs_options->EmitNoIndirectSampler = true; ctx->Const.MaxDrawBuffers = 1; ctx->Const.QueryCounterBits.SamplesPassed = 0; _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, 36 * sizeof(GLfloat)); intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf; i915InitState(i915); /* Always enable pixel fog. Vertex fog using fog coord will conflict * with fog code appended onto fragment program. */ _tnl_allow_vertex_fog(ctx, 0); _tnl_allow_pixel_fog(ctx, 1); _mesa_override_extensions(ctx); _mesa_compute_version(ctx); _mesa_initialize_dispatch_tables(ctx); _mesa_initialize_vbo_vtxfmt(ctx); return true; }
GLboolean i830CreateContext(const struct gl_config * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate) { struct dd_function_table functions; struct i830_context *i830 = CALLOC_STRUCT(i830_context); struct intel_context *intel = &i830->intel; struct gl_context *ctx = &intel->ctx; if (!i830) return GL_FALSE; i830InitVtbl(i830); i830InitDriverFunctions(&functions); if (!intelInitContext(intel, __DRI_API_OPENGL, mesaVis, driContextPriv, sharedContextPrivate, &functions)) { FREE(i830); return GL_FALSE; } _math_matrix_ctr(&intel->ViewportMatrix); /* Initialize swrast, tnl driver tables: */ intelInitSpanFuncs(ctx); intelInitTriFuncs(ctx); /* Install the customized pipeline: */ _tnl_destroy_pipeline(ctx); _tnl_install_pipeline(ctx, intel_pipeline); if (intel->no_rast) FALLBACK(intel, INTEL_FALLBACK_USER, 1); intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS; intel->ctx.Const.MaxTextureImageUnits = I830_TEX_UNITS; intel->ctx.Const.MaxTextureCoordUnits = I830_TEX_UNITS; /* Advertise the full hardware capabilities. The new memory * manager should cope much better with overload situations: */ ctx->Const.MaxTextureLevels = 12; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 11; ctx->Const.MaxTextureRectSize = (1 << 11); ctx->Const.MaxTextureUnits = I830_TEX_UNITS; ctx->Const.MaxTextureMaxAnisotropy = 2.0; ctx->Const.MaxDrawBuffers = 1; _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, 18 * sizeof(GLfloat)); intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf; i830InitState(i830); _tnl_allow_vertex_fog(ctx, 1); _tnl_allow_pixel_fog(ctx, 0); return GL_TRUE; }