[Mesa-dev] [PATCH 3/5] draw/llvm: fix viewport transformations

Zack Rusin zackr at vmware.com
Thu Apr 25 10:44:49 PDT 2013


----- Original Message -----
> Am 24.04.2013 00:58, schrieb Zack Rusin:
> > This was a very serious bug. We were always doing the viewport
> > transformations on the first output of the vertex shader. That means
> > that every application that was storing position in anything but
> > OUT[0] was outputing untransformed vertices and had broken output
> > for whatever it was storing at OUT[0]. Correctly take into
> > consideration where the vertex position is actually stored.
> > 
> > Signed-off-by: Zack Rusin <zackr at vmware.com>
> > ---
> >  src/gallium/auxiliary/draw/draw_llvm.c |    9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/gallium/auxiliary/draw/draw_llvm.c
> > b/src/gallium/auxiliary/draw/draw_llvm.c
> > index 594b0ec..bdd24be 100644
> > --- a/src/gallium/auxiliary/draw/draw_llvm.c
> > +++ b/src/gallium/auxiliary/draw/draw_llvm.c
> > @@ -996,18 +996,19 @@ generate_viewport(struct draw_llvm_variant *variant,
> >     int i;
> >     struct gallivm_state *gallivm = variant->gallivm;
> >     struct lp_type f32_type = vs_type;
> > +   const unsigned pos =
> > draw_current_shader_position_output(variant->llvm->draw);
> >     LLVMTypeRef vs_type_llvm = lp_build_vec_type(gallivm, vs_type);
> > -   LLVMValueRef out3 = LLVMBuildLoad(builder, outputs[0][3], ""); /*w0 w1
> > .. wn*/
> > +   LLVMValueRef out3 = LLVMBuildLoad(builder, outputs[pos][3], ""); /*w0
> > w1 .. wn*/
> >     LLVMValueRef const1 = lp_build_const_vec(gallivm, f32_type, 1.0);
> >     /*1.0 1.0 1.0 1.0*/
> >     LLVMValueRef vp_ptr = draw_jit_context_viewport(gallivm, context_ptr);
> >  
> >     /* for 1/w convention*/
> >     out3 = LLVMBuildFDiv(builder, const1, out3, "");
> > -   LLVMBuildStore(builder, out3, outputs[0][3]);
> > +   LLVMBuildStore(builder, out3, outputs[pos][3]);
> >  
> >     /* Viewport Mapping */
> >     for (i=0; i<3; i++) {
> > -      LLVMValueRef out = LLVMBuildLoad(builder, outputs[0][i], ""); /*x0
> > x1 .. xn*/
> > +      LLVMValueRef out = LLVMBuildLoad(builder, outputs[pos][i], ""); /*x0
> > x1 .. xn*/
> >        LLVMValueRef scale;
> >        LLVMValueRef trans;
> >        LLVMValueRef scale_i;
> > @@ -1033,7 +1034,7 @@ generate_viewport(struct draw_llvm_variant *variant,
> >        out = LLVMBuildFAdd(builder, out, trans, "");
> >  
> >        /* store transformed outputs */
> > -      LLVMBuildStore(builder, out, outputs[0][i]);
> > +      LLVMBuildStore(builder, out, outputs[pos][i]);
> >     }
> >  
> >  }
> > 
> 
> The change itself looks good but I think there's quite some more
> assumptions that position must be output zero elsewhere.

Nothing that I could find in draw. If you're aware of something I'd like to know.

z 


More information about the mesa-dev mailing list