[gtk+/wip/baedert/gl: 30/94] gl renderer: Don't pass MVP to shaders
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/gl: 30/94] gl renderer: Don't pass MVP to shaders
- Date: Mon, 11 Dec 2017 07:25:00 +0000 (UTC)
commit ad7d3b2ea4a3a6038c87a1a685e7a110d34e5e46
Author: Timm Bäder <mail baedert org>
Date: Sun Nov 19 14:39:56 2017 +0100
gl renderer: Don't pass MVP to shaders
We already pass both modelview and projection matrix individually.
gsk/gskglrenderer.c | 20 +++++---------------
gsk/meson.build | 2 --
gsk/resources/glsl/blend.vs.glsl | 2 +-
gsk/resources/glsl/blit.vs.glsl | 3 +--
gsk/resources/glsl/color.vs.glsl | 6 ------
gsk/resources/glsl/color_matrix.vs.glsl | 6 ------
gsk/resources/glsl/gl3_common.fs.glsl | 1 -
gsk/resources/glsl/gl3_common.vs.glsl | 3 +--
gsk/resources/glsl/linear_gradient.fs.glsl | 4 ++--
9 files changed, 10 insertions(+), 37 deletions(-)
---
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 665c48e..f11a5d3 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -66,7 +66,6 @@ gsk_gl_renderer_setup_render_mode (GskGLRenderer *self);
typedef struct {
int id;
/* Common locations (gl_common)*/
- int mvp_location;
int source_location;
int mask_location;
int uv_location;
@@ -128,7 +127,6 @@ typedef struct {
graphene_size_t size;
- graphene_matrix_t mvp;
graphene_matrix_t projection;
graphene_matrix_t modelview;
@@ -179,7 +177,6 @@ destroy_render_item (RenderItem *item)
enum {
- MVP,
SOURCE,
MASK,
ALPHA,
@@ -331,8 +328,6 @@ init_common_locations (GskGLRenderer *self,
gsk_shader_builder_get_uniform_location (builder, prog->id, self->uniforms[SOURCE]);
prog->mask_location =
gsk_shader_builder_get_uniform_location (builder, prog->id, self->uniforms[MASK]);
- prog->mvp_location =
- gsk_shader_builder_get_uniform_location (builder, prog->id, self->uniforms[MVP]);
prog->alpha_location =
gsk_shader_builder_get_uniform_location (builder, prog->id, self->uniforms[ALPHA]);
prog->blendMode_location =
@@ -368,7 +363,6 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
gsk_shader_builder_set_resource_base_path (builder, "/org/gtk/libgsk/glsl");
- self->uniforms[MVP] = gsk_shader_builder_add_uniform (builder, "uMVP");
self->uniforms[SOURCE] = gsk_shader_builder_add_uniform (builder, "uSource");
self->uniforms[MASK] = gsk_shader_builder_add_uniform (builder, "uMask");
self->uniforms[ALPHA] = gsk_shader_builder_add_uniform (builder, "uAlpha");
@@ -440,7 +434,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
init_common_locations (self, builder, &self->blit_program);
self->color_program.id =
- gsk_shader_builder_create_program (builder, "color.vs.glsl", "color.fs.glsl", &shader_error);
+ gsk_shader_builder_create_program (builder, "blit.vs.glsl", "color.fs.glsl", &shader_error);
if (shader_error != NULL)
{
g_propagate_prefixed_error (error,
@@ -466,7 +460,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
INIT_PROGRAM_UNIFORM_LOCATION (coloring_program, color_location, "uColor");
self->color_matrix_program.id = gsk_shader_builder_create_program (builder,
- "color_matrix.vs.glsl",
+ "blit.vs.glsl",
"color_matrix.fs.glsl",
&shader_error);
if (shader_error != NULL)
@@ -779,14 +773,12 @@ render_item (GskGLRenderer *self,
}
/* Common uniforms */
- graphene_matrix_to_float (&item->mvp, mat);
- glUniformMatrix4fv (item->program->mvp_location, 1, GL_FALSE, mat);
-
graphene_matrix_to_float (&item->projection, mat);
- glUniformMatrix4fv (item->program->projection_location, 1, GL_TRUE, mat);
+ glUniformMatrix4fv (item->program->projection_location, 1, GL_FALSE, mat);
graphene_matrix_to_float (&item->modelview, mat);
- glUniformMatrix4fv (item->program->modelview_location, 1, GL_TRUE, mat);
+ glUniformMatrix4fv (item->program->modelview_location, 1, GL_FALSE, mat);
+
glUniform1f (item->program->alpha_location, item->opacity);
glUniform4f (item->program->viewport_location,
self->viewport.origin.x, self->viewport.origin.y,
@@ -899,8 +891,6 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
item.max.x = item.min.x + node->bounds.size.width;
item.max.y = item.min.y + node->bounds.size.height;
- /* The location of the item, in normalized world coordinates */
- graphene_matrix_multiply (modelview, projection, &item.mvp);
item.z = project_item (projection, modelview);
item.opacity = 1.0;
diff --git a/gsk/meson.build b/gsk/meson.build
index 894c314..7f2ebcc 100644
--- a/gsk/meson.build
+++ b/gsk/meson.build
@@ -4,10 +4,8 @@ gsk_private_source_shaders = [
'resources/glsl/blit.fs.glsl',
'resources/glsl/blit.vs.glsl',
'resources/glsl/color.fs.glsl',
- 'resources/glsl/color.vs.glsl',
'resources/glsl/coloring.fs.glsl',
'resources/glsl/color_matrix.fs.glsl',
- 'resources/glsl/color_matrix.vs.glsl',
'resources/glsl/linear_gradient.fs.glsl',
'resources/glsl/es2_common.fs.glsl',
'resources/glsl/es2_common.vs.glsl',
diff --git a/gsk/resources/glsl/blend.vs.glsl b/gsk/resources/glsl/blend.vs.glsl
index a453e32..da1d541 100644
--- a/gsk/resources/glsl/blend.vs.glsl
+++ b/gsk/resources/glsl/blend.vs.glsl
@@ -1,5 +1,5 @@
void main() {
- gl_Position = uMVP * vec4(aPosition, 0.0, 1.0);
+ gl_Position = uModelview * uProjection * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
diff --git a/gsk/resources/glsl/blit.vs.glsl b/gsk/resources/glsl/blit.vs.glsl
index 1208513..68a406d 100644
--- a/gsk/resources/glsl/blit.vs.glsl
+++ b/gsk/resources/glsl/blit.vs.glsl
@@ -1,6 +1,5 @@
void main() {
- gl_Position = uMVP * vec4(aPosition, 0.0, 1.0);
+ gl_Position = uProjection * uModelview * vec4(aPosition, 0.0, 1.0);
- // Flip the sampling
vUv = vec2(aUv.x, aUv.y);
}
diff --git a/gsk/resources/glsl/gl3_common.fs.glsl b/gsk/resources/glsl/gl3_common.fs.glsl
index ad465bc..4e516d2 100644
--- a/gsk/resources/glsl/gl3_common.fs.glsl
+++ b/gsk/resources/glsl/gl3_common.fs.glsl
@@ -2,7 +2,6 @@ precision highp float;
uniform sampler2D uSource;
uniform sampler2D uMask;
-uniform mat4 uMVP;
uniform mat4 uProjection = mat4(1.0);
uniform mat4 uModelview = mat4(1.0);
uniform float uAlpha = 1.0;
diff --git a/gsk/resources/glsl/gl3_common.vs.glsl b/gsk/resources/glsl/gl3_common.vs.glsl
index 9794cf0..2fb825f 100644
--- a/gsk/resources/glsl/gl3_common.vs.glsl
+++ b/gsk/resources/glsl/gl3_common.vs.glsl
@@ -1,6 +1,5 @@
-uniform mat4 uMVP;
uniform mat4 uProjection;
-//uniform mat4 uModelview;
+uniform mat4 uModelview;
in vec2 aPosition;
in vec2 aUv;
diff --git a/gsk/resources/glsl/linear_gradient.fs.glsl b/gsk/resources/glsl/linear_gradient.fs.glsl
index d107e8a..f14b3eb 100644
--- a/gsk/resources/glsl/linear_gradient.fs.glsl
+++ b/gsk/resources/glsl/linear_gradient.fs.glsl
@@ -12,8 +12,8 @@ vec4 fragCoord() {
}
void main() {
- vec2 startPoint = (vec4(uStartPoint, 0, 1) * uModelview).xy;
- vec2 endPoint = (vec4(uEndPoint, 0, 1) * uModelview).xy;
+ vec2 startPoint = (uModelview * vec4(uStartPoint, 0, 1)).xy;
+ vec2 endPoint = (uModelview * vec4(uEndPoint, 0, 1)).xy;
float maxDist = length(endPoint - startPoint);
// Position relative to startPoint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]