[03/10] nv_conditional_render: do not depend on float-textures

Submitted by Erik Faye-Lund on Nov. 5, 2018, 5:23 p.m.

Details

Message ID 20181105172335.17229-4-erik.faye-lund@collabora.com
State New
Headers show
Series "port NV_conditional_render tests to GLES3" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Erik Faye-Lund Nov. 5, 2018, 5:23 p.m.
OpenGL is pretty flexible in how you can upload textures, but OpenGL ES
isn't. Let's change this to use unsigned byte texture components instead
of floats, to increase compatiblity.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
---
 .../spec/nv_conditional_render/blitframebuffer.c  | 13 +++++++------
 tests/spec/nv_conditional_render/copyteximage.c   | 12 ++++++------
 .../spec/nv_conditional_render/copytexsubimage.c  | 12 ++++++------
 tests/spec/nv_conditional_render/generatemipmap.c | 15 ++++++++-------
 4 files changed, 27 insertions(+), 25 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/spec/nv_conditional_render/blitframebuffer.c b/tests/spec/nv_conditional_render/blitframebuffer.c
index 3c017a3db..3dd0d2efe 100644
--- a/tests/spec/nv_conditional_render/blitframebuffer.c
+++ b/tests/spec/nv_conditional_render/blitframebuffer.c
@@ -42,20 +42,20 @@  PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
-static void fill_tex(int level, int w, int h, const GLfloat *color)
+static void fill_tex(int level, int w, int h, const GLubyte *color)
 {
-	GLfloat *data;
+	GLubyte *data;
 	int i;
 
-	data = malloc(w * h * 4 * sizeof(GLfloat));
+	data = malloc(w * h * 4 * sizeof(GLubyte));
 	for (i = 0; i < 4 * w * h; i += 4) {
 		data[i + 0] = color[0];
 		data[i + 1] = color[1];
 		data[i + 2] = color[2];
 		data[i + 3] = color[3];
 	}
-        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
-		     GL_RGBA, GL_FLOAT, data);
+	glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+		     GL_RGBA, GL_UNSIGNED_BYTE, data);
 	free(data);
 }
 
@@ -80,6 +80,7 @@  piglit_display(void)
 {
 	bool pass = true;
 	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLubyte green_ub[4] = {0, 0xFF, 0, 0};
 	GLuint q, texture;
 
 	glClearColor(0.5, 0.5, 0.5, 0.5);
@@ -99,7 +100,7 @@  piglit_display(void)
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
-	fill_tex(0, piglit_width, piglit_height / 2, green);
+	fill_tex(0, piglit_width, piglit_height / 2, green_ub);
 
 	glGenQueries(1, &q);
 
diff --git a/tests/spec/nv_conditional_render/copyteximage.c b/tests/spec/nv_conditional_render/copyteximage.c
index a0e50f7f4..f6667a409 100644
--- a/tests/spec/nv_conditional_render/copyteximage.c
+++ b/tests/spec/nv_conditional_render/copyteximage.c
@@ -43,20 +43,20 @@  PIGLIT_GL_TEST_CONFIG_BEGIN
 PIGLIT_GL_TEST_CONFIG_END
 
 static void
-fill_tex(int level, int w, int h, const GLfloat *color)
+fill_tex(int level, int w, int h, const GLubyte *color)
 {
-	GLfloat *data;
+	GLubyte *data;
 	int i;
 
-	data = malloc(w * h * 4 * sizeof(GLfloat));
+	data = malloc(w * h * 4 * sizeof(GLubyte));
 	for (i = 0; i < 4 * w * h; i += 4) {
 		data[i + 0] = color[0];
 		data[i + 1] = color[1];
 		data[i + 2] = color[2];
 		data[i + 3] = color[3];
 	}
-        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
-		     GL_RGBA, GL_FLOAT, data);
+	glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+		     GL_RGBA, GL_UNSIGNED_BYTE, data);
 	free(data);
 }
 
