[mutter/wip/3-monitors-on-nvidia: 221/221] fixup! wip! renderer-native-gles3: add function for drawing pixels to egl surface
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/3-monitors-on-nvidia: 221/221] fixup! wip! renderer-native-gles3: add function for drawing pixels to egl surface
- Date: Tue, 27 Nov 2018 20:14:57 +0000 (UTC)
commit 619bde8e380890da009d9588bb4b840633791c5f
Author: Ray Strode <rstrode redhat com>
Date: Tue Nov 27 15:11:53 2018 -0500
fixup! wip! renderer-native-gles3: add function for drawing pixels to egl surface
this hacks out the bits that may be leaking so they only get called
once. It's untested, so it may not draw anymore, I'm unsure.
This adds a lot of global state that needs to be cleaned up.
src/backends/native/meta-renderer-native-gles3.c | 190 +++++++++++++----------
src/backends/native/meta-renderer-native-gles3.h | 6 +-
src/backends/native/meta-renderer-native.c | 2 +-
3 files changed, 112 insertions(+), 86 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native-gles3.c
b/src/backends/native/meta-renderer-native-gles3.c
index 70b4facba..98fdcfdf3 100644
--- a/src/backends/native/meta-renderer-native-gles3.c
+++ b/src/backends/native/meta-renderer-native-gles3.c
@@ -179,6 +179,61 @@ paint_egl_image (MetaGles3 *gles3,
GL_NEAREST));
}
+/* FIXME: all these declarations are just floating here
+ */
+struct __attribute__ ((__packed__)) position
+{
+ float x, y;
+};
+
+struct __attribute__ ((__packed__)) texture_coordinate
+{
+ float u, v;
+};
+
+struct __attribute__ ((__packed__)) vertex
+{
+ struct position position;
+ struct texture_coordinate texture_coordinate;
+};
+
+struct __attribute__ ((__packed__)) triangle
+{
+ unsigned int first_vertex;
+ unsigned int middle_vertex;
+ unsigned int last_vertex;
+};
+
+enum
+{
+ RIGHT_TOP_VERTEX = 0,
+ BOTTOM_RIGHT_VERTEX,
+ BOTTOM_LEFT_VERTEX,
+ TOP_LEFT_VERTEX
+};
+
+static const float view_left = -1.0f, view_right = 1.0f, view_top = 1.0f, view_bottom = -1.0f;
+static const float texture_left = 0.0f, texture_right = 1.0f, texture_top = 0.0f, texture_bottom = 1.0f;
+static GLuint vertex_array;
+static GLuint vertex_buffer;
+static GLuint triangle_buffer;
+
+struct vertex vertices[] = {
+ [RIGHT_TOP_VERTEX] = {{view_right, view_top},
+ {texture_right, texture_top}},
+ [BOTTOM_RIGHT_VERTEX] = {{view_right, view_bottom},
+ {texture_right, texture_bottom}},
+ [BOTTOM_LEFT_VERTEX] = {{view_left, view_bottom},
+ {texture_left, texture_bottom}},
+ [TOP_LEFT_VERTEX] = {{view_left, view_top},
+ {texture_left, texture_top}},
+};
+
+struct triangle triangles[] = {
+ {TOP_LEFT_VERTEX, BOTTOM_RIGHT_VERTEX, BOTTOM_LEFT_VERTEX},
+ {TOP_LEFT_VERTEX, RIGHT_TOP_VERTEX, BOTTOM_RIGHT_VERTEX},
+};
+
gboolean
meta_renderer_native_gles3_draw_pixels (MetaEgl *egl,
MetaGles3 *gles3,
@@ -187,101 +242,30 @@ meta_renderer_native_gles3_draw_pixels (MetaEgl *egl,
uint8_t *pixels,
GError **error)
{
- GLuint vertex_array;
- GLuint vertex_buffer;
- GLuint triangle_buffer;
- static const float view_left = -1.0f, view_right = 1.0f, view_top = 1.0f, view_bottom = -1.0f;
- static const float texture_left = 0.0f, texture_right = 1.0f, texture_top = 0.0f, texture_bottom = 1.0f;
-
- struct __attribute__ ((__packed__)) position
- {
- float x, y;
- };
-
- struct __attribute__ ((__packed__)) texture_coordinate
- {
- float u, v;
- };
-
- struct __attribute__ ((__packed__)) vertex
- {
- struct position position;
- struct texture_coordinate texture_coordinate;
- };
-
- struct __attribute__ ((__packed__)) triangle
- {
- unsigned int first_vertex;
- unsigned int middle_vertex;
- unsigned int last_vertex;
- };
-
- enum
- {
- RIGHT_TOP_VERTEX = 0,
- BOTTOM_RIGHT_VERTEX,
- BOTTOM_LEFT_VERTEX,
- TOP_LEFT_VERTEX
- };
-
- struct vertex vertices[] = {
- [RIGHT_TOP_VERTEX] = {{view_right, view_top},
- {texture_right, texture_top}},
- [BOTTOM_RIGHT_VERTEX] = {{view_right, view_bottom},
- {texture_right, texture_bottom}},
- [BOTTOM_LEFT_VERTEX] = {{view_left, view_bottom},
- {texture_left, texture_bottom}},
- [TOP_LEFT_VERTEX] = {{view_left, view_top},
- {texture_left, texture_top}},
- };
-
- struct triangle triangles[] = {
- {TOP_LEFT_VERTEX, BOTTOM_RIGHT_VERTEX, BOTTOM_LEFT_VERTEX},
- {TOP_LEFT_VERTEX, RIGHT_TOP_VERTEX, BOTTOM_RIGHT_VERTEX},
- };
-
- GLuint texture;
-
meta_gles3_clear_error (gles3);
GLBAS (gles3, glClearColor, (0.0,1.0,0.0,1.0));
GLBAS (gles3, glClear, (GL_COLOR_BUFFER_BIT));
GLBAS (gles3, glViewport, (0, 0, width, height));
- GLBAS (gles3, glGenVertexArrays, (1, &vertex_array));
- GLBAS (gles3, glBindVertexArray, (vertex_array));
-
- GLBAS (gles3, glGenBuffers, (1, &vertex_buffer));
- GLBAS (gles3, glBindBuffer, (GL_ARRAY_BUFFER, vertex_buffer));
- GLBAS (gles3, glBufferData, (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STREAM_DRAW));
-
- GLBAS (gles3, glGenBuffers, (1, &triangle_buffer));
- GLBAS (gles3, glBindBuffer, (GL_ELEMENT_ARRAY_BUFFER, triangle_buffer));
- GLBAS (gles3, glBufferData, (GL_ELEMENT_ARRAY_BUFFER, sizeof (triangles), triangles, GL_STREAM_DRAW));
-
- GLBAS (gles3, glActiveTexture, (GL_TEXTURE0));
- GLBAS (gles3, glGenTextures, (1, &texture));
- GLBAS (gles3, glBindTexture, (GL_TEXTURE_2D, texture));
- GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
- GL_NEAREST));
- GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_NEAREST));
- GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
- GL_CLAMP_TO_EDGE));
- GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
- GL_CLAMP_TO_EDGE));
- GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_WRAP_R_OES,
- GL_CLAMP_TO_EDGE));
GLBAS (gles3, glTexImage2D, (GL_TEXTURE_2D, 0, GL_RGBA,
width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, pixels));
GLBAS (gles3, glBindBuffer, (GL_ARRAY_BUFFER, vertex_buffer));
GLBAS (gles3, glEnableVertexAttribArray, (0));
- GLBAS (gles3, glVertexAttribPointer, (0, sizeof (struct position) / sizeof (float), GL_FLOAT, GL_FALSE,
sizeof (struct vertex), (void *) offsetof (struct vertex, position)));
+ GLBAS (gles3, glVertexAttribPointer, (0,
+ sizeof (struct position) / sizeof (float), GL_FLOAT,
+ GL_FALSE,
+ sizeof (struct vertex), (void *) offsetof (struct vertex,
position)));
GLBAS (gles3, glEnableVertexAttribArray, (1));
- GLBAS (gles3, glVertexAttribPointer, (1, sizeof (struct texture_coordinate) / sizeof (float), GL_FLOAT,
GL_FALSE, sizeof (struct vertex), (void *) offsetof (struct vertex, texture_coordinate)));
- GLBAS (gles3, glDrawElements, (GL_TRIANGLES, G_N_ELEMENTS (triangles) * (sizeof (struct triangle) / sizeof
(unsigned int)), GL_UNSIGNED_INT, 0));
+ GLBAS (gles3, glVertexAttribPointer, (1,
+ sizeof (struct texture_coordinate) / sizeof (float), GL_FLOAT,
+ GL_FALSE,
+ sizeof (struct vertex), (void *) offsetof (struct vertex,
texture_coordinate)));
+ GLBAS (gles3, glDrawElements, (GL_TRIANGLES,
+ G_N_ELEMENTS (triangles) * (sizeof (struct triangle) / sizeof (unsigned
int)), GL_UNSIGNED_INT,
+ 0));
return TRUE;
}
@@ -346,7 +330,7 @@ meta_renderer_native_gles3_blit_shared_bo (MetaEgl *egl,
return TRUE;
}
-void
+static void
meta_renderer_native_gles3_load_basic_shaders (MetaEgl *egl,
MetaGles3 *gles3)
{
@@ -423,3 +407,43 @@ out:
if (fragment_shader)
glDeleteShader (fragment_shader);
}
+
+gboolean
+meta_renderer_native_gles3_prepare_for_drawing (MetaEgl *egl,
+ MetaGles3 *gles3,
+ GError **error)
+{
+ GLuint texture;
+
+ meta_renderer_native_gles3_load_basic_shaders (egl, gles3);
+
+ meta_gles3_clear_error (gles3);
+
+ GLBAS (gles3, glGenVertexArrays, (1, &vertex_array));
+ GLBAS (gles3, glBindVertexArray, (vertex_array));
+
+ GLBAS (gles3, glGenBuffers, (1, &vertex_buffer));
+ GLBAS (gles3, glBindBuffer, (GL_ARRAY_BUFFER, vertex_buffer));
+ GLBAS (gles3, glBufferData, (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STREAM_DRAW));
+
+ GLBAS (gles3, glGenBuffers, (1, &triangle_buffer));
+ GLBAS (gles3, glBindBuffer, (GL_ELEMENT_ARRAY_BUFFER, triangle_buffer));
+ GLBAS (gles3, glBufferData, (GL_ELEMENT_ARRAY_BUFFER, sizeof (triangles), triangles, GL_STREAM_DRAW));
+
+ GLBAS (gles3, glActiveTexture, (GL_TEXTURE0));
+ GLBAS (gles3, glGenTextures, (1, &texture));
+ GLBAS (gles3, glBindTexture, (GL_TEXTURE_2D, texture));
+
+ GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST));
+ GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST));
+ GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE));
+ GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE));
+ GLBAS (gles3, glTexParameteri, (GL_TEXTURE_2D, GL_TEXTURE_WRAP_R_OES,
+ GL_CLAMP_TO_EDGE));
+
+ return TRUE;
+}
diff --git a/src/backends/native/meta-renderer-native-gles3.h
b/src/backends/native/meta-renderer-native-gles3.h
index 2791302a0..1de13f9be 100644
--- a/src/backends/native/meta-renderer-native-gles3.h
+++ b/src/backends/native/meta-renderer-native-gles3.h
@@ -37,6 +37,10 @@ gboolean meta_renderer_native_gles3_blit_shared_bo (MetaEgl *egl,
struct gbm_bo *shared_bo,
GError **error);
+gboolean meta_renderer_native_gles3_prepare_for_drawing (MetaEgl *egl,
+ MetaGles3 *gles3,
+ GError **error);
+
gboolean meta_renderer_native_gles3_draw_pixels (MetaEgl *egl,
MetaGles3 *gles3,
unsigned int width,
@@ -44,6 +48,4 @@ gboolean meta_renderer_native_gles3_draw_pixels (MetaEgl *egl,
uint8_t *pixels,
GError **error);
-void meta_renderer_native_gles3_load_basic_shaders (MetaEgl *egl,
- MetaGles3 *gles3);
#endif /* META_RENDERER_NATIVE_GLES3_H */
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 0d9d42095..afdb3b508 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -3582,7 +3582,7 @@ init_secondary_gpu_data_stream (MetaRendererNativeGpuData *renderer_gpu_data,
return FALSE;
}
- meta_renderer_native_gles3_load_basic_shaders (egl, renderer_native->gles3);
+ meta_renderer_native_gles3_prepare_for_drawing (egl, renderer_native->gles3, NULL);
renderer_gpu_data->secondary.egl_context = egl_context;
renderer_gpu_data->secondary.egl_config = egl_config;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]