aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers/common
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/drivers/common')
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c93
1 files changed, 41 insertions, 52 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index d0bb5e0ae..24d8d485a 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -78,7 +78,6 @@
#include "main/glformats.h"
#include "../glsl/ralloc.h"
-static void *mem_ctx;
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
@@ -3048,7 +3047,6 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
};
struct glsl_sampler *sampler;
const char *vs_source;
- const char *fs_template;
static const char *vs_int_source =
"#version 130\n"
@@ -3071,49 +3069,8 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
" out_color = texture(tex2d, texCoords.xy);\n"
"}\n";
char *fs_source;
- const char *extension_mode;
GLuint vs, fs;
-
- if (ctx->Const.GLSLVersion < 130) {
- vs_source =
- "attribute vec2 position;\n"
- "attribute vec3 textureCoords;\n"
- "varying vec3 texCoords;\n"
- "void main()\n"
- "{\n"
- " texCoords = textureCoords;\n"
- " gl_Position = vec4(position, 0.0, 1.0);\n"
- "}\n";
- fs_template =
- "#extension GL_EXT_texture_array : %s\n"
- "uniform %s texSampler;\n"
- "varying vec3 texCoords;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = %s(texSampler, %s);\n"
- "}\n";
- } else {
- vs_source =
- "#version 130\n"
- "in vec2 position;\n"
- "in vec3 textureCoords;\n"
- "out vec3 texCoords;\n"
- "void main()\n"
- "{\n"
- " texCoords = textureCoords;\n"
- " gl_Position = vec4(position, 0.0, 1.0);\n"
- "}\n";
- fs_template =
- "#version 130\n"
- "uniform %s texSampler;\n"
- "in vec3 texCoords;\n"
- "out %s out_color;\n"
- "\n"
- "void main()\n"
- "{\n"
- " out_color = texture(texSampler, %s);\n"
- "}\n";
- }
+ void *mem_ctx;
/* Check if already initialized */
if (mipmap->ArrayObj == 0) {
@@ -3143,18 +3100,50 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
mem_ctx = ralloc_context(NULL);
- if (ctx->Const.GLSLVersion < 130) {
- extension_mode = ((target == GL_TEXTURE_1D_ARRAY) ||
- (target == GL_TEXTURE_2D_ARRAY)) ?
- "require" : "disable";
+ if (ctx->API == API_OPENGLES2 || ctx->Const.GLSLVersion < 130) {
+ vs_source =
+ "attribute vec2 position;\n"
+ "attribute vec3 textureCoords;\n"
+ "varying vec3 texCoords;\n"
+ "void main()\n"
+ "{\n"
+ " texCoords = textureCoords;\n"
+ " gl_Position = vec4(position, 0.0, 1.0);\n"
+ "}\n";
- fs_source = ralloc_asprintf(mem_ctx, fs_template,
- extension_mode, sampler->type,
+ fs_source = ralloc_asprintf(mem_ctx,
+ "#extension GL_EXT_texture_array : enable\n"
+ "uniform %s texSampler;\n"
+ "varying vec3 texCoords;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = %s(texSampler, %s);\n"
+ "}\n",
+ sampler->type,
sampler->func, sampler->texcoords);
}
else {
- fs_source = ralloc_asprintf(mem_ctx, fs_template,
- sampler->type, "vec4",
+ vs_source =
+ "#version 130\n"
+ "in vec2 position;\n"
+ "in vec3 textureCoords;\n"
+ "out vec3 texCoords;\n"
+ "void main()\n"
+ "{\n"
+ " texCoords = textureCoords;\n"
+ " gl_Position = vec4(position, 0.0, 1.0);\n"
+ "}\n";
+ fs_source = ralloc_asprintf(mem_ctx,
+ "#version 130\n"
+ "uniform %s texSampler;\n"
+ "in vec3 texCoords;\n"
+ "out vec4 out_color;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " out_color = texture(texSampler, %s);\n"
+ "}\n",
+ sampler->type,
sampler->texcoords);
}