dri: Move i965-specific context flag logic to dri common.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_context.c
index 44a35d1a84013a9c61c062906289a4820e40fbd4..5d5f41a32fe5e9d0fb16cf19ec4930a1b7ded0bb 100644 (file)
@@ -176,6 +176,7 @@ brw_initialize_context_constants(struct brw_context *brw)
       ctx->Const.MaxColorTextureSamples = 8;
       ctx->Const.MaxDepthTextureSamples = 8;
       ctx->Const.MaxIntegerSamples = 8;
+      ctx->Const.MaxProgramTextureGatherComponents = 4;
    }
 
    ctx->Const.MinLineWidth = 1.0;
@@ -247,8 +248,16 @@ brw_initialize_context_constants(struct brw_context *brw)
    ctx->Const.DisableGLSLLineContinuations =
       driQueryOptionb(&brw->optionCache, "disable_glsl_line_continuations");
 
+   if (brw->gen >= 6) {
+      ctx->Const.MaxVarying = 32;
+      ctx->Const.VertexProgram.MaxOutputComponents = 128;
+      ctx->Const.GeometryProgram.MaxInputComponents = 128;
+      ctx->Const.GeometryProgram.MaxOutputComponents = 128;
+      ctx->Const.FragmentProgram.MaxInputComponents = 128;
+   }
+
    /* We want the GLSL compiler to emit code that uses condition codes */
-   for (int i = 0; i <= MESA_SHADER_FRAGMENT; i++) {
+   for (int i = 0; i < MESA_SHADER_TYPES; i++) {
       ctx->ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX;
       ctx->ShaderCompilerOptions[i].EmitCondCodes = true;
       ctx->ShaderCompilerOptions[i].EmitNoNoise = true;
@@ -267,7 +276,7 @@ brw_initialize_context_constants(struct brw_context *brw)
 }
 
 bool
-brwCreateContext(int api,
+brwCreateContext(gl_api api,
                 const struct gl_config *mesaVis,
                 __DRIcontext *driContextPriv,
                  unsigned major_version,
@@ -302,7 +311,7 @@ brwCreateContext(int api,
                           mesaVis, driContextPriv,
                          sharedContextPrivate, &functions,
                          error)) {
-      ralloc_free(brw);
+      intelDestroyContext(driContextPriv);
       return false;
    }
 
@@ -323,7 +332,7 @@ brwCreateContext(int api,
 
       if (!brw->hw_ctx) {
          fprintf(stderr, "Gen6+ requires Kernel 3.6 or later.\n");
-         ralloc_free(brw);
+         intelDestroyContext(driContextPriv);
          return false;
       }
    }
@@ -361,6 +370,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 70;
         brw->max_gs_threads = 70;
         brw->urb.size = 128;
+         brw->urb.min_vs_entries = 32;
         brw->urb.max_vs_entries = 640;
         brw->urb.max_gs_entries = 256;
       } else if (brw->gt == 2) {
@@ -368,6 +378,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 280;
         brw->max_gs_threads = 256;
         brw->urb.size = 256;
+         brw->urb.min_vs_entries = 64;
         brw->urb.max_vs_entries = 1664;
         brw->urb.max_gs_entries = 640;
       } else if (brw->gt == 3) {
@@ -375,6 +386,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 280;
         brw->max_gs_threads = 256;
         brw->urb.size = 512;
+         brw->urb.min_vs_entries = 64;
         brw->urb.max_vs_entries = 1664;
         brw->urb.max_gs_entries = 640;
       }
@@ -384,6 +396,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 36;
         brw->max_gs_threads = 36;
         brw->urb.size = 128;
+         brw->urb.min_vs_entries = 32;
         brw->urb.max_vs_entries = 512;
         brw->urb.max_gs_entries = 192;
       } else if (brw->gt == 2) {
@@ -391,6 +404,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 128;
         brw->max_gs_threads = 128;
         brw->urb.size = 256;
+         brw->urb.min_vs_entries = 32;
         brw->urb.max_vs_entries = 704;
         brw->urb.max_gs_entries = 320;
       } else {
@@ -402,6 +416,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 60;
         brw->max_gs_threads = 60;
         brw->urb.size = 64;            /* volume 5c.5 section 5.1 */
+         brw->urb.min_vs_entries = 24;
         brw->urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */
         brw->urb.max_gs_entries = 256;
       } else {
@@ -409,6 +424,7 @@ brwCreateContext(int api,
         brw->max_vs_threads = 24;
         brw->max_gs_threads = 21; /* conservative; 24 if rendering disabled */
         brw->urb.size = 32;            /* volume 5c.5 section 5.1 */
+         brw->urb.min_vs_entries = 24;
         brw->urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */
         brw->urb.max_gs_entries = 256;
       }
@@ -463,19 +479,16 @@ brwCreateContext(int api,
    brw_draw_init( brw );
 
    brw->precompile = driQueryOptionb(&brw->optionCache, "shader_precompile");
-
-   ctx->Const.ContextFlags = 0;
-   if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
-      ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+   brw->disable_derivative_optimization =
+      driQueryOptionb(&brw->optionCache, "disable_derivative_optimization");
 
    if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
-      ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
-
       /* Turn on some extra GL_ARB_debug_output generation. */
       brw->perf_debug = true;
    }
 
    brw_fs_alloc_reg_sets(brw);
+   brw_vec4_alloc_reg_set(brw);
 
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
       brw_init_shader_time(brw);
@@ -485,6 +498,10 @@ brwCreateContext(int api,
    _mesa_initialize_dispatch_tables(ctx);
    _mesa_initialize_vbo_vtxfmt(ctx);
 
+   if (ctx->Extensions.AMD_performance_monitor) {
+      brw_init_performance_monitors(brw);
+   }
+
    return true;
 }