Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit ef3ba64

Browse files
wermanstrassek
authored andcommitted
UPSTREAM: i965: Disable dual source blending when shader doesn't support it on gen8+
Dual source blending behaviour is undefined when shader doesn't have second color output, dismissing fragment in such situation leads to a hang on gen8+ if depth test in enabled. Since blending cannot be gracefully fixed in such case and the result is undefined - blending is simply disabled. v2 (Kenneth Graunke): - Listen to BRW_NEW_FS_PROG_DATA in 3DSTATE_PS_BLEND - Also whack BLEND_STATE[] to keep the two in sync, since we're not sure exactly which copy of the redundant info the hardware will use. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107088 Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> (cherry picked from commit eca4a65)
1 parent 9467b58 commit ef3ba64

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

src/mesa/drivers/dri/i965/genX_state_upload.c

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,7 +3042,26 @@ set_blend_entry_bits(struct brw_context *brw, BLEND_ENTRY_GENXML *entry, int i,
30423042
dstA = fix_dual_blend_alpha_to_one(dstA);
30433043
}
30443044

3045-
entry->ColorBufferBlendEnable = true;
3045+
/* BRW_NEW_FS_PROG_DATA */
3046+
const struct brw_wm_prog_data *wm_prog_data =
3047+
brw_wm_prog_data(brw->wm.base.prog_data);
3048+
3049+
/* The Dual Source Blending documentation says:
3050+
*
3051+
* "If SRC1 is included in a src/dst blend factor and
3052+
* a DualSource RT Write message is not used, results
3053+
* are UNDEFINED. (This reflects the same restriction in DX APIs,
3054+
* where undefined results are produced if “o1” is not written
3055+
* by a PS – there are no default values defined).
3056+
* If SRC1 is not included in a src/dst blend factor,
3057+
* dual source blending must be disabled."
3058+
*
3059+
* There is no way to gracefully fix this undefined situation
3060+
* so we just disable the blending to prevent possible issues.
3061+
*/
3062+
entry->ColorBufferBlendEnable =
3063+
!ctx->Color.Blend[0]._UsesDualSrc || wm_prog_data->dual_src_blend;
3064+
30463065
entry->DestinationBlendFactor = blend_factor(dstRGB);
30473066
entry->SourceBlendFactor = blend_factor(srcRGB);
30483067
entry->DestinationAlphaBlendFactor = blend_factor(dstA);
@@ -3188,6 +3207,7 @@ static const struct brw_tracked_state genX(blend_state) = {
31883207
_NEW_MULTISAMPLE,
31893208
.brw = BRW_NEW_BATCH |
31903209
BRW_NEW_BLORP |
3210+
BRW_NEW_FS_PROG_DATA |
31913211
BRW_NEW_STATE_BASE_ADDRESS,
31923212
},
31933213
.emit = genX(upload_blend_state),
@@ -4814,7 +4834,25 @@ genX(upload_ps_blend)(struct brw_context *brw)
48144834
dstA = fix_dual_blend_alpha_to_one(dstA);
48154835
}
48164836

4817-
pb.ColorBufferBlendEnable = true;
4837+
/* BRW_NEW_FS_PROG_DATA */
4838+
const struct brw_wm_prog_data *wm_prog_data =
4839+
brw_wm_prog_data(brw->wm.base.prog_data);
4840+
4841+
/* The Dual Source Blending documentation says:
4842+
*
4843+
* "If SRC1 is included in a src/dst blend factor and
4844+
* a DualSource RT Write message is not used, results
4845+
* are UNDEFINED. (This reflects the same restriction in DX APIs,
4846+
* where undefined results are produced if “o1” is not written
4847+
* by a PS – there are no default values defined).
4848+
* If SRC1 is not included in a src/dst blend factor,
4849+
* dual source blending must be disabled."
4850+
*
4851+
* There is no way to gracefully fix this undefined situation
4852+
* so we just disable the blending to prevent possible issues.
4853+
*/
4854+
pb.ColorBufferBlendEnable =
4855+
!color->Blend[0]._UsesDualSrc || wm_prog_data->dual_src_blend;
48184856
pb.SourceAlphaBlendFactor = brw_translate_blend_factor(srcA);
48194857
pb.DestinationAlphaBlendFactor = brw_translate_blend_factor(dstA);
48204858
pb.SourceBlendFactor = brw_translate_blend_factor(srcRGB);
@@ -4833,7 +4871,8 @@ static const struct brw_tracked_state genX(ps_blend) = {
48334871
_NEW_MULTISAMPLE,
48344872
.brw = BRW_NEW_BLORP |
48354873
BRW_NEW_CONTEXT |
4836-
BRW_NEW_FRAGMENT_PROGRAM,
4874+
BRW_NEW_FRAGMENT_PROGRAM |
4875+
BRW_NEW_FS_PROG_DATA,
48374876
},
48384877
.emit = genX(upload_ps_blend)
48394878
};

0 commit comments

Comments
 (0)