aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c113
-rw-r--r--mesalib/src/mesa/main/format_unpack.c120
-rw-r--r--mesalib/src/mesa/main/format_unpack.h8
-rw-r--r--mesalib/src/mesa/main/mtypes.h13
-rw-r--r--mesalib/src/mesa/swrast/s_readpix.c19
5 files changed, 263 insertions, 10 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 3e553341d..8d589e4c3 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -182,7 +182,6 @@ struct save_state
GLboolean Lighting;
};
-
/**
* Temporary texture used for glBlitFramebuffer, glDrawPixels, etc.
* This is currently shared by all the meta ops. But we could create a
@@ -221,6 +220,9 @@ struct clear_state
GLuint VBO;
GLuint ShaderProg;
GLint ColorLocation;
+
+ GLuint IntegerShaderProg;
+ GLint IntegerColorLocation;
};
@@ -310,6 +312,67 @@ struct gl_meta_state
struct drawtex_state DrawTex; /**< For _mesa_meta_DrawTex() */
};
+static GLuint
+compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source)
+{
+ GLuint shader;
+ GLint ok, size;
+ GLchar *info;
+
+ shader = _mesa_CreateShaderObjectARB(target);
+ _mesa_ShaderSourceARB(shader, 1, &source, NULL);
+ _mesa_CompileShaderARB(shader);
+
+ _mesa_GetShaderiv(shader, GL_COMPILE_STATUS, &ok);
+ if (ok)
+ return shader;
+
+ _mesa_GetShaderiv(shader, GL_INFO_LOG_LENGTH, &size);
+ if (size == 0)
+ return 0;
+
+ info = malloc(size);
+ if (!info)
+ return 0;
+
+ _mesa_GetProgramInfoLog(shader, size, NULL, info);
+ _mesa_problem(ctx,
+ "meta program compile failed:\n%s\n"
+ "source:\n%s\n",
+ info, source);
+
+ free(info);
+
+ return 0;
+}
+
+static GLuint
+link_program_with_debug(struct gl_context *ctx, GLuint program)
+{
+ GLint ok, size;
+ GLchar *info;
+
+ _mesa_LinkProgramARB(program);
+
+ _mesa_GetProgramiv(program, GL_LINK_STATUS, &ok);
+ if (ok)
+ return program;
+
+ _mesa_GetProgramiv(program, GL_INFO_LOG_LENGTH, &size);
+ if (size == 0)
+ return 0;
+
+ info = malloc(size);
+ if (!info)
+ return 0;
+
+ _mesa_GetProgramInfoLog(program, size, NULL, info);
+ _mesa_problem(ctx, "meta program link failed:\n%s", info);
+
+ free(info);
+
+ return 0;
+}
/**
* Initialize meta-ops for a context.
@@ -1646,6 +1709,22 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
"{\n"
" gl_FragColor = color;\n"
"}\n";
+ const char *vs_int_source =
+ "#version 130\n"
+ "attribute vec4 position;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = position;\n"
+ "}\n";
+ const char *fs_int_source =
+ "#version 130\n"
+ "uniform ivec4 color;\n"
+ "out ivec4 out_color;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " out_color = color;\n"
+ "}\n";
GLuint vs, fs;
if (clear->ArrayObj != 0)
@@ -1679,6 +1758,26 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
clear->ColorLocation = _mesa_GetUniformLocationARB(clear->ShaderProg,
"color");
+
+ if (ctx->Const.GLSLVersion >= 130) {
+ vs = compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_int_source);
+ fs = compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_int_source);
+
+ clear->IntegerShaderProg = _mesa_CreateProgramObjectARB();
+ _mesa_AttachShader(clear->IntegerShaderProg, fs);
+ _mesa_AttachShader(clear->IntegerShaderProg, vs);
+ _mesa_BindAttribLocationARB(clear->IntegerShaderProg, 0, "position");
+
+ /* Note that user-defined out attributes get automatically assigned
+ * locations starting from 0, so we don't need to explicitly
+ * BindFragDataLocation to 0.
+ */
+
+ link_program_with_debug(ctx, clear->IntegerShaderProg);
+
+ clear->IntegerColorLocation =
+ _mesa_GetUniformLocationARB(clear->IntegerShaderProg, "color");
+ }
}
/**
@@ -1722,9 +1821,15 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
meta_glsl_clear_init(ctx, clear);
- _mesa_UseProgramObjectARB(clear->ShaderProg);
- _mesa_Uniform4fvARB(clear->ColorLocation, 1,
- ctx->Color.ClearColor.f);
+ if (fb->_IntegerColor) {
+ _mesa_UseProgramObjectARB(clear->IntegerShaderProg);
+ _mesa_Uniform4ivARB(clear->IntegerColorLocation, 1,
+ ctx->Color.ClearColor.i);
+ } else {
+ _mesa_UseProgramObjectARB(clear->ShaderProg);
+ _mesa_Uniform4fvARB(clear->ColorLocation, 1,
+ ctx->Color.ClearColor.f);
+ }
_mesa_BindVertexArray(clear->ArrayObj);
_mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index eaa33dfdb..525bbcb1c 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -1258,7 +1258,127 @@ _mesa_unpack_rgba_row(gl_format format, GLuint n,
}
}
+static void
+unpack_int_rgba_RGBA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ memcpy(dst, src, n * 4 * sizeof(GLuint));
+}
+
+static void
+unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i * 3 + 0];
+ dst[i][1] = src[i * 3 + 1];
+ dst[i][2] = src[i * 3 + 2];
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_RG_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i * 2 + 0];
+ dst[i][1] = src[i * 2 + 1];
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i];
+ dst[i][1] = 0;
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = src[i];
+ dst[i][3] = 1;
+ }
+}
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+ dst[i][3] = src[i * 2 + 1];
+ }
+}
+
+static void
+unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+ }
+}
+
+void
+_mesa_unpack_int_rgba_row(gl_format format, GLuint n,
+ const void *src, GLuint dst[][4])
+{
+ switch (format) {
+ /* Since there won't be any sign extension happening, there's no need to
+ * make separate paths for 32-bit-to-32-bit integer unpack.
+ */
+ case MESA_FORMAT_RGBA_UINT32:
+ case MESA_FORMAT_RGBA_INT32:
+ unpack_int_rgba_RGBA_UINT32(src, dst, n);
+ break;
+ case MESA_FORMAT_RGB_UINT32:
+ case MESA_FORMAT_RGB_INT32:
+ unpack_int_rgba_RGB_UINT32(src, dst, n);
+ break;
+ case MESA_FORMAT_RG_UINT32:
+ case MESA_FORMAT_RG_INT32:
+ unpack_int_rgba_RG_UINT32(src, dst, n);
+ break;
+ case MESA_FORMAT_R_UINT32:
+ case MESA_FORMAT_R_INT32:
+ unpack_int_rgba_R_UINT32(src, dst, n);
+ break;
+
+ case MESA_FORMAT_LUMINANCE_UINT32:
+ case MESA_FORMAT_LUMINANCE_INT32:
+ unpack_int_rgba_LUMINANCE_UINT32(src, dst, n);
+ break;
+ case MESA_FORMAT_LUMINANCE_ALPHA_UINT32:
+ case MESA_FORMAT_LUMINANCE_ALPHA_INT32:
+ unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src, dst, n);
+ break;
+ case MESA_FORMAT_INTENSITY_UINT32:
+ case MESA_FORMAT_INTENSITY_INT32:
+ unpack_int_rgba_INTENSITY_UINT32(src, dst, n);
+ break;
+
+ default:
+ _mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
+ _mesa_get_format_name(format));
+ return;
+ }
+}
/**
* Unpack a 2D rect of pixels returning float RGBA colors.
diff --git a/mesalib/src/mesa/main/format_unpack.h b/mesalib/src/mesa/main/format_unpack.h
index a8a829c88..0d13a2d39 100644
--- a/mesalib/src/mesa/main/format_unpack.h
+++ b/mesalib/src/mesa/main/format_unpack.h
@@ -29,12 +29,20 @@ _mesa_unpack_rgba_row(gl_format format, GLuint n,
const void *src, GLfloat dst[][4]);
+void
+_mesa_unpack_int_rgba_row(gl_format format, GLuint n,
+ const void *src, GLuint dst[][4]);
+
extern void
_mesa_unpack_rgba_block(gl_format format,
const void *src, GLint srcRowStride,
GLfloat dst[][4], GLint dstRowStride,
GLuint x, GLuint y, GLuint width, GLuint height);
+extern void
+_mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
+ const void *src, GLuint dst[][4]);
+
extern void
_mesa_unpack_float_z_row(gl_format format, GLuint n,
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 58dc9af0f..adcbaeb19 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1824,6 +1824,16 @@ struct prog_instruction;
struct gl_program_parameter_list;
struct gl_uniform_list;
+/** Post-link transform feedback info. */
+struct gl_transform_feedback_info {
+ unsigned NumOutputs;
+
+ struct {
+ unsigned OutputRegister;
+ unsigned OutputBuffer;
+ unsigned NumComponents;
+ } Outputs[MAX_PROGRAM_OUTPUTS];
+};
/**
* Base class for any kind of program object
@@ -2206,6 +2216,9 @@ struct gl_shader_program
GLchar **VaryingNames; /**< Array [NumVarying] of char * */
} TransformFeedback;
+ /** Post-link transform feedback info. */
+ struct gl_transform_feedback_info LinkedTransformFeedback;
+
/** Geometry shader state - copied into gl_geometry_program at link time */
struct {
GLint VerticesOut;
diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c
index 4438b9a20..b5618e884 100644
--- a/mesalib/src/mesa/swrast/s_readpix.c
+++ b/mesalib/src/mesa/swrast/s_readpix.c
@@ -236,7 +236,10 @@ slow_read_rgba_pixels( struct gl_context *ctx,
GLbitfield transferOps )
{
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
- GLfloat rgba[MAX_WIDTH][4];
+ union {
+ float f[MAX_WIDTH][4];
+ unsigned int i[MAX_WIDTH][4];
+ } rgba;
GLubyte *dst, *map;
int dstStride, stride, j;
@@ -248,11 +251,15 @@ slow_read_rgba_pixels( struct gl_context *ctx,
&map, &stride);
for (j = 0; j < height; j++) {
- _mesa_unpack_rgba_row(_mesa_get_srgb_format_linear(rb->Format),
- width, map, rgba);
- _mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
- packing, transferOps);
-
+ if (_mesa_is_integer_format(format)) {
+ _mesa_unpack_int_rgba_row(rb->Format, width, map, rgba.i);
+ _mesa_pack_rgba_span_int(ctx, width, rgba.i, format, type, dst);
+ } else {
+ _mesa_unpack_rgba_row(_mesa_get_srgb_format_linear(rb->Format),
+ width, map, rgba.f);
+ _mesa_pack_rgba_span_float(ctx, width, rgba.f, format, type, dst,
+ packing, transferOps);
+ }
dst += dstStride;
map += stride;
}