driconf: Support selection by Vulkan applicationName.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_context.c
index 16f987812fc463ecfd1d6fa627232c14d226a792..0320e72537e8307fa5960431d37fd27178aab4e6 100644 (file)
@@ -37,7 +37,6 @@
 #include "main/fbobject.h"
 #include "main/extensions.h"
 #include "main/glthread.h"
-#include "main/imports.h"
 #include "main/macros.h"
 #include "main/points.h"
 #include "main/version.h"
@@ -76,6 +75,7 @@
 #include "util/ralloc.h"
 #include "util/debug.h"
 #include "util/disk_cache.h"
+#include "util/u_memory.h"
 #include "isl/isl.h"
 
 #include "common/gen_defines.h"
@@ -289,6 +289,31 @@ intel_glFlush(struct gl_context *ctx)
    brw->need_flush_throttle = true;
 }
 
+static void
+intel_glEnable(struct gl_context *ctx, GLenum cap, GLboolean state)
+{
+   struct brw_context *brw = brw_context(ctx);
+
+   switch (cap) {
+   case GL_BLACKHOLE_RENDER_INTEL:
+      brw->frontend_noop = state;
+      intel_batchbuffer_flush(brw);
+      intel_batchbuffer_maybe_noop(brw);
+      /* Because we started previous batches with a potential
+       * MI_BATCH_BUFFER_END if NOOP was enabled, that means that anything
+       * that was ever emitted after that never made it to the HW. So when the
+       * blackhole state changes from NOOP->!NOOP reupload the entire state.
+       */
+      if (!brw->frontend_noop) {
+         brw->NewGLState = ~0u;
+         brw->ctx.NewDriverState = ~0ull;
+      }
+      break;
+   default:
+      break;
+   }
+}
+
 static void
 intel_finish(struct gl_context * ctx)
 {
@@ -318,6 +343,7 @@ brw_init_driver_functions(struct brw_context *brw,
    if (!brw->driContext->driScreenPriv->dri2.useInvalidate)
       functions->Viewport = intel_viewport;
 
+   functions->Enable = intel_glEnable;
    functions->Flush = intel_glFlush;
    functions->Finish = intel_finish;
    functions->GetString = intel_get_string;
@@ -576,14 +602,6 @@ brw_initialize_context_constants(struct brw_context *brw)
    ctx->Const.MaxIntegerSamples = max_samples;
    ctx->Const.MaxImageSamples = 0;
 
-   /* gen6_set_sample_maps() sets SampleMap{2,4,8}x variables which are used
-    * to map indices of rectangular grid to sample numbers within a pixel.
-    * These variables are used by GL_EXT_framebuffer_multisample_blit_scaled
-    * extension implementation. For more details see the comment above
-    * gen6_set_sample_maps() definition.
-    */
-   gen6_set_sample_maps(ctx);
-
    ctx->Const.MinLineWidth = 1.0;
    ctx->Const.MinLineWidthAA = 1.0;
    if (devinfo->gen >= 6) {
@@ -817,6 +835,15 @@ brw_initialize_cs_context_constants(struct brw_context *brw)
    ctx->Const.MaxComputeWorkGroupSize[2] = max_invocations;
    ctx->Const.MaxComputeWorkGroupInvocations = max_invocations;
    ctx->Const.MaxComputeSharedMemorySize = 64 * 1024;
+
+   /* Constants used for ARB_compute_variable_group_size. */
+   if (devinfo->gen >= 7) {
+      assert(max_invocations >= 512);
+      ctx->Const.MaxComputeVariableGroupSize[0] = max_invocations;
+      ctx->Const.MaxComputeVariableGroupSize[1] = max_invocations;
+      ctx->Const.MaxComputeVariableGroupSize[2] = max_invocations;
+      ctx->Const.MaxComputeVariableGroupInvocations = max_invocations;
+   }
 }
 
 /**
@@ -835,7 +862,7 @@ brw_process_driconf_options(struct brw_context *brw)
    driOptionCache *options = &brw->optionCache;
    driParseConfigFiles(options, &brw->screen->optionCache,
                        brw->driContext->driScreenPriv->myNum,
-                       "i965", NULL, NULL, 0);
+                       "i965", NULL, NULL, 0, NULL, 0);
 
    if (INTEL_DEBUG & DEBUG_NO_HIZ) {
        brw->has_hiz = false;
@@ -888,7 +915,7 @@ brw_process_driconf_options(struct brw_context *brw)
    ctx->Const.ForceGLSLAbsSqrt =
       driQueryOptionb(options, "force_glsl_abs_sqrt");
 
-   ctx->Const.GLSLZeroInit = driQueryOptionb(options, "glsl_zero_init");
+   ctx->Const.GLSLZeroInit = driQueryOptionb(options, "glsl_zero_init") ? 1 : 0;
 
    brw->dual_color_blend_by_location =
       driQueryOptionb(options, "dual_color_blend_by_location");
@@ -896,6 +923,11 @@ brw_process_driconf_options(struct brw_context *brw)
    ctx->Const.AllowGLSLCrossStageInterpolationMismatch =
       driQueryOptionb(options, "allow_glsl_cross_stage_interpolation_mismatch");
 
+   char *vendor_str = driQueryOptionstr(options, "force_gl_vendor");
+   /* not an empty string */
+   if (*vendor_str)
+      ctx->Const.VendorOverride = vendor_str;
+
    ctx->Const.dri_config_options_sha1 = ralloc_array(brw, unsigned char, 20);
    driComputeOptionsSha1(&brw->screen->optionCache,
                          ctx->Const.dri_config_options_sha1);
@@ -1000,7 +1032,7 @@ brwCreateContext(gl_api api,
       _swrast_CreateContext(ctx);
    }
 
-   _vbo_CreateContext(ctx);
+   _vbo_CreateContext(ctx, true);
    if (ctx->swrast_context) {
       _tnl_CreateContext(ctx);
       TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
@@ -1134,9 +1166,6 @@ brwCreateContext(gl_api api,
    if (ctx->Extensions.INTEL_performance_query)
       brw_init_performance_queries(brw);
 
-   vbo_use_buffer_objects(ctx);
-   vbo_always_unmap_buffers(ctx);
-
    brw->ctx.Cache = brw->screen->disk_cache;
 
    if (driContextPriv->driScreenPriv->dri2.backgroundCallable &&
@@ -1218,7 +1247,7 @@ intelDestroyContext(__DRIcontext * driContextPriv)
    driDestroyOptionCache(&brw->optionCache);
 
    /* free the Mesa context */
-   _mesa_free_context_data(&brw->ctx);
+   _mesa_free_context_data(&brw->ctx, true);
 
    ralloc_free(brw);
    driContextPriv->driverPrivate = NULL;