[Mesa-dev] [PATCH 1/2] st/mesa: fix samplerCubeShadow with bias
From: Marek Olšák marek.ol...@amd.com It has 5 coordinates: (x,y,z,depth,lodbias) Cc: mesa-sta...@lists.freedesktop.org --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e19431..65ef89c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2820,7 +2820,13 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_txb: - opcode = is_cube_array ? TGSI_OPCODE_TXB2 : TGSI_OPCODE_TXB; + if (is_cube_array || + sampler_type == glsl_type::samplerCubeShadow_type) { + opcode = TGSI_OPCODE_TXB2; + } + else { + opcode = TGSI_OPCODE_TXB; + } ir-lod_info.bias-accept(this); lod_info = this-result; if (ir-offset) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: fix samplerCubeShadow with bias
On Fri, Jul 4, 2014 at 8:10 AM, Marek Olšák mar...@gmail.com wrote: From: Marek Olšák marek.ol...@amd.com It has 5 coordinates: (x,y,z,depth,lodbias) Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: Ilia Mirkin imir...@alum.mit.edu Although I still haven't worked out what else is wrong with nouveau... nv50 hits an assert, while nvc0 just generates wrong code. But it does look like your patch is correct. --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e19431..65ef89c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2820,7 +2820,13 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_txb: - opcode = is_cube_array ? TGSI_OPCODE_TXB2 : TGSI_OPCODE_TXB; + if (is_cube_array || + sampler_type == glsl_type::samplerCubeShadow_type) { + opcode = TGSI_OPCODE_TXB2; + } + else { + opcode = TGSI_OPCODE_TXB; + } ir-lod_info.bias-accept(this); lod_info = this-result; if (ir-offset) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: fix samplerCubeShadow with bias
On Fri, Jul 4, 2014 at 2:49 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 8:10 AM, Marek Olšák mar...@gmail.com wrote: From: Marek Olšák marek.ol...@amd.com It has 5 coordinates: (x,y,z,depth,lodbias) Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: Ilia Mirkin imir...@alum.mit.edu Although I still haven't worked out what else is wrong with nouveau... nv50 hits an assert, while nvc0 just generates wrong code. But it does look like your patch is correct. Actually this makes the TXL2 instruction pretty confusing =/ Right now it's always just used for cube arrays, so the shadow/lod are in a fixed position (first and second components of second arg). I think that behaviour should be maintained -- for example, TXB (http://gallium.readthedocs.org/en/latest/tgsi.html#opcode-TXB) always has the bias in the 'w' component [ugh, should fix the docs on that, it says 'z']. Same with TXL. -ilia --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e19431..65ef89c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2820,7 +2820,13 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_txb: - opcode = is_cube_array ? TGSI_OPCODE_TXB2 : TGSI_OPCODE_TXB; + if (is_cube_array || + sampler_type == glsl_type::samplerCubeShadow_type) { + opcode = TGSI_OPCODE_TXB2; + } + else { + opcode = TGSI_OPCODE_TXB; + } ir-lod_info.bias-accept(this); lod_info = this-result; if (ir-offset) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: fix samplerCubeShadow with bias
On Fri, Jul 4, 2014 at 3:30 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 2:49 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 8:10 AM, Marek Olšák mar...@gmail.com wrote: From: Marek Olšák marek.ol...@amd.com It has 5 coordinates: (x,y,z,depth,lodbias) Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: Ilia Mirkin imir...@alum.mit.edu Although I still haven't worked out what else is wrong with nouveau... nv50 hits an assert, while nvc0 just generates wrong code. But it does look like your patch is correct. Actually this makes the TXL2 instruction pretty confusing =/ Right now it's always just used for cube arrays, so the shadow/lod are in a fixed position (first and second components of second arg). I think that behaviour should be maintained -- for example, TXB (http://gallium.readthedocs.org/en/latest/tgsi.html#opcode-TXB) always has the bias in the 'w' component [ugh, should fix the docs on that, it says 'z']. Same with TXL. Err, sorry, I got confused between TXL and TXB. But my point still stands. Unless we're doing something horribly wrong in nouveau, it appears that for cube arrays, the lod is in src1.x and shadow is in src1.y, while for the samplerCubeShadow case, lod is in src1.x while shadow is in src0.w. Once I adjusted that, the texture(bias) CubeShadow case started passing. In any case, it'd be great of TEX2/TXB2/TXL2 could be documented in the TGSI docs... -ilia -ilia --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e19431..65ef89c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2820,7 +2820,13 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_txb: - opcode = is_cube_array ? TGSI_OPCODE_TXB2 : TGSI_OPCODE_TXB; + if (is_cube_array || + sampler_type == glsl_type::samplerCubeShadow_type) { + opcode = TGSI_OPCODE_TXB2; + } + else { + opcode = TGSI_OPCODE_TXB; + } ir-lod_info.bias-accept(this); lod_info = this-result; if (ir-offset) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: fix samplerCubeShadow with bias
samplerCubeArrayShadow cannot be used with lod and bias in GLSL 4.40, so it's impossible to get TXL or TXB with it. Some sampler types are more limited than others. For example, samplerCubeArrayShadow can only be used with this: float texture(gsamplerCubeArrayShadow sampler, vec4 P, float compare) textureLod is supported for 1DArrayShadow, but not for 2DArrayShadow, etc. See the specification. Marek On Fri, Jul 4, 2014 at 9:48 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 3:30 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 2:49 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 8:10 AM, Marek Olšák mar...@gmail.com wrote: From: Marek Olšák marek.ol...@amd.com It has 5 coordinates: (x,y,z,depth,lodbias) Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: Ilia Mirkin imir...@alum.mit.edu Although I still haven't worked out what else is wrong with nouveau... nv50 hits an assert, while nvc0 just generates wrong code. But it does look like your patch is correct. Actually this makes the TXL2 instruction pretty confusing =/ Right now it's always just used for cube arrays, so the shadow/lod are in a fixed position (first and second components of second arg). I think that behaviour should be maintained -- for example, TXB (http://gallium.readthedocs.org/en/latest/tgsi.html#opcode-TXB) always has the bias in the 'w' component [ugh, should fix the docs on that, it says 'z']. Same with TXL. Err, sorry, I got confused between TXL and TXB. But my point still stands. Unless we're doing something horribly wrong in nouveau, it appears that for cube arrays, the lod is in src1.x and shadow is in src1.y, while for the samplerCubeShadow case, lod is in src1.x while shadow is in src0.w. Once I adjusted that, the texture(bias) CubeShadow case started passing. In any case, it'd be great of TEX2/TXB2/TXL2 could be documented in the TGSI docs... -ilia -ilia --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e19431..65ef89c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2820,7 +2820,13 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_txb: - opcode = is_cube_array ? TGSI_OPCODE_TXB2 : TGSI_OPCODE_TXB; + if (is_cube_array || + sampler_type == glsl_type::samplerCubeShadow_type) { + opcode = TGSI_OPCODE_TXB2; + } + else { + opcode = TGSI_OPCODE_TXB; + } ir-lod_info.bias-accept(this); lod_info = this-result; if (ir-offset) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: fix samplerCubeShadow with bias
Ah yes, my bad. I did try to look at all the stuff, but it doesn't help that e.g. the texture man page is wrong for samplerCubeShadow (http://www.opengl.org/sdk/docs/man/html/texture.xhtml -- it lists the argument as vec3... I did double-check in the GL 4.4 spec, and it's correct there with a vec4). OK, so this patch seems good... would still be *awesome* if you (or someone else) could add TEX2/TXB2/TXL2 entries in the tgsi doc for people like me who don't know what's up. One question is whether DX allows this even though GL doesn't, but I'm less concerned about that. On Fri, Jul 4, 2014 at 4:00 PM, Marek Olšák mar...@gmail.com wrote: samplerCubeArrayShadow cannot be used with lod and bias in GLSL 4.40, so it's impossible to get TXL or TXB with it. Some sampler types are more limited than others. For example, samplerCubeArrayShadow can only be used with this: float texture(gsamplerCubeArrayShadow sampler, vec4 P, float compare) textureLod is supported for 1DArrayShadow, but not for 2DArrayShadow, etc. See the specification. Marek On Fri, Jul 4, 2014 at 9:48 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 3:30 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 2:49 PM, Ilia Mirkin imir...@alum.mit.edu wrote: On Fri, Jul 4, 2014 at 8:10 AM, Marek Olšák mar...@gmail.com wrote: From: Marek Olšák marek.ol...@amd.com It has 5 coordinates: (x,y,z,depth,lodbias) Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: Ilia Mirkin imir...@alum.mit.edu Although I still haven't worked out what else is wrong with nouveau... nv50 hits an assert, while nvc0 just generates wrong code. But it does look like your patch is correct. Actually this makes the TXL2 instruction pretty confusing =/ Right now it's always just used for cube arrays, so the shadow/lod are in a fixed position (first and second components of second arg). I think that behaviour should be maintained -- for example, TXB (http://gallium.readthedocs.org/en/latest/tgsi.html#opcode-TXB) always has the bias in the 'w' component [ugh, should fix the docs on that, it says 'z']. Same with TXL. Err, sorry, I got confused between TXL and TXB. But my point still stands. Unless we're doing something horribly wrong in nouveau, it appears that for cube arrays, the lod is in src1.x and shadow is in src1.y, while for the samplerCubeShadow case, lod is in src1.x while shadow is in src0.w. Once I adjusted that, the texture(bias) CubeShadow case started passing. In any case, it'd be great of TEX2/TXB2/TXL2 could be documented in the TGSI docs... -ilia -ilia --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e19431..65ef89c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2820,7 +2820,13 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_txb: - opcode = is_cube_array ? TGSI_OPCODE_TXB2 : TGSI_OPCODE_TXB; + if (is_cube_array || + sampler_type == glsl_type::samplerCubeShadow_type) { + opcode = TGSI_OPCODE_TXB2; + } + else { + opcode = TGSI_OPCODE_TXB; + } ir-lod_info.bias-accept(this); lod_info = this-result; if (ir-offset) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev