[Mesa-dev] [PATCH] gallium/tests/trivial: fix viewport depth transform

Ilia Mirkin imirkin at alum.mit.edu
Thu Mar 1 02:28:06 UTC 2018


On Wed, Feb 28, 2018 at 8:42 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> I suppose that's ok (and safer), albeit I'm not sure why it wouldn't
> work with nv50.
> Depth clip is enabled, yes, but I can't see why the produced values
> wouldn't be inside the view volume (which is defined by the near/far
> values for z).
> Granted values outside [0,1] are not permitted by standard GL, but
> there's extensions for it (NV_depth_buffer_float), so I'm a bit confused.

Right. I think we have something enabled which clips to 0..1 in the
view frustrum. Presumably if one were to use glDepthBoundsdNV() with a
larger range, the driver would have to stop using that 0..1 flag in
the clipping config.

Is this not the correct behavior? Or is it undefined what happens
outside of 0..1?

>
> Reviewed-by: Roland Scheidegger <sroland at vmware.com>

Thanks!

>
>
> Am 01.03.2018 um 01:43 schrieb Ilia Mirkin:
>> These were getting mapped off into outer space, which would cause nv50
>> and nvc0 to clip the primitives (as depth_clip was enabled).
>>
>> Oddly enough, it worked with nv30 and llvmpipe though. Perhaps their
>> frustrum clipping rules are a bit different?
>>
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>>  src/gallium/tests/trivial/quad-tex.c | 7 ++++---
>>  src/gallium/tests/trivial/tri.c      | 6 +++---
>>  2 files changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
>> index df0e1301f5e..1f29306ec04 100644
>> --- a/src/gallium/tests/trivial/quad-tex.c
>> +++ b/src/gallium/tests/trivial/quad-tex.c
>> @@ -27,8 +27,8 @@
>>  #define USE_TRACE 0
>>  #define WIDTH 300
>>  #define HEIGHT 300
>> -#define NEAR 30
>> -#define FAR 1000
>> +#define NEAR 0
>> +#define FAR 1
>>  #define FLIP 0
>>
>>  /* pipe_*_state structs */
>> @@ -174,6 +174,7 @@ static void init_prog(struct program *p)
>>               memset(&box, 0, sizeof(box));
>>               box.width = 2;
>>               box.height = 2;
>> +             box.depth = 1;
>>
>>               ptr = p->pipe->transfer_map(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box, &t);
>>               ptr[0] = 0xffff0000;
>> @@ -226,7 +227,7 @@ static void init_prog(struct program *p)
>>       {
>>               float x = 0;
>>               float y = 0;
>> -             float z = FAR;
>> +             float z = NEAR;
>>               float half_width = (float)WIDTH / 2.0f;
>>               float half_height = (float)HEIGHT / 2.0f;
>>               float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
>> diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
>> index 71e97022752..87a335fba1e 100644
>> --- a/src/gallium/tests/trivial/tri.c
>> +++ b/src/gallium/tests/trivial/tri.c
>> @@ -27,8 +27,8 @@
>>  #define USE_TRACE 0
>>  #define WIDTH 300
>>  #define HEIGHT 300
>> -#define NEAR 30
>> -#define FAR 1000
>> +#define NEAR 0
>> +#define FAR 1
>>  #define FLIP 0
>>
>>  /* pipe_*_state structs */
>> @@ -171,7 +171,7 @@ static void init_prog(struct program *p)
>>       {
>>               float x = 0;
>>               float y = 0;
>> -             float z = FAR;
>> +             float z = NEAR;
>>               float half_width = (float)WIDTH / 2.0f;
>>               float half_height = (float)HEIGHT / 2.0f;
>>               float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
>>
>


More information about the mesa-dev mailing list