bool i915CreateContext(int api, const struct gl_config * mesaVis, __DRIcontext * driContextPriv, unsigned major_version, unsigned minor_version, 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, mesaVis, driContextPriv, sharedContextPrivate, &functions)) { *error = __DRI_CTX_ERROR_NO_MEMORY; return false; } /* Now that the extension bits are known, filter against the requested API * and version. */ switch (api) { case API_OPENGL: { const unsigned max_version = (ctx->Extensions.ARB_fragment_shader && ctx->Extensions.ARB_occlusion_query) ? 20 : 15; const unsigned req_version = major_version * 10 + minor_version; if (req_version > max_version) { *error = __DRI_CTX_ERROR_BAD_VERSION; return false; } break; } case API_OPENGLES: case API_OPENGLES2: break; default: *error = __DRI_CTX_ERROR_BAD_API; return false; } intel_init_texture_formats(ctx); _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); ctx->Const.MaxTextureUnits = I915_TEX_UNITS; ctx->Const.MaxTextureImageUnits = I915_TEX_UNITS; ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS; ctx->Const.MaxVarying = I915_TEX_UNITS; ctx->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits + ctx->Const.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.FragmentProgram.MaxNativeTemps = I915_MAX_TEMPORARY; ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */ ctx->Const.FragmentProgram.MaxNativeParameters = I915_MAX_CONSTANT; ctx->Const.FragmentProgram.MaxNativeAluInstructions = I915_MAX_ALU_INSN; ctx->Const.FragmentProgram.MaxNativeTexInstructions = I915_MAX_TEX_INSN; ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN + I915_MAX_TEX_INSN); ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT; ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */ ctx->Const.FragmentProgram.MaxEnvParams = MIN2(ctx->Const.FragmentProgram.MaxNativeParameters, ctx->Const.FragmentProgram.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.FragmentProgram.MediumFloat.RangeMin = 127; ctx->Const.FragmentProgram.MediumFloat.RangeMax = 127; ctx->Const.FragmentProgram.MediumFloat.Precision = 23; ctx->Const.FragmentProgram.LowFloat = ctx->Const.FragmentProgram.HighFloat = ctx->Const.FragmentProgram.MediumFloat; ctx->Const.FragmentProgram.MediumInt.RangeMin = 24; ctx->Const.FragmentProgram.MediumInt.RangeMax = 24; ctx->Const.FragmentProgram.MediumInt.Precision = 0; ctx->Const.FragmentProgram.LowInt = ctx->Const.FragmentProgram.HighInt = ctx->Const.FragmentProgram.MediumInt; ctx->FragmentProgram._MaintainTexEnvProgram = true; /* FINISHME: Are there other options that should be enabled for software * FINISHME: vertex shaders? */ ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitCondCodes = true; struct gl_shader_compiler_options *const fs_options = & ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; fs_options->MaxIfDepth = 0; fs_options->EmitNoNoise = true; fs_options->EmitNoPow = true; fs_options->EmitNoMainReturn = true; fs_options->EmitNoIndirectInput = true; fs_options->EmitNoIndirectOutput = true; fs_options->EmitNoIndirectUniform = true; fs_options->EmitNoIndirectTemp = true; ctx->Const.MaxDrawBuffers = 1; _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); return true; }
GLboolean i830CreateContext(const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate) { struct dd_function_table functions; struct i830_context *i830 = CALLOC_STRUCT(i830_context); struct intel_context *intel = &i830->intel; GLcontext *ctx = &intel->ctx; if (!i830) return GL_FALSE; i830InitVtbl(i830); i830InitDriverFunctions(&functions); if (!intelInitContext(intel, 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; }