<div dir="ltr"><div>We've been talking about switching frag_coord to an intrinsic in i965 for a while. It'll take a bit of work, but it's probably good to have the intrinsic anyway.<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 5, 2017 at 3:47 AM, Nicolai Hähnle <span dir="ltr"><<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Nicolai Hähnle <<a href="mailto:nicolai.haehnle@amd.com">nicolai.haehnle@amd.com</a>><br>
<br>
Some drivers prefer to treat gl_FragCoord as a system value rather than<br>
a fragment shader input, see Const.GLSLFragCoordIsSysVal.<br>
---<br>
src/compiler/nir/nir.c | 4 ++++<br>
src/compiler/nir/nir_gather_<wbr>info.c | 1 +<br>
src/compiler/nir/nir_<wbr>intrinsics.h | 1 +<br>
3 files changed, 6 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c<br>
index f81f4ee..bb4e684 100644<br>
--- a/src/compiler/nir/nir.c<br>
+++ b/src/compiler/nir/nir.c<br>
@@ -1884,20 +1884,22 @@ nir_intrinsic_from_system_<wbr>value(gl_system_value val)<br>
case SYSTEM_VALUE_DRAW_ID:<br>
return nir_intrinsic_load_draw_id;<br>
case SYSTEM_VALUE_BASE_INSTANCE:<br>
return nir_intrinsic_load_base_<wbr>instance;<br>
case SYSTEM_VALUE_VERTEX_ID_ZERO_<wbr>BASE:<br>
return nir_intrinsic_load_vertex_id_<wbr>zero_base;<br>
case SYSTEM_VALUE_BASE_VERTEX:<br>
return nir_intrinsic_load_base_<wbr>vertex;<br>
case SYSTEM_VALUE_INVOCATION_ID:<br>
return nir_intrinsic_load_invocation_<wbr>id;<br>
+ case SYSTEM_VALUE_FRAG_COORD:<br>
+ return nir_intrinsic_load_frag_coord;<br>
case SYSTEM_VALUE_FRONT_FACE:<br>
return nir_intrinsic_load_front_face;<br>
case SYSTEM_VALUE_SAMPLE_ID:<br>
return nir_intrinsic_load_sample_id;<br>
case SYSTEM_VALUE_SAMPLE_POS:<br>
return nir_intrinsic_load_sample_pos;<br>
case SYSTEM_VALUE_SAMPLE_MASK_IN:<br>
return nir_intrinsic_load_sample_<wbr>mask_in;<br>
case SYSTEM_VALUE_LOCAL_INVOCATION_<wbr>ID:<br>
return nir_intrinsic_load_local_<wbr>invocation_id;<br>
@@ -1937,20 +1939,22 @@ nir_system_value_from_<wbr>intrinsic(nir_intrinsic_op intrin)<br>
case nir_intrinsic_load_draw_id:<br>
return SYSTEM_VALUE_DRAW_ID;<br>
case nir_intrinsic_load_base_<wbr>instance:<br>
return SYSTEM_VALUE_BASE_INSTANCE;<br>
case nir_intrinsic_load_vertex_id_<wbr>zero_base:<br>
return SYSTEM_VALUE_VERTEX_ID_ZERO_<wbr>BASE;<br>
case nir_intrinsic_load_base_<wbr>vertex:<br>
return SYSTEM_VALUE_BASE_VERTEX;<br>
case nir_intrinsic_load_invocation_<wbr>id:<br>
return SYSTEM_VALUE_INVOCATION_ID;<br>
+ case nir_intrinsic_load_frag_coord:<br>
+ return SYSTEM_VALUE_FRAG_COORD;<br>
case nir_intrinsic_load_front_face:<br>
return SYSTEM_VALUE_FRONT_FACE;<br>
case nir_intrinsic_load_sample_id:<br>
return SYSTEM_VALUE_SAMPLE_ID;<br>
case nir_intrinsic_load_sample_pos:<br>
return SYSTEM_VALUE_SAMPLE_POS;<br>
case nir_intrinsic_load_sample_<wbr>mask_in:<br>
return SYSTEM_VALUE_SAMPLE_MASK_IN;<br>
case nir_intrinsic_load_local_<wbr>invocation_id:<br>
return SYSTEM_VALUE_LOCAL_INVOCATION_<wbr>ID;<br>
diff --git a/src/compiler/nir/nir_gather_<wbr>info.c b/src/compiler/nir/nir_gather_<wbr>info.c<br>
index 24ac74e..ac87bec 100644<br>
--- a/src/compiler/nir/nir_gather_<wbr>info.c<br>
+++ b/src/compiler/nir/nir_gather_<wbr>info.c<br>
@@ -220,20 +220,21 @@ gather_intrinsic_info(nir_<wbr>intrinsic_instr *instr, nir_shader *shader)<br>
for (uint i = 0; i < glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
int idx = var->data.location + i;<br>
shader->info.double_inputs_<wbr>read |= BITFIELD64_BIT(idx);<br>
}<br>
}<br>
}<br>
break;<br>
}<br>
<br>
case nir_intrinsic_load_draw_id:<br>
+ case nir_intrinsic_load_frag_coord:<br>
case nir_intrinsic_load_front_face:<br>
case nir_intrinsic_load_vertex_id:<br>
case nir_intrinsic_load_vertex_id_<wbr>zero_base:<br>
case nir_intrinsic_load_base_<wbr>vertex:<br>
case nir_intrinsic_load_base_<wbr>instance:<br>
case nir_intrinsic_load_instance_<wbr>id:<br>
case nir_intrinsic_load_sample_id:<br>
case nir_intrinsic_load_sample_pos:<br>
case nir_intrinsic_load_sample_<wbr>mask_in:<br>
case nir_intrinsic_load_primitive_<wbr>id:<br>
diff --git a/src/compiler/nir/nir_<wbr>intrinsics.h b/src/compiler/nir/nir_<wbr>intrinsics.h<br>
index 21e7d90..dcd9642 100644<br>
--- a/src/compiler/nir/nir_<wbr>intrinsics.h<br>
+++ b/src/compiler/nir/nir_<wbr>intrinsics.h<br>
@@ -297,20 +297,21 @@ INTRINSIC(shared_atomic_comp_<wbr>swap, 3, ARR(1, 1, 1), true, 1, 0, 1, BASE, xx, xx,<br>
#ifndef DEFINE_SYSTEM_VALUE<br>
#define DEFINE_SYSTEM_VALUE(name)<br>
#endif<br>
<br>
#define SYSTEM_VALUE(name, components, num_indices, idx0, idx1, idx2) \<br>
DEFINE_SYSTEM_VALUE(name) \<br>
INTRINSIC(load_##name, 0, ARR(0), true, components, 0, num_indices, \<br>
idx0, idx1, idx2, \<br>
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)<br>
<br>
+SYSTEM_VALUE(frag_coord, 4, 0, xx, xx, xx)<br>
SYSTEM_VALUE(front_face, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(vertex_id, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(vertex_id_zero_<wbr>base, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(base_vertex, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(instance_id, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(base_instance, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(draw_id, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(sample_id, 1, 0, xx, xx, xx)<br>
SYSTEM_VALUE(sample_pos, 2, 0, xx, xx, xx)<br>
SYSTEM_VALUE(sample_mask_in, 1, 0, xx, xx, xx)<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>