@@ -64,7 +64,7 @@  enum piglit_result
 piglit_display(void)
 {
 	bool pass = true;
-	float red[4] = {1.0, 0.0, 0.0, 0.0};
+	GLubyte red[4] = {0xFF, 0, 0, 0};
 	float green[4] = {0.0, 1.0, 0.0, 0.0};
 	GLuint q, texture;
 
diff --git a/tests/spec/nv_conditional_render/copytexsubimage.c b/tests/spec/nv_conditional_render/copytexsubimage.c
index a9d0c0d4d..98dcc15ec 100644
--- a/tests/spec/nv_conditional_render/copytexsubimage.c
+++ b/tests/spec/nv_conditional_render/copytexsubimage.c
@@ -43,20 +43,20 @@  PIGLIT_GL_TEST_CONFIG_BEGIN
 PIGLIT_GL_TEST_CONFIG_END
 
 static void
-fill_tex(int level, int w, int h, const GLfloat *color)
+fill_tex(int level, int w, int h, const GLubyte *color)
 {
-	GLfloat *data;
+	GLubyte *data;
 	int i;
 
-	data = malloc(w * h * 4 * sizeof(GLfloat));
+	data = malloc(w * h * 4 * sizeof(GLubyte));
 	for (i = 0; i < 4 * w * h; i += 4) {
 		data[i + 0] = color[0];
 		data[i + 1] = color[1];
 		data[i + 2] = color[2];
 		data[i + 3] = color[3];
 	}
-        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
-		     GL_RGBA, GL_FLOAT, data);
+	glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+		     GL_RGBA, GL_UNSIGNED_BYTE, data);
 	free(data);
 }
 
@@ -64,7 +64,7 @@  enum piglit_result
 piglit_display(void)
 {
 	bool pass = true;
-	float red[4] = {1.0, 0.0, 0.0, 0.0};
+	GLubyte red[4] = {0xFF, 0, 0, 0};
 	float green[4] = {0.0, 1.0, 0.0, 0.0};
 	GLuint q, texture;
 
diff --git a/tests/spec/nv_conditional_render/generatemipmap.c b/tests/spec/nv_conditional_render/generatemipmap.c
index 315d2d7e1..7f29a71a3 100644
--- a/tests/spec/nv_conditional_render/generatemipmap.c
+++ b/tests/spec/nv_conditional_render/generatemipmap.c
@@ -47,20 +47,20 @@  PIGLIT_GL_TEST_CONFIG_BEGIN
 PIGLIT_GL_TEST_CONFIG_END
 
 static void
-fill_level(int level, int size, const GLfloat *color)
+fill_level(int level, int size, const GLubyte *color)
 {
-	GLfloat *data;
+	GLubyte *data;
 	int i;
 
-	data = malloc(size * size * 4 * sizeof(GLfloat));
+	data = malloc(size * size * 4 * sizeof(GLubyte));
 	for (i = 0; i < 4 * size * size; i += 4) {
 		data[i + 0] = color[0];
 		data[i + 1] = color[1];
 		data[i + 2] = color[2];
 		data[i + 3] = color[3];
 	}
-        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0,
-		     GL_RGBA, GL_FLOAT, data);
+	glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0,
+		     GL_RGBA, GL_UNSIGNED_BYTE, data);
 	free(data);
 }
 
@@ -68,8 +68,9 @@  enum piglit_result
 piglit_display(void)
 {
 	bool pass = true;
-	float red[4] = {1.0, 0.0, 0.0, 0.0};
+	GLubyte red[4] = {0xFF, 0, 0, 0};
 	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLubyte green_ub[4] = {0, 0xFF, 0, 0};
 	GLuint q, texture;
 	int tex_size = 64;
 	int i;
@@ -89,7 +90,7 @@  piglit_display(void)
 	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
 
 	for (i = 0; tex_size / (1 << i) > 0; i++)
-		fill_level(i, tex_size / (1 << i), i == 0 ? green : red);
+		fill_level(i, tex_size / (1 << i), i == 0 ? green_ub : red);
 
 	glGenQueries(1, &q);