<div dir="ltr">All four Tested-by: Nick Sarnie <<a href="mailto:commendsarnex@gmail.com" target="_blank">commendsarnex@gmail.com</a>> using Gallium Nine.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 9, 2014 at 6:08 PM, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@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: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
---<br>
src/gallium/auxiliary/tgsi/tgsi_ureg.c | 153 ++------------------------<br>
src/gallium/auxiliary/tgsi/tgsi_ureg.h | 35 +-----<br>
src/gallium/auxiliary/util/u_simple_shaders.c | 2 +-<br>
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 12 +-<br>
src/mesa/state_tracker/st_mesa_to_tgsi.c | 12 +-<br>
src/mesa/state_tracker/st_program.c | 23 ++--<br>
6 files changed, 43 insertions(+), 194 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c<br>
index 6d3ac91..f524dfb 100644<br>
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c<br>
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c<br>
@@ -165,15 +165,7 @@ struct ureg_program<br>
struct const_decl const_decls;<br>
struct const_decl const_decls2D[PIPE_MAX_CONSTANT_BUFFERS];<br>
<br>
- unsigned property_gs_input_prim;<br>
- unsigned property_gs_output_prim;<br>
- unsigned property_gs_max_vertices;<br>
- unsigned property_gs_invocations;<br>
- unsigned char property_fs_coord_origin; /* = TGSI_FS_COORD_ORIGIN_* */<br>
- unsigned char property_fs_coord_pixel_center; /* = TGSI_FS_COORD_PIXEL_CENTER_* */<br>
- unsigned char property_fs_color0_writes_all_cbufs; /* = TGSI_FS_COLOR0_WRITES_ALL_CBUFS * */<br>
- unsigned char property_fs_depth_layout; /* TGSI_FS_DEPTH_LAYOUT */<br>
- boolean property_vs_window_space_position; /* TGSI_VS_WINDOW_SPACE_POSITION */<br>
+ unsigned properties[TGSI_PROPERTY_COUNT];<br>
<br>
unsigned nr_addrs;<br>
unsigned nr_preds;<br>
@@ -278,65 +270,10 @@ ureg_dst_register( unsigned file,<br>
<br>
<br>
void<br>
-ureg_property_gs_input_prim(struct ureg_program *ureg,<br>
- unsigned input_prim)<br>
+ureg_property(struct ureg_program *ureg, unsigned name, unsigned value)<br>
{<br>
- ureg->property_gs_input_prim = input_prim;<br>
-}<br>
-<br>
-void<br>
-ureg_property_gs_output_prim(struct ureg_program *ureg,<br>
- unsigned output_prim)<br>
-{<br>
- ureg->property_gs_output_prim = output_prim;<br>
-}<br>
-<br>
-void<br>
-ureg_property_gs_max_vertices(struct ureg_program *ureg,<br>
- unsigned max_vertices)<br>
-{<br>
- ureg->property_gs_max_vertices = max_vertices;<br>
-}<br>
-void<br>
-ureg_property_gs_invocations(struct ureg_program *ureg,<br>
- unsigned invocations)<br>
-{<br>
- ureg->property_gs_invocations = invocations;<br>
-}<br>
-<br>
-void<br>
-ureg_property_fs_coord_origin(struct ureg_program *ureg,<br>
- unsigned fs_coord_origin)<br>
-{<br>
- ureg->property_fs_coord_origin = fs_coord_origin;<br>
-}<br>
-<br>
-void<br>
-ureg_property_fs_coord_pixel_center(struct ureg_program *ureg,<br>
- unsigned fs_coord_pixel_center)<br>
-{<br>
- ureg->property_fs_coord_pixel_center = fs_coord_pixel_center;<br>
-}<br>
-<br>
-void<br>
-ureg_property_fs_color0_writes_all_cbufs(struct ureg_program *ureg,<br>
- unsigned fs_color0_writes_all_cbufs)<br>
-{<br>
- ureg->property_fs_color0_writes_all_cbufs = fs_color0_writes_all_cbufs;<br>
-}<br>
-<br>
-void<br>
-ureg_property_fs_depth_layout(struct ureg_program *ureg,<br>
- unsigned fs_depth_layout)<br>
-{<br>
- ureg->property_fs_depth_layout = fs_depth_layout;<br>
-}<br>
-<br>
-void<br>
-ureg_property_vs_window_space_position(struct ureg_program *ureg,<br>
- boolean vs_window_space_position)<br>
-{<br>
- ureg->property_vs_window_space_position = vs_window_space_position;<br>
+ assert(name < Elements(ureg->properties));<br>
+ ureg->properties[name] = value;<br>
}<br>
<br>
struct ureg_src<br>
@@ -1452,77 +1389,9 @@ static void emit_decls( struct ureg_program *ureg )<br>
{<br>
unsigned i;<br>
<br>
- if (ureg->property_gs_input_prim != ~0) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_GS_INPUT_PRIM,<br>
- ureg->property_gs_input_prim);<br>
- }<br>
-<br>
- if (ureg->property_gs_output_prim != ~0) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_GS_OUTPUT_PRIM,<br>
- ureg->property_gs_output_prim);<br>
- }<br>
-<br>
- if (ureg->property_gs_max_vertices != ~0) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,<br>
- ureg->property_gs_max_vertices);<br>
- }<br>
-<br>
- if (ureg->property_gs_invocations != ~0) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_GS_INVOCATIONS,<br>
- ureg->property_gs_invocations);<br>
- }<br>
-<br>
- if (ureg->property_fs_coord_origin) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_FS_COORD_ORIGIN,<br>
- ureg->property_fs_coord_origin);<br>
- }<br>
-<br>
- if (ureg->property_fs_coord_pixel_center) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,<br>
- ureg->property_fs_coord_pixel_center);<br>
- }<br>
-<br>
- if (ureg->property_fs_color0_writes_all_cbufs) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS,<br>
- ureg->property_fs_color0_writes_all_cbufs);<br>
- }<br>
-<br>
- if (ureg->property_fs_depth_layout) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_FS_DEPTH_LAYOUT,<br>
- ureg->property_fs_depth_layout);<br>
- }<br>
-<br>
- if (ureg->property_vs_window_space_position) {<br>
- assert(ureg->processor == TGSI_PROCESSOR_VERTEX);<br>
-<br>
- emit_property(ureg,<br>
- TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION,<br>
- ureg->property_vs_window_space_position);<br>
- }<br>
+ for (i = 0; i < Elements(ureg->properties); i++)<br>
+ if (ureg->properties[i] != ~0)<br>
+ emit_property(ureg, i, ureg->properties[i]);<br>
<br>
if (ureg->processor == TGSI_PROCESSOR_VERTEX) {<br>
for (i = 0; i < UREG_MAX_INPUT; i++) {<br>
@@ -1773,15 +1642,15 @@ void ureg_free_tokens( const struct tgsi_token *tokens )<br>
<br>
struct ureg_program *ureg_create( unsigned processor )<br>
{<br>
+ int i;<br>
struct ureg_program *ureg = CALLOC_STRUCT( ureg_program );<br>
if (ureg == NULL)<br>
goto no_ureg;<br>
<br>
ureg->processor = processor;<br>
- ureg->property_gs_input_prim = ~0;<br>
- ureg->property_gs_output_prim = ~0;<br>
- ureg->property_gs_max_vertices = ~0;<br>
- ureg->property_gs_invocations = ~0;<br>
+<br>
+ for (i = 0; i < Elements(ureg->properties); i++)<br>
+ ureg->properties[i] = ~0;<br>
<br>
ureg->free_temps = util_bitmask_create();<br>
if (ureg->free_temps == NULL)<br>
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h<br>
index f014b53..f254b1e 100644<br>
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h<br>
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h<br>
@@ -153,40 +153,7 @@ ureg_create_shader_and_destroy( struct ureg_program *p,<br>
*/<br>
<br>
void<br>
-ureg_property_gs_input_prim(struct ureg_program *ureg,<br>
- unsigned input_prim);<br>
-<br>
-void<br>
-ureg_property_gs_output_prim(struct ureg_program *ureg,<br>
- unsigned output_prim);<br>
-<br>
-void<br>
-ureg_property_gs_max_vertices(struct ureg_program *ureg,<br>
- unsigned max_vertices);<br>
-<br>
-void<br>
-ureg_property_gs_invocations(struct ureg_program *ureg,<br>
- unsigned invocations);<br>
-<br>
-void<br>
-ureg_property_fs_coord_origin(struct ureg_program *ureg,<br>
- unsigned fs_coord_origin);<br>
-<br>
-void<br>
-ureg_property_fs_coord_pixel_center(struct ureg_program *ureg,<br>
- unsigned fs_coord_pixel_center);<br>
-<br>
-void<br>
-ureg_property_fs_color0_writes_all_cbufs(struct ureg_program *ureg,<br>
- unsigned fs_color0_writes_all_cbufs);<br>
-<br>
-void<br>
-ureg_property_fs_depth_layout(struct ureg_program *ureg,<br>
- unsigned fs_depth_layout);<br>
-<br>
-void<br>
-ureg_property_vs_window_space_position(struct ureg_program *ureg,<br>
- boolean vs_window_space_position);<br>
+ureg_property(struct ureg_program *ureg, unsigned name, unsigned value);<br>
<br>
<br>
/***********************************************************************<br>
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c<br>
index 280ed8f..0eeb7d9 100644<br>
--- a/src/gallium/auxiliary/util/u_simple_shaders.c<br>
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c<br>
@@ -84,7 +84,7 @@ util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,<br>
return NULL;<br>
<br>
if (window_space)<br>
- ureg_property_vs_window_space_position(ureg, TRUE);<br>
+ ureg_property(ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, TRUE);<br>
<br>
for (i = 0; i < num_attribs; i++) {<br>
struct ureg_src src;<br>
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp<br>
index 0920987..5eb702e 100644<br>
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp<br>
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp<br>
@@ -4723,7 +4723,8 @@ emit_wpos(struct st_context *st,<br>
}<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) {<br>
/* the driver supports lower-left origin, need to invert Y */<br>
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,<br>
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
invert = TRUE;<br>
}<br>
else<br>
@@ -4733,7 +4734,8 @@ emit_wpos(struct st_context *st,<br>
/* Fragment shader wants origin in lower-left */<br>
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT))<br>
/* the driver supports lower-left origin */<br>
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,<br>
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT))<br>
/* the driver supports upper-left origin, need to invert Y */<br>
invert = TRUE;<br>
@@ -4746,7 +4748,8 @@ emit_wpos(struct st_context *st,<br>
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {<br>
/* the driver supports pixel center integer */<br>
adjY[1] = (float)t->fs_coord_y_flip;<br>
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,<br>
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
}<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) {<br>
/* the driver supports pixel center half integer, need to bias X,Y */<br>
@@ -4765,7 +4768,8 @@ emit_wpos(struct st_context *st,<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {<br>
/* the driver supports pixel center integer, need to bias X,Y */<br>
adjX = adjY[0] = adjY[1] = 0.5f;<br>
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,<br>
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
}<br>
else<br>
assert(0);<br>
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c<br>
index 5659c08..76341b5 100644<br>
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c<br>
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c<br>
@@ -893,7 +893,8 @@ emit_wpos(struct st_context *st,<br>
}<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) {<br>
/* the driver supports lower-left origin, need to invert Y */<br>
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,<br>
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
invert = TRUE;<br>
}<br>
else<br>
@@ -903,7 +904,8 @@ emit_wpos(struct st_context *st,<br>
/* Fragment shader wants origin in lower-left */<br>
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT))<br>
/* the driver supports lower-left origin */<br>
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,<br>
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT))<br>
/* the driver supports upper-left origin, need to invert Y */<br>
invert = TRUE;<br>
@@ -916,7 +918,8 @@ emit_wpos(struct st_context *st,<br>
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {<br>
/* the driver supports pixel center integer */<br>
adjY[1] = (float)!t->fs_coord_y_flip;<br>
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,<br>
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
}<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) {<br>
/* the driver supports pixel center half integer, need to bias X,Y */<br>
@@ -935,7 +938,8 @@ emit_wpos(struct st_context *st,<br>
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {<br>
/* the driver supports pixel center integer, need to bias X,Y */<br>
adjX = adjY[0] = adjY[1] = 0.5f;<br>
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,<br>
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);<br>
}<br>
else<br>
assert(0);<br>
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c<br>
index 926086b..737c269 100644<br>
--- a/src/mesa/state_tracker/st_program.c<br>
+++ b/src/mesa/state_tracker/st_program.c<br>
@@ -742,21 +742,25 @@ st_translate_fragment_program(struct st_context *st,<br>
debug_printf("\n");<br>
}<br>
if (write_all == GL_TRUE)<br>
- ureg_property_fs_color0_writes_all_cbufs(ureg, 1);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS, 1);<br>
<br>
if (stfp->Base.FragDepthLayout != FRAG_DEPTH_LAYOUT_NONE) {<br>
switch (stfp->Base.FragDepthLayout) {<br>
case FRAG_DEPTH_LAYOUT_ANY:<br>
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_ANY);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,<br>
+ TGSI_FS_DEPTH_LAYOUT_ANY);<br>
break;<br>
case FRAG_DEPTH_LAYOUT_GREATER:<br>
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_GREATER);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,<br>
+ TGSI_FS_DEPTH_LAYOUT_GREATER);<br>
break;<br>
case FRAG_DEPTH_LAYOUT_LESS:<br>
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_LESS);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,<br>
+ TGSI_FS_DEPTH_LAYOUT_LESS);<br>
break;<br>
case FRAG_DEPTH_LAYOUT_UNCHANGED:<br>
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_UNCHANGED);<br>
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,<br>
+ TGSI_FS_DEPTH_LAYOUT_UNCHANGED);<br>
break;<br>
default:<br>
assert(0);<br>
@@ -1122,10 +1126,11 @@ st_translate_geometry_program(struct st_context *st,<br>
stgp->tgsi.tokens = NULL;<br>
}<br>
<br>
- ureg_property_gs_input_prim(ureg, stgp->Base.InputType);<br>
- ureg_property_gs_output_prim(ureg, stgp->Base.OutputType);<br>
- ureg_property_gs_max_vertices(ureg, stgp->Base.VerticesOut);<br>
- ureg_property_gs_invocations(ureg, stgp->Base.Invocations);<br>
+ ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType);<br>
+ ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType);<br>
+ ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,<br>
+ stgp->Base.VerticesOut);<br>
+ ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations);<br>
<br>
if (stgp->glsl_to_tgsi)<br>
st_translate_program(st->ctx,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>