Kenneth Graunke <kenn...@whitecape.org> writes:

> Intel hardware doesn't natively support textureGrad with shadow
> comparisons.  So we need to generate code to handle it somehow.
>
> Based on the equations of page 205 of the OpenGL 3.0 specification,
> it's possible to compute the LOD value that would be selected given the
> gradient values.  Then, we can simply convert the TXD to a TXL.
>
> Currently, this passes 38/46 of oglconform's shadow-grad subtests,
> and selects the wrong level for the other 6 (but doesn't crash).
>
> While we should investigate the remaining failures, this new method at
> least works better than the old one.  Texturing with explicit gradients,
> shadow sampling, and either projection or texel offsets is pretty
> obscure anyway.
>
> Signed-off-by: Kenneth Graunke <kenn...@whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/Makefile.sources         |    1 +
>  src/mesa/drivers/dri/i965/brw_context.h            |    1 +
>  .../dri/i965/brw_lower_texture_gradients.cpp       |  153 
> ++++++++++++++++++++
>  src/mesa/drivers/dri/i965/brw_shader.cpp           |    1 +
>  4 files changed, 156 insertions(+)
>  create mode 100644 src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
>
> diff --git a/src/mesa/drivers/dri/i965/Makefile.sources 
> b/src/mesa/drivers/dri/i965/Makefile.sources
> index 82143ac..334bfd9 100644
> --- a/src/mesa/drivers/dri/i965/Makefile.sources
> +++ b/src/mesa/drivers/dri/i965/Makefile.sources
> @@ -125,6 +125,7 @@ i965_CXX_FILES = \
>       brw_fs_reg_allocate.cpp \
>       brw_fs_schedule_instructions.cpp \
>       brw_fs_vector_splitting.cpp \
> +     brw_lower_texture_gradients.cpp \
>       brw_shader.cpp \
>       brw_vec4.cpp \
>       brw_vec4_emit.cpp \
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
> b/src/mesa/drivers/dri/i965/brw_context.h
> index c1f2314..b4868fe 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -1276,6 +1276,7 @@ brw_program_reloc(struct brw_context *brw, uint32_t 
> state_offset,
>  }
>  
>  bool brw_do_cubemap_normalize(struct exec_list *instructions);
> +bool brw_lower_texture_gradients(struct exec_list *instructions);
>  
>  #ifdef __cplusplus
>  }
> diff --git a/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp 
> b/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
> new file mode 100644
> index 0000000..2d4f2ab
> --- /dev/null
> +++ b/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp

> +   /* Calculate rho from equation 3.20 of the GL 3.0 specification. */
> +   ir_rvalue *rho;
> +   if (dPdx->type->is_scalar()) {
> +      rho = expr(ir_binop_max, dPdx, dPdy);
> +   } else {
> +      rho = expr(ir_binop_max, expr(ir_unop_sqrt, dot(dPdx, dPdx)),
> +                            expr(ir_unop_sqrt, dot(dPdy, dPdy)));
> +   }

Does the is_scalar() case need an abs() on the two args?  I was thinking
"huh, it would be cool if we recognized how to make the second
expression better automatically", and realized that it doesn't quite
reduce to the is_scalar() case.

Other than that, this series is

Reviewed-by: Eric Anholt <e...@anholt.net>

Attachment: pgphQoko3zLw4.pgp
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to