<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Jul 27, 2017, at 1:25 PM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On
Wed, Jul 26, 2017 at 6:27 PM, George Kyriazis</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><</span><a href="mailto:george.kyriazis@intel.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">george.kyriazis@intel.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">>
wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">
The shader that is used to copy vertex data out of the vs/gs shaders to<br class="">
the user-specified buffer (streamout or SO shader) was not using the<br class="">
correct offsets.<br class="">
<br class="">
Adjust the offsets that are used just for the SO shader:<br class="">
- Make sure that position is handled in the same special way<br class="">
as in the vs/gs shaders<br class="">
- Use the correct offset to be passed in the core<br class="">
- consolidate register slot mapping logic into one function, since it's<br class="">
been calculated in 2 different places (one for calcuating the slot mask,<br class="">
and one for the register offsets themselves<br class="">
<br class="">
Also make room for all attibutes in the backend vertex area.<br class="">
<br class="">
Fixes:<br class="">
- all vtk GL2PS tests<br class="">
- 18 piglit tests (16 ext_transform_feedback tests,<br class="">
arb-quads-follow-provoking-vertex and primitive-type gl_points<br class="">
<br class="">
v2:<br class="">
<br class="">
- take care of more SGV slots in slot mapping logic<br class="">
- trim feState.vsVertexSize<br class="">
- fix GS interface and incorporate GS while calculating vsVertexSize<br class="">
<br class="">
Note that vsVertexSize is used in the core as the one parameter that<br class="">
controls vertex size between all stages, so it has to be adjusted appropriately<br class="">
for the whole vs/gs/fs pipeline.<br class="">
<br class="">
fixes:<br class="">
- fixes total of 20 piglit tests<br class="">
<br class="">
CC: 17.2 <<a href="mailto:mesa-stable@lists.freedesktop.org" class="">mesa-stable@lists.freedesktop.org</a>><br class="">
---<br class="">
src/gallium/drivers/swr/swr_draw.cpp | 38 +++++++++++++++++++++++++++++-----<br class="">
src/gallium/drivers/swr/swr_shader.cpp | 32 +++++++++++++++++++++++++++-<br class="">
src/gallium/drivers/swr/swr_shader.h | 3 +++<br class="">
src/gallium/drivers/swr/swr_state.cpp | 5 +++--<br class="">
4 files changed, 70 insertions(+), 8 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp<br class="">
index 62ad3f7..38a711e 100644<br class="">
--- a/src/gallium/drivers/swr/swr_draw.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_draw.cpp<br class="">
@@ -81,8 +81,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)<br class="">
offsets[output_buffer] = so->output[i].dst_offset;<br class="">
}<br class="">
<br class="">
+ unsigned attrib_slot = so->output[i].register_index;<br class="">
+ attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);<br class="">
+<br class="">
state.stream.decl[num].bufferIndex = output_buffer;<br class="">
- state.stream.decl[num].attribSlot = so->output[i].register_index - 1;<br class="">
+ state.stream.decl[num].attribSlot = attrib_slot;<br class="">
</blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I'm
confused... this still doesn't take GS into account. There does</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">not
need to be any relation between VS outputs and GS outputs, and the</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">SO
is all in reference to GS outputs (if a GS is there).</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
</div>
</blockquote>
<div>Yes, it doesn’t take GS into account in swr_draw_vbo() at this point. There are some other issues with GS that will prevent it from working. Of course we want to fix it, just not in this patch. This patch fixes the majority of the issues that we are
concerned with relating to SO, which is what is important for 17.2.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">
state.stream.decl[num].componentMask =<br class="">
((1 << so->output[i].num_components) - 1)<br class="">
<< so->output[i].start_component;<br class="">
@@ -129,10 +132,35 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)<br class="">
* XXX setup provokingVertex & topologyProvokingVertex */<br class="">
SWR_FRONTEND_STATE feState = {0};<br class="">
<br class="">
- feState.vsVertexSize =<br class="">
- VERTEX_ATTRIB_START_SLOT +<br class="">
- + ctx->vs->info.base.num_outputs<br class="">
- - (ctx->vs->info.base.writes_position ? 1 : 0);<br class="">
+ // feState.vsVertexSize seeds the PA size that is used as an interface<br class="">
+ // between all the shader stages, so it has to be large enough to<br class="">
+ // incorporate all interfaces between stages<br class="">
+<br class="">
+ // max of gs and vs num_outputs<br class="">
+ feState.vsVertexSize = ctx->vs->info.base.num_outputs;<br class="">
+ if (ctx->gs &&<br class="">
+ ctx->gs->info.base.num_outputs > feState.vsVertexSize) {<br class="">
+ feState.vsVertexSize = ctx->gs->info.base.num_outputs;<br class="">
+ }<br class="">
+<br class="">
+ if (ctx->vs->info.base.num_outputs)<br class="">
+ // gs does not adjust for position in SGV slot at input from vs<br class="">
+ if (!ctx->gs)<br class="">
+ feState.vsVertexSize--;<br class="">
+<br class="">
+ // other (non-SGV) slots start at VERTEX_ATTRIB_START_SLOT<br class="">
+ feState.vsVertexSize += VERTEX_ATTRIB_START_SLOT;<br class="">
+<br class="">
+ // The PA in the clipper does not handle BE vertex sizes<br class="">
+ // different from FE. Increase vertexsize only for the cases that needed it<br class="">
+<br class="">
+ // primid needs a slot<br class="">
+ if (ctx->fs->info.base.uses_primid)<br class="">
+ feState.vsVertexSize++;<br class="">
+ // sprite coord enable<br class="">
+ if (ctx->rasterizer->sprite_coord_enable)<br class="">
+ feState.vsVertexSize++;<br class="">
+<br class="">
<br class="">
if (ctx->rasterizer->flatshade_first) {<br class="">
feState.provokingVertex = {1, 0, 0};<br class="">
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp<br class="">
index 83b49c4..0a81eaa 100644<br class="">
--- a/src/gallium/drivers/swr/swr_shader.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_shader.cpp<br class="">
@@ -414,7 +414,10 @@ BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base<br class="">
} else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_POSITION) {<br class="">
attribSlot = VERTEX_POSITION_SLOT;<br class="">
} else {<br class="">
- attribSlot = VERTEX_ATTRIB_START_SLOT + attrib - 1;<br class="">
+ attribSlot = VERTEX_ATTRIB_START_SLOT + attrib;<br class="">
+ if (iface->info->writes_position) {<br class="">
+ attribSlot--;<br class="">
+ }<br class="">
}<br class="">
<br class="">
#if USE_SIMD16_FRONTEND<br class="">
@@ -923,6 +926,33 @@ swr_compile_vs(struct swr_context *ctx, swr_jit_vs_key &key)<br class="">
return func;<br class="">
}<br class="">
<br class="">
+unsigned<br class="">
+swr_so_adjust_attrib(unsigned in_attrib,<br class="">
+ swr_vertex_shader *swr_vs)<br class="">
+{<br class="">
+ ubyte semantic_name;<br class="">
+ unsigned attrib;<br class="">
+<br class="">
+ attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;<br class="">
+<br class="">
+ if (swr_vs) {<br class="">
+ semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];<br class="">
+ if (semantic_name == TGSI_SEMANTIC_POSITION) {<br class="">
+ attrib = VERTEX_POSITION_SLOT;<br class="">
+ } else if (semantic_name == TGSI_SEMANTIC_PSIZE) {<br class="">
+ attrib = VERTEX_SGV_SLOT;<br class="">
+ } else if (semantic_name == TGSI_SEMANTIC_LAYER) {<br class="">
+ attrib = VERTEX_SGV_SLOT;<br class="">
+ } else {<br class="">
+ if (swr_vs->info.base.writes_position) {<br class="">
+ attrib--;<br class="">
+ }<br class="">
+ }<br class="">
+ }<br class="">
+<br class="">
+ return attrib;<br class="">
+}<br class="">
+<br class="">
static unsigned<br class="">
locate_linkage(ubyte name, ubyte index, struct tgsi_shader_info *info)<br class="">
{<br class="">
diff --git a/src/gallium/drivers/swr/swr_shader.h b/src/gallium/drivers/swr/swr_shader.h<br class="">
index 1ab6846..6468874 100644<br class="">
--- a/src/gallium/drivers/swr/swr_shader.h<br class="">
+++ b/src/gallium/drivers/swr/swr_shader.h<br class="">
@@ -30,6 +30,9 @@ struct swr_jit_fs_key;<br class="">
struct swr_jit_vs_key;<br class="">
struct swr_jit_gs_key;<br class="">
<br class="">
+unsigned swr_so_adjust_attrib(unsigned in_attrib,<br class="">
+ swr_vertex_shader *swr_vs);<br class="">
+<br class="">
PFN_VERTEX_FUNC<br class="">
swr_compile_vs(struct swr_context *ctx, swr_jit_vs_key &key);<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp<br class="">
index 501fdea..47ab445 100644<br class="">
--- a/src/gallium/drivers/swr/swr_state.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_state.cpp<br class="">
@@ -345,13 +345,14 @@ swr_create_vs_state(struct pipe_context *pipe,<br class="">
// soState.streamToRasterizer not used<br class="">
<br class="">
for (uint32_t i = 0; i < stream_output->num_outputs; i++) {<br class="">
+ unsigned attrib_slot = stream_output->output[i].register_index;<br class="">
+ attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);<br class="">
swr_vs->soState.streamMasks[stream_output->output[i].stream] |=<br class="">
- 1 << (stream_output->output[i].register_index - 1);<br class="">
+ (1 << attrib_slot);<br class="">
}<br class="">
for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {<br class="">
swr_vs->soState.streamNumEntries[i] =<br class="">
_mm_popcnt_u32(swr_vs->soState.streamMasks[i]);<br class="">
- swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // TODO: optimize<br class="">
}<br class="">
}<br class="">
<br class="">
--<br class="">
2.7.4<br class="">
<br class="">
_______________________________________________<br class="">
mesa-dev mailing list<br class="">
<a href="mailto:mesa-dev@lists.freedesktop.org" class="">mesa-dev@lists.freedesktop.org</a><br class="">
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" class="">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br class="">
</blockquote>
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">mesa-dev
mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="mailto:mesa-dev@lists.freedesktop.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">mesa-dev@lists.freedesktop.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></div>
</blockquote>
</div>
<br class="">
</body>
</html>