[Mesa-dev] [PATCH] swrast: fix Z testing of points/lines for 16-bit depth buffers

Brian Paul brianp at vmware.com
Mon Jan 9 11:41:27 PST 2012


On 01/09/2012 12:09 PM, Jose Fonseca wrote:
> ----- Original Message -----
>> We were comparing 32-bit Z buffer values against 16-bit fragment
>> values.
>> Need to do scaling like for the 24-bit case.
>>
>> Triangle Z testing was OK since it didn't hit this code path.
>> ---
>>   src/mesa/swrast/s_depth.c |   36
>>   +++++++++++++++++++++++++++++-------
>>   1 files changed, 29 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
>> index 53f21cb..42724c7 100644
>> --- a/src/mesa/swrast/s_depth.c
>> +++ b/src/mesa/swrast/s_depth.c
>> @@ -205,6 +205,7 @@ _swrast_depth_clamp_span( struct gl_context *ctx,
>> SWspan *span )
>>
>>   /**
>>    * Get array of 32-bit z values from the depth buffer.  With
>>    clipping.
>> + * Note: the returned values are always in the range [0, 2^32-1].
>>    */
>>   static void
>>   get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
>> @@ -235,6 +236,11 @@ get_z32_values(struct gl_context *ctx, struct
>> gl_renderbuffer *rb,
>>      }
>>   }
>>
>> +
>> +/**
>> + * Put an array of 32-bit z values into the depth buffer.
>> + * Note: the z values are always in the range [0, 2^32-1].
>> + */
>>   static void
>>   put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
>>                  GLuint count, const GLint x[], const GLint y[],
>> @@ -284,8 +290,8 @@ _swrast_depth_test_span(struct gl_context *ctx,
>> SWspan *span)
>>      void *zBufferVals;
>>      GLuint *zBufferTemp = NULL;
>>      GLuint passed;
>> +   GLuint zBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS);
>>      GLboolean ztest16 = GL_FALSE;
>
> is ztest16 still necessary?

Yes, for the case of depth-testing 16-bit Z values for a horizontal 
run of pixels using a MESA_FORMAT_Z16 buffer, we can do an optimized 
16-bit depth test.


> Otherwise looks good.

-Brian



More information about the mesa-dev mailing list