LLVMValueRef emitted_prims_vec;
LLVMValueRef total_emitted_vertices_vec;
LLVMValueRef emitted_vertices_vec;
+ /* if a shader doesn't have ENDPRIM instruction but it has
+ * a number of EMIT instructions it means the END instruction
+ * implicitly invokes ENDPRIM. handle this via a flag here
+ * in the future maybe we can enforce TGSI to always have
+ * an explicit ENDPRIM */
+ boolean pending_end_primitive;
LLVMValueRef consts_ptr;
const LLVMValueRef *pos;
LLVMBuildAdd(builder, bld->emitted_vertices_vec, masked_ones, "");
bld->total_emitted_vertices_vec =
LLVMBuildAdd(builder, bld->total_emitted_vertices_vec, masked_ones, "");
+ bld->pending_end_primitive = TRUE;
}
}
bld->emitted_prims_vec =
LLVMBuildAdd(builder, bld->emitted_prims_vec, masked_ones, "");
bld->emitted_vertices_vec = bld_base->uint_bld.zero;
+ bld->pending_end_primitive = FALSE;
}
}
/* If we have indirect addressing in outputs we need to copy our alloca array
* to the outputs slots specified by the caller */
if (bld->gs_iface) {
+ /* flush the accumulated vertices as a primitive */
+ if (bld->pending_end_primitive) {
+ end_primitive(NULL, bld_base, NULL);
+ bld->pending_end_primitive = FALSE;
+ }
+
bld->gs_iface->gs_epilogue(&bld->bld_base,
bld->total_emitted_vertices_vec,
bld->emitted_prims_vec,
/* inputs are always indirect with gs */
bld.indirect_files |= (1 << TGSI_FILE_INPUT);
bld.gs_iface = gs_iface;
+ bld.pending_end_primitive = FALSE;
bld.bld_base.emit_fetch_funcs[TGSI_FILE_INPUT] = emit_fetch_gs_input;
bld.bld_base.op_actions[TGSI_OPCODE_EMIT].emit = emit_vertex;
bld.bld_base.op_actions[TGSI_OPCODE_ENDPRIM].emit = end_primitive;