diff options
author | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2014-03-01 13:11:16 +0400 |
---|---|---|
committer | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2014-03-01 13:11:16 +0400 |
commit | b302cd09ec8b582ccf9cc54db9d7efb7ed3a73e9 (patch) | |
tree | 2c65e12624c0f134db2d2e8061531817e9bf221f /hw/vigs | |
parent | f7f78f74373df057f39d5fc4c4906c76a9000287 (diff) | |
download | qemu-b302cd09ec8b582ccf9cc54db9d7efb7ed3a73e9.tar.gz qemu-b302cd09ec8b582ccf9cc54db9d7efb7ed3a73e9.tar.bz2 qemu-b302cd09ec8b582ccf9cc54db9d7efb7ed3a73e9.zip |
VIGS: Use proper shader versions
We need to use 120 shaders when in legacy mode and
140 shaders when in GL3 mode
Change-Id: Ic9cd8aee5a9dd936c57f40c9d255f7497f158c45
Diffstat (limited to 'hw/vigs')
-rw-r--r-- | hw/vigs/vigs_gl_backend.c | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/hw/vigs/vigs_gl_backend.c b/hw/vigs/vigs_gl_backend.c index a0175208e0..c20d45749b 100644 --- a/hw/vigs/vigs_gl_backend.c +++ b/hw/vigs/vigs_gl_backend.c @@ -128,7 +128,8 @@ static __inline struct vigs_winsys_gl_surface * @{ */ -static const char *g_vs_tex_source = +static const char *g_vs_tex_source_gl2 = + "#version 120\n\n" "attribute vec4 vertCoord;\n" "uniform mat4 proj;\n" "attribute vec2 texCoord;\n" @@ -139,7 +140,20 @@ static const char *g_vs_tex_source = " gl_Position = proj * vertCoord;\n" "}\n"; -static const char *g_fs_tex_source = +static const char *g_vs_tex_source_gl3 = + "#version 140\n\n" + "in vec4 vertCoord;\n" + "uniform mat4 proj;\n" + "in vec2 texCoord;\n" + "out vec2 v_texCoord;\n" + "void main()\n" + "{\n" + " v_texCoord = texCoord;\n" + " gl_Position = proj * vertCoord;\n" + "}\n"; + +static const char *g_fs_tex_source_gl2 = + "#version 120\n\n" "uniform sampler2D tex;\n" "varying vec2 v_texCoord;\n" "void main()\n" @@ -147,7 +161,18 @@ static const char *g_fs_tex_source = " gl_FragColor = texture2D(tex, v_texCoord);\n" "}\n"; -static const char *g_vs_color_source = +static const char *g_fs_tex_source_gl3 = + "#version 140\n\n" + "uniform sampler2D tex;\n" + "in vec2 v_texCoord;\n" + "out vec4 FragColor;\n" + "void main()\n" + "{\n" + " FragColor = texture(tex, v_texCoord);\n" + "}\n"; + +static const char *g_vs_color_source_gl2 = + "#version 120\n\n" "attribute vec4 vertCoord;\n" "uniform mat4 proj;\n" "void main()\n" @@ -155,13 +180,32 @@ static const char *g_vs_color_source = " gl_Position = proj * vertCoord;\n" "}\n"; -static const char *g_fs_color_source = +static const char *g_vs_color_source_gl3 = + "#version 140\n\n" + "in vec4 vertCoord;\n" + "uniform mat4 proj;\n" + "void main()\n" + "{\n" + " gl_Position = proj * vertCoord;\n" + "}\n"; + +static const char *g_fs_color_source_gl2 = + "#version 120\n\n" "uniform vec4 color;\n" "void main()\n" "{\n" " gl_FragColor = color;\n" "}\n"; +static const char *g_fs_color_source_gl3 = + "#version 140\n\n" + "uniform vec4 color;\n" + "out vec4 FragColor;\n" + "void main()\n" + "{\n" + " FragColor = color;\n" + "}\n"; + static GLuint vigs_gl_create_shader(struct vigs_gl_backend *backend, const char *source, GLenum type) @@ -1367,16 +1411,16 @@ bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend) } gl_backend->tex_prog_vs_id = vigs_gl_create_shader(gl_backend, - g_vs_tex_source, - GL_VERTEX_SHADER); + (gl_backend->is_gl_2 ? g_vs_tex_source_gl2 : g_vs_tex_source_gl3), + GL_VERTEX_SHADER); if (!gl_backend->tex_prog_vs_id) { goto fail; } gl_backend->tex_prog_fs_id = vigs_gl_create_shader(gl_backend, - g_fs_tex_source, - GL_FRAGMENT_SHADER); + (gl_backend->is_gl_2 ? g_fs_tex_source_gl2 : g_fs_tex_source_gl3), + GL_FRAGMENT_SHADER); if (!gl_backend->tex_prog_fs_id) { goto fail; @@ -1395,16 +1439,16 @@ bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend) gl_backend->tex_prog_texCoord_loc = gl_backend->GetAttribLocation(gl_backend->tex_prog_id, "texCoord"); gl_backend->color_prog_vs_id = vigs_gl_create_shader(gl_backend, - g_vs_color_source, - GL_VERTEX_SHADER); + (gl_backend->is_gl_2 ? g_vs_color_source_gl2 : g_vs_color_source_gl3), + GL_VERTEX_SHADER); if (!gl_backend->color_prog_vs_id) { goto fail; } gl_backend->color_prog_fs_id = vigs_gl_create_shader(gl_backend, - g_fs_color_source, - GL_FRAGMENT_SHADER); + (gl_backend->is_gl_2 ? g_fs_color_source_gl2 : g_fs_color_source_gl3), + GL_FRAGMENT_SHADER); if (!gl_backend->color_prog_fs_id) { goto fail; |