ext_render_snorm-render: change verify_contents to use base_format size

Submitted by Tapani Pälli on Aug. 29, 2018, 7:33 a.m.

Details

Message ID 20180829073336.4482-1-tapani.palli@intel.com
State New
Headers show
Series "ext_render_snorm-render: fix read back assumptions" ( rev: 2 ) in Piglit

Not browsing as part of any series.

Commit Message

Tapani Pälli Aug. 29, 2018, 7:33 a.m.
OpenGL ES 3.1 specification lists valid combinations for format, type
and internalformat for transfer of pixel rectangles. This change follows
the table 8.4 in spec so that we use exact same number of components
for format as is expected from corresponding internalformat.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
---
 tests/spec/ext_render_snorm/render.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/spec/ext_render_snorm/render.c b/tests/spec/ext_render_snorm/render.c
index 3df16991e..ec1856806 100644
--- a/tests/spec/ext_render_snorm/render.c
+++ b/tests/spec/ext_render_snorm/render.c
@@ -203,15 +203,15 @@  verify_contents(const struct fmt_test *test)
 {
 	bool result = true;
 	unsigned amount = piglit_width * piglit_height;
-	void *pix = malloc(amount * 4);
-	glReadPixels(0, 0, piglit_width, piglit_height, GL_RGBA, GL_BYTE, pix);
+	void *pix = malloc(amount * test->bpp);
+	glReadPixels(0, 0, piglit_width, piglit_height, test->base_format, GL_BYTE, pix);
 
-	char value[4] = { 0, 0, 0, SCHAR_MAX };
+	char *value = malloc(test->bpp);
 	value_for_format(test, value);
 
 	char *p = pix;
-	for (unsigned i = 0; i < amount; i++, p += 4) {
-		if (memcmp(p, value, sizeof(value)) == 0)
+	for (unsigned i = 0; i < amount; i++, p += test->bpp) {
+		if (memcmp(p, value, test->bpp * sizeof(char)) == 0)
 			continue;
 
                 fprintf(stderr, "value:\n%d % d %d %d\nexpect:\n%d %d %d %d",

Comments

On Wed, Aug 29, 2018 at 3:33 AM, Tapani Pälli <tapani.palli@intel.com> wrote:
> OpenGL ES 3.1 specification lists valid combinations for format, type
> and internalformat for transfer of pixel rectangles. This change follows
> the table 8.4 in spec so that we use exact same number of components
> for format as is expected from corresponding internalformat.
>
> Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
> ---
>  tests/spec/ext_render_snorm/render.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tests/spec/ext_render_snorm/render.c b/tests/spec/ext_render_snorm/render.c
> index 3df16991e..ec1856806 100644
> --- a/tests/spec/ext_render_snorm/render.c
> +++ b/tests/spec/ext_render_snorm/render.c
> @@ -203,15 +203,15 @@ verify_contents(const struct fmt_test *test)
>  {
>         bool result = true;
>         unsigned amount = piglit_width * piglit_height;
> -       void *pix = malloc(amount * 4);
> -       glReadPixels(0, 0, piglit_width, piglit_height, GL_RGBA, GL_BYTE, pix);
> +       void *pix = malloc(amount * test->bpp);
> +       glReadPixels(0, 0, piglit_width, piglit_height, test->base_format, GL_BYTE, pix);
>
> -       char value[4] = { 0, 0, 0, SCHAR_MAX };
> +       char *value = malloc(test->bpp);

You never free this. Might be easier to just have it be a
stack-allocated array though as it was before.

>         value_for_format(test, value);
>
>         char *p = pix;
> -       for (unsigned i = 0; i < amount; i++, p += 4) {
> -               if (memcmp(p, value, sizeof(value)) == 0)
> +       for (unsigned i = 0; i < amount; i++, p += test->bpp) {
> +               if (memcmp(p, value, test->bpp * sizeof(char)) == 0)
>                         continue;
>
>                  fprintf(stderr, "value:\n%d % d %d %d\nexpect:\n%d %d %d %d",
> --
> 2.13.6
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
On 08/29/2018 02:44 PM, Ilia Mirkin wrote:
> On Wed, Aug 29, 2018 at 3:33 AM, Tapani Pälli <tapani.palli@intel.com> wrote:
>> OpenGL ES 3.1 specification lists valid combinations for format, type
>> and internalformat for transfer of pixel rectangles. This change follows
>> the table 8.4 in spec so that we use exact same number of components
>> for format as is expected from corresponding internalformat.
>>
>> Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
>> ---
>>   tests/spec/ext_render_snorm/render.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/tests/spec/ext_render_snorm/render.c b/tests/spec/ext_render_snorm/render.c
>> index 3df16991e..ec1856806 100644
>> --- a/tests/spec/ext_render_snorm/render.c
>> +++ b/tests/spec/ext_render_snorm/render.c
>> @@ -203,15 +203,15 @@ verify_contents(const struct fmt_test *test)
>>   {
>>          bool result = true;
>>          unsigned amount = piglit_width * piglit_height;
>> -       void *pix = malloc(amount * 4);
>> -       glReadPixels(0, 0, piglit_width, piglit_height, GL_RGBA, GL_BYTE, pix);
>> +       void *pix = malloc(amount * test->bpp);
>> +       glReadPixels(0, 0, piglit_width, piglit_height, test->base_format, GL_BYTE, pix);
>>
>> -       char value[4] = { 0, 0, 0, SCHAR_MAX };
>> +       char *value = malloc(test->bpp);
> 
> You never free this. Might be easier to just have it be a
> stack-allocated array though as it was before.

Thanks, I'll fix this. This patch might not land though as it might be 
issue in the vk-gl-cts suite tests.

>>          value_for_format(test, value);
>>
>>          char *p = pix;
>> -       for (unsigned i = 0; i < amount; i++, p += 4) {
>> -               if (memcmp(p, value, sizeof(value)) == 0)
>> +       for (unsigned i = 0; i < amount; i++, p += test->bpp) {
>> +               if (memcmp(p, value, test->bpp * sizeof(char)) == 0)
>>                          continue;
>>
>>                   fprintf(stderr, "value:\n%d % d %d %d\nexpect:\n%d %d %d %d",
>> --
>> 2.13.6
>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/piglit