From 262e5d3924312923e64064f0cfd4a9137984cc9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= <pavel.ondracka@gmail.com>
Date: Thu, 7 Nov 2024 14:50:28 +0100
Subject: [PATCH] ARB_clear_texture: fix GL_CLEAR_TEXTURE query check for
 unsupported formats
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is OK to return GL_NONE even if the specific format supports clearing,
but there is no HW support for the format.

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/970>
---
 tests/spec/arb_clear_texture/supported-formats.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tests/spec/arb_clear_texture/supported-formats.c b/tests/spec/arb_clear_texture/supported-formats.c
index e2eca537be..771b893781 100644
--- a/tests/spec/arb_clear_texture/supported-formats.c
+++ b/tests/spec/arb_clear_texture/supported-formats.c
@@ -204,9 +204,15 @@ try(const GLenum *targets, unsigned num_targets,
 
 	for (unsigned i = 0; i < num_targets; i++) {
 		for (unsigned j = 0; j < num_formats; j++) {
-			GLint param;
+			GLint param, is_supported;
 			GLint64 param64;
 
+			glGetInternalformativ(targets[i],
+					      pinternal_formats[j],
+					      GL_INTERNALFORMAT_SUPPORTED,
+					      1,
+					      &is_supported);
+
 			glGetInternalformativ(targets[i],
 					      pinternal_formats[j],
 					      GL_CLEAR_TEXTURE,
@@ -219,8 +225,10 @@ try(const GLenum *targets, unsigned num_targets,
 						1,
 						&param64);
 
-			bool test = (expected_result == param);
-			bool test64 = (expected_result == param64);
+			bool test = (expected_result == param ||
+				     (is_supported == GL_FALSE && param == GL_NONE));
+			bool test64 = (expected_result == param64 ||
+				       (is_supported == GL_FALSE && param == GL_NONE));
 
 			if (test && test64)
 				continue;
-- 
GitLab