[Mesa-dev] [RFC PATCH 1/2] i965/vec4: Extract function to set up vec4 prog key for precompiling.
Paul Berry
stereotype441 at gmail.com
Wed Oct 23 19:29:07 CEST 2013
This will allow us to re-use it for precompiling geometry shaders.
---
src/mesa/drivers/dri/i965/brw_vec4.cpp | 22 ++++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_vec4.h | 4 ++++
src/mesa/drivers/dri/i965/brw_vs.c | 15 +--------------
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index d3ee9a1..90db4c1 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1592,6 +1592,28 @@ brw_vs_emit(struct brw_context *brw,
}
+void
+brw_vec4_setup_prog_key_for_precompile(struct gl_context *ctx,
+ struct brw_vec4_prog_key *key,
+ GLuint id, struct gl_program *prog)
+{
+ key->program_string_id = id;
+ key->clamp_vertex_color = ctx->API == API_OPENGL_COMPAT;
+
+ unsigned sampler_count = _mesa_fls(prog->SamplersUsed);
+ for (unsigned i = 0; i < sampler_count; i++) {
+ if (prog->ShadowSamplers & (1 << i)) {
+ /* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
+ key->tex.swizzles[i] =
+ MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_ONE);
+ } else {
+ /* Color sampler: assume no swizzling. */
+ key->tex.swizzles[i] = SWIZZLE_XYZW;
+ }
+ }
+}
+
+
bool
brw_vec4_prog_data_compare(const struct brw_vec4_prog_data *a,
const struct brw_vec4_prog_data *b)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 41d91e5..fa0dd2f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -80,6 +80,10 @@ struct brw_vec4_prog_key {
extern "C" {
#endif
+void
+brw_vec4_setup_prog_key_for_precompile(struct gl_context *ctx,
+ struct brw_vec4_prog_key *key,
+ GLuint id, struct gl_program *prog);
bool brw_vec4_prog_data_compare(const struct brw_vec4_prog_data *a,
const struct brw_vec4_prog_data *b);
void brw_vec4_prog_data_free(const struct brw_vec4_prog_data *prog_data);
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index c0ae3ed..3cab3fe 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -536,20 +536,7 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
memset(&key, 0, sizeof(key));
- key.base.program_string_id = bvp->id;
- key.base.clamp_vertex_color = ctx->API == API_OPENGL_COMPAT;
-
- unsigned sampler_count = _mesa_fls(vp->Base.SamplersUsed);
- for (unsigned i = 0; i < sampler_count; i++) {
- if (vp->Base.ShadowSamplers & (1 << i)) {
- /* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
- key.base.tex.swizzles[i] =
- MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_ONE);
- } else {
- /* Color sampler: assume no swizzling. */
- key.base.tex.swizzles[i] = SWIZZLE_XYZW;
- }
- }
+ brw_vec4_setup_prog_key_for_precompile(ctx, &key.base, bvp->id, &vp->Base);
success = do_vs_prog(brw, prog, bvp, &key);
--
1.8.4.1
More information about the mesa-dev
mailing list