summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2013-09-27 10:40:57 -0700
committerKenneth Graunke <kenneth@whitecape.org>2013-10-13 00:10:43 -0700
commit90511faedddff834ab1f6d92f4d5d25a3c32bd82 (patch)
treebdeabd1744f6a94f396cfc358d0e25abc67502ec
parent0fb525b87ceae543d581a5755ca547b54c58aa76 (diff)
i965: Pull most driconf option handling into a centralized function.
Using a helper function clarifies the context initialization code. I would've liked to completely centralize it, but moving the optionCache code from intelInitExtensions into here would've required setting flags in the context, which seems like a waste. v2: Rebase for the introduction of disable_derivative_optimization. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c71
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.c37
2 files changed, 61 insertions, 47 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 3846d3d0b07..840a384ba21 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -243,12 +243,6 @@ brw_initialize_context_constants(struct brw_context *brw)
ctx->Const.UniformBooleanTrue = 1;
ctx->Const.UniformBufferOffsetAlignment = 16;
- ctx->Const.ForceGLSLExtensionsWarn =
- driQueryOptionb(&brw->optionCache, "force_glsl_extensions_warn");
-
- ctx->Const.DisableGLSLLineContinuations =
- driQueryOptionb(&brw->optionCache, "disable_glsl_line_continuations");
-
if (brw->gen >= 6) {
ctx->Const.MaxVarying = 32;
ctx->Const.VertexProgram.MaxOutputComponents = 128;
@@ -276,6 +270,65 @@ brw_initialize_context_constants(struct brw_context *brw)
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = true;
}
+/**
+ * Process driconf (drirc) options, setting appropriate context flags.
+ *
+ * intelInitExtensions still pokes at optionCache directly, in order to
+ * avoid advertising various extensions. No flags are set, so it makes
+ * sense to continue doing that there.
+ */
+static void
+brw_process_driconf_options(struct brw_context *brw)
+{
+ struct gl_context *ctx = &brw->ctx;
+
+ driOptionCache *options = &brw->optionCache;
+ driParseConfigFiles(options, &brw->intelScreen->optionCache,
+ brw->driContext->driScreenPriv->myNum, "i965");
+
+ int bo_reuse_mode = driQueryOptioni(options, "bo_reuse");
+ switch (bo_reuse_mode) {
+ case DRI_CONF_BO_REUSE_DISABLED:
+ break;
+ case DRI_CONF_BO_REUSE_ALL:
+ intel_bufmgr_gem_enable_reuse(brw->bufmgr);
+ break;
+ }
+
+ if (!driQueryOptionb(options, "hiz")) {
+ brw->has_hiz = false;
+ /* On gen6, you can only do separate stencil with HIZ. */
+ if (brw->gen == 6)
+ brw->has_separate_stencil = false;
+ }
+
+ if (driQueryOptionb(options, "always_flush_batch")) {
+ fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
+ brw->always_flush_batch = true;
+ }
+
+ if (driQueryOptionb(options, "always_flush_cache")) {
+ fprintf(stderr, "flushing GPU caches before/after each draw call\n");
+ brw->always_flush_cache = true;
+ }
+
+ if (driQueryOptionb(options, "disable_throttling")) {
+ fprintf(stderr, "disabling flush throttling\n");
+ brw->disable_throttling = true;
+ }
+
+ brw->disable_derivative_optimization =
+ driQueryOptionb(&brw->optionCache, "disable_derivative_optimization");
+
+ brw->precompile = driQueryOptionb(&brw->optionCache, "shader_precompile");
+
+ ctx->Const.ForceGLSLExtensionsWarn =
+ driQueryOptionb(options, "force_glsl_extensions_warn");
+
+ ctx->Const.DisableGLSLLineContinuations =
+ driQueryOptionb(options, "disable_glsl_line_continuations");
+}
+
bool
brwCreateContext(gl_api api,
const struct gl_config *mesaVis,
@@ -348,6 +401,8 @@ brwCreateContext(gl_api api,
return false;
}
+ brw_process_driconf_options(brw);
+
if (!intelInitContext( brw, api, major_version, minor_version,
mesaVis, driContextPriv,
sharedContextPrivate, &functions,
@@ -519,10 +574,6 @@ brwCreateContext(gl_api api,
brw_draw_init( brw );
- brw->precompile = driQueryOptionb(&brw->optionCache, "shader_precompile");
- brw->disable_derivative_optimization =
- driQueryOptionb(&brw->optionCache, "disable_derivative_optimization");
-
if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
/* Turn on some extra GL_ARB_debug_output generation. */
brw->perf_debug = true;
diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c
index 430967b5242..a5805ec8909 100644
--- a/src/mesa/drivers/dri/i965/intel_context.c
+++ b/src/mesa/drivers/dri/i965/intel_context.c
@@ -367,9 +367,6 @@ intelInitContext(struct brw_context *brw,
unsigned *dri_ctx_error)
{
struct gl_context *ctx = &brw->ctx;
- __DRIscreen *sPriv = driContextPriv->driScreenPriv;
- struct intel_screen *intelScreen = sPriv->driverPrivate;
- int bo_reuse_mode;
/* GLX uses DRI2 invalidate events to handle window resizing.
* Unfortunately, EGL does not - libEGL is written in XCB (not Xlib),
@@ -386,9 +383,6 @@ intelInitContext(struct brw_context *brw,
memset(&ctx->TextureFormatSupported,
0, sizeof(ctx->TextureFormatSupported));
- driParseConfigFiles(&brw->optionCache, &intelScreen->optionCache,
- sPriv->myNum, "i965");
-
/* Estimate the size of the mappable aperture into the GTT. There's an
* ioctl to get the whole GTT size, but not one to get the mappable subset.
* It turns out it's basically always 256MB, though some ancient hardware
@@ -404,15 +398,6 @@ intelInitContext(struct brw_context *brw,
*/
brw->max_gtt_map_object_size = gtt_size / 4;
- bo_reuse_mode = driQueryOptioni(&brw->optionCache, "bo_reuse");
- switch (bo_reuse_mode) {
- case DRI_CONF_BO_REUSE_DISABLED:
- break;
- case DRI_CONF_BO_REUSE_ALL:
- intel_bufmgr_gem_enable_reuse(brw->bufmgr);
- break;
- }
-
/* Initialize the software rasterizer and helper modules.
*
* As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
@@ -443,28 +428,6 @@ intelInitContext(struct brw_context *brw,
intel_fbo_init(brw);
- if (!driQueryOptionb(&brw->optionCache, "hiz")) {
- brw->has_hiz = false;
- /* On gen6, you can only do separate stencil with HIZ. */
- if (brw->gen == 6)
- brw->has_separate_stencil = false;
- }
-
- if (driQueryOptionb(&brw->optionCache, "always_flush_batch")) {
- fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
- brw->always_flush_batch = 1;
- }
-
- if (driQueryOptionb(&brw->optionCache, "always_flush_cache")) {
- fprintf(stderr, "flushing GPU caches before/after each draw call\n");
- brw->always_flush_cache = 1;
- }
-
- if (driQueryOptionb(&brw->optionCache, "disable_throttling")) {
- fprintf(stderr, "disabling flush throttling\n");
- brw->disable_throttling = 1;
- }
-
return true;
}