[Mesa-dev] [PATCH 10/16] i965/blorp: Use virtual function for wm/ps configuration
Topi Pohjolainen
topi.pohjolainen at intel.com
Thu Apr 23 11:00:35 PDT 2015
instead of resolving the program offset and data. Different flavours
of blorp programs (blit, clear, hiz) each have its own parameter type.
The decision making on how state is configured will be moved for the
parameter type to make instead of branching explicitly in the main
body of batch submission (gen6/7_blorp_exec()).
This will be exploited even further in the subsequent patches when one
more program type is added - the one representing programs compiled
from real glsl-sources.
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/mesa/drivers/dri/i965/brw_blorp.cpp | 7 -------
src/mesa/drivers/dri/i965/brw_blorp.h | 20 ++++++++++++-------
src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 13 ++++++-------
src/mesa/drivers/dri/i965/gen6_blorp.cpp | 17 ++++++++++++----
src/mesa/drivers/dri/i965/gen7_blorp.cpp | 29 ++++++++++++++++++++++++----
5 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp
index b404869..300cafe 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp
@@ -335,10 +335,3 @@ brw_hiz_op_params::brw_hiz_op_params(struct intel_mipmap_tree *mt,
default: unreachable("not reached");
}
}
-
-uint32_t
-brw_hiz_op_params::get_wm_prog(struct brw_context *brw,
- brw_blorp_prog_data **prog_data) const
-{
- return 0;
-}
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h
index 695414a..a2682da 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.h
+++ b/src/mesa/drivers/dri/i965/brw_blorp.h
@@ -215,8 +215,10 @@ public:
unsigned num_draw_buffers = 1,
unsigned num_layers = 1);
- virtual uint32_t get_wm_prog(struct brw_context *brw,
- brw_blorp_prog_data **prog_data) const = 0;
+ virtual void gen6_emit_wm_config(struct brw_context *brw) const;
+ virtual void gen7_emit_wm_config(struct brw_context *brw) const;
+
+ virtual void gen7_emit_ps_config(struct brw_context *brw) const;
uint32_t x0;
uint32_t y0;
@@ -254,9 +256,6 @@ public:
brw_hiz_op_params(struct intel_mipmap_tree *mt,
unsigned int level, unsigned int layer,
gen6_hiz_op op);
-
- virtual uint32_t get_wm_prog(struct brw_context *brw,
- brw_blorp_prog_data **prog_data) const;
};
struct brw_blorp_blit_prog_key
@@ -354,11 +353,18 @@ public:
GLfloat dst_x1, GLfloat dst_y1,
GLenum filter, bool mirror_x, bool mirror_y);
- virtual uint32_t get_wm_prog(struct brw_context *brw,
- brw_blorp_prog_data **prog_data) const;
+ virtual void gen6_emit_wm_config(struct brw_context *brw) const;
+ virtual void gen7_emit_wm_config(struct brw_context *brw) const;
+
+ virtual void gen7_emit_ps_config(struct brw_context *brw) const;
private:
+ void set_wm_prog(struct brw_context *brw);
+
brw_blorp_blit_prog_key wm_prog_key;
+
+ brw_blorp_prog_data *prog_data;
+ uint32_t prog_offset;
};
/**
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 1561b59..947f3b0 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -2115,16 +2115,16 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw,
src.x_offset *= 2;
src.y_offset /= 2;
}
+
+ set_wm_prog(brw);
}
-uint32_t
-brw_blorp_blit_params::get_wm_prog(struct brw_context *brw,
- brw_blorp_prog_data **prog_data) const
+void
+brw_blorp_blit_params::set_wm_prog(struct brw_context *brw)
{
- uint32_t prog_offset = 0;
if (!brw_search_cache(&brw->cache, BRW_CACHE_BLORP_BLIT_PROG,
&this->wm_prog_key, sizeof(this->wm_prog_key),
- &prog_offset, prog_data)) {
+ &prog_offset, &prog_data)) {
brw_blorp_blit_program prog(brw, &this->wm_prog_key,
INTEL_DEBUG & DEBUG_BLORP);
GLuint program_size;
@@ -2133,7 +2133,6 @@ brw_blorp_blit_params::get_wm_prog(struct brw_context *brw,
&this->wm_prog_key, sizeof(this->wm_prog_key),
program, program_size,
&prog.prog_data, sizeof(prog.prog_data),
- &prog_offset, prog_data);
+ &prog_offset, &prog_data);
}
- return prog_offset;
}
diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp
index 21c8423..39fbb24 100644
--- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp
@@ -998,6 +998,18 @@ gen6_blorp_emit_primitive(struct brw_context *brw,
ADVANCE_BATCH();
}
+void
+brw_blorp_params::gen6_emit_wm_config(struct brw_context *brw) const
+{
+ gen6_blorp_emit_wm_config(brw, this, 0, NULL);
+}
+
+void
+brw_blorp_blit_params::gen6_emit_wm_config(struct brw_context *brw) const
+{
+ gen6_blorp_emit_wm_config(brw, this, prog_offset, prog_data);
+}
+
/**
* \brief Execute a blit or render pass operation.
*
@@ -1011,15 +1023,12 @@ void
gen6_blorp_exec(struct brw_context *brw,
const brw_blorp_params *params)
{
- brw_blorp_prog_data *prog_data = NULL;
uint32_t cc_blend_state_offset = 0;
uint32_t cc_state_offset = 0;
uint32_t depthstencil_offset;
uint32_t wm_push_const_offset = 0;
uint32_t wm_bind_bo_offset = 0;
- uint32_t prog_offset = params->get_wm_prog(brw, &prog_data);
-
/* Emit workaround flushes when we switch from drawing to blorping. */
intel_emit_post_sync_nonzero_flush(brw);
@@ -1068,7 +1077,7 @@ gen6_blorp_exec(struct brw_context *brw,
gen6_blorp_emit_constant_ps(brw, params, wm_push_const_offset);
else
gen6_blorp_emit_constant_ps_disable(brw, params);
- gen6_blorp_emit_wm_config(brw, params, prog_offset, prog_data);
+ params->gen6_emit_wm_config(brw);
if (params->use_wm_prog)
gen6_blorp_emit_binding_table_pointers(brw, wm_bind_bo_offset);
gen6_blorp_emit_viewport_state(brw, params);
diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp
index 2bdc82b..e2b865f 100644
--- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp
@@ -759,6 +759,29 @@ gen7_blorp_emit_primitive(struct brw_context *brw,
ADVANCE_BATCH();
}
+void
+brw_blorp_params::gen7_emit_wm_config(struct brw_context *brw) const
+{
+ gen7_blorp_emit_wm_config(brw, this, NULL);
+}
+
+void
+brw_blorp_params::gen7_emit_ps_config(struct brw_context *brw) const
+{
+ gen7_blorp_emit_ps_config(brw, this, 0, NULL);
+}
+
+void
+brw_blorp_blit_params::gen7_emit_wm_config(struct brw_context *brw) const
+{
+ gen7_blorp_emit_wm_config(brw, this, prog_data);
+}
+
+void
+brw_blorp_blit_params::gen7_emit_ps_config(struct brw_context *brw) const
+{
+ gen7_blorp_emit_ps_config(brw, this, prog_offset, prog_data);
+}
/**
* \copydoc gen6_blorp_exec()
@@ -770,7 +793,6 @@ gen7_blorp_exec(struct brw_context *brw,
if (brw->gen >= 8)
return;
- brw_blorp_prog_data *prog_data = NULL;
uint32_t cc_blend_state_offset = 0;
uint32_t cc_state_offset = 0;
uint32_t depthstencil_offset;
@@ -778,7 +800,6 @@ gen7_blorp_exec(struct brw_context *brw,
uint32_t wm_bind_bo_offset = 0;
uint32_t sampler_offset = 0;
- uint32_t prog_offset = params->get_wm_prog(brw, &prog_data);
gen6_emit_3dstate_multisample(brw, params->dst.num_samples);
gen6_emit_3dstate_sample_mask(brw,
params->dst.num_samples > 1 ?
@@ -825,7 +846,7 @@ gen7_blorp_exec(struct brw_context *brw,
gen7_blorp_emit_streamout_disable(brw);
gen6_blorp_emit_clip_disable(brw);
gen7_blorp_emit_sf_config(brw, params);
- gen7_blorp_emit_wm_config(brw, params, prog_data);
+ params->gen7_emit_wm_config(brw);
if (params->use_wm_prog) {
gen7_blorp_emit_binding_table_pointers_ps(brw, wm_bind_bo_offset);
gen7_blorp_emit_sampler_state_pointers_ps(brw, sampler_offset);
@@ -833,7 +854,7 @@ gen7_blorp_exec(struct brw_context *brw,
} else {
gen7_blorp_emit_constant_ps_disable(brw);
}
- gen7_blorp_emit_ps_config(brw, params, prog_offset, prog_data);
+ params->gen7_emit_ps_config(brw);
gen7_blorp_emit_cc_viewport(brw);
if (params->depth.mt)
--
1.9.3
More information about the mesa-dev
mailing list