Mesa (master): swr: [rasterizer jitter] canonicalize blend compile state
Tim Rowley
torowley at kemper.freedesktop.org
Mon Oct 3 16:29:37 UTC 2016
Module: Mesa
Branch: master
Commit: 114f7a92c6a5ea796a4fea9a7b71188fdb243950
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=114f7a92c6a5ea796a4fea9a7b71188fdb243950
Author: Tim Rowley <timothy.o.rowley at intel.com>
Date: Fri Sep 30 15:18:13 2016 -0500
swr: [rasterizer jitter] canonicalize blend compile state
Canonicalize to prevent unnecessary JIT compiles.
Signed-off-by: Tim Rowley <timothy.o.rowley at intel.com>
---
.../drivers/swr/rasterizer/jitter/blend_jit.h | 37 ++++++++++++++++++++++
src/gallium/drivers/swr/swr_state.cpp | 2 ++
2 files changed, 39 insertions(+)
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.h b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.h
index af317cc..ddb7374 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.h
@@ -89,4 +89,41 @@ struct BLEND_COMPILE_STATE
{
return memcmp(this, &other, sizeof(BLEND_COMPILE_STATE)) == 0;
}
+
+ // Canonicalize state to reduce unnecessary JIT compiles
+ void Canonicalize()
+ {
+ if (!desc.alphaTestEnable)
+ {
+ alphaTestFormat = (ALPHA_TEST_FORMAT)0;
+ alphaTestFunction = (SWR_ZFUNCTION)0;
+ }
+
+ if (!blendState.blendEnable)
+ {
+ blendState.sourceAlphaBlendFactor = (SWR_BLEND_FACTOR)0;
+ blendState.destAlphaBlendFactor = (SWR_BLEND_FACTOR)0;
+ blendState.sourceBlendFactor = (SWR_BLEND_FACTOR)0;
+ blendState.destBlendFactor = (SWR_BLEND_FACTOR)0;
+ blendState.colorBlendFunc = (SWR_BLEND_OP)0;
+ blendState.alphaBlendFunc = (SWR_BLEND_OP)0;
+ }
+
+ if (!blendState.logicOpEnable)
+ {
+ blendState.logicOpFunc = (SWR_LOGIC_OP)0;
+ }
+
+ if (!blendState.blendEnable && !blendState.logicOpEnable)
+ {
+ format = (SWR_FORMAT)0;
+ }
+
+ if (!desc.independentAlphaBlendEnable)
+ {
+ blendState.sourceAlphaBlendFactor = (SWR_BLEND_FACTOR)0;
+ blendState.destAlphaBlendFactor = (SWR_BLEND_FACTOR)0;
+ blendState.alphaBlendFunc = (SWR_BLEND_OP)0;
+ }
+ }
};
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
index 7d49ce7..3e02322 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -1318,6 +1318,8 @@ swr_update_derived(struct pipe_context *pipe,
swr_convert_depth_func(ctx->depth_stencil->alpha.func);
compileState.alphaTestFormat = ALPHA_TEST_FLOAT32; // xxx
+ compileState.Canonicalize();
+
PFN_BLEND_JIT_FUNC func = NULL;
auto search = ctx->blendJIT->find(compileState);
if (search != ctx->blendJIT->end()) {
More information about the mesa-commit
mailing list