<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<p dir="auto" style="text-align:left; margin-top:25px; margin-bottom:25px; font-family:sans-serif; font-size:11pt; color:black; background-color:white">
Patch 1 looks good to me. Yes, not using compilation key is a recipe for problems.</p>
<p dir="auto" style="text-align:left; margin-top:25px; margin-bottom:25px; font-family:sans-serif; font-size:11pt; color:black; background-color:white">
Regarding patch 2, I need a bit more time to review. I'd also like the new lp_build_umul... function to be added to lp_bld_arit: there is a single caller note, but that might change in the future, so might as well place it in its natural place.</p>
<p dir="auto" style="text-align:left; margin-top:25px; margin-bottom:25px; font-family:sans-serif; font-size:11pt; color:black; background-color:white">
José</p>
<br>
<br>
<br>
<div class="x_gmail_quote">On Thu, Nov 3, 2016 at 10:48 AM +0000, "Nicolai Hähnle"
<span dir="ltr"><<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>></span> wrote:<br>
<br>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On 03.11.2016 02:15, sroland@vmware.com wrote:<br>
> From: Roland Scheidegger <sroland@vmware.com><br>
><br>
> Previous fixes were incomplete - some code still iterated through the number<br>
> of elements provided by velem layout instead of the number stored in the key<br>
> (which is the same as the number defined by the vs). And also actually<br>
> accessed the elements from the layout directly instead of those in the key.<br>
> This mismatch could still cause crashes.<br>
> (Besides, it is a very good idea to only use data stored in the key anyway.)<br>
<br>
Makes sense to me. It would make sense to pull the check for <br>
PIPE_FORMAT_NONE from generate_fetch into draw_llvm_generate for <br>
consistency between the two loops. Either way,<br>
<br>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com><br>
<br>
> ---<br>
> src/gallium/auxiliary/draw/draw_llvm.c | 77 ++++++++++++++++++----------------<br>
> 1 file changed, 40 insertions(+), 37 deletions(-)<br>
><br>
> diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c<br>
> index 2f82d9d..d5fc1c2 100644<br>
> --- a/src/gallium/auxiliary/draw/draw_llvm.c<br>
> +++ b/src/gallium/auxiliary/draw/draw_llvm.c<br>
> @@ -1658,10 +1658,10 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,<br>
> /*<br>
> * Pre-calculate everything which is constant per shader invocation.<br>
> */<br>
> - for (j = 0; j < draw->pt.nr_vertex_elements; ++j) {<br>
> + for (j = 0; j < key->nr_vertex_elements; ++j) {<br>
> LLVMValueRef vb_buffer_offset, buffer_size;<br>
> LLVMValueRef vb_info, vbuffer_ptr;<br>
> - struct pipe_vertex_element *velem = &draw->pt.vertex_element[j];<br>
> + struct pipe_vertex_element *velem = &key->vertex_element[j];<br>
> LLVMValueRef vb_index =<br>
> lp_build_const_int32(gallivm, velem->vertex_buffer_index);<br>
> LLVMValueRef bsize = lp_build_const_int32(gallivm,<br>
> @@ -1669,41 +1669,44 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,<br>
> LLVMValueRef src_offset = lp_build_const_int32(gallivm,<br>
> velem->src_offset);<br>
><br>
> - vbuffer_ptr = LLVMBuildGEP(builder, vbuffers_ptr, &vb_index, 1, "");<br>
> - vb_info = LLVMBuildGEP(builder, vb_ptr, &vb_index, 1, "");<br>
> - vb_stride[j] = draw_jit_vbuffer_stride(gallivm, vb_info);<br>
> - vb_buffer_offset = draw_jit_vbuffer_offset(gallivm, vb_info);<br>
> - map_ptr[j] = draw_jit_dvbuffer_map(gallivm, vbuffer_ptr);<br>
> - buffer_size = draw_jit_dvbuffer_size(gallivm, vbuffer_ptr);<br>
> -<br>
> - ofbit[j] = NULL;<br>
> - stride_fixed[j] = lp_build_uadd_overflow(gallivm, vb_buffer_offset,<br>
> - src_offset, &ofbit[j]);<br>
> - buffer_size_adj[j] = lp_build_usub_overflow(gallivm, buffer_size, bsize,<br>
> - &ofbit[j]);<br>
> -<br>
> - if (velem->instance_divisor) {<br>
> - /* Index is equal to the start instance plus the number of current<br>
> - * instance divided by the divisor. In this case we compute it as:<br>
> - * index = start_instance + (instance_id / divisor)<br>
> - */<br>
> - LLVMValueRef current_instance;<br>
> - current_instance = LLVMBuildUDiv(builder, system_values.instance_id,<br>
> - lp_build_const_int32(gallivm,<br>
> - velem->instance_divisor),<br>
> - "instance_divisor");<br>
> - instance_index[j] = lp_build_uadd_overflow(gallivm, start_instance,<br>
> - current_instance, &ofbit[j]);<br>
> - }<br>
> + if (velem->src_format != PIPE_FORMAT_NONE) {<br>
> + vbuffer_ptr = LLVMBuildGEP(builder, vbuffers_ptr, &vb_index, 1, "");<br>
> + vb_info = LLVMBuildGEP(builder, vb_ptr, &vb_index, 1, "");<br>
> + vb_stride[j] = draw_jit_vbuffer_stride(gallivm, vb_info);<br>
> + vb_buffer_offset = draw_jit_vbuffer_offset(gallivm, vb_info);<br>
> + map_ptr[j] = draw_jit_dvbuffer_map(gallivm, vbuffer_ptr);<br>
> + buffer_size = draw_jit_dvbuffer_size(gallivm, vbuffer_ptr);<br>
> +<br>
> + ofbit[j] = NULL;<br>
> + stride_fixed[j] = lp_build_uadd_overflow(gallivm, vb_buffer_offset,<br>
> + src_offset, &ofbit[j]);<br>
> + buffer_size_adj[j] = lp_build_usub_overflow(gallivm, buffer_size, bsize,<br>
> + &ofbit[j]);<br>
> +<br>
> + if (velem->instance_divisor) {<br>
> + /* Index is equal to the start instance plus the number of current<br>
> + * instance divided by the divisor. In this case we compute it as:<br>
> + * index = start_instance + (instance_id / divisor)<br>
> + */<br>
> + LLVMValueRef current_instance;<br>
> + current_instance = LLVMBuildUDiv(builder, system_values.instance_id,<br>
> + lp_build_const_int32(gallivm,<br>
> + velem->instance_divisor),<br>
> + "instance_divisor");<br>
> + instance_index[j] = lp_build_uadd_overflow(gallivm, start_instance,<br>
> + current_instance, &ofbit[j]);<br>
> + }<br>
><br>
> - if (0) {<br>
> - lp_build_printf(gallivm, "vbuf index = %u, vb_stride is %u\n",<br>
> - vb_index, vb_stride[j]);<br>
> - lp_build_printf(gallivm, " vb_buffer_offset = %u, src_offset is %u\n",<br>
> - vb_buffer_offset, src_offset);<br>
> - lp_build_print_value(gallivm, " blocksize = ", bsize);<br>
> - lp_build_printf(gallivm, " instance_id = %u\n", system_values.instance_id);<br>
> - lp_build_printf(gallivm, " buffer size = %u\n", buffer_size);<br>
> + if (0) {<br>
> + lp_build_printf(gallivm, "vbuf index = %u, vb_stride is %u\n",<br>
> + vb_index, vb_stride[j]);<br>
> + lp_build_printf(gallivm, " vb_buffer_offset = %u, src_offset is %u\n",<br>
> + vb_buffer_offset, src_offset);<br>
> + lp_build_print_value(gallivm, " blocksize = ", bsize);<br>
> + lp_build_printf(gallivm, " instance_id = %u\n",<br>
> + system_values.instance_id);<br>
> + lp_build_printf(gallivm, " buffer size = %u\n", buffer_size);<br>
> + }<br>
> }<br>
> }<br>
><br>
> @@ -1782,7 +1785,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,<br>
> }<br>
><br>
> for (j = 0; j < key->nr_vertex_elements; ++j) {<br>
> - struct pipe_vertex_element *velem = &draw->pt.vertex_element[j];<br>
> + struct pipe_vertex_element *velem = &key->vertex_element[j];<br>
> const struct util_format_description *format_desc =<br>
> util_format_description(velem->src_format);<br>
><br>
><br>
</div>
</span></font>
</body>
</html>