Created attachment 131825 [details]
Piglit test reproducing the problem
When comparing a constant to the result of a call to the ballotARB function, or a variable containing the result, an assert in void glsl_to_tgsi_visitor::copy_propagate() can fail. If assertions are disabled, then copy_propagate writes over the end of an allocation, corrupting memory instead.
The attached patch to piglit adds a test reproducing the problem.
Steps to reproduce:
1) Apply attached patch to piglit
2) Run ./piglit run -t arb_shader_ballot shader results/ballot
The newly added test will crash.
The test crashes with:
state_tracker/st_glsl_to_tgsi.cpp:4936: void glsl_to_tgsi_visitor::copy_propagate(): Assertion `inst->dst.file != PROGRAM_TEMPORARY || inst->dst.index < this->next_temp' failed.
I'm using mesa ada3c3aa3da5d04bd597014dc1b5d4b028313513 with an AMD RX480.
Hi James, thanks for the report. I can reproduce and am investigating.
Created attachment 131885 [details] [review]
Please try with the attached patch.
The attached patch fixes the issue for me.
Fixed in Mesa master, commit b28938ffce0580e89e6012826900da2b6013b0df ("st/glsl_to_tgsi: use correct writemask when converting generic intrinsics").