[Mesa-dev] [PATCH 05/29] i965: Pull most driconf option handling into a centralized function.
Kenneth Graunke
kenneth at whitecape.org
Fri Sep 27 16:45:44 PDT 2013
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.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_context.c | 66 +++++++++++++++++++++++++++----
src/mesa/drivers/dri/i965/intel_context.c | 37 -----------------
2 files changed, 58 insertions(+), 45 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 7a7acec..6c68692 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -242,12 +242,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;
@@ -275,6 +269,62 @@ 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->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(int api,
const struct gl_config *mesaVis,
@@ -347,6 +397,8 @@ brwCreateContext(int api,
return false;
}
+ brw_process_driconf_options(brw);
+
if (!intelInitContext( brw, api, major_version, minor_version,
mesaVis, driContextPriv,
sharedContextPrivate, &functions,
@@ -518,8 +570,6 @@ brwCreateContext(int api,
brw_draw_init( brw );
- brw->precompile = driQueryOptionb(&brw->optionCache, "shader_precompile");
-
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 430967b..a5805ec 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;
}
--
1.8.3.4
More information about the mesa-dev
mailing list