<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Nov 21, 2016, at 11:52 AM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Fixes a few things:<br class="">
- sprite coords only apply to generic varyings, and are a bitmask<br class="">
- back color only applies in 2-sided lighting mode<br class="">
- handle some odd situations between only some front/back colors being<br class="">
there. This is only semi-legal in GL, but we shouldn't start<br class="">
crashing.<br class="">
<br class="">
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>><br class="">
---<br class="">
src/gallium/drivers/swr/swr_shader.cpp | 93 ++++++++++++++++++----------------<br class="">
1 file changed, 50 insertions(+), 43 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp<br class="">
index 2f72239..d29f635 100644<br class="">
--- a/src/gallium/drivers/swr/swr_shader.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_shader.cpp<br class="">
@@ -372,15 +372,6 @@ locate_linkage(ubyte name, ubyte index, struct tgsi_shader_info *info)<br class="">
}<br class="">
}<br class="">
<br class="">
- if (name == TGSI_SEMANTIC_COLOR) { // BCOLOR fallback<br class="">
- for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {<br class="">
- if ((info->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR)<br class="">
- && (info->output_semantic_index[i] == index)) {<br class="">
- return i - 1; // position is not part of the linkage<br class="">
- }<br class="">
- }<br class="">
- }<br class="">
-<br class="">
return 0xFFFFFFFF;<br class="">
}<br class="">
<br class="">
@@ -523,54 +514,70 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)<br class="">
<br class="">
unsigned linkedAttrib =<br class="">
locate_linkage(semantic_name, semantic_idx, &ctx->vs->info.base);<br class="">
- if (linkedAttrib == 0xFFFFFFFF) {<br class="">
- // not found - check for point sprite<br class="">
- if (ctx->rasterizer->sprite_coord_enable) {<br class="">
- linkedAttrib = ctx->vs->info.base.num_outputs - 1;<br class="">
- swr_fs->pointSpriteMask |= (1 << linkedAttrib);<br class="">
- } else {<br class="">
- fprintf(stderr,<br class="">
- "Missing %s[%d]\n",<br class="">
- tgsi_semantic_names[semantic_name],<br class="">
- semantic_idx);<br class="">
- assert(0 && "attribute linkage not found");<br class="">
+ if (semantic_name == TGSI_SEMANTIC_GENERIC &&<br class="">
+ ctx->rasterizer->sprite_coord_enable & (1 << semantic_idx)) {<br class="">
+ /* we add an extra attrib to the backendState in swr_update_derived. */<br class="">
+ linkedAttrib = ctx->vs->info.base.num_outputs - 1;<br class="">
+ swr_fs->pointSpriteMask |= (1 << linkedAttrib);<br class="">
+ } else if (linkedAttrib == 0xFFFFFFFF) {<br class="">
+ inputs[attrib][0] = wrap(VIMMED1(0.0f));<br class="">
+ inputs[attrib][1] = wrap(VIMMED1(0.0f));<br class="">
+ inputs[attrib][2] = wrap(VIMMED1(0.0f));<br class="">
+ inputs[attrib][3] = wrap(VIMMED1(1.0f));<br class="">
+ /* If we're reading in color and 2-sided lighting is enabled, we have<br class="">
+ * to keep going.<br class="">
+ */<br class="">
+ if (semantic_name != TGSI_SEMANTIC_COLOR || !key.light_twoside)<br class="">
+ continue;<br class="">
+ } else {<br class="">
+ if (interpMode == TGSI_INTERPOLATE_CONSTANT) {<br class="">
+ swr_fs->constantMask |= 1 << linkedAttrib;<br class="">
+ } else if (interpMode == TGSI_INTERPOLATE_COLOR) {<br class="">
+ swr_fs->flatConstantMask |= 1 << linkedAttrib;<br class="">
}<br class="">
}<br class="">
<br class="">
- if (interpMode == TGSI_INTERPOLATE_CONSTANT) {<br class="">
- swr_fs->constantMask |= 1 << linkedAttrib;<br class="">
- } else if (interpMode == TGSI_INTERPOLATE_COLOR) {<br class="">
- swr_fs->flatConstantMask |= 1 << linkedAttrib;<br class="">
- }<br class="">
-<br class="">
- for (int channel = 0; channel < TGSI_NUM_CHANNELS; channel++) {<br class="">
- if (mask & (1 << channel)) {<br class="">
- Value *indexA = C(linkedAttrib * 12 + channel);<br class="">
- Value *indexB = C(linkedAttrib * 12 + channel + 4);<br class="">
- Value *indexC = C(linkedAttrib * 12 + channel + 8);<br class="">
+ unsigned bcolorAttrib = 0xFFFFFFFF;<br class="">
+ Value *offset = NULL;<br class="">
+ if (semantic_name == TGSI_SEMANTIC_COLOR && key.light_twoside) {<br class="">
+ bcolorAttrib = locate_linkage(<br class="">
+ TGSI_SEMANTIC_BCOLOR, semantic_idx, &ctx->vs->info.base);<br class="">
+ /* Neither front nor back colors were available. Nothing to load. */<br class="">
+ if (bcolorAttrib == 0xFFFFFFFF && linkedAttrib == 0xFFFFFFFF)<br class="">
+ continue;<br class="">
+ /* If there is no front color, just always use the back color. */<br class="">
+ if (linkedAttrib == 0xFFFFFFFF)<br class="">
+ linkedAttrib = bcolorAttrib;<br class="">
<br class="">
- if ((semantic_name == TGSI_SEMANTIC_COLOR)<br class="">
- && ctx->rasterizer->light_twoside) {<br class="">
- unsigned bcolorAttrib = locate_linkage(<br class="">
- TGSI_SEMANTIC_BCOLOR, semantic_idx, &ctx->vs->info.base);<br class="">
+ if (bcolorAttrib != 0xFFFFFFFF) {<br class="">
+ if (interpMode == TGSI_INTERPOLATE_CONSTANT) {<br class="">
+ swr_fs->constantMask |= 1 << bcolorAttrib;<br class="">
+ } else if (interpMode == TGSI_INTERPOLATE_COLOR) {<br class="">
+ swr_fs->flatConstantMask |= 1 << bcolorAttrib;<br class="">
+ }<br class="">
<br class="">
- unsigned diff = 12 * (bcolorAttrib - linkedAttrib);<br class="">
+ unsigned diff = 12 * (bcolorAttrib - linkedAttrib);<br class="">
<br class="">
+ if (diff) {<br class="">
Value *back =<br class="">
XOR(C(1), LOAD(pPS, {0, SWR_PS_CONTEXT_frontFace}), "backFace");<br class="">
<br class="">
- Value *offset = MUL(back, C(diff));<br class="">
+ offset = MUL(back, C(diff));<br class="">
offset->setName("offset");<br class="">
+ }<br class="">
+ }<br class="">
+ }<br class="">
<br class="">
+ for (int channel = 0; channel < TGSI_NUM_CHANNELS; channel++) {<br class="">
+ if (mask & (1 << channel)) {<br class="">
+ Value *indexA = C(linkedAttrib * 12 + channel);<br class="">
+ Value *indexB = C(linkedAttrib * 12 + channel + 4);<br class="">
+ Value *indexC = C(linkedAttrib * 12 + channel + 8);<br class="">
+<br class="">
+ if (offset) {<br class="">
indexA = ADD(indexA, offset);<br class="">
indexB = ADD(indexB, offset);<br class="">
indexC = ADD(indexC, offset);<br class="">
-<br class="">
- if (interpMode == TGSI_INTERPOLATE_CONSTANT) {<br class="">
- swr_fs->constantMask |= 1 << bcolorAttrib;<br class="">
- } else if (interpMode == TGSI_INTERPOLATE_COLOR) {<br class="">
- swr_fs->flatConstantMask |= 1 << bcolorAttrib;<br class="">
- }<br class="">
}<br class="">
<br class="">
Value *va = VBROADCAST(LOAD(GEP(pAttribs, indexA)));<br class="">
-- <br class="">
2.7.3<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>