[Mesa-dev] [PATCH 1/5] i965: Make a few tessellation related functions non-static.
Kenneth Graunke
kenneth at whitecape.org
Fri Apr 22 05:32:05 UTC 2016
Also, move them to brw_shader.cpp so they're in a location for code
used by both the vec4 and fs worlds.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_shader.cpp | 47 ++++++++++++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_shader.h | 4 +++
src/mesa/drivers/dri/i965/brw_vec4_tcs.cpp | 47 ------------------------------
3 files changed, 51 insertions(+), 47 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 376cb25..b3aade1 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -582,6 +582,53 @@ brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg)
return false;
}
+unsigned
+tesslevel_outer_components(GLenum tes_primitive_mode)
+{
+ switch (tes_primitive_mode) {
+ case GL_QUADS:
+ return 4;
+ case GL_TRIANGLES:
+ return 3;
+ case GL_ISOLINES:
+ return 2;
+ default:
+ unreachable("Bogus tessellation domain");
+ }
+ return 0;
+}
+
+unsigned
+tesslevel_inner_components(GLenum tes_primitive_mode)
+{
+ switch (tes_primitive_mode) {
+ case GL_QUADS:
+ return 2;
+ case GL_TRIANGLES:
+ return 1;
+ case GL_ISOLINES:
+ return 0;
+ default:
+ unreachable("Bogus tessellation domain");
+ }
+ return 0;
+}
+
+/**
+ * Given a normal .xyzw writemask, convert it to a writemask for a vector
+ * that's stored backwards, i.e. .wzyx.
+ */
+unsigned
+writemask_for_backwards_vector(unsigned mask)
+{
+ unsigned new_mask = 0;
+
+ for (int i = 0; i < 4; i++)
+ new_mask |= ((mask >> i) & 1) << (3 - i);
+
+ return new_mask;
+}
+
backend_shader::backend_shader(const struct brw_compiler *compiler,
void *log_data,
void *mem_ctx,
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 15bed78..fc228f6 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -292,6 +292,10 @@ int type_size_scalar(const struct glsl_type *type);
int type_size_vec4(const struct glsl_type *type);
int type_size_vec4_times_4(const struct glsl_type *type);
+unsigned tesslevel_outer_components(GLenum tes_primitive_mode);
+unsigned tesslevel_inner_components(GLenum tes_primitive_mode);
+unsigned writemask_for_backwards_vector(unsigned mask);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_tcs.cpp b/src/mesa/drivers/dri/i965/brw_vec4_tcs.cpp
index 28aaaeb..8e2713a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_tcs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_tcs.cpp
@@ -286,53 +286,6 @@ vec4_tcs_visitor::emit_urb_write(const src_reg &value,
inst->base_mrf = -1;
}
-static unsigned
-tesslevel_outer_components(GLenum tes_primitive_mode)
-{
- switch (tes_primitive_mode) {
- case GL_QUADS:
- return 4;
- case GL_TRIANGLES:
- return 3;
- case GL_ISOLINES:
- return 2;
- default:
- unreachable("Bogus tessellation domain");
- }
- return 0;
-}
-
-static unsigned
-tesslevel_inner_components(GLenum tes_primitive_mode)
-{
- switch (tes_primitive_mode) {
- case GL_QUADS:
- return 2;
- case GL_TRIANGLES:
- return 1;
- case GL_ISOLINES:
- return 0;
- default:
- unreachable("Bogus tessellation domain");
- }
- return 0;
-}
-
-/**
- * Given a normal .xyzw writemask, convert it to a writemask for a vector
- * that's stored backwards, i.e. .wzyx.
- */
-static unsigned
-writemask_for_backwards_vector(unsigned mask)
-{
- unsigned new_mask = 0;
-
- for (int i = 0; i < 4; i++)
- new_mask |= ((mask >> i) & 1) << (3 - i);
-
- return new_mask;
-}
-
void
vec4_tcs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
{
--
2.8.0
More information about the mesa-dev
mailing list