aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-10 08:28:58 +0200
committermarha <marha@users.sourceforge.net>2011-10-10 08:28:58 +0200
commitbaf98f9bb36f956245d83ecd04f90625d6d68d2b (patch)
treec4af86b7cdb9c57cc539fa0764050865233e3617 /mesalib/src
parent7fae5492e3ef8e5fa15f742be4c2a15b9782e89a (diff)
parentafbd3947071a33f59dda122f1ac396442a02c128 (diff)
downloadvcxsrv-baf98f9bb36f956245d83ecd04f90625d6d68d2b.tar.gz
vcxsrv-baf98f9bb36f956245d83ecd04f90625d6d68d2b.tar.bz2
vcxsrv-baf98f9bb36f956245d83ecd04f90625d6d68d2b.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c353
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.h47
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c132
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.csv61
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h86
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_pack.py1388
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_parse.py594
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_table.py409
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tile.c138
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tile.h291
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp3
-rw-r--r--mesalib/src/glsl/ir.cpp8
-rw-r--r--mesalib/src/glsl/ir.h8
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c3
-rw-r--r--mesalib/src/mesa/main/APIspec.xml14
-rw-r--r--mesalib/src/mesa/main/context.c8
-rw-r--r--mesalib/src/mesa/main/dd.h1
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp10
-rw-r--r--mesalib/src/mesa/main/formats.c8
-rw-r--r--mesalib/src/mesa/main/get.c3
-rw-r--r--mesalib/src/mesa/main/imports.c13
-rw-r--r--mesalib/src/mesa/main/imports.h3
-rw-r--r--mesalib/src/mesa/main/mipmap.c38
-rw-r--r--mesalib/src/mesa/main/mtypes.h7
-rw-r--r--mesalib/src/mesa/main/pack.c63
-rw-r--r--mesalib/src/mesa/main/pack.h5
-rw-r--r--mesalib/src/mesa/main/shaderapi.c32
-rw-r--r--mesalib/src/mesa/main/shaderobj.c4
-rw-r--r--mesalib/src/mesa/main/state.c18
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.c9
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c16
-rw-r--r--mesalib/src/mesa/main/texformat.c204
-rw-r--r--mesalib/src/mesa/main/texstate.c18
-rw-r--r--mesalib/src/mesa/main/uniforms.c42
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp37
-rw-r--r--mesalib/src/mesa/program/prog_uniform.c74
-rw-r--r--mesalib/src/mesa/program/prog_uniform.h4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_readpixels.c40
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c453
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp44
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c9
-rw-r--r--mesalib/src/mesa/swrast/s_context.h17
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c74
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.h2
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c80
-rw-r--r--mesalib/src/mesa/swrast/s_texrender.c34
-rw-r--r--mesalib/src/mesa/tnl/t_vb_program.c14
47 files changed, 2976 insertions, 1943 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 58a52b3f2..89dae9556 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -68,6 +68,7 @@ struct blitter_context_priv
/* Fragment shaders. */
/* The shader at index i outputs color to color buffers 0,1,...,i-1. */
void *fs_col[PIPE_MAX_COLOR_BUFS+1];
+ void *fs_col_int[PIPE_MAX_COLOR_BUFS+1];
/* FS which outputs a color from a texture,
where the index is PIPE_TEXTURE_* to be sampled. */
@@ -88,6 +89,8 @@ struct blitter_context_priv
void *dsa_keep_depth_write_stencil;
void *velem_state;
+ void *velem_uint_state;
+ void *velem_sint_state;
/* Sampler state for clamping to a miplevel. */
void *sampler_state[PIPE_MAX_TEXTURE_LEVELS * 2];
@@ -104,6 +107,9 @@ struct blitter_context_priv
/* Destination surface dimensions. */
unsigned dst_width;
unsigned dst_height;
+
+ boolean has_geometry_shader;
+ boolean vertex_has_integers;
};
static void blitter_draw_rectangle(struct blitter_context *blitter,
@@ -137,12 +143,20 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
ctx->base.saved_rs_state = INVALID_PTR;
ctx->base.saved_fs = INVALID_PTR;
ctx->base.saved_vs = INVALID_PTR;
+ ctx->base.saved_gs = INVALID_PTR;
ctx->base.saved_velem_state = INVALID_PTR;
ctx->base.saved_fb_state.nr_cbufs = ~0;
ctx->base.saved_num_sampler_views = ~0;
ctx->base.saved_num_sampler_states = ~0;
ctx->base.saved_num_vertex_buffers = ~0;
+ ctx->has_geometry_shader =
+ pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_GEOMETRY,
+ PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0;
+ ctx->vertex_has_integers =
+ pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_VERTEX,
+ PIPE_SHADER_CAP_INTEGERS);
+
/* blend state objects */
memset(&blend, 0, sizeof(blend));
ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend);
@@ -201,6 +215,30 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
}
ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
+ if (ctx->vertex_has_integers) {
+ memset(&velem[0], 0, sizeof(velem[0]) * 2);
+ for (i = 0; i < 2; i++) {
+ velem[i].src_offset = i * 4 * sizeof(float);
+ if (i == 0) {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ } else {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_SINT;
+ }
+ }
+ ctx->velem_sint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
+
+ memset(&velem[0], 0, sizeof(velem[0]) * 2);
+ for (i = 0; i < 2; i++) {
+ velem[i].src_offset = i * 4 * sizeof(float);
+ if (i == 0) {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ } else {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_UINT;
+ }
+ }
+ ctx->velem_uint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
+ }
+
/* fragment shaders are created on-demand */
/* vertex shader */
@@ -243,6 +281,10 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe->delete_rasterizer_state(pipe, ctx->rs_state);
pipe->delete_vs_state(pipe, ctx->vs);
pipe->delete_vertex_elements_state(pipe, ctx->velem_state);
+ if (ctx->vertex_has_integers) {
+ pipe->delete_vertex_elements_state(pipe, ctx->velem_sint_state);
+ pipe->delete_vertex_elements_state(pipe, ctx->velem_uint_state);
+ }
for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) {
if (ctx->fs_texfetch_col[i])
@@ -251,9 +293,12 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
}
- for (i = 0; i <= PIPE_MAX_COLOR_BUFS; i++)
+ for (i = 0; i <= PIPE_MAX_COLOR_BUFS; i++) {
if (ctx->fs_col[i])
pipe->delete_fs_state(pipe, ctx->fs_col[i]);
+ if (ctx->fs_col_int[i])
+ pipe->delete_fs_state(pipe, ctx->fs_col_int[i]);
+ }
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS * 2; i++)
if (ctx->sampler_state[i])
@@ -263,100 +308,140 @@ void util_blitter_destroy(struct blitter_context *blitter)
FREE(ctx);
}
-static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx)
+static void blitter_set_running_flag(struct blitter_context_priv *ctx)
{
if (ctx->base.running) {
- _debug_printf("u_blitter: Caught recursion on save. "
- "This is a driver bug.\n");
+ _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n",
+ __LINE__);
}
ctx->base.running = TRUE;
+}
- /* make sure these CSOs have been saved */
- assert(ctx->base.saved_blend_state != INVALID_PTR &&
- ctx->base.saved_dsa_state != INVALID_PTR &&
- ctx->base.saved_rs_state != INVALID_PTR &&
- ctx->base.saved_fs != INVALID_PTR &&
+static void blitter_unset_running_flag(struct blitter_context_priv *ctx)
+{
+ if (!ctx->base.running) {
+ _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n",
+ __LINE__);
+ }
+ ctx->base.running = FALSE;
+}
+
+static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_num_vertex_buffers != ~0 &&
+ ctx->base.saved_velem_state != INVALID_PTR &&
ctx->base.saved_vs != INVALID_PTR &&
- ctx->base.saved_velem_state != INVALID_PTR);
+ (!ctx->has_geometry_shader || ctx->base.saved_gs != INVALID_PTR) &&
+ ctx->base.saved_rs_state != INVALID_PTR);
}
-static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
+static void blitter_restore_vertex_states(struct blitter_context_priv *ctx)
{
struct pipe_context *pipe = ctx->base.pipe;
unsigned i;
- /* restore the state objects which are always required to be saved */
- pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state);
- pipe->bind_vs_state(pipe, ctx->base.saved_vs);
+ /* Vertex buffers. */
+ pipe->set_vertex_buffers(pipe,
+ ctx->base.saved_num_vertex_buffers,
+ ctx->base.saved_vertex_buffers);
+
+ for (i = 0; i < ctx->base.saved_num_vertex_buffers; i++) {
+ if (ctx->base.saved_vertex_buffers[i].buffer) {
+ pipe_resource_reference(&ctx->base.saved_vertex_buffers[i].buffer,
+ NULL);
+ }
+ }
+ ctx->base.saved_num_vertex_buffers = ~0;
+
+ /* Vertex elements. */
pipe->bind_vertex_elements_state(pipe, ctx->base.saved_velem_state);
+ ctx->base.saved_velem_state = INVALID_PTR;
- ctx->base.saved_rs_state = INVALID_PTR;
+ /* Vertex shader. */
+ pipe->bind_vs_state(pipe, ctx->base.saved_vs);
ctx->base.saved_vs = INVALID_PTR;
- ctx->base.saved_velem_state = INVALID_PTR;
- /* restore the state objects which are required to be saved for clear/copy
- */
- if (ctx->base.saved_blend_state != INVALID_PTR) {
- pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
- ctx->base.saved_blend_state = INVALID_PTR;
- }
- if (ctx->base.saved_dsa_state != INVALID_PTR) {
- pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
- ctx->base.saved_dsa_state = INVALID_PTR;
- }
- if (ctx->base.saved_fs != INVALID_PTR) {
- pipe->bind_fs_state(pipe, ctx->base.saved_fs);
- ctx->base.saved_fs = INVALID_PTR;
+ /* Geometry shader. */
+ if (ctx->has_geometry_shader) {
+ pipe->bind_gs_state(pipe, ctx->base.saved_gs);
+ ctx->base.saved_gs = INVALID_PTR;
}
+ /* Rasterizer. */
+ pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state);
+ ctx->base.saved_rs_state = INVALID_PTR;
+}
+
+static void blitter_check_saved_fragment_states(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_fs != INVALID_PTR &&
+ ctx->base.saved_dsa_state != INVALID_PTR &&
+ ctx->base.saved_blend_state != INVALID_PTR);
+}
+
+static void blitter_restore_fragment_states(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->base.pipe;
+
+ /* Fragment shader. */
+ pipe->bind_fs_state(pipe, ctx->base.saved_fs);
+ ctx->base.saved_fs = INVALID_PTR;
+
+ /* Depth, stencil, alpha. */
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
+ ctx->base.saved_dsa_state = INVALID_PTR;
+
+ /* Blend state. */
+ pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
+ ctx->base.saved_blend_state = INVALID_PTR;
+
+ /* Miscellaneous states. */
+ /* XXX check whether these are saved and whether they need to be restored
+ * (depending on the operation) */
pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
pipe->set_viewport_state(pipe, &ctx->base.saved_viewport);
pipe->set_clip_state(pipe, &ctx->base.saved_clip);
+}
- if (ctx->base.saved_fb_state.nr_cbufs != ~0) {
- pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state);
- util_unreference_framebuffer_state(&ctx->base.saved_fb_state);
- ctx->base.saved_fb_state.nr_cbufs = ~0;
- }
+static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_fb_state.nr_cbufs != ~0);
+}
- if (ctx->base.saved_num_sampler_states != ~0) {
- pipe->bind_fragment_sampler_states(pipe,
- ctx->base.saved_num_sampler_states,
- ctx->base.saved_sampler_states);
- ctx->base.saved_num_sampler_states = ~0;
- }
+static void blitter_restore_fb_state(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->base.pipe;
- if (ctx->base.saved_num_sampler_views != ~0) {
- pipe->set_fragment_sampler_views(pipe,
- ctx->base.saved_num_sampler_views,
- ctx->base.saved_sampler_views);
+ pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state);
+ util_unreference_framebuffer_state(&ctx->base.saved_fb_state);
+}
- for (i = 0; i < ctx->base.saved_num_sampler_views; i++)
- pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i],
- NULL);
+static void blitter_check_saved_textures(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_num_sampler_states != ~0 &&
+ ctx->base.saved_num_sampler_views != ~0);
+}
- ctx->base.saved_num_sampler_views = ~0;
- }
+static void blitter_restore_textures(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->base.pipe;
+ unsigned i;
- if (ctx->base.saved_num_vertex_buffers != ~0) {
- pipe->set_vertex_buffers(pipe,
- ctx->base.saved_num_vertex_buffers,
- ctx->base.saved_vertex_buffers);
+ /* Fragment sampler states. */
+ pipe->bind_fragment_sampler_states(pipe,
+ ctx->base.saved_num_sampler_states,
+ ctx->base.saved_sampler_states);
+ ctx->base.saved_num_sampler_states = ~0;
- for (i = 0; i < ctx->base.saved_num_vertex_buffers; i++) {
- if (ctx->base.saved_vertex_buffers[i].buffer) {
- pipe_resource_reference(&ctx->base.saved_vertex_buffers[i].buffer,
- NULL);
- }
- }
- ctx->base.saved_num_vertex_buffers = ~0;
- }
+ /* Fragment sampler views. */
+ pipe->set_fragment_sampler_views(pipe,
+ ctx->base.saved_num_sampler_views,
+ ctx->base.saved_sampler_views);
- if (!ctx->base.running) {
- _debug_printf("u_blitter: Caught recursion on restore. "
- "This is a driver bug.\n");
- }
- ctx->base.running = FALSE;
+ for (i = 0; i < ctx->base.saved_num_sampler_views; i++)
+ pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i], NULL);
+
+ ctx->base.saved_num_sampler_views = ~0;
}
static void blitter_set_rectangle(struct blitter_context_priv *ctx,
@@ -404,10 +489,11 @@ static void blitter_set_clear_color(struct blitter_context_priv *ctx,
if (color) {
for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][0] = color->f[0];
- ctx->vertices[i][1][1] = color->f[1];
- ctx->vertices[i][1][2] = color->f[2];
- ctx->vertices[i][1][3] = color->f[3];
+ uint32_t *uiverts = (uint32_t *)ctx->vertices[i][1];
+ uiverts[0] = color->ui[0];
+ uiverts[1] = color->ui[1];
+ uiverts[2] = color->ui[2];
+ uiverts[3] = color->ui[3];
}
} else {
for (i = 0; i < 4; i++) {
@@ -562,19 +648,28 @@ void **blitter_get_sampler_state(struct blitter_context_priv *ctx,
}
static INLINE
-void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
+void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs,
+ boolean int_format)
{
struct pipe_context *pipe = ctx->base.pipe;
assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
- if (!ctx->fs_col[num_cbufs])
- ctx->fs_col[num_cbufs] =
- util_make_fragment_cloneinput_shader(pipe, num_cbufs,
- TGSI_SEMANTIC_GENERIC,
- TGSI_INTERPOLATE_LINEAR);
-
- return ctx->fs_col[num_cbufs];
+ if (int_format) {
+ if (!ctx->fs_col_int[num_cbufs])
+ ctx->fs_col_int[num_cbufs] =
+ util_make_fragment_cloneinput_shader(pipe, num_cbufs,
+ TGSI_SEMANTIC_GENERIC,
+ TGSI_INTERPOLATE_CONSTANT);
+ return ctx->fs_col_int[num_cbufs];
+ } else {
+ if (!ctx->fs_col[num_cbufs])
+ ctx->fs_col[num_cbufs] =
+ util_make_fragment_cloneinput_shader(pipe, num_cbufs,
+ TGSI_SEMANTIC_GENERIC,
+ TGSI_INTERPOLATE_LINEAR);
+ return ctx->fs_col[num_cbufs];
+ }
}
/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
@@ -674,6 +769,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
+ enum pipe_format cbuf_format,
const union pipe_color_union *color,
double depth, unsigned stencil,
void *custom_blend, void *custom_dsa)
@@ -681,12 +777,14 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_stencil_ref sr = { { 0 } };
-
+ boolean int_format = util_format_is_pure_integer(cbuf_format);
assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
- blitter_check_saved_CSOs(ctx);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
- /* bind CSOs */
+ /* bind states */
if (custom_blend) {
pipe->bind_blend_state(pipe, custom_blend);
} else if (clear_buffers & PIPE_CLEAR_COLOR) {
@@ -711,25 +809,37 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
pipe->set_stencil_ref(pipe, &sr);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs));
+ if (util_format_is_pure_sint(cbuf_format)) {
+ pipe->bind_vertex_elements_state(pipe, ctx->velem_sint_state);
+ } else if (util_format_is_pure_uint(cbuf_format)) {
+ pipe->bind_vertex_elements_state(pipe, ctx->velem_uint_state);
+ } else {
+ pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
+ }
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs, int_format));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
blitter_set_dst_dimensions(ctx, width, height);
blitter->draw_rectangle(blitter, 0, 0, width, height, depth,
UTIL_BLITTER_ATTRIB_COLOR, color);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_unset_running_flag(ctx);
}
void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
+ enum pipe_format cbuf_format,
const union pipe_color_union *color,
double depth, unsigned stencil)
{
util_blitter_clear_custom(blitter, width, height, num_cbufs,
- clear_buffers, color, depth, stencil,
+ clear_buffers, cbuf_format, color, depth, stencil,
NULL, NULL);
}
@@ -739,7 +849,7 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
{
static const union pipe_color_union color;
util_blitter_clear_custom(blitter, width, height, 0,
- 0, &color, depth, 0, NULL, custom_dsa);
+ 0, PIPE_FORMAT_NONE, &color, depth, 0, NULL, custom_dsa);
}
static
@@ -817,10 +927,11 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
dstsurf = pipe->create_surface(pipe, dst, &surf_templ);
/* Check whether the states are properly saved. */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
- assert(blitter->saved_num_sampler_views != ~0);
- assert(blitter->saved_num_sampler_states != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_textures(ctx);
+ blitter_check_saved_fb_state(ctx);
/* Initialize framebuffer state. */
fb_state.width = dstsurf->width;
@@ -855,6 +966,8 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
/* Set rasterizer state, shaders, and textures. */
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_fragment_sampler_states(pipe, 1,
blitter_get_sampler_state(ctx, srclevel, normalized));
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
@@ -918,7 +1031,11 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
break;
}
- blitter_restore_CSOs(ctx);
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_textures(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
pipe_surface_reference(&dstsurf, NULL);
pipe_sampler_view_reference(&view, NULL);
@@ -940,15 +1057,19 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
return;
/* check the saved state */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_fb_state(ctx);
- /* bind CSOs */
+ /* bind states */
pipe->bind_blend_state(pipe, ctx->blend_write_color);
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1));
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
@@ -962,7 +1083,11 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
UTIL_BLITTER_ATTRIB_COLOR, color);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
}
/* Clear a region of a depth stencil surface. */
@@ -984,10 +1109,12 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
return;
/* check the saved state */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_fb_state(ctx);
- /* bind CSOs */
+ /* bind states */
pipe->bind_blend_state(pipe, ctx->blend_keep_color);
if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) == PIPE_CLEAR_DEPTHSTENCIL) {
sr.ref_value[0] = stencil & 0xff;
@@ -1007,8 +1134,10 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0));
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
@@ -1022,7 +1151,11 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, depth,
UTIL_BLITTER_ATTRIB_NONE, NULL);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
}
/* draw a rectangle across a region using a custom dsa stage - for r600g */
@@ -1040,16 +1173,20 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
return;
/* check the saved state */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_fb_state(ctx);
- /* bind CSOs */
+ /* bind states */
pipe->bind_blend_state(pipe, ctx->blend_write_color);
pipe->bind_depth_stencil_alpha_state(pipe, dsa_stage);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0));
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
@@ -1069,5 +1206,9 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height);
blitter->draw_rectangle(blitter, 0, 0, zsurf->width, zsurf->height, depth,
UTIL_BLITTER_ATTRIB_NONE, NULL);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h
index a9ad02364..798096e74 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.h
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h
@@ -89,7 +89,7 @@ struct blitter_context
void *saved_dsa_state; /**< depth stencil alpha state */
void *saved_velem_state; /**< vertex elements state */
void *saved_rs_state; /**< rasterizer state */
- void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */
+ void *saved_fs, *saved_vs, *saved_gs; /**< shaders */
struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */
@@ -126,24 +126,28 @@ struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
}
/*
- * These states must be saved before any of the following functions is called:
- * - blend state
- * - depth stencil alpha state
- * - rasterizer state
- * - vertex shader
- * - any other shader??? (XXX)
- * - fragment shader
+ * These states must be saved before any of the following functions are called:
* - vertex buffers
* - vertex elements
+ * - vertex shader
+ * - geometry shader (if supported)
+ * - rasterizer state
*/
/**
* Clear a specified set of currently bound buffers to specified values.
+ *
+ * These states must be saved in the blitter in addition to the state objects
+ * already required to be saved:
+ * - fragment shader
+ * - depth stencil alpha state
+ * - blend state
*/
void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
+ enum pipe_format cbuf_format,
const union pipe_color_union *color,
double depth, unsigned stencil);
@@ -155,7 +159,7 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
* Copy a block of pixels from one surface to another.
*
* You can copy from any color format to any other color format provided
- * the former can be sampled and the latter can be rendered to. Otherwise,
+ * the former can be sampled from and the latter can be rendered to. Otherwise,
* a software fallback path is taken and both surfaces must be of the same
* format.
*
@@ -163,14 +167,18 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
* cannot be copied unless you set ignore_stencil to FALSE. In that case,
* a software fallback path is taken and both surfaces must be of the same
* format.
+ * XXX implement hw-accel stencil copy using shader stencil export.
*
* Use pipe_screen->is_format_supported to know your options.
*
* These states must be saved in the blitter in addition to the state objects
* already required to be saved:
- * - framebuffer state
+ * - fragment shader
+ * - depth stencil alpha state
+ * - blend state
* - fragment sampler states
* - fragment sampler textures
+ * - framebuffer state
*/
void util_blitter_copy_texture(struct blitter_context *blitter,
struct pipe_resource *dst,
@@ -186,6 +194,9 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
*
* These states must be saved in the blitter in addition to the state objects
* already required to be saved:
+ * - fragment shader
+ * - depth stencil alpha state
+ * - blend state
* - framebuffer state
*/
void util_blitter_clear_render_target(struct blitter_context *blitter,
@@ -200,6 +211,9 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
*
* These states must be saved in the blitter in addition to the state objects
* already required to be saved:
+ * - fragment shader
+ * - depth stencil alpha state
+ * - blend state
* - framebuffer state
*/
void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
@@ -220,7 +234,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
* of the util_blitter_{clear, copy_region, fill_region} functions and then
* forgotten.
*
- * CSOs not listed here are not affected by util_blitter. */
+ * States not listed here are not affected by util_blitter. */
static INLINE
void util_blitter_save_blend(struct blitter_context *blitter,
@@ -272,6 +286,13 @@ void util_blitter_save_vertex_shader(struct blitter_context *blitter,
}
static INLINE
+void util_blitter_save_geometry_shader(struct blitter_context *blitter,
+ void *gs)
+{
+ blitter->saved_gs = gs;
+}
+
+static INLINE
void util_blitter_save_framebuffer(struct blitter_context *blitter,
const struct pipe_framebuffer_state *state)
{
@@ -322,8 +343,8 @@ util_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
static INLINE void
util_blitter_save_vertex_buffers(struct blitter_context *blitter,
- int num_vertex_buffers,
- struct pipe_vertex_buffer *vertex_buffers)
+ int num_vertex_buffers,
+ struct pipe_vertex_buffer *vertex_buffers)
{
assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers));
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c
index 9bf42583e..730dc31ac 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format.c
@@ -52,14 +52,8 @@ util_format_is_float(enum pipe_format format)
return FALSE;
}
- /* Find the first non-void channel. */
- for (i = 0; i < 4; i++) {
- if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
- break;
- }
- }
-
- if (i == 4) {
+ i = util_format_get_first_non_void_channel(format);
+ if (i == -1) {
return FALSE;
}
@@ -124,6 +118,45 @@ util_format_is_luminance(enum pipe_format format)
return FALSE;
}
+boolean
+util_format_is_pure_integer(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ int i;
+
+ /* Find the first non-void channel. */
+ i = util_format_get_first_non_void_channel(format);
+ if (i == -1)
+ return FALSE;
+
+ return desc->channel[i].pure_integer ? TRUE : FALSE;
+}
+
+boolean
+util_format_is_pure_sint(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ int i;
+
+ i = util_format_get_first_non_void_channel(format);
+ if (i == -1)
+ return FALSE;
+
+ return (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
+}
+
+boolean
+util_format_is_pure_uint(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ int i;
+
+ i = util_format_get_first_non_void_channel(format);
+ if (i == -1)
+ return FALSE;
+
+ return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
+}
boolean
util_format_is_luminance_alpha(enum pipe_format format)
@@ -262,6 +295,89 @@ util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_
format_desc->pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
}
+void
+util_format_read_4ui(enum pipe_format format,
+ unsigned *dst, unsigned dst_stride,
+ const void *src, unsigned src_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ const struct util_format_description *format_desc;
+ const uint8_t *src_row;
+ unsigned *dst_row;
+
+ format_desc = util_format_description(format);
+
+ assert(x % format_desc->block.width == 0);
+ assert(y % format_desc->block.height == 0);
+
+ src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
+ dst_row = dst;
+
+ format_desc->unpack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h);
+}
+
+void
+util_format_write_4ui(enum pipe_format format,
+ const unsigned int *src, unsigned src_stride,
+ void *dst, unsigned dst_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ const struct util_format_description *format_desc;
+ uint8_t *dst_row;
+ const unsigned *src_row;
+
+ format_desc = util_format_description(format);
+
+ assert(x % format_desc->block.width == 0);
+ assert(y % format_desc->block.height == 0);
+
+ dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
+ src_row = src;
+
+ format_desc->pack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h);
+}
+
+void
+util_format_read_4i(enum pipe_format format,
+ int *dst, unsigned dst_stride,
+ const void *src, unsigned src_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ const struct util_format_description *format_desc;
+ const uint8_t *src_row;
+ int *dst_row;
+
+ format_desc = util_format_description(format);
+
+ assert(x % format_desc->block.width == 0);
+ assert(y % format_desc->block.height == 0);
+
+ src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
+ dst_row = dst;
+
+ format_desc->unpack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h);
+}
+
+void
+util_format_write_4i(enum pipe_format format,
+ const int *src, unsigned src_stride,
+ void *dst, unsigned dst_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ const struct util_format_description *format_desc;
+ uint8_t *dst_row;
+ const int *src_row;
+
+ format_desc = util_format_description(format);
+
+ assert(x % format_desc->block.width == 0);
+ assert(y % format_desc->block.height == 0);
+
+ dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
+ src_row = src;
+
+ format_desc->pack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h);
+}
boolean
util_is_format_compatible(const struct util_format_description *src_desc,
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.csv b/mesalib/src/gallium/auxiliary/util/u_format.csv
index 621a46dba..08aa0a49d 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.csv
+++ b/mesalib/src/gallium/auxiliary/util/u_format.csv
@@ -42,6 +42,7 @@
# - 'h': fixed
# - 'f': FLOAT
# - optionally followed by 'n' if it is normalized
+# - optionally followed by 'p' if it is pure
# - number of bits
# - channel swizzle
# - color space: rgb, yub, sz
@@ -278,3 +279,63 @@ PIPE_FORMAT_R10G10B10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2, xyzw,
PIPE_FORMAT_B10G10R10A2_USCALED , plain, 1, 1, u10, u10, u10, u2, zyxw, rgb
PIPE_FORMAT_B10G10R10A2_SSCALED , plain, 1, 1, s10, s10, s10, s2, zyxw, rgb
PIPE_FORMAT_B10G10R10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2, zyxw, rgb
+
+PIPE_FORMAT_R8_UINT , plain, 1, 1, up8, , , , x001, rgb
+PIPE_FORMAT_R8G8_UINT , plain, 1, 1, up8, up8, , , xy01, rgb
+PIPE_FORMAT_R8G8B8_UINT , plain, 1, 1, up8, up8, up8, , xyz1, rgb
+PIPE_FORMAT_R8G8B8A8_UINT , plain, 1, 1, up8, up8, up8, up8, xyzw, rgb
+
+PIPE_FORMAT_R8_SINT , plain, 1, 1, sp8, , , , x001, rgb
+PIPE_FORMAT_R8G8_SINT , plain, 1, 1, sp8, sp8, , , xy01, rgb
+PIPE_FORMAT_R8G8B8_SINT , plain, 1, 1, sp8, sp8, sp8, , xyz1, rgb
+PIPE_FORMAT_R8G8B8A8_SINT , plain, 1, 1, sp8, sp8, sp8, sp8, xyzw, rgb
+
+PIPE_FORMAT_R16_UINT , plain, 1, 1, up16, , , , x001, rgb
+PIPE_FORMAT_R16G16_UINT , plain, 1, 1, up16, up16, , , xy01, rgb
+PIPE_FORMAT_R16G16B16_UINT , plain, 1, 1, up16, up16, up16, , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_UINT , plain, 1, 1, up16, up16, up16, up16, xyzw, rgb
+
+PIPE_FORMAT_R16_SINT , plain, 1, 1, sp16, , , , x001, rgb
+PIPE_FORMAT_R16G16_SINT , plain, 1, 1, sp16, sp16, , , xy01, rgb
+PIPE_FORMAT_R16G16B16_SINT , plain, 1, 1, sp16, sp16, sp16, , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_SINT , plain, 1, 1, sp16, sp16, sp16, sp16, xyzw, rgb
+
+PIPE_FORMAT_R32_UINT , plain, 1, 1, up32, , , , x001, rgb
+PIPE_FORMAT_R32G32_UINT , plain, 1, 1, up32, up32, , , xy01, rgb
+PIPE_FORMAT_R32G32B32_UINT , plain, 1, 1, up32, up32, up32, , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_UINT , plain, 1, 1, up32, up32, up32, up32, xyzw, rgb
+
+PIPE_FORMAT_R32_SINT , plain, 1, 1, sp32, , , , x001, rgb
+PIPE_FORMAT_R32G32_SINT , plain, 1, 1, sp32, sp32, , , xy01, rgb
+PIPE_FORMAT_R32G32B32_SINT , plain, 1, 1, sp32, sp32, sp32, , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_SINT , plain, 1, 1, sp32, sp32, sp32, sp32, xyzw, rgb
+
+PIPE_FORMAT_A8_UINT , plain, 1, 1, up8, , , , 000x, rgb
+PIPE_FORMAT_I8_UINT , plain, 1, 1, up8, , , , xxxx, rgb
+PIPE_FORMAT_L8_UINT , plain, 1, 1, up8, , , , xxx1, rgb
+PIPE_FORMAT_L8A8_UINT , plain, 1, 1, up8, up8, , , xxxy, rgb
+
+PIPE_FORMAT_A8_SINT , plain, 1, 1, sp8, , , , 000x, rgb
+PIPE_FORMAT_I8_SINT , plain, 1, 1, sp8, , , , xxxx, rgb
+PIPE_FORMAT_L8_SINT , plain, 1, 1, sp8, , , , xxx1, rgb
+PIPE_FORMAT_L8A8_SINT , plain, 1, 1, sp8, sp8, , , xxxy, rgb
+
+PIPE_FORMAT_A16_UINT , plain, 1, 1, up16, , , , 000x, rgb
+PIPE_FORMAT_I16_UINT , plain, 1, 1, up16, , , , xxxx, rgb
+PIPE_FORMAT_L16_UINT , plain, 1, 1, up16, , , , xxx1, rgb
+PIPE_FORMAT_L16A16_UINT , plain, 1, 1, up16, up16, , , xxxy, rgb
+
+PIPE_FORMAT_A16_SINT , plain, 1, 1, sp16, , , , 000x, rgb
+PIPE_FORMAT_I16_SINT , plain, 1, 1, sp16, , , , xxxx, rgb
+PIPE_FORMAT_L16_SINT , plain, 1, 1, sp16, , , , xxx1, rgb
+PIPE_FORMAT_L16A16_SINT , plain, 1, 1, sp16, sp16, , , xxxy, rgb
+
+PIPE_FORMAT_A32_UINT , plain, 1, 1, up32, , , , 000x, rgb
+PIPE_FORMAT_I32_UINT , plain, 1, 1, up32, , , , xxxx, rgb
+PIPE_FORMAT_L32_UINT , plain, 1, 1, up32, , , , xxx1, rgb
+PIPE_FORMAT_L32A32_UINT , plain, 1, 1, up32, up32, , , xxxy, rgb
+
+PIPE_FORMAT_A32_SINT , plain, 1, 1, sp32, , , , 000x, rgb
+PIPE_FORMAT_I32_SINT , plain, 1, 1, sp32, , , , xxxx, rgb
+PIPE_FORMAT_L32_SINT , plain, 1, 1, sp32, , , , xxx1, rgb
+PIPE_FORMAT_L32A32_SINT , plain, 1, 1, sp32, sp32, , , xxxy, rgb \ No newline at end of file
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 98528ea59..215a00ab5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -120,8 +120,9 @@ enum util_format_colorspace {
struct util_format_channel_description
{
- unsigned type:6; /**< UTIL_FORMAT_TYPE_x */
+ unsigned type:5; /**< UTIL_FORMAT_TYPE_x */
unsigned normalized:1;
+ unsigned pure_integer:1;
unsigned size:9; /**< bits per channel */
};
@@ -321,6 +322,37 @@ struct util_format_description
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height);
+ /**
+ * Unpack pixel blocks to R32G32B32A32_UINT.
+ * Note: strides are in bytes.
+ *
+ * Only defined for INT formats.
+ */
+ void
+ (*unpack_rgba_uint)(unsigned *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ void
+ (*pack_rgba_uint)(uint8_t *dst, unsigned dst_stride,
+ const unsigned *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ /**
+ * Unpack pixel blocks to R32G32B32A32_SINT.
+ * Note: strides are in bytes.
+ *
+ * Only defined for INT formats.
+ */
+ void
+ (*unpack_rgba_sint)(signed *dst, unsigned dst_stride,
+ const uint8_t *src, unsigned src_stride,
+ unsigned width, unsigned height);
+
+ void
+ (*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride,
+ const int *src, unsigned src_stride,
+ unsigned width, unsigned height);
};
@@ -511,6 +543,14 @@ util_format_is_luminance_alpha(enum pipe_format format);
boolean
util_format_is_intensity(enum pipe_format format);
+boolean
+util_format_is_pure_integer(enum pipe_format format);
+
+boolean
+util_format_is_pure_sint(enum pipe_format format);
+
+boolean
+util_format_is_pure_uint(enum pipe_format format);
/**
* Whether the src format can be blitted to destation format with a simple
@@ -806,6 +846,26 @@ util_format_get_nr_components(enum pipe_format format)
return desc->nr_channels;
}
+/**
+ * Return the index of the first non-void channel
+ * -1 if no non-void channels
+ */
+static INLINE int
+util_format_get_first_non_void_channel(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ int i;
+
+ for (i = 0; i < 4; i++)
+ if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
+ break;
+
+ if (i == 4)
+ return -1;
+
+ return i;
+}
+
/*
* Format access functions.
*/
@@ -834,6 +894,30 @@ util_format_write_4ub(enum pipe_format format,
void *dst, unsigned dst_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
+void
+util_format_read_4ui(enum pipe_format format,
+ unsigned *dst, unsigned dst_stride,
+ const void *src, unsigned src_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
+void
+util_format_write_4ui(enum pipe_format format,
+ const unsigned int *src, unsigned src_stride,
+ void *dst, unsigned dst_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
+void
+util_format_read_4i(enum pipe_format format,
+ int *dst, unsigned dst_stride,
+ const void *src, unsigned src_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
+void
+util_format_write_4i(enum pipe_format format,
+ const int *src, unsigned src_stride,
+ void *dst, unsigned dst_stride,
+ unsigned x, unsigned y, unsigned w, unsigned h);
+
/*
* Generic format conversion;
*/
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
index 497efad5a..5cfbe323d 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
@@ -1,670 +1,718 @@
-#!/usr/bin/env python
-
-'''
-/**************************************************************************
- *
- * Copyright 2009-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * @file
- * Pixel format packing and unpacking functions.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-'''
-
-
-from u_format_parse import *
-
-
-def generate_format_type(format):
- '''Generate a structure that describes the format.'''
-
- assert format.layout == PLAIN
-
- print 'union util_format_%s {' % format.short_name()
-
- if format.block_size() in (8, 16, 32, 64):
- print ' uint%u_t value;' % (format.block_size(),)
-
- use_bitfields = False
- for channel in format.channels:
- if channel.size % 8 or not is_pot(channel.size):
- use_bitfields = True
-
- print ' struct {'
- for channel in format.channels:
- if use_bitfields:
- if channel.type == VOID:
- if channel.size:
- print ' unsigned %s:%u;' % (channel.name, channel.size)
- elif channel.type == UNSIGNED:
- print ' unsigned %s:%u;' % (channel.name, channel.size)
- elif channel.type in (SIGNED, FIXED):
- print ' int %s:%u;' % (channel.name, channel.size)
- elif channel.type == FLOAT:
- if channel.size == 64:
- print ' double %s;' % (channel.name)
- elif channel.size == 32:
- print ' float %s;' % (channel.name)
- else:
- print ' unsigned %s:%u;' % (channel.name, channel.size)
- else:
- assert 0
- else:
- assert channel.size % 8 == 0 and is_pot(channel.size)
- if channel.type == VOID:
- if channel.size:
- print ' uint%u_t %s;' % (channel.size, channel.name)
- elif channel.type == UNSIGNED:
- print ' uint%u_t %s;' % (channel.size, channel.name)
- elif channel.type in (SIGNED, FIXED):
- print ' int%u_t %s;' % (channel.size, channel.name)
- elif channel.type == FLOAT:
- if channel.size == 64:
- print ' double %s;' % (channel.name)
- elif channel.size == 32:
- print ' float %s;' % (channel.name)
- elif channel.size == 16:
- print ' uint16_t %s;' % (channel.name)
- else:
- assert 0
- else:
- assert 0
- print ' } chan;'
- print '};'
- print
-
-
-def bswap_format(format):
- '''Generate a structure that describes the format.'''
-
- if format.is_bitmask() and not format.is_array() and format.block_size() > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size()
- print '#endif'
-
-
-def is_format_supported(format):
- '''Determines whether we actually have the plumbing necessary to generate the
- to read/write to/from this format.'''
-
- # FIXME: Ideally we would support any format combination here.
-
- if format.layout != PLAIN:
- return False
-
- for i in range(4):
- channel = format.channels[i]
- if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT, FIXED):
- return False
- if channel.type == FLOAT and channel.size not in (16, 32, 64):
- return False
-
- return True
-
-
-def native_type(format):
- '''Get the native appropriate for a format.'''
-
- if format.layout == PLAIN:
- if not format.is_array():
- # For arithmetic pixel formats return the integer type that matches the whole pixel
- return 'uint%u_t' % format.block_size()
- else:
- # For array pixel formats return the integer type that matches the color channel
- channel = format.channels[0]
- if channel.type in (UNSIGNED, VOID):
- return 'uint%u_t' % channel.size
- elif channel.type in (SIGNED, FIXED):
- return 'int%u_t' % channel.size
- elif channel.type == FLOAT:
- if channel.size == 16:
- return 'uint16_t'
- elif channel.size == 32:
- return 'float'
- elif channel.size == 64:
- return 'double'
- else:
- assert False
- else:
- assert False
- else:
- assert False
-
-
-def intermediate_native_type(bits, sign):
- '''Find a native type adequate to hold intermediate results of the request bit size.'''
-
- bytes = 4 # don't use anything smaller than 32bits
- while bytes * 8 < bits:
- bytes *= 2
- bits = bytes*8
-
- if sign:
- return 'int%u_t' % bits
- else:
- return 'uint%u_t' % bits
-
-
-def get_one_shift(type):
- '''Get the number of the bit that matches unity for this type.'''
- if type.type == 'FLOAT':
- assert False
- if not type.norm:
- return 0
- if type.type == UNSIGNED:
- return type.size
- if type.type == SIGNED:
- return type.size - 1
- if type.type == FIXED:
- return type.size / 2
- assert False
-
-
-def value_to_native(type, value):
- '''Get the value of unity for this type.'''
- if type.type == FLOAT:
- return value
- if type.type == FIXED:
- return int(value * (1 << (type.size/2)))
- if not type.norm:
- return int(value)
- if type.type == UNSIGNED:
- return int(value * ((1 << type.size) - 1))
- if type.type == SIGNED:
- return int(value * ((1 << (type.size - 1)) - 1))
- assert False
-
-
-def native_to_constant(type, value):
- '''Get the value of unity for this type.'''
- if type.type == FLOAT:
- if type.size <= 32:
- return "%ff" % value
- else:
- return "%ff" % value
- else:
- return str(int(value))
-
-
-def get_one(type):
- '''Get the value of unity for this type.'''
- return value_to_native(type, 1)
-
-
-def clamp_expr(src_channel, dst_channel, dst_native_type, value):
- '''Generate the expression to clamp the value in the source type to the
- destination type range.'''
-
- if src_channel == dst_channel:
- return value
-
- src_min = src_channel.min()
- src_max = src_channel.max()
- dst_min = dst_channel.min()
- dst_max = dst_channel.max()
-
- # Translate the destination range to the src native value
- dst_min_native = value_to_native(src_channel, dst_min)
- dst_max_native = value_to_native(src_channel, dst_max)
-
- if src_min < dst_min and src_max > dst_max:
- return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native)
-
- if src_max > dst_max:
- return 'MIN2(%s, %s)' % (value, dst_max_native)
-
- if src_min < dst_min:
- return 'MAX2(%s, %s)' % (value, dst_min_native)
-
- return value
-
-
-def conversion_expr(src_channel,
- dst_channel, dst_native_type,
- value,
- clamp=True,
- src_colorspace = RGB,
- dst_colorspace = RGB):
- '''Generate the expression to convert a value between two types.'''
-
- if src_colorspace != dst_colorspace:
- if src_colorspace == SRGB:
- assert src_channel.type == UNSIGNED
- assert src_channel.norm
- assert src_channel.size == 8
- assert dst_colorspace == RGB
- if dst_channel.type == FLOAT:
- return 'util_format_srgb_8unorm_to_linear_float(%s)' % value
- else:
- assert dst_channel.type == UNSIGNED
- assert dst_channel.norm
- assert dst_channel.size == 8
- return 'util_format_srgb_to_linear_8unorm(%s)' % value
- elif dst_colorspace == SRGB:
- assert dst_channel.type == UNSIGNED
- assert dst_channel.norm
- assert dst_channel.size == 8
- assert src_colorspace == RGB
- if src_channel.type == FLOAT:
- return 'util_format_linear_float_to_srgb_8unorm(%s)' % value
- else:
- assert src_channel.type == UNSIGNED
- assert src_channel.norm
- assert src_channel.size == 8
- return 'util_format_linear_to_srgb_8unorm(%s)' % value
- elif src_colorspace == ZS:
- pass
- elif dst_colorspace == ZS:
- pass
- else:
- assert 0
-
- if src_channel == dst_channel:
- return value
-
- src_type = src_channel.type
- src_size = src_channel.size
- src_norm = src_channel.norm
-
- # Promote half to float
- if src_type == FLOAT and src_size == 16:
- value = 'util_half_to_float(%s)' % value
- src_size = 32
-
- # Special case for float <-> ubytes for more accurate results
- # Done before clamping since these functions already take care of that
- if src_type == UNSIGNED and src_norm and src_size == 8 and dst_channel.type == FLOAT and dst_channel.size == 32:
- return 'ubyte_to_float(%s)' % value
- if src_type == FLOAT and src_size == 32 and dst_channel.type == UNSIGNED and dst_channel.norm and dst_channel.size == 8:
- return 'float_to_ubyte(%s)' % value
-
- if clamp:
- if dst_channel.type != FLOAT or src_type != FLOAT:
- value = clamp_expr(src_channel, dst_channel, dst_native_type, value)
-
- if src_type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, UNSIGNED):
- if not src_norm and not dst_channel.norm:
- # neither is normalized -- just cast
- return '(%s)%s' % (dst_native_type, value)
-
- src_one = get_one(src_channel)
- dst_one = get_one(dst_channel)
-
- if src_one > dst_one and src_norm and dst_channel.norm:
- # We can just bitshift
- src_shift = get_one_shift(src_channel)
- dst_shift = get_one_shift(dst_channel)
- value = '(%s >> %s)' % (value, src_shift - dst_shift)
- else:
- # We need to rescale using an intermediate type big enough to hold the multiplication of both
- tmp_native_type = intermediate_native_type(src_size + dst_channel.size, src_channel.sign and dst_channel.sign)
- value = '((%s)%s)' % (tmp_native_type, value)
- value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one)
- value = '(%s)%s' % (dst_native_type, value)
- return value
-
- # Promote to either float or double
- if src_type != FLOAT:
- if src_norm or src_type == FIXED:
- one = get_one(src_channel)
- if src_size <= 23:
- value = '(%s * (1.0f/0x%x))' % (value, one)
- if dst_channel.size <= 32:
- value = '(float)%s' % value
- src_size = 32
- else:
- # bigger than single precision mantissa, use double
- value = '(%s * (1.0/0x%x))' % (value, one)
- src_size = 64
- src_norm = False
- else:
- if src_size <= 23 or dst_channel.size <= 32:
- value = '(float)%s' % value
- src_size = 32
- else:
- # bigger than single precision mantissa, use double
- value = '(double)%s' % value
- src_size = 64
- src_type = FLOAT
-
- # Convert double or float to non-float
- if dst_channel.type != FLOAT:
- if dst_channel.norm or dst_channel.type == FIXED:
- dst_one = get_one(dst_channel)
- if dst_channel.size <= 23:
- value = '(%s * 0x%x)' % (value, dst_one)
- else:
- # bigger than single precision mantissa, use double
- value = '(%s * (double)0x%x)' % (value, dst_one)
- value = '(%s)%s' % (dst_native_type, value)
- else:
- # Cast double to float when converting to either half or float
- if dst_channel.size <= 32 and src_size > 32:
- value = '(float)%s' % value
- src_size = 32
-
- if dst_channel.size == 16:
- value = 'util_float_to_half(%s)' % value
- elif dst_channel.size == 64 and src_size < 64:
- value = '(double)%s' % value
-
- return value
-
-
-def generate_unpack_kernel(format, dst_channel, dst_native_type):
-
- if not is_format_supported(format):
- return
-
- assert format.layout == PLAIN
-
- src_native_type = native_type(format)
-
- if format.is_bitmask():
- depth = format.block_size()
- print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth)
-
- # Declare the intermediate variables
- for i in range(format.nr_channels()):
- src_channel = format.channels[i]
- if src_channel.type == UNSIGNED:
- print ' uint%u_t %s;' % (depth, src_channel.name)
- elif src_channel.type == SIGNED:
- print ' int%u_t %s;' % (depth, src_channel.name)
-
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
- # Compute the intermediate unshifted values
- shift = 0
- for i in range(format.nr_channels()):
- src_channel = format.channels[i]
- value = 'value'
- if src_channel.type == UNSIGNED:
- if shift:
- value = '%s >> %u' % (value, shift)
- if shift + src_channel.size < depth:
- value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1)
- elif src_channel.type == SIGNED:
- if shift + src_channel.size < depth:
- # Align the sign bit
- lshift = depth - (shift + src_channel.size)
- value = '%s << %u' % (value, lshift)
- # Cast to signed
- value = '(int%u_t)(%s) ' % (depth, value)
- if src_channel.size < depth:
- # Align the LSB bit
- rshift = depth - src_channel.size
- value = '(%s) >> %u' % (value, rshift)
- else:
- value = None
-
- if value is not None:
- print ' %s = %s;' % (src_channel.name, value)
-
- shift += src_channel.size
-
- # Convert, swizzle, and store final values
- for i in range(4):
- swizzle = format.swizzles[i]
- if swizzle < 4:
- src_channel = format.channels[swizzle]
- src_colorspace = format.colorspace
- if src_colorspace == SRGB and i == 3:
- # Alpha channel is linear
- src_colorspace = RGB
- value = src_channel.name
- value = conversion_expr(src_channel,
- dst_channel, dst_native_type,
- value,
- src_colorspace = src_colorspace)
- elif swizzle == SWIZZLE_0:
- value = '0'
- elif swizzle == SWIZZLE_1:
- value = get_one(dst_channel)
- elif swizzle == SWIZZLE_NONE:
- value = '0'
- else:
- assert False
- print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
-
- else:
- print ' union util_format_%s pixel;' % format.short_name()
- print ' memcpy(&pixel, src, sizeof pixel);'
- bswap_format(format)
-
- for i in range(4):
- swizzle = format.swizzles[i]
- if swizzle < 4:
- src_channel = format.channels[swizzle]
- src_colorspace = format.colorspace
- if src_colorspace == SRGB and i == 3:
- # Alpha channel is linear
- src_colorspace = RGB
- value = 'pixel.chan.%s' % src_channel.name
- value = conversion_expr(src_channel,
- dst_channel, dst_native_type,
- value,
- src_colorspace = src_colorspace)
- elif swizzle == SWIZZLE_0:
- value = '0'
- elif swizzle == SWIZZLE_1:
- value = get_one(dst_channel)
- elif swizzle == SWIZZLE_NONE:
- value = '0'
- else:
- assert False
- print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
-
-
-def generate_pack_kernel(format, src_channel, src_native_type):
-
- if not is_format_supported(format):
- return
-
- dst_native_type = native_type(format)
-
- assert format.layout == PLAIN
-
- inv_swizzle = format.inv_swizzles()
-
- if format.is_bitmask():
- depth = format.block_size()
- print ' uint%u_t value = 0;' % depth
-
- shift = 0
- for i in range(4):
- dst_channel = format.channels[i]
- if inv_swizzle[i] is not None:
- value ='src[%u]' % inv_swizzle[i]
- dst_colorspace = format.colorspace
- if dst_colorspace == SRGB and inv_swizzle[i] == 3:
- # Alpha channel is linear
- dst_colorspace = RGB
- value = conversion_expr(src_channel,
- dst_channel, dst_native_type,
- value,
- dst_colorspace = dst_colorspace)
- if dst_channel.type in (UNSIGNED, SIGNED):
- if shift + dst_channel.size < depth:
- value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1)
- if shift:
- value = '(%s) << %u' % (value, shift)
- if dst_channel.type == SIGNED:
- # Cast to unsigned
- value = '(uint%u_t)(%s) ' % (depth, value)
- else:
- value = None
- if value is not None:
- print ' value |= %s;' % (value)
-
- shift += dst_channel.size
-
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
- print ' *(uint%u_t *)dst = value;' % depth
-
- else:
- print ' union util_format_%s pixel;' % format.short_name()
-
- for i in range(4):
- dst_channel = format.channels[i]
- width = dst_channel.size
- if inv_swizzle[i] is None:
- continue
- dst_colorspace = format.colorspace
- if dst_colorspace == SRGB and inv_swizzle[i] == 3:
- # Alpha channel is linear
- dst_colorspace = RGB
- value ='src[%u]' % inv_swizzle[i]
- value = conversion_expr(src_channel,
- dst_channel, dst_native_type,
- value,
- dst_colorspace = dst_colorspace)
- print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
-
- bswap_format(format)
- print ' memcpy(dst, &pixel, sizeof pixel);'
-
-
-def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
- '''Generate the function to unpack pixels from a particular format'''
-
- name = format.short_name()
-
- print 'static INLINE void'
- print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)
- print '{'
-
- if is_format_supported(format):
- print ' unsigned x, y;'
- print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
- print ' %s *dst = dst_row;' % (dst_native_type)
- print ' const uint8_t *src = src_row;'
- print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
-
- generate_unpack_kernel(format, dst_channel, dst_native_type)
-
- print ' src += %u;' % (format.block_size() / 8,)
- print ' dst += 4;'
- print ' }'
- print ' src_row += src_stride;'
- print ' dst_row += dst_stride/sizeof(*dst_row);'
- print ' }'
-
- print '}'
- print
-
-
-def generate_format_pack(format, src_channel, src_native_type, src_suffix):
- '''Generate the function to pack pixels to a particular format'''
-
- name = format.short_name()
-
- print 'static INLINE void'
- print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type)
- print '{'
-
- if is_format_supported(format):
- print ' unsigned x, y;'
- print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
- print ' const %s *src = src_row;' % (src_native_type)
- print ' uint8_t *dst = dst_row;'
- print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
-
- generate_pack_kernel(format, src_channel, src_native_type)
-
- print ' src += 4;'
- print ' dst += %u;' % (format.block_size() / 8,)
- print ' }'
- print ' dst_row += dst_stride;'
- print ' src_row += src_stride/sizeof(*src_row);'
- print ' }'
-
- print '}'
- print
-
-
-def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
- '''Generate the function to unpack pixels from a particular format'''
-
- name = format.short_name()
-
- print 'static INLINE void'
- print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, unsigned i, unsigned j)' % (name, dst_suffix, dst_native_type)
- print '{'
-
- if is_format_supported(format):
- generate_unpack_kernel(format, dst_channel, dst_native_type)
-
- print '}'
- print
-
-
-def is_format_hand_written(format):
- return format.layout in ('s3tc', 'rgtc', 'subsampled', 'other') or format.colorspace == ZS
-
-
-def generate(formats):
- print
- print '#include "pipe/p_compiler.h"'
- print '#include "u_math.h"'
- print '#include "u_half.h"'
- print '#include "u_format.h"'
- print '#include "u_format_other.h"'
- print '#include "u_format_srgb.h"'
- print '#include "u_format_yuv.h"'
- print '#include "u_format_zs.h"'
- print
-
- for format in formats:
- if not is_format_hand_written(format):
-
- if is_format_supported(format):
- generate_format_type(format)
-
- channel = Channel(FLOAT, False, 32)
- native_type = 'float'
- suffix = 'rgba_float'
-
- generate_format_unpack(format, channel, native_type, suffix)
- generate_format_pack(format, channel, native_type, suffix)
- generate_format_fetch(format, channel, native_type, suffix)
-
- channel = Channel(UNSIGNED, True, 8)
- native_type = 'uint8_t'
- suffix = 'rgba_8unorm'
-
- generate_format_unpack(format, channel, native_type, suffix)
- generate_format_pack(format, channel, native_type, suffix)
-
+#!/usr/bin/env python
+
+'''
+/**************************************************************************
+ *
+ * Copyright 2009-2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Pixel format packing and unpacking functions.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+'''
+
+
+from u_format_parse import *
+
+
+def generate_format_type(format):
+ '''Generate a structure that describes the format.'''
+
+ assert format.layout == PLAIN
+
+ print 'union util_format_%s {' % format.short_name()
+
+ if format.block_size() in (8, 16, 32, 64):
+ print ' uint%u_t value;' % (format.block_size(),)
+
+ use_bitfields = False
+ for channel in format.channels:
+ if channel.size % 8 or not is_pot(channel.size):
+ use_bitfields = True
+
+ print ' struct {'
+ for channel in format.channels:
+ if use_bitfields:
+ if channel.type == VOID:
+ if channel.size:
+ print ' unsigned %s:%u;' % (channel.name, channel.size)
+ elif channel.type == UNSIGNED:
+ print ' unsigned %s:%u;' % (channel.name, channel.size)
+ elif channel.type in (SIGNED, FIXED):
+ print ' int %s:%u;' % (channel.name, channel.size)
+ elif channel.type == FLOAT:
+ if channel.size == 64:
+ print ' double %s;' % (channel.name)
+ elif channel.size == 32:
+ print ' float %s;' % (channel.name)
+ else:
+ print ' unsigned %s:%u;' % (channel.name, channel.size)
+ else:
+ assert 0
+ else:
+ assert channel.size % 8 == 0 and is_pot(channel.size)
+ if channel.type == VOID:
+ if channel.size:
+ print ' uint%u_t %s;' % (channel.size, channel.name)
+ elif channel.type == UNSIGNED:
+ print ' uint%u_t %s;' % (channel.size, channel.name)
+ elif channel.type in (SIGNED, FIXED):
+ print ' int%u_t %s;' % (channel.size, channel.name)
+ elif channel.type == FLOAT:
+ if channel.size == 64:
+ print ' double %s;' % (channel.name)
+ elif channel.size == 32:
+ print ' float %s;' % (channel.name)
+ elif channel.size == 16:
+ print ' uint16_t %s;' % (channel.name)
+ else:
+ assert 0
+ else:
+ assert 0
+ print ' } chan;'
+ print '};'
+ print
+
+
+def bswap_format(format):
+ '''Generate a structure that describes the format.'''
+
+ if format.is_bitmask() and not format.is_array() and format.block_size() > 8:
+ print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size()
+ print '#endif'
+
+
+def is_format_supported(format):
+ '''Determines whether we actually have the plumbing necessary to generate the
+ to read/write to/from this format.'''
+
+ # FIXME: Ideally we would support any format combination here.
+
+ if format.layout != PLAIN:
+ return False
+
+ for i in range(4):
+ channel = format.channels[i]
+ if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT, FIXED):
+ return False
+ if channel.type == FLOAT and channel.size not in (16, 32, 64):
+ return False
+
+ return True
+
+def is_format_pure_unsigned(format):
+ for i in range(4):
+ channel = format.channels[i]
+ if channel.type not in (VOID, UNSIGNED):
+ return False
+ if channel.type == UNSIGNED and channel.pure == False:
+ return False
+
+ return True
+
+
+def is_format_pure_signed(format):
+ for i in range(4):
+ channel = format.channels[i]
+ if channel.type not in (VOID, SIGNED):
+ return False
+ if channel.type == SIGNED and channel.pure == False:
+ return False
+
+ return True
+
+def native_type(format):
+ '''Get the native appropriate for a format.'''
+
+ if format.layout == PLAIN:
+ if not format.is_array():
+ # For arithmetic pixel formats return the integer type that matches the whole pixel
+ return 'uint%u_t' % format.block_size()
+ else:
+ # For array pixel formats return the integer type that matches the color channel
+ channel = format.channels[0]
+ if channel.type in (UNSIGNED, VOID):
+ return 'uint%u_t' % channel.size
+ elif channel.type in (SIGNED, FIXED):
+ return 'int%u_t' % channel.size
+ elif channel.type == FLOAT:
+ if channel.size == 16:
+ return 'uint16_t'
+ elif channel.size == 32:
+ return 'float'
+ elif channel.size == 64:
+ return 'double'
+ else:
+ assert False
+ else:
+ assert False
+ else:
+ assert False
+
+
+def intermediate_native_type(bits, sign):
+ '''Find a native type adequate to hold intermediate results of the request bit size.'''
+
+ bytes = 4 # don't use anything smaller than 32bits
+ while bytes * 8 < bits:
+ bytes *= 2
+ bits = bytes*8
+
+ if sign:
+ return 'int%u_t' % bits
+ else:
+ return 'uint%u_t' % bits
+
+
+def get_one_shift(type):
+ '''Get the number of the bit that matches unity for this type.'''
+ if type.type == 'FLOAT':
+ assert False
+ if not type.norm:
+ return 0
+ if type.type == UNSIGNED:
+ return type.size
+ if type.type == SIGNED:
+ return type.size - 1
+ if type.type == FIXED:
+ return type.size / 2
+ assert False
+
+
+def value_to_native(type, value):
+ '''Get the value of unity for this type.'''
+ if type.type == FLOAT:
+ return value
+ if type.type == FIXED:
+ return int(value * (1 << (type.size/2)))
+ if not type.norm:
+ return int(value)
+ if type.type == UNSIGNED:
+ return int(value * ((1 << type.size) - 1))
+ if type.type == SIGNED:
+ return int(value * ((1 << (type.size - 1)) - 1))
+ assert False
+
+
+def native_to_constant(type, value):
+ '''Get the value of unity for this type.'''
+ if type.type == FLOAT:
+ if type.size <= 32:
+ return "%ff" % value
+ else:
+ return "%ff" % value
+ else:
+ return str(int(value))
+
+
+def get_one(type):
+ '''Get the value of unity for this type.'''
+ return value_to_native(type, 1)
+
+
+def clamp_expr(src_channel, dst_channel, dst_native_type, value):
+ '''Generate the expression to clamp the value in the source type to the
+ destination type range.'''
+
+ if src_channel == dst_channel:
+ return value
+
+ src_min = src_channel.min()
+ src_max = src_channel.max()
+ dst_min = dst_channel.min()
+ dst_max = dst_channel.max()
+
+ # Translate the destination range to the src native value
+ dst_min_native = value_to_native(src_channel, dst_min)
+ dst_max_native = value_to_native(src_channel, dst_max)
+
+ if src_min < dst_min and src_max > dst_max:
+ return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native)
+
+ if src_max > dst_max:
+ return 'MIN2(%s, %s)' % (value, dst_max_native)
+
+ if src_min < dst_min:
+ return 'MAX2(%s, %s)' % (value, dst_min_native)
+
+ return value
+
+
+def conversion_expr(src_channel,
+ dst_channel, dst_native_type,
+ value,
+ clamp=True,
+ src_colorspace = RGB,
+ dst_colorspace = RGB):
+ '''Generate the expression to convert a value between two types.'''
+
+ if src_colorspace != dst_colorspace:
+ if src_colorspace == SRGB:
+ assert src_channel.type == UNSIGNED
+ assert src_channel.norm
+ assert src_channel.size == 8
+ assert dst_colorspace == RGB
+ if dst_channel.type == FLOAT:
+ return 'util_format_srgb_8unorm_to_linear_float(%s)' % value
+ else:
+ assert dst_channel.type == UNSIGNED
+ assert dst_channel.norm
+ assert dst_channel.size == 8
+ return 'util_format_srgb_to_linear_8unorm(%s)' % value
+ elif dst_colorspace == SRGB:
+ assert dst_channel.type == UNSIGNED
+ assert dst_channel.norm
+ assert dst_channel.size == 8
+ assert src_colorspace == RGB
+ if src_channel.type == FLOAT:
+ return 'util_format_linear_float_to_srgb_8unorm(%s)' % value
+ else:
+ assert src_channel.type == UNSIGNED
+ assert src_channel.norm
+ assert src_channel.size == 8
+ return 'util_format_linear_to_srgb_8unorm(%s)' % value
+ elif src_colorspace == ZS:
+ pass
+ elif dst_colorspace == ZS:
+ pass
+ else:
+ assert 0
+
+ if src_channel == dst_channel:
+ return value
+
+ src_type = src_channel.type
+ src_size = src_channel.size
+ src_norm = src_channel.norm
+ src_pure = src_channel.pure
+
+ # Promote half to float
+ if src_type == FLOAT and src_size == 16:
+ value = 'util_half_to_float(%s)' % value
+ src_size = 32
+
+ # Special case for float <-> ubytes for more accurate results
+ # Done before clamping since these functions already take care of that
+ if src_type == UNSIGNED and src_norm and src_size == 8 and dst_channel.type == FLOAT and dst_channel.size == 32:
+ return 'ubyte_to_float(%s)' % value
+ if src_type == FLOAT and src_size == 32 and dst_channel.type == UNSIGNED and dst_channel.norm and dst_channel.size == 8:
+ return 'float_to_ubyte(%s)' % value
+
+ if clamp:
+ if dst_channel.type != FLOAT or src_type != FLOAT:
+ value = clamp_expr(src_channel, dst_channel, dst_native_type, value)
+
+ if src_type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, UNSIGNED):
+ if not src_norm and not dst_channel.norm:
+ # neither is normalized -- just cast
+ return '(%s)%s' % (dst_native_type, value)
+
+ src_one = get_one(src_channel)
+ dst_one = get_one(dst_channel)
+
+ if src_one > dst_one and src_norm and dst_channel.norm:
+ # We can just bitshift
+ src_shift = get_one_shift(src_channel)
+ dst_shift = get_one_shift(dst_channel)
+ value = '(%s >> %s)' % (value, src_shift - dst_shift)
+ else:
+ # We need to rescale using an intermediate type big enough to hold the multiplication of both
+ tmp_native_type = intermediate_native_type(src_size + dst_channel.size, src_channel.sign and dst_channel.sign)
+ value = '((%s)%s)' % (tmp_native_type, value)
+ value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one)
+ value = '(%s)%s' % (dst_native_type, value)
+ return value
+
+ # Promote to either float or double
+ if src_type != FLOAT:
+ if src_norm or src_type == FIXED:
+ one = get_one(src_channel)
+ if src_size <= 23:
+ value = '(%s * (1.0f/0x%x))' % (value, one)
+ if dst_channel.size <= 32:
+ value = '(float)%s' % value
+ src_size = 32
+ else:
+ # bigger than single precision mantissa, use double
+ value = '(%s * (1.0/0x%x))' % (value, one)
+ src_size = 64
+ src_norm = False
+ else:
+ if src_size <= 23 or dst_channel.size <= 32:
+ value = '(float)%s' % value
+ src_size = 32
+ else:
+ # bigger than single precision mantissa, use double
+ value = '(double)%s' % value
+ src_size = 64
+ src_type = FLOAT
+
+ # Convert double or float to non-float
+ if dst_channel.type != FLOAT:
+ if dst_channel.norm or dst_channel.type == FIXED:
+ dst_one = get_one(dst_channel)
+ if dst_channel.size <= 23:
+ value = '(%s * 0x%x)' % (value, dst_one)
+ else:
+ # bigger than single precision mantissa, use double
+ value = '(%s * (double)0x%x)' % (value, dst_one)
+ value = '(%s)%s' % (dst_native_type, value)
+ else:
+ # Cast double to float when converting to either half or float
+ if dst_channel.size <= 32 and src_size > 32:
+ value = '(float)%s' % value
+ src_size = 32
+
+ if dst_channel.size == 16:
+ value = 'util_float_to_half(%s)' % value
+ elif dst_channel.size == 64 and src_size < 64:
+ value = '(double)%s' % value
+
+ return value
+
+
+def generate_unpack_kernel(format, dst_channel, dst_native_type):
+
+ if not is_format_supported(format):
+ return
+
+ assert format.layout == PLAIN
+
+ src_native_type = native_type(format)
+
+ if format.is_bitmask():
+ depth = format.block_size()
+ print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth)
+
+ # Declare the intermediate variables
+ for i in range(format.nr_channels()):
+ src_channel = format.channels[i]
+ if src_channel.type == UNSIGNED:
+ print ' uint%u_t %s;' % (depth, src_channel.name)
+ elif src_channel.type == SIGNED:
+ print ' int%u_t %s;' % (depth, src_channel.name)
+
+ if depth > 8:
+ print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print ' value = util_bswap%u(value);' % depth
+ print '#endif'
+
+ # Compute the intermediate unshifted values
+ shift = 0
+ for i in range(format.nr_channels()):
+ src_channel = format.channels[i]
+ value = 'value'
+ if src_channel.type == UNSIGNED:
+ if shift:
+ value = '%s >> %u' % (value, shift)
+ if shift + src_channel.size < depth:
+ value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1)
+ elif src_channel.type == SIGNED:
+ if shift + src_channel.size < depth:
+ # Align the sign bit
+ lshift = depth - (shift + src_channel.size)
+ value = '%s << %u' % (value, lshift)
+ # Cast to signed
+ value = '(int%u_t)(%s) ' % (depth, value)
+ if src_channel.size < depth:
+ # Align the LSB bit
+ rshift = depth - src_channel.size
+ value = '(%s) >> %u' % (value, rshift)
+ else:
+ value = None
+
+ if value is not None:
+ print ' %s = %s;' % (src_channel.name, value)
+
+ shift += src_channel.size
+
+ # Convert, swizzle, and store final values
+ for i in range(4):
+ swizzle = format.swizzles[i]
+ if swizzle < 4:
+ src_channel = format.channels[swizzle]
+ src_colorspace = format.colorspace
+ if src_colorspace == SRGB and i == 3:
+ # Alpha channel is linear
+ src_colorspace = RGB
+ value = src_channel.name
+ value = conversion_expr(src_channel,
+ dst_channel, dst_native_type,
+ value,
+ src_colorspace = src_colorspace)
+ elif swizzle == SWIZZLE_0:
+ value = '0'
+ elif swizzle == SWIZZLE_1:
+ value = get_one(dst_channel)
+ elif swizzle == SWIZZLE_NONE:
+ value = '0'
+ else:
+ assert False
+ print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+
+ else:
+ print ' union util_format_%s pixel;' % format.short_name()
+ print ' memcpy(&pixel, src, sizeof pixel);'
+ bswap_format(format)
+
+ for i in range(4):
+ swizzle = format.swizzles[i]
+ if swizzle < 4:
+ src_channel = format.channels[swizzle]
+ src_colorspace = format.colorspace
+ if src_colorspace == SRGB and i == 3:
+ # Alpha channel is linear
+ src_colorspace = RGB
+ value = 'pixel.chan.%s' % src_channel.name
+ value = conversion_expr(src_channel,
+ dst_channel, dst_native_type,
+ value,
+ src_colorspace = src_colorspace)
+ elif swizzle == SWIZZLE_0:
+ value = '0'
+ elif swizzle == SWIZZLE_1:
+ value = get_one(dst_channel)
+ elif swizzle == SWIZZLE_NONE:
+ value = '0'
+ else:
+ assert False
+ print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+
+
+def generate_pack_kernel(format, src_channel, src_native_type):
+
+ if not is_format_supported(format):
+ return
+
+ dst_native_type = native_type(format)
+
+ assert format.layout == PLAIN
+
+ inv_swizzle = format.inv_swizzles()
+
+ if format.is_bitmask():
+ depth = format.block_size()
+ print ' uint%u_t value = 0;' % depth
+
+ shift = 0
+ for i in range(4):
+ dst_channel = format.channels[i]
+ if inv_swizzle[i] is not None:
+ value ='src[%u]' % inv_swizzle[i]
+ dst_colorspace = format.colorspace
+ if dst_colorspace == SRGB and inv_swizzle[i] == 3:
+ # Alpha channel is linear
+ dst_colorspace = RGB
+ value = conversion_expr(src_channel,
+ dst_channel, dst_native_type,
+ value,
+ dst_colorspace = dst_colorspace)
+ if dst_channel.type in (UNSIGNED, SIGNED):
+ if shift + dst_channel.size < depth:
+ value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1)
+ if shift:
+ value = '(%s) << %u' % (value, shift)
+ if dst_channel.type == SIGNED:
+ # Cast to unsigned
+ value = '(uint%u_t)(%s) ' % (depth, value)
+ else:
+ value = None
+ if value is not None:
+ print ' value |= %s;' % (value)
+
+ shift += dst_channel.size
+
+ if depth > 8:
+ print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print ' value = util_bswap%u(value);' % depth
+ print '#endif'
+
+ print ' *(uint%u_t *)dst = value;' % depth
+
+ else:
+ print ' union util_format_%s pixel;' % format.short_name()
+
+ for i in range(4):
+ dst_channel = format.channels[i]
+ width = dst_channel.size
+ if inv_swizzle[i] is None:
+ continue
+ dst_colorspace = format.colorspace
+ if dst_colorspace == SRGB and inv_swizzle[i] == 3:
+ # Alpha channel is linear
+ dst_colorspace = RGB
+ value ='src[%u]' % inv_swizzle[i]
+ value = conversion_expr(src_channel,
+ dst_channel, dst_native_type,
+ value,
+ dst_colorspace = dst_colorspace)
+ print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
+
+ bswap_format(format)
+ print ' memcpy(dst, &pixel, sizeof pixel);'
+
+
+def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
+ '''Generate the function to unpack pixels from a particular format'''
+
+ name = format.short_name()
+
+ print 'static INLINE void'
+ print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)
+ print '{'
+
+ if is_format_supported(format):
+ print ' unsigned x, y;'
+ print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
+ print ' %s *dst = dst_row;' % (dst_native_type)
+ print ' const uint8_t *src = src_row;'
+ print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
+
+ generate_unpack_kernel(format, dst_channel, dst_native_type)
+
+ print ' src += %u;' % (format.block_size() / 8,)
+ print ' dst += 4;'
+ print ' }'
+ print ' src_row += src_stride;'
+ print ' dst_row += dst_stride/sizeof(*dst_row);'
+ print ' }'
+
+ print '}'
+ print
+
+
+def generate_format_pack(format, src_channel, src_native_type, src_suffix):
+ '''Generate the function to pack pixels to a particular format'''
+
+ name = format.short_name()
+
+ print 'static INLINE void'
+ print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type)
+ print '{'
+
+ if is_format_supported(format):
+ print ' unsigned x, y;'
+ print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
+ print ' const %s *src = src_row;' % (src_native_type)
+ print ' uint8_t *dst = dst_row;'
+ print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
+
+ generate_pack_kernel(format, src_channel, src_native_type)
+
+ print ' src += 4;'
+ print ' dst += %u;' % (format.block_size() / 8,)
+ print ' }'
+ print ' dst_row += dst_stride;'
+ print ' src_row += src_stride/sizeof(*src_row);'
+ print ' }'
+
+ print '}'
+ print
+
+
+def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
+ '''Generate the function to unpack pixels from a particular format'''
+
+ name = format.short_name()
+
+ print 'static INLINE void'
+ print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, unsigned i, unsigned j)' % (name, dst_suffix, dst_native_type)
+ print '{'
+
+ if is_format_supported(format):
+ generate_unpack_kernel(format, dst_channel, dst_native_type)
+
+ print '}'
+ print
+
+
+def is_format_hand_written(format):
+ return format.layout in ('s3tc', 'rgtc', 'subsampled', 'other') or format.colorspace == ZS
+
+
+def generate(formats):
+ print
+ print '#include "pipe/p_compiler.h"'
+ print '#include "u_math.h"'
+ print '#include "u_half.h"'
+ print '#include "u_format.h"'
+ print '#include "u_format_other.h"'
+ print '#include "u_format_srgb.h"'
+ print '#include "u_format_yuv.h"'
+ print '#include "u_format_zs.h"'
+ print
+
+ for format in formats:
+ if not is_format_hand_written(format):
+
+ if is_format_supported(format):
+ generate_format_type(format)
+
+ if is_format_pure_unsigned(format):
+ native_type = 'unsigned'
+ suffix = 'unsigned'
+ channel = Channel(UNSIGNED, False, True, 32)
+
+ generate_format_unpack(format, channel, native_type, suffix)
+ generate_format_pack(format, channel, native_type, suffix)
+
+ channel = Channel(SIGNED, False, True, 32)
+ native_type = 'int'
+ suffix = 'signed'
+ generate_format_unpack(format, channel, native_type, suffix)
+ generate_format_pack(format, channel, native_type, suffix)
+ elif is_format_pure_signed(format):
+ native_type = 'int'
+ suffix = 'signed'
+ channel = Channel(SIGNED, False, True, 32)
+
+ generate_format_unpack(format, channel, native_type, suffix)
+ generate_format_pack(format, channel, native_type, suffix)
+
+ native_type = 'unsigned'
+ suffix = 'unsigned'
+ channel = Channel(UNSIGNED, False, True, 32)
+ generate_format_unpack(format, channel, native_type, suffix)
+ generate_format_pack(format, channel, native_type, suffix)
+ else:
+ channel = Channel(FLOAT, False, False, 32)
+ native_type = 'float'
+ suffix = 'rgba_float'
+
+ generate_format_unpack(format, channel, native_type, suffix)
+ generate_format_pack(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type, suffix)
+
+ channel = Channel(UNSIGNED, True, False, 8)
+ native_type = 'uint8_t'
+ suffix = 'rgba_8unorm'
+
+ generate_format_unpack(format, channel, native_type, suffix)
+ generate_format_pack(format, channel, native_type, suffix)
+
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
index f47f65d26..73a4bcb21 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
@@ -1,291 +1,303 @@
-#!/usr/bin/env python
-
-'''
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-'''
-
-
-VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
-
-SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7)
-
-PLAIN = 'plain'
-
-RGB = 'rgb'
-SRGB = 'srgb'
-YUV = 'yuv'
-ZS = 'zs'
-
-
-def is_pot(x):
- return (x & (x - 1)) == 0
-
-
-VERY_LARGE = 99999999999999999999999
-
-
-class Channel:
- '''Describe the channel of a color channel.'''
-
- def __init__(self, type, norm, size, name = ''):
- self.type = type
- self.norm = norm
- self.size = size
- self.sign = type in (SIGNED, FIXED, FLOAT)
- self.name = name
-
- def __str__(self):
- s = str(self.type)
- if self.norm:
- s += 'n'
- s += str(self.size)
- return s
-
- def __eq__(self, other):
- return self.type == other.type and self.norm == other.norm and self.size == other.size
-
- def max(self):
- '''Maximum representable number.'''
- if self.type == FLOAT:
- return VERY_LARGE
- if self.type == FIXED:
- return (1 << (self.size/2)) - 1
- if self.norm:
- return 1
- if self.type == UNSIGNED:
- return (1 << self.size) - 1
- if self.type == SIGNED:
- return (1 << (self.size - 1)) - 1
- assert False
-
- def min(self):
- '''Minimum representable number.'''
- if self.type == FLOAT:
- return -VERY_LARGE
- if self.type == FIXED:
- return -(1 << (self.size/2))
- if self.type == UNSIGNED:
- return 0
- if self.norm:
- return -1
- if self.type == SIGNED:
- return -(1 << (self.size - 1))
- assert False
-
-
-class Format:
- '''Describe a pixel format.'''
-
- def __init__(self, name, layout, block_width, block_height, channels, swizzles, colorspace):
- self.name = name
- self.layout = layout
- self.block_width = block_width
- self.block_height = block_height
- self.channels = channels
- self.swizzles = swizzles
- self.name = name
- self.colorspace = colorspace
-
- def __str__(self):
- return self.name
-
- def short_name(self):
- '''Make up a short norm for a format, suitable to be used as suffix in
- function names.'''
-
- name = self.name
- if name.startswith('PIPE_FORMAT_'):
- name = name[len('PIPE_FORMAT_'):]
- name = name.lower()
- return name
-
- def block_size(self):
- size = 0
- for channel in self.channels:
- size += channel.size
- return size
-
- def nr_channels(self):
- nr_channels = 0
- for channel in self.channels:
- if channel.size:
- nr_channels += 1
- return nr_channels
-
- def is_array(self):
- if self.layout != PLAIN:
- return False
- ref_channel = self.channels[0]
- for channel in self.channels[1:]:
- if channel.size and (channel.size != ref_channel.size or channel.size % 8):
- return False
- return True
-
- def is_mixed(self):
- if self.layout != PLAIN:
- return False
- ref_channel = self.channels[0]
- if ref_channel.type == VOID:
- ref_channel = self.channels[1]
- for channel in self.channels[1:]:
- if channel.type != VOID:
- if channel.type != ref_channel.type:
- return True
- if channel.norm != ref_channel.norm:
- return True
- return False
-
- def is_pot(self):
- return is_pot(self.block_size())
-
- def is_int(self):
- if self.layout != PLAIN:
- return False
- for channel in self.channels:
- if channel.type not in (VOID, UNSIGNED, SIGNED):
- return False
- return True
-
- def is_float(self):
- if self.layout != PLAIN:
- return False
- for channel in self.channels:
- if channel.type not in (VOID, FLOAT):
- return False
- return True
-
- def is_bitmask(self):
- if self.layout != PLAIN:
- return False
- if self.block_size() not in (8, 16, 32):
- return False
- for channel in self.channels:
- if channel.type not in (VOID, UNSIGNED, SIGNED):
- return False
- return True
-
- def inv_swizzles(self):
- '''Return an array[4] of inverse swizzle terms'''
- inv_swizzle = [None]*4
- for i in range(4):
- swizzle = self.swizzles[i]
- if swizzle < 4:
- inv_swizzle[swizzle] = i
- return inv_swizzle
-
- def stride(self):
- return self.block_size()/8
-
-
-_type_parse_map = {
- '': VOID,
- 'x': VOID,
- 'u': UNSIGNED,
- 's': SIGNED,
- 'h': FIXED,
- 'f': FLOAT,
-}
-
-_swizzle_parse_map = {
- 'x': SWIZZLE_X,
- 'y': SWIZZLE_Y,
- 'z': SWIZZLE_Z,
- 'w': SWIZZLE_W,
- '0': SWIZZLE_0,
- '1': SWIZZLE_1,
- '_': SWIZZLE_NONE,
-}
-
-def parse(filename):
- '''Parse the format descrition in CSV format in terms of the
- Channel and Format classes above.'''
-
- stream = open(filename)
- formats = []
- for line in stream:
- try:
- comment = line.index('#')
- except ValueError:
- pass
- else:
- line = line[:comment]
- line = line.strip()
- if not line:
- continue
-
- fields = [field.strip() for field in line.split(',')]
-
- name = fields[0]
- layout = fields[1]
- block_width, block_height = map(int, fields[2:4])
-
- swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
- colorspace = fields[9]
-
- if layout == PLAIN:
- names = ['']*4
- if colorspace in (RGB, SRGB):
- for i in range(4):
- swizzle = swizzles[i]
- if swizzle < 4:
- names[swizzle] += 'rgba'[i]
- elif colorspace == ZS:
- for i in range(4):
- swizzle = swizzles[i]
- if swizzle < 4:
- names[swizzle] += 'zs'[i]
- else:
- assert False
- for i in range(4):
- if names[i] == '':
- names[i] = 'x'
- else:
- names = ['x', 'y', 'z', 'w']
-
- channels = []
- for i in range(0, 4):
- field = fields[4 + i]
- if field:
- type = _type_parse_map[field[0]]
- if field[1] == 'n':
- norm = True
- size = int(field[2:])
- else:
- norm = False
- size = int(field[1:])
- else:
- type = VOID
- norm = False
- size = 0
- channel = Channel(type, norm, size, names[i])
- channels.append(channel)
-
- format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace)
- formats.append(format)
- return formats
-
+#!/usr/bin/env python
+
+'''
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+'''
+
+
+VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
+
+SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7)
+
+PLAIN = 'plain'
+
+RGB = 'rgb'
+SRGB = 'srgb'
+YUV = 'yuv'
+ZS = 'zs'
+
+
+def is_pot(x):
+ return (x & (x - 1)) == 0
+
+
+VERY_LARGE = 99999999999999999999999
+
+
+class Channel:
+ '''Describe the channel of a color channel.'''
+
+ def __init__(self, type, norm, pure, size, name = ''):
+ self.type = type
+ self.norm = norm
+ self.pure = pure
+ self.size = size
+ self.sign = type in (SIGNED, FIXED, FLOAT)
+ self.name = name
+
+ def __str__(self):
+ s = str(self.type)
+ if self.norm:
+ s += 'n'
+ if self.pure:
+ s += 'p'
+ s += str(self.size)
+ return s
+
+ def __eq__(self, other):
+ return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size
+
+ def max(self):
+ '''Maximum representable number.'''
+ if self.type == FLOAT:
+ return VERY_LARGE
+ if self.type == FIXED:
+ return (1 << (self.size/2)) - 1
+ if self.norm:
+ return 1
+ if self.type == UNSIGNED:
+ return (1 << self.size) - 1
+ if self.type == SIGNED:
+ return (1 << (self.size - 1)) - 1
+ assert False
+
+ def min(self):
+ '''Minimum representable number.'''
+ if self.type == FLOAT:
+ return -VERY_LARGE
+ if self.type == FIXED:
+ return -(1 << (self.size/2))
+ if self.type == UNSIGNED:
+ return 0
+ if self.norm:
+ return -1
+ if self.type == SIGNED:
+ return -(1 << (self.size - 1))
+ assert False
+
+
+class Format:
+ '''Describe a pixel format.'''
+
+ def __init__(self, name, layout, block_width, block_height, channels, swizzles, colorspace):
+ self.name = name
+ self.layout = layout
+ self.block_width = block_width
+ self.block_height = block_height
+ self.channels = channels
+ self.swizzles = swizzles
+ self.name = name
+ self.colorspace = colorspace
+
+ def __str__(self):
+ return self.name
+
+ def short_name(self):
+ '''Make up a short norm for a format, suitable to be used as suffix in
+ function names.'''
+
+ name = self.name
+ if name.startswith('PIPE_FORMAT_'):
+ name = name[len('PIPE_FORMAT_'):]
+ name = name.lower()
+ return name
+
+ def block_size(self):
+ size = 0
+ for channel in self.channels:
+ size += channel.size
+ return size
+
+ def nr_channels(self):
+ nr_channels = 0
+ for channel in self.channels:
+ if channel.size:
+ nr_channels += 1
+ return nr_channels
+
+ def is_array(self):
+ if self.layout != PLAIN:
+ return False
+ ref_channel = self.channels[0]
+ for channel in self.channels[1:]:
+ if channel.size and (channel.size != ref_channel.size or channel.size % 8):
+ return False
+ return True
+
+ def is_mixed(self):
+ if self.layout != PLAIN:
+ return False
+ ref_channel = self.channels[0]
+ if ref_channel.type == VOID:
+ ref_channel = self.channels[1]
+ for channel in self.channels[1:]:
+ if channel.type != VOID:
+ if channel.type != ref_channel.type:
+ return True
+ if channel.norm != ref_channel.norm:
+ return True
+ if channel.pure != ref_channel.pure:
+ return True
+ return False
+
+ def is_pot(self):
+ return is_pot(self.block_size())
+
+ def is_int(self):
+ if self.layout != PLAIN:
+ return False
+ for channel in self.channels:
+ if channel.type not in (VOID, UNSIGNED, SIGNED):
+ return False
+ return True
+
+ def is_float(self):
+ if self.layout != PLAIN:
+ return False
+ for channel in self.channels:
+ if channel.type not in (VOID, FLOAT):
+ return False
+ return True
+
+ def is_bitmask(self):
+ if self.layout != PLAIN:
+ return False
+ if self.block_size() not in (8, 16, 32):
+ return False
+ for channel in self.channels:
+ if channel.type not in (VOID, UNSIGNED, SIGNED):
+ return False
+ return True
+
+ def inv_swizzles(self):
+ '''Return an array[4] of inverse swizzle terms'''
+ inv_swizzle = [None]*4
+ for i in range(4):
+ swizzle = self.swizzles[i]
+ if swizzle < 4:
+ inv_swizzle[swizzle] = i
+ return inv_swizzle
+
+ def stride(self):
+ return self.block_size()/8
+
+
+_type_parse_map = {
+ '': VOID,
+ 'x': VOID,
+ 'u': UNSIGNED,
+ 's': SIGNED,
+ 'h': FIXED,
+ 'f': FLOAT,
+}
+
+_swizzle_parse_map = {
+ 'x': SWIZZLE_X,
+ 'y': SWIZZLE_Y,
+ 'z': SWIZZLE_Z,
+ 'w': SWIZZLE_W,
+ '0': SWIZZLE_0,
+ '1': SWIZZLE_1,
+ '_': SWIZZLE_NONE,
+}
+
+def parse(filename):
+ '''Parse the format descrition in CSV format in terms of the
+ Channel and Format classes above.'''
+
+ stream = open(filename)
+ formats = []
+ for line in stream:
+ try:
+ comment = line.index('#')
+ except ValueError:
+ pass
+ else:
+ line = line[:comment]
+ line = line.strip()
+ if not line:
+ continue
+
+ fields = [field.strip() for field in line.split(',')]
+
+ name = fields[0]
+ layout = fields[1]
+ block_width, block_height = map(int, fields[2:4])
+
+ swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
+ colorspace = fields[9]
+
+ if layout == PLAIN:
+ names = ['']*4
+ if colorspace in (RGB, SRGB):
+ for i in range(4):
+ swizzle = swizzles[i]
+ if swizzle < 4:
+ names[swizzle] += 'rgba'[i]
+ elif colorspace == ZS:
+ for i in range(4):
+ swizzle = swizzles[i]
+ if swizzle < 4:
+ names[swizzle] += 'zs'[i]
+ else:
+ assert False
+ for i in range(4):
+ if names[i] == '':
+ names[i] = 'x'
+ else:
+ names = ['x', 'y', 'z', 'w']
+
+ channels = []
+ for i in range(0, 4):
+ field = fields[4 + i]
+ if field:
+ type = _type_parse_map[field[0]]
+ if field[1] == 'n':
+ norm = True
+ pure = False
+ size = int(field[2:])
+ elif field[1] == 'p':
+ pure = True
+ norm = False
+ size = int(field[2:])
+ else:
+ norm = False
+ pure = False
+ size = int(field[1:])
+ else:
+ type = VOID
+ norm = False
+ pure = False
+ size = 0
+ channel = Channel(type, norm, pure, size, names[i])
+ channels.append(channel)
+
+ format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace)
+ formats.append(format)
+ return formats
+
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py
index addc47481..6c00b0df3 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_table.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py
@@ -1,197 +1,212 @@
-#!/usr/bin/env python
-
-CopyRight = '''
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-'''
-
-
-import sys
-
-from u_format_parse import *
-import u_format_pack
-
-
-def layout_map(layout):
- return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper()
-
-
-def colorspace_map(colorspace):
- return 'UTIL_FORMAT_COLORSPACE_' + str(colorspace).upper()
-
-
-colorspace_channels_map = {
- 'rgb': ['r', 'g', 'b', 'a'],
- 'srgb': ['sr', 'sg', 'sb', 'a'],
- 'zs': ['z', 's'],
- 'yuv': ['y', 'u', 'v'],
-}
-
-
-type_map = {
- VOID: "UTIL_FORMAT_TYPE_VOID",
- UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED",
- SIGNED: "UTIL_FORMAT_TYPE_SIGNED",
- FIXED: "UTIL_FORMAT_TYPE_FIXED",
- FLOAT: "UTIL_FORMAT_TYPE_FLOAT",
-}
-
-
-def bool_map(value):
- if value:
- return "TRUE"
- else:
- return "FALSE"
-
-
-swizzle_map = {
- SWIZZLE_X: "UTIL_FORMAT_SWIZZLE_X",
- SWIZZLE_Y: "UTIL_FORMAT_SWIZZLE_Y",
- SWIZZLE_Z: "UTIL_FORMAT_SWIZZLE_Z",
- SWIZZLE_W: "UTIL_FORMAT_SWIZZLE_W",
- SWIZZLE_0: "UTIL_FORMAT_SWIZZLE_0",
- SWIZZLE_1: "UTIL_FORMAT_SWIZZLE_1",
- SWIZZLE_NONE: "UTIL_FORMAT_SWIZZLE_NONE",
-}
-
-
-def write_format_table(formats):
- print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'
- print
- # This will print the copyright message on the top of this file
- print CopyRight.strip()
- print
- print '#include "u_format.h"'
- print '#include "u_format_s3tc.h"'
- print '#include "u_format_rgtc.h"'
- print '#include "u_format_latc.h"'
- print
-
- u_format_pack.generate(formats)
-
- for format in formats:
- print 'const struct util_format_description'
- print 'util_format_%s_description = {' % (format.short_name(),)
- print " %s," % (format.name,)
- print " \"%s\"," % (format.name,)
- print " \"%s\"," % (format.short_name(),)
- print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
- print " %s," % (layout_map(format.layout),)
- print " %u,\t/* nr_channels */" % (format.nr_channels(),)
- print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
- print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
- print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
- print " {"
- for i in range(4):
- channel = format.channels[i]
- if i < 3:
- sep = ","
- else:
- sep = ""
- if channel.size:
- print " {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name)
- else:
- print " {0, 0, 0}%s" % (sep,)
- print " },"
- print " {"
- for i in range(4):
- swizzle = format.swizzles[i]
- if i < 3:
- sep = ","
- else:
- sep = ""
- try:
- comment = colorspace_channels_map[format.colorspace][i]
- except (KeyError, IndexError):
- comment = 'ignored'
- print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
- print " },"
- print " %s," % (colorspace_map(format.colorspace),)
- if format.colorspace != ZS:
- print " &util_format_%s_unpack_rgba_8unorm," % format.short_name()
- print " &util_format_%s_pack_rgba_8unorm," % format.short_name()
- if format.layout == 's3tc' or format.layout == 'rgtc':
- print " &util_format_%s_fetch_rgba_8unorm," % format.short_name()
- else:
- print " NULL, /* fetch_rgba_8unorm */"
- print " &util_format_%s_unpack_rgba_float," % format.short_name()
- print " &util_format_%s_pack_rgba_float," % format.short_name()
- print " &util_format_%s_fetch_rgba_float," % format.short_name()
- else:
- print " NULL, /* unpack_rgba_8unorm */"
- print " NULL, /* pack_rgba_8unorm */"
- print " NULL, /* fetch_rgba_8unorm */"
- print " NULL, /* unpack_rgba_float */"
- print " NULL, /* pack_rgba_float */"
- print " NULL, /* fetch_rgba_float */"
- if format.colorspace == ZS and format.swizzles[0] != SWIZZLE_NONE:
- print " &util_format_%s_unpack_z_32unorm," % format.short_name()
- print " &util_format_%s_pack_z_32unorm," % format.short_name()
- print " &util_format_%s_unpack_z_float," % format.short_name()
- print " &util_format_%s_pack_z_float," % format.short_name()
- else:
- print " NULL, /* unpack_z_32unorm */"
- print " NULL, /* pack_z_32unorm */"
- print " NULL, /* unpack_z_float */"
- print " NULL, /* pack_z_float */"
- if format.colorspace == ZS and format.swizzles[1] != SWIZZLE_NONE:
- print " &util_format_%s_unpack_s_8uscaled," % format.short_name()
- print " &util_format_%s_pack_s_8uscaled" % format.short_name()
- else:
- print " NULL, /* unpack_s_8uscaled */"
- print " NULL /* pack_s_8uscaled */"
- print "};"
- print
-
- print "const struct util_format_description *"
- print "util_format_description(enum pipe_format format)"
- print "{"
- print " if (format >= PIPE_FORMAT_COUNT) {"
- print " return NULL;"
- print " }"
- print
- print " switch (format) {"
- for format in formats:
- print " case %s:" % format.name
- print " return &util_format_%s_description;" % (format.short_name(),)
- print " default:"
- print " return NULL;"
- print " }"
- print "}"
- print
-
-
-def main():
-
- formats = []
- for arg in sys.argv[1:]:
- formats.extend(parse(arg))
- write_format_table(formats)
-
-
-if __name__ == '__main__':
- main()
+#!/usr/bin/env python
+
+CopyRight = '''
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+'''
+
+
+import sys
+
+from u_format_parse import *
+import u_format_pack
+
+
+def layout_map(layout):
+ return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper()
+
+
+def colorspace_map(colorspace):
+ return 'UTIL_FORMAT_COLORSPACE_' + str(colorspace).upper()
+
+
+colorspace_channels_map = {
+ 'rgb': ['r', 'g', 'b', 'a'],
+ 'srgb': ['sr', 'sg', 'sb', 'a'],
+ 'zs': ['z', 's'],
+ 'yuv': ['y', 'u', 'v'],
+}
+
+
+type_map = {
+ VOID: "UTIL_FORMAT_TYPE_VOID",
+ UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED",
+ SIGNED: "UTIL_FORMAT_TYPE_SIGNED",
+ FIXED: "UTIL_FORMAT_TYPE_FIXED",
+ FLOAT: "UTIL_FORMAT_TYPE_FLOAT",
+}
+
+
+def bool_map(value):
+ if value:
+ return "TRUE"
+ else:
+ return "FALSE"
+
+
+swizzle_map = {
+ SWIZZLE_X: "UTIL_FORMAT_SWIZZLE_X",
+ SWIZZLE_Y: "UTIL_FORMAT_SWIZZLE_Y",
+ SWIZZLE_Z: "UTIL_FORMAT_SWIZZLE_Z",
+ SWIZZLE_W: "UTIL_FORMAT_SWIZZLE_W",
+ SWIZZLE_0: "UTIL_FORMAT_SWIZZLE_0",
+ SWIZZLE_1: "UTIL_FORMAT_SWIZZLE_1",
+ SWIZZLE_NONE: "UTIL_FORMAT_SWIZZLE_NONE",
+}
+
+
+def write_format_table(formats):
+ print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'
+ print
+ # This will print the copyright message on the top of this file
+ print CopyRight.strip()
+ print
+ print '#include "u_format.h"'
+ print '#include "u_format_s3tc.h"'
+ print '#include "u_format_rgtc.h"'
+ print '#include "u_format_latc.h"'
+ print
+
+ u_format_pack.generate(formats)
+
+ for format in formats:
+ print 'const struct util_format_description'
+ print 'util_format_%s_description = {' % (format.short_name(),)
+ print " %s," % (format.name,)
+ print " \"%s\"," % (format.name,)
+ print " \"%s\"," % (format.short_name(),)
+ print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
+ print " %s," % (layout_map(format.layout),)
+ print " %u,\t/* nr_channels */" % (format.nr_channels(),)
+ print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
+ print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
+ print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+ print " {"
+ for i in range(4):
+ channel = format.channels[i]
+ if i < 3:
+ sep = ","
+ else:
+ sep = ""
+ if channel.size:
+ print " {%s, %s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, sep, "xyzw"[i], channel.name)
+ else:
+ print " {0, 0, 0}%s" % (sep,)
+ print " },"
+ print " {"
+ for i in range(4):
+ swizzle = format.swizzles[i]
+ if i < 3:
+ sep = ","
+ else:
+ sep = ""
+ try:
+ comment = colorspace_channels_map[format.colorspace][i]
+ except (KeyError, IndexError):
+ comment = 'ignored'
+ print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
+ print " },"
+ print " %s," % (colorspace_map(format.colorspace),)
+ if format.colorspace != ZS and format.channels[0].pure == False:
+ print " &util_format_%s_unpack_rgba_8unorm," % format.short_name()
+ print " &util_format_%s_pack_rgba_8unorm," % format.short_name()
+ if format.layout == 's3tc' or format.layout == 'rgtc':
+ print " &util_format_%s_fetch_rgba_8unorm," % format.short_name()
+ else:
+ print " NULL, /* fetch_rgba_8unorm */"
+ print " &util_format_%s_unpack_rgba_float," % format.short_name()
+ print " &util_format_%s_pack_rgba_float," % format.short_name()
+ print " &util_format_%s_fetch_rgba_float," % format.short_name()
+ else:
+ print " NULL, /* unpack_rgba_8unorm */"
+ print " NULL, /* pack_rgba_8unorm */"
+ print " NULL, /* fetch_rgba_8unorm */"
+ print " NULL, /* unpack_rgba_float */"
+ print " NULL, /* pack_rgba_float */"
+ print " NULL, /* fetch_rgba_float */"
+ if format.colorspace == ZS and format.swizzles[0] != SWIZZLE_NONE:
+ print " &util_format_%s_unpack_z_32unorm," % format.short_name()
+ print " &util_format_%s_pack_z_32unorm," % format.short_name()
+ print " &util_format_%s_unpack_z_float," % format.short_name()
+ print " &util_format_%s_pack_z_float," % format.short_name()
+ else:
+ print " NULL, /* unpack_z_32unorm */"
+ print " NULL, /* pack_z_32unorm */"
+ print " NULL, /* unpack_z_float */"
+ print " NULL, /* pack_z_float */"
+ if format.colorspace == ZS and format.swizzles[1] != SWIZZLE_NONE:
+ print " &util_format_%s_unpack_s_8uscaled," % format.short_name()
+ print " &util_format_%s_pack_s_8uscaled," % format.short_name()
+ else:
+ print " NULL, /* unpack_s_8uscaled */"
+ print " NULL, /* pack_s_8uscaled */"
+ if format.channels[0].pure == True and format.channels[0].type == UNSIGNED:
+ print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
+ print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
+ print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name()
+ elif format.channels[0].pure == True and format.channels[0].type == SIGNED:
+ print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
+ print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
+ print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name()
+ else:
+ print " NULL, /* unpack_rgba_uint */"
+ print " NULL, /* pack_rgba_uint */"
+ print " NULL, /* unpack_rgba_sint */"
+ print " NULL /* pack_rgba_sint */"
+ print "};"
+ print
+
+ print "const struct util_format_description *"
+ print "util_format_description(enum pipe_format format)"
+ print "{"
+ print " if (format >= PIPE_FORMAT_COUNT) {"
+ print " return NULL;"
+ print " }"
+ print
+ print " switch (format) {"
+ for format in formats:
+ print " case %s:" % format.name
+ print " return &util_format_%s_description;" % (format.short_name(),)
+ print " default:"
+ print " return NULL;"
+ print " }"
+ print "}"
+ print
+
+
+def main():
+
+ formats = []
+ for arg in sys.argv[1:]:
+ formats.extend(parse(arg))
+ write_format_table(formats)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.c b/mesalib/src/gallium/auxiliary/util/u_tile.c
index 23f12e5f4..6342bfbfc 100644
--- a/mesalib/src/gallium/auxiliary/util/u_tile.c
+++ b/mesalib/src/gallium/auxiliary/util/u_tile.c
@@ -389,6 +389,29 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
}
}
+void
+pipe_tile_raw_to_unsigned(enum pipe_format format,
+ void *src,
+ uint w, uint h,
+ unsigned *dst, unsigned dst_stride)
+{
+ util_format_read_4ui(format,
+ dst, dst_stride * sizeof(float),
+ src, util_format_get_stride(format, w),
+ 0, 0, w, h);
+}
+
+void
+pipe_tile_raw_to_signed(enum pipe_format format,
+ void *src,
+ uint w, uint h,
+ int *dst, unsigned dst_stride)
+{
+ util_format_read_4i(format,
+ dst, dst_stride * sizeof(float),
+ src, util_format_get_stride(format, w),
+ 0, 0, w, h);
+}
void
pipe_get_tile_rgba(struct pipe_context *pipe,
@@ -492,6 +515,61 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe,
FREE(packed);
}
+void
+pipe_put_tile_i_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ const int *p)
+{
+ unsigned src_stride = w * 4;
+ void *packed;
+
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
+ return;
+
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+
+ if (!packed)
+ return;
+
+ util_format_write_4i(format,
+ p, src_stride * sizeof(float),
+ packed, util_format_get_stride(format, w),
+ 0, 0, w, h);
+
+ pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+
+ FREE(packed);
+}
+
+void
+pipe_put_tile_ui_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ const unsigned int *p)
+{
+ unsigned src_stride = w * 4;
+ void *packed;
+
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
+ return;
+
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+
+ if (!packed)
+ return;
+
+ util_format_write_4ui(format,
+ p, src_stride * sizeof(float),
+ packed, util_format_get_stride(format, w),
+ 0, 0, w, h);
+
+ pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+
+ FREE(packed);
+}
/**
* Get a block of Z values, converted to 32-bit range.
@@ -688,3 +766,63 @@ pipe_put_tile_z(struct pipe_context *pipe,
}
+void
+pipe_get_tile_ui_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ unsigned int *p)
+{
+ unsigned dst_stride = w * 4;
+ void *packed;
+
+ if (u_clip_tile(x, y, &w, &h, &pt->box)) {
+ return;
+ }
+
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+ if (!packed) {
+ return;
+ }
+
+ if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {
+ assert((x & 1) == 0);
+ }
+
+ pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+
+ pipe_tile_raw_to_unsigned(format, packed, w, h, p, dst_stride);
+
+ FREE(packed);
+}
+
+
+void
+pipe_get_tile_i_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ int *p)
+{
+ unsigned dst_stride = w * 4;
+ void *packed;
+
+ if (u_clip_tile(x, y, &w, &h, &pt->box)) {
+ return;
+ }
+
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+ if (!packed) {
+ return;
+ }
+
+ if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {
+ assert((x & 1) == 0);
+ }
+
+ pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+
+ pipe_tile_raw_to_signed(format, packed, w, h, p, dst_stride);
+
+ FREE(packed);
+}
diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.h b/mesalib/src/gallium/auxiliary/util/u_tile.h
index 0abc95e2b..926f1695f 100644
--- a/mesalib/src/gallium/auxiliary/util/u_tile.h
+++ b/mesalib/src/gallium/auxiliary/util/u_tile.h
@@ -1,126 +1,165 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef P_TILE_H
-#define P_TILE_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-#include "pipe/p_state.h"
-
-struct pipe_context;
-struct pipe_transfer;
-
-/**
- * Clip tile against transfer dims.
- *
- * XXX: this only clips width and height!
- *
- * \return TRUE if tile is totally clipped, FALSE otherwise
- */
-static INLINE boolean
-u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box)
-{
- if (x >= box->width)
- return TRUE;
- if (y >= box->height)
- return TRUE;
- if (x + *w > box->width)
- *w = box->width - x;
- if (y + *h > box->height)
- *h = box->height - y;
- return FALSE;
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void
-pipe_get_tile_raw(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- void *p, int dst_stride);
-
-void
-pipe_put_tile_raw(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- const void *p, int src_stride);
-
-
-void
-pipe_get_tile_rgba(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- float *p);
-
-void
-pipe_get_tile_rgba_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- enum pipe_format format,
- float *p);
-
-void
-pipe_put_tile_rgba(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- const float *p);
-
-void
-pipe_put_tile_rgba_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- enum pipe_format format,
- const float *p);
-
-
-void
-pipe_get_tile_z(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- uint *z);
-
-void
-pipe_put_tile_z(struct pipe_context *pipe,
- struct pipe_transfer *pt,
- uint x, uint y, uint w, uint h,
- const uint *z);
-
-void
-pipe_tile_raw_to_rgba(enum pipe_format format,
- void *src,
- uint w, uint h,
- float *dst, unsigned dst_stride);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef P_TILE_H
+#define P_TILE_H
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+
+struct pipe_context;
+struct pipe_transfer;
+
+/**
+ * Clip tile against transfer dims.
+ *
+ * XXX: this only clips width and height!
+ *
+ * \return TRUE if tile is totally clipped, FALSE otherwise
+ */
+static INLINE boolean
+u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box)
+{
+ if (x >= box->width)
+ return TRUE;
+ if (y >= box->height)
+ return TRUE;
+ if (x + *w > box->width)
+ *w = box->width - x;
+ if (y + *h > box->height)
+ *h = box->height - y;
+ return FALSE;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void
+pipe_get_tile_raw(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ void *p, int dst_stride);
+
+void
+pipe_put_tile_raw(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ const void *p, int src_stride);
+
+
+void
+pipe_get_tile_rgba(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ float *p);
+
+void
+pipe_get_tile_rgba_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ float *p);
+
+void
+pipe_put_tile_rgba(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ const float *p);
+
+void
+pipe_put_tile_rgba_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ const float *p);
+
+
+void
+pipe_get_tile_z(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ uint *z);
+
+void
+pipe_put_tile_z(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ const uint *z);
+
+void
+pipe_tile_raw_to_rgba(enum pipe_format format,
+ void *src,
+ uint w, uint h,
+ float *dst, unsigned dst_stride);
+
+void
+pipe_tile_raw_to_unsigned(enum pipe_format format,
+ void *src,
+ uint w, uint h,
+ unsigned *dst, unsigned dst_stride);
+
+void
+pipe_tile_raw_to_signed(enum pipe_format format,
+ void *src,
+ uint w, uint h,
+ int *dst, unsigned dst_stride);
+
+void
+pipe_get_tile_ui_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ unsigned int *p);
+
+void
+pipe_get_tile_i_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ int *p);
+
+void
+pipe_put_tile_ui_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ const unsigned *p);
+
+void
+pipe_put_tile_i_format(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
+ uint x, uint y, uint w, uint h,
+ enum pipe_format format,
+ const int *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 4f8a5482b..70afb67df 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -2803,8 +2803,7 @@ ast_declarator_list::hir(exec_list *instructions,
_mesa_glsl_error(& loc, state,
"identifier `%s' uses reserved `gl_' prefix",
decl->identifier);
- else if (state->language_version >= 130 &&
- strstr(decl->identifier, "__")) {
+ else if (strstr(decl->identifier, "__")) {
/* From page 14 (page 20 of the PDF) of the GLSL 1.10
* spec:
*
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index d6594cd9a..d968890a2 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -1353,14 +1353,6 @@ ir_variable::interpolation_string() const
}
-unsigned
-ir_variable::component_slots() const
-{
- /* FINISHME: Sparsely accessed arrays require fewer slots. */
- return this->type->component_slots();
-}
-
-
ir_function_signature::ir_function_signature(const glsl_type *return_type)
: return_type(return_type), is_defined(false), _function(NULL)
{
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index cc4e68002..b707634ea 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -293,14 +293,6 @@ public:
const char *interpolation_string() const;
/**
- * Calculate the number of slots required to hold this variable
- *
- * This is used to determine how many uniform or varying locations a variable
- * occupies. The count is in units of floating point components.
- */
- unsigned component_slots() const;
-
- /**
* Delcared name of the variable
*/
const char *name;
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 4d645e200..5b73dcdfb 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -496,7 +496,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
_mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE);
if (ctx->Extensions.ARB_texture_cube_map)
_mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE);
+ if (ctx->Extensions.NV_texture_rectangle)
+ _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE);
diff --git a/mesalib/src/mesa/main/APIspec.xml b/mesalib/src/mesa/main/APIspec.xml
index 5d5fc03be..574480e28 100644
--- a/mesalib/src/mesa/main/APIspec.xml
+++ b/mesalib/src/mesa/main/APIspec.xml
@@ -41,10 +41,6 @@
<param name="plane" type="GLenum"/>
<vector name="equation" type="const GLtype *" size="4"/>
</proto>
-
- <desc name="plane">
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
- </desc>
</template>
<template name="CullFace">
@@ -807,6 +803,8 @@
<value name="GL_RESCALE_NORMAL"/>
<range base="GL_CLIP_PLANE" from="0" to="5"/>
+ <value name="GL_CLIP_PLANE0+6"/>
+ <value name="GL_CLIP_PLANE0+7"/>
<value name="GL_FOG"/>
<value name="GL_LIGHTING"/>
@@ -862,6 +860,8 @@
<value name="GL_RESCALE_NORMAL"/>
<range base="GL_CLIP_PLANE" from="0" to="5"/>
+ <value name="GL_CLIP_PLANE0+6"/>
+ <value name="GL_CLIP_PLANE0+7"/>
<value name="GL_FOG"/>
<value name="GL_LIGHTING"/>
@@ -1260,10 +1260,6 @@
<param name="plane" type="GLenum"/>
<vector name="equation" type="GLtype *" size="4"/>
</proto>
-
- <desc name="plane">
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
- </desc>
</template>
<template name="GetError" direction="get">
@@ -1517,6 +1513,8 @@
<value name="GL_RESCALE_NORMAL"/>
<range base="GL_CLIP_PLANE" from="0" to="5"/>
+ <value name="GL_CLIP_PLANE0+6"/>
+ <value name="GL_CLIP_PLANE0+7"/>
<value name="GL_FOG"/>
<value name="GL_LIGHTING"/>
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 2532c47de..fc52e8c15 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -1852,17 +1852,15 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
sh = shProg[i]->_LinkedShaders[i];
switch (sh->Type) {
case GL_VERTEX_SHADER:
- _mesa_append_uniforms_to_file(sh, &shProg[i]->VertexProgram->Base);
+ _mesa_append_uniforms_to_file(sh, sh->Program);
break;
case GL_GEOMETRY_SHADER_ARB:
- _mesa_append_uniforms_to_file(sh,
- &shProg[i]->GeometryProgram->Base);
+ _mesa_append_uniforms_to_file(sh, sh->Program);
break;
case GL_FRAGMENT_SHADER:
- _mesa_append_uniforms_to_file(sh,
- &shProg[i]->FragmentProgram->Base);
+ _mesa_append_uniforms_to_file(sh, sh->Program);
break;
}
}
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 787556451..4e017ae38 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -901,6 +901,7 @@ struct dd_function_table {
*/
void (*EndCallList)( struct gl_context *ctx );
+ /**@}*/
/**
* \name GL_ARB_sync interfaces
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 7cc172168..e6451c98b 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -315,7 +315,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
const GLboolean vertexShader =
(ctx->Shader.CurrentVertexProgram &&
ctx->Shader.CurrentVertexProgram->LinkStatus &&
- ctx->Shader.CurrentVertexProgram->VertexProgram);
+ ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]);
const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
GLbitfield fp_inputs = 0x0;
@@ -371,7 +371,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
}
else {
/* calculate from vp->outputs */
- struct gl_vertex_program *vprog;
+ struct gl_program *vprog;
GLbitfield64 vp_outputs;
/* Choose GLSL vertex shader over ARB vertex program. Need this
@@ -379,11 +379,11 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
* validation (see additional comments in state.c).
*/
if (vertexShader)
- vprog = ctx->Shader.CurrentVertexProgram->VertexProgram;
+ vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
else
- vprog = ctx->VertexProgram.Current;
+ vprog = &ctx->VertexProgram.Current->Base;
- vp_outputs = vprog->Base.OutputsWritten;
+ vp_outputs = vprog->OutputsWritten;
/* These get generated in the setup routine regardless of the
* vertex program:
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 02b20284b..6307f8e4d 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -2075,13 +2075,13 @@ _mesa_format_to_type_and_comps(gl_format format,
return;
case MESA_FORMAT_Z24_S8:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1; /* XXX OK? */
+ *datatype = GL_UNSIGNED_INT_24_8_MESA;
+ *comps = 2;
return;
case MESA_FORMAT_S8_Z24:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1; /* XXX OK? */
+ *datatype = GL_UNSIGNED_INT_8_24_REV_MESA;
+ *comps = 2;
return;
case MESA_FORMAT_Z16:
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index a869133a1..160a4f218 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -512,6 +512,7 @@ static const struct value_desc values[] = {
#if FEATURE_GL || FEATURE_ES1
/* Enums in OpenGL and GLES1 */
{ 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA },
+ { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
{ GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA },
{ GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA },
{ GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA },
@@ -680,8 +681,6 @@ static const struct value_desc values[] = {
#if FEATURE_GL || FEATURE_ES2
{ 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA },
- /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */
- { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
{ GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */
CONTEXT_INT(Const.MaxTextureCoordUnits),
extra_ARB_fragment_program_NV_fragment_program },
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index 8f0971959..345a1c53e 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -527,6 +527,19 @@ _mesa_bitcount(unsigned int n)
}
return bits;
}
+
+/**
+ * Return number of bits set in given 64-bit uint.
+ */
+unsigned int
+_mesa_bitcount_64(uint64_t n)
+{
+ unsigned int bits;
+ for (bits = 0; n > 0; n = n >> 1) {
+ bits += (n & 1);
+ }
+ return bits;
+}
#endif
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 5fb5581ef..20fa148fe 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -578,9 +578,12 @@ _mesa_init_sqrt_table(void);
#if ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
#define _mesa_bitcount(i) __builtin_popcount(i)
+#define _mesa_bitcount_64(i) __builtin_popcountll(i)
#else
extern unsigned int
_mesa_bitcount(unsigned int n);
+extern unsigned int
+_mesa_bitcount_64(uint64_t n);
#endif
#else
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index f04a98b03..46d71bb22 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -43,7 +43,13 @@
static GLint
bytes_per_pixel(GLenum datatype, GLuint comps)
{
- GLint b = _mesa_sizeof_packed_type(datatype);
+ GLint b;
+
+ if (datatype == GL_UNSIGNED_INT_8_24_REV_MESA ||
+ datatype == GL_UNSIGNED_INT_24_8_MESA)
+ return 4;
+
+ b = _mesa_sizeof_packed_type(datatype);
assert(b >= 0);
if (_mesa_type_is_packed(datatype))
@@ -717,6 +723,36 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
}
}
+ else if (datatype == GL_UNSIGNED_INT_24_8_MESA && comps == 2) {
+ GLuint i, j, k;
+ const GLuint *rowA = (const GLuint *) srcRowA;
+ const GLuint *rowB = (const GLuint *) srcRowB;
+ GLuint *dst = (GLuint *) dstRow;
+ /* note: averaging stencil values seems weird, but what else? */
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ GLuint z = (((rowA[j] >> 8) + (rowA[k] >> 8) +
+ (rowB[j] >> 8) + (rowB[k] >> 8)) / 4) << 8;
+ GLuint s = ((rowA[j] & 0xff) + (rowA[k] & 0xff) +
+ (rowB[j] & 0xff) + (rowB[k] & 0xff)) / 4;
+ dst[i] = z | s;
+ }
+ }
+ else if (datatype == GL_UNSIGNED_INT_8_24_REV_MESA && comps == 2) {
+ GLuint i, j, k;
+ const GLuint *rowA = (const GLuint *) srcRowA;
+ const GLuint *rowB = (const GLuint *) srcRowB;
+ GLuint *dst = (GLuint *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ GLuint z = ((rowA[j] & 0xffffff) + (rowA[k] & 0xffffff) +
+ (rowB[j] & 0xffffff) + (rowB[k] & 0xffffff)) / 4;
+ GLuint s = (((rowA[j] >> 24) + (rowA[k] >> 24) +
+ (rowB[j] >> 24) + (rowB[k] >> 24)) / 4) << 24;
+ dst[i] = z | s;
+ }
+ }
+
else {
_mesa_problem(NULL, "bad format in do_row()");
}
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index c97c0bf80..749324d76 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1231,8 +1231,8 @@ typedef enum
/**
- * Texture image state. Describes the dimensions of a texture image,
- * the texel format and pointers to Texel Fetch functions.
+ * Texture image state. Drivers will typically create a subclass of this
+ * with extra fields for memory buffers, etc.
*/
struct gl_texture_image
{
@@ -2171,9 +2171,6 @@ struct gl_shader_program
} Vert;
/* post-link info: */
- struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
- struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
- struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */
struct gl_uniform_list *Uniforms;
struct gl_program_parameter_list *Varying;
GLboolean LinkStatus; /**< GL_LINK_STATUS */
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 62e352f3f..092e541c5 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -467,6 +467,69 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
}
}
+/*
+ * integer packing , no transfer operations only packs
+ * to dst of GL_UNSIGNED_INT or GL_INT
+ */
+void
+_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr)
+{
+ int i;
+
+ switch(dstType) {
+ case GL_UNSIGNED_INT: {
+ GLuint *dst = (GLuint *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = (GLuint) rgba[i][RCOMP];
+ dst[i*4+1] = (GLuint) rgba[i][GCOMP];
+ dst[i*4+2] = (GLuint) rgba[i][BCOMP];
+ dst[i*4+3] = (GLuint) rgba[i][ACOMP];
+ }
+ break;
+ }
+ }
+ break;
+ case GL_INT: {
+ GLint *dst = (GLint *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = (GLint) rgba[i][RCOMP];
+ dst[i*4+1] = (GLint) rgba[i][GCOMP];
+ dst[i*4+2] = (GLint) rgba[i][BCOMP];
+ dst[i*4+3] = (GLint) rgba[i][ACOMP];
+ }
+ break;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ return;
+ }
+}
/**
diff --git a/mesalib/src/mesa/main/pack.h b/mesalib/src/mesa/main/pack.h
index 7c76baae4..7a0089c2f 100644
--- a/mesalib/src/mesa/main/pack.h
+++ b/mesalib/src/mesa/main/pack.h
@@ -144,4 +144,9 @@ _mesa_unpack_image(GLuint dimensions,
const struct gl_pixelstore_attrib *unpack);
+void
+_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr);
+
#endif
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 9e0ed9c69..c3aabe43f 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -808,12 +808,15 @@ print_shader_info(const struct gl_shader_program *shProg)
shProg->Shaders[i]->Name,
shProg->Shaders[i]->SourceChecksum);
}
- if (shProg->VertexProgram)
- printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
- if (shProg->FragmentProgram)
- printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
- if (shProg->GeometryProgram)
- printf(" geom prog %u\n", shProg->GeometryProgram->Base.Id);
+ if (shProg->_LinkedShaders[MESA_SHADER_VERTEX])
+ printf(" vert prog %u\n",
+ shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id);
+ if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT])
+ printf(" frag prog %u\n",
+ shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Id);
+ if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY])
+ printf(" geom prog %u\n",
+ shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program->Id);
}
@@ -963,9 +966,7 @@ static GLboolean
validate_shader_program(const struct gl_shader_program *shProg,
char *errMsg)
{
- const struct gl_vertex_program *vp = shProg->VertexProgram;
- const struct gl_geometry_program *gp = shProg->GeometryProgram;
- const struct gl_fragment_program *fp = shProg->FragmentProgram;
+ unsigned i;
if (!shProg->LinkStatus) {
return GL_FALSE;
@@ -991,14 +992,11 @@ validate_shader_program(const struct gl_shader_program *shProg,
* Check: any two active samplers in the current program object are of
* different types, but refer to the same texture image unit,
*/
- if (vp && !validate_samplers(&vp->Base, errMsg)) {
- return GL_FALSE;
- }
- if (gp && !validate_samplers(&gp->Base, errMsg)) {
- return GL_FALSE;
- }
- if (fp && !validate_samplers(&fp->Base, errMsg)) {
- return GL_FALSE;
+ for (i = 0; i < Elements(shProg->_LinkedShaders); i++) {
+ if (shProg->_LinkedShaders[i]
+ && !validate_samplers(shProg->_LinkedShaders[i]->Program, errMsg)) {
+ return GL_FALSE;
+ }
}
return GL_TRUE;
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index 1eba75697..ccf7efddb 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -275,10 +275,6 @@ void
_mesa_clear_shader_program_data(struct gl_context *ctx,
struct gl_shader_program *shProg)
{
- _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
- _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
- _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL);
-
if (shProg->Uniforms) {
_mesa_free_uniform_list(shProg->Uniforms);
shProg->Uniforms = NULL;
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index fc25515a0..bbe90a32e 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -246,10 +246,12 @@ update_program(struct gl_context *ctx)
* come up, or matter.
*/
- if (fsProg && fsProg->LinkStatus && fsProg->FragmentProgram) {
+ if (fsProg && fsProg->LinkStatus
+ && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
/* Use GLSL fragment shader */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
- fsProg->FragmentProgram);
+ (struct gl_fragment_program *)
+ fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
}
else if (ctx->FragmentProgram._Enabled) {
/* Use user-defined fragment program */
@@ -268,10 +270,12 @@ update_program(struct gl_context *ctx)
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
}
- if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) {
+ if (gsProg && gsProg->LinkStatus
+ && gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
/* Use GLSL geometry shader */
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current,
- gsProg->GeometryProgram);
+ (struct gl_geometry_program *)
+ gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
} else {
/* No geometry program */
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
@@ -281,10 +285,12 @@ update_program(struct gl_context *ctx)
* _mesa_get_fixed_func_vertex_program() needs to know active
* fragprog inputs.
*/
- if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) {
+ if (vsProg && vsProg->LinkStatus
+ && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
/* Use GLSL vertex shader */
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- vsProg->VertexProgram);
+ (struct gl_vertex_program *)
+ vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
}
else if (ctx->VertexProgram._Enabled) {
/* Use user-defined vertex program */
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c
index b6d8ae016..41630a47c 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.c
+++ b/mesalib/src/mesa/main/texcompress_fxt1.c
@@ -76,6 +76,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
if (srcFormat != GL_RGB ||
srcType != GL_UNSIGNED_BYTE ||
ctx->_ImageTransferState ||
+ srcPacking->RowLength != srcWidth ||
srcPacking->SwapBytes) {
/* convert image to RGB/GLubyte */
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
@@ -91,7 +92,9 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
srcFormat = GL_RGB;
}
else {
- pixels = (const GLubyte *) srcAddr;
+ pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0);
+
srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
srcType) / sizeof(GLubyte);
}
@@ -146,7 +149,9 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
srcFormat = GL_RGBA;
}
else {
- pixels = (const GLubyte *) srcAddr;
+ pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0);
+
srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
srcType) / sizeof(GLubyte);
}
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c
index 83bd6b950..29386a37d 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -182,6 +182,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
if (srcFormat != GL_RGB ||
srcType != GL_UNSIGNED_BYTE ||
ctx->_ImageTransferState ||
+ srcPacking->RowLength != srcWidth ||
srcPacking->SwapBytes) {
/* convert image to RGB/GLubyte */
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
@@ -196,7 +197,8 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
srcFormat = GL_RGB;
}
else {
- pixels = (const GLubyte *) srcAddr;
+ pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0);
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -240,6 +242,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
ctx->_ImageTransferState ||
+ srcPacking->RowLength != srcWidth ||
srcPacking->SwapBytes) {
/* convert image to RGBA/GLubyte */
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
@@ -254,7 +257,8 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
srcFormat = GL_RGBA;
}
else {
- pixels = (const GLubyte *) srcAddr;
+ pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0);
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -297,6 +301,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
ctx->_ImageTransferState ||
+ srcPacking->RowLength != srcWidth ||
srcPacking->SwapBytes) {
/* convert image to RGBA/GLubyte */
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
@@ -310,7 +315,8 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
pixels = tempImage;
}
else {
- pixels = (const GLubyte *) srcAddr;
+ pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0);
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
@@ -353,6 +359,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
ctx->_ImageTransferState ||
+ srcPacking->RowLength != srcWidth ||
srcPacking->SwapBytes) {
/* convert image to RGBA/GLubyte */
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
@@ -366,7 +373,8 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
pixels = tempImage;
}
else {
- pixels = (const GLubyte *) srcAddr;
+ pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0);
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index ccc3c49f5..7f262d6d8 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -591,86 +591,144 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
if (ctx->Extensions.EXT_texture_integer) {
switch (internalFormat) {
- case GL_RGBA32UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_ALPHA32UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
- break;
- case GL_RGBA16UI_EXT:
- case GL_RGB16UI_EXT:
+ case GL_ALPHA8UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+ break;
case GL_ALPHA16UI_EXT:
- case GL_INTENSITY16UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+ break;
+ case GL_ALPHA32UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+ break;
+ case GL_ALPHA8I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+ break;
+ case GL_ALPHA16I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+ break;
+ case GL_ALPHA32I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+ break;
+ case GL_LUMINANCE8UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+ break;
case GL_LUMINANCE16UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+ break;
+ case GL_LUMINANCE32UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+ break;
+ case GL_LUMINANCE8I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+ break;
+ case GL_LUMINANCE16I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+ break;
+ case GL_LUMINANCE32I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+ break;
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+ break;
case GL_LUMINANCE_ALPHA16UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
- break;
- case GL_RGBA8UI_EXT:
- case GL_RGB8UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
- break;
- case GL_ALPHA8UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT8);
- break;
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+ break;
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+ break;
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+ break;
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+ break;
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+ break;
case GL_INTENSITY8UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT8);
- break;
- case GL_LUMINANCE8UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT8);
- break;
- case GL_LUMINANCE_ALPHA8UI_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT8);
- break;
- case GL_RGBA32I_EXT:
- case GL_RGB32I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
- break;
- case GL_ALPHA32I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT32);
- break;
+ RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+ break;
+ case GL_INTENSITY16UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+ break;
+ case GL_INTENSITY32UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+ break;
+ case GL_INTENSITY8I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+ break;
+ case GL_INTENSITY16I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+ break;
case GL_INTENSITY32I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT32);
- break;
- case GL_LUMINANCE32I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT32);
- break;
- case GL_LUMINANCE_ALPHA32I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT32);
- break;
- case GL_RGBA16I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+ break;
+ case GL_RGB8UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+ break;
+ case GL_RGB16UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+ break;
+ case GL_RGB32UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+ break;
+ case GL_RGB8I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+ break;
case GL_RGB16I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
- break;
- case GL_ALPHA16I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT16);
- break;
- case GL_INTENSITY16I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT16);
- break;
- case GL_LUMINANCE16I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT16);
- break;
- case GL_LUMINANCE_ALPHA16I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT16);
- break;
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+ break;
+ case GL_RGB32I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+ break;
+ case GL_RGBA8UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+ break;
+ case GL_RGBA16UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+ break;
+ case GL_RGBA32UI_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+ break;
case GL_RGBA8I_EXT:
- case GL_RGB8I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
- break;
- case GL_ALPHA8I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT8);
- break;
- case GL_INTENSITY8I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT8);
- break;
- case GL_LUMINANCE8I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT8);
- break;
- case GL_LUMINANCE_ALPHA8I_EXT:
- RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT8);
- break;
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+ break;
+ case GL_RGBA16I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+ break;
+ case GL_RGBA32I_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+ break;
}
}
diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c
index e02f16240..9f14d8a0d 100644
--- a/mesalib/src/mesa/main/texstate.c
+++ b/mesalib/src/mesa/main/texstate.c
@@ -489,26 +489,26 @@ static void
update_texture_state( struct gl_context *ctx )
{
GLuint unit;
- struct gl_fragment_program *fprog = NULL;
- struct gl_vertex_program *vprog = NULL;
+ struct gl_program *fprog = NULL;
+ struct gl_program *vprog = NULL;
GLbitfield enabledFragUnits = 0x0;
if (ctx->Shader.CurrentVertexProgram &&
ctx->Shader.CurrentVertexProgram->LinkStatus) {
- vprog = ctx->Shader.CurrentVertexProgram->VertexProgram;
+ vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
} else if (ctx->VertexProgram._Enabled) {
/* XXX enable this if/when non-shader vertex programs get
* texture fetches:
- vprog = ctx->VertexProgram.Current;
+ vprog = &ctx->VertexProgram.Current->Base;
*/
}
if (ctx->Shader.CurrentFragmentProgram &&
ctx->Shader.CurrentFragmentProgram->LinkStatus) {
- fprog = ctx->Shader.CurrentFragmentProgram->FragmentProgram;
+ fprog = ctx->Shader.CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
}
else if (ctx->FragmentProgram._Enabled) {
- fprog = ctx->FragmentProgram.Current;
+ fprog = &ctx->FragmentProgram.Current->Base;
}
/* FINISHME: Geometry shader texture accesses should also be considered
@@ -540,11 +540,11 @@ update_texture_state( struct gl_context *ctx )
* settle on the one with highest priority (see below).
*/
if (vprog) {
- enabledVertTargets |= vprog->Base.TexturesUsed[unit];
+ enabledVertTargets |= vprog->TexturesUsed[unit];
}
if (fprog) {
- enabledFragTargets |= fprog->Base.TexturesUsed[unit];
+ enabledFragTargets |= fprog->TexturesUsed[unit];
}
else {
/* fixed-function fragment program */
@@ -611,7 +611,7 @@ update_texture_state( struct gl_context *ctx )
if (fprog) {
const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
ctx->Texture._EnabledCoordUnits
- = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
+ = (fprog->InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
}
else {
ctx->Texture._EnabledCoordUnits = enabledFragUnits;
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index 2323819aa..7252c099a 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -180,17 +180,17 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index,
pos = shProg->Uniforms->Uniforms[index].VertPos;
if (pos >= 0) {
- prog = &shProg->VertexProgram->Base;
+ prog = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
}
else {
pos = shProg->Uniforms->Uniforms[index].FragPos;
if (pos >= 0) {
- prog = &shProg->FragmentProgram->Base;
+ prog = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
}
else {
pos = shProg->Uniforms->Uniforms[index].GeomPos;
if (pos >= 0) {
- prog = &shProg->GeometryProgram->Base;
+ prog = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
}
}
}
@@ -911,29 +911,32 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
/* A uniform var may be used by both a vertex shader and a fragment
* shader. We may need to update one or both shader's uniform here:
*/
- if (shProg->VertexProgram) {
+ if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
/* convert uniform location to program parameter index */
GLint index = uniform->VertPos;
if (index >= 0) {
- set_program_uniform(ctx, &shProg->VertexProgram->Base,
+ set_program_uniform(ctx,
+ shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
index, offset, type, count, elems, values);
}
}
- if (shProg->FragmentProgram) {
+ if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
/* convert uniform location to program parameter index */
GLint index = uniform->FragPos;
if (index >= 0) {
- set_program_uniform(ctx, &shProg->FragmentProgram->Base,
+ set_program_uniform(ctx,
+ shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program,
index, offset, type, count, elems, values);
}
}
- if (shProg->GeometryProgram) {
+ if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
/* convert uniform location to program parameter index */
GLint index = uniform->GeomPos;
if (index >= 0) {
- set_program_uniform(ctx, &shProg->GeometryProgram->Base,
+ set_program_uniform(ctx,
+ shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program,
index, offset, type, count, elems, values);
}
}
@@ -1056,31 +1059,34 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
uniform = &shProg->Uniforms->Uniforms[location];
- if (shProg->VertexProgram) {
+ if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
/* convert uniform location to program parameter index */
GLint index = uniform->VertPos;
if (index >= 0) {
- set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base,
+ set_program_uniform_matrix(ctx,
+ shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
index, offset,
count, rows, cols, transpose, values);
}
}
- if (shProg->FragmentProgram) {
+ if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
/* convert uniform location to program parameter index */
GLint index = uniform->FragPos;
if (index >= 0) {
- set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base,
+ set_program_uniform_matrix(ctx,
+ shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program,
index, offset,
count, rows, cols, transpose, values);
}
}
- if (shProg->GeometryProgram) {
+ if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
/* convert uniform location to program parameter index */
GLint index = uniform->GeomPos;
if (index >= 0) {
- set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base,
+ set_program_uniform_matrix(ctx,
+ shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program,
index, offset,
count, rows, cols, transpose, values);
}
@@ -1437,6 +1443,12 @@ _mesa_GetnUniformdvARB(GLhandleARB program, GLint location,
GLsizei bufSize, GLdouble *params)
{
GET_CURRENT_CONTEXT(ctx);
+
+ (void) program;
+ (void) location;
+ (void) bufSize;
+ (void) params;
+
/*
get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params);
*/
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 2e1b8fba3..5be44bc51 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -3288,31 +3288,20 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
if (linked_prog) {
- bool ok = true;
+ static const GLenum targets[] = {
+ GL_VERTEX_PROGRAM_ARB,
+ GL_FRAGMENT_PROGRAM_ARB,
+ GL_GEOMETRY_PROGRAM_NV
+ };
- switch (prog->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER:
+ if (i == MESA_SHADER_VERTEX) {
((struct gl_vertex_program *)linked_prog)->UsesClipDistance
= prog->Vert.UsesClipDistance;
- _mesa_reference_vertprog(ctx, &prog->VertexProgram,
- (struct gl_vertex_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_FRAGMENT_SHADER:
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
- (struct gl_fragment_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_GEOMETRY_SHADER:
- _mesa_reference_geomprog(ctx, &prog->GeometryProgram,
- (struct gl_geometry_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
- linked_prog);
- break;
- }
- if (!ok) {
+ }
+
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ linked_prog);
+ if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
return GL_FALSE;
}
}
@@ -3427,10 +3416,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
- _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
- _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
-
if (prog->LinkStatus) {
link_shaders(ctx, prog);
}
diff --git a/mesalib/src/mesa/program/prog_uniform.c b/mesalib/src/mesa/program/prog_uniform.c
index 28acb8871..d0b25e5c5 100644
--- a/mesalib/src/mesa/program/prog_uniform.c
+++ b/mesalib/src/mesa/program/prog_uniform.c
@@ -56,80 +56,6 @@ _mesa_free_uniform_list(struct gl_uniform_list *list)
}
-struct gl_uniform *
-_mesa_append_uniform(struct gl_uniform_list *list,
- const char *name, GLenum target, GLuint progPos)
-{
- const GLuint oldNum = list->NumUniforms;
- struct gl_uniform *uniform;
- GLint index;
-
- assert(target == GL_VERTEX_PROGRAM_ARB ||
- target == GL_FRAGMENT_PROGRAM_ARB ||
- target == MESA_GEOMETRY_PROGRAM);
-
- index = _mesa_lookup_uniform(list, name);
- if (index < 0) {
- /* not found - append to list */
-
- if (oldNum + 1 > list->Size) {
- /* Need to grow the list array (alloc some extra) */
- list->Size += 4;
-
- /* realloc arrays */
- list->Uniforms = (struct gl_uniform *)
- _mesa_realloc(list->Uniforms,
- oldNum * sizeof(struct gl_uniform),
- list->Size * sizeof(struct gl_uniform));
- }
-
- if (!list->Uniforms) {
- /* out of memory */
- list->NumUniforms = 0;
- list->Size = 0;
- return GL_FALSE;
- }
-
- uniform = list->Uniforms + oldNum;
-
- uniform->Name = _mesa_strdup(name);
- uniform->VertPos = -1;
- uniform->FragPos = -1;
- uniform->GeomPos = -1;
- uniform->Initialized = GL_FALSE;
-
- list->NumUniforms++;
- }
- else {
- /* found */
- uniform = list->Uniforms + index;
- }
-
- /* update position for the vertex or fragment program */
- if (target == GL_VERTEX_PROGRAM_ARB) {
- if (uniform->VertPos != -1) {
- /* this uniform is already in the list - that shouldn't happen */
- return GL_FALSE;
- }
- uniform->VertPos = progPos;
- } else if (target == GL_FRAGMENT_PROGRAM_ARB) {
- if (uniform->FragPos != -1) {
- /* this uniform is already in the list - that shouldn't happen */
- return GL_FALSE;
- }
- uniform->FragPos = progPos;
- } else {
- if (uniform->GeomPos != -1) {
- /* this uniform is already in the list - that shouldn't happen */
- return GL_FALSE;
- }
- uniform->GeomPos = progPos;
- }
-
- return uniform;
-}
-
-
/**
* Return the location/index of the named uniform in the uniform list,
* or -1 if not found.
diff --git a/mesalib/src/mesa/program/prog_uniform.h b/mesalib/src/mesa/program/prog_uniform.h
index 67f78006e..83cd30780 100644
--- a/mesalib/src/mesa/program/prog_uniform.h
+++ b/mesalib/src/mesa/program/prog_uniform.h
@@ -72,10 +72,6 @@ _mesa_new_uniform_list(void);
extern void
_mesa_free_uniform_list(struct gl_uniform_list *list);
-extern struct gl_uniform *
-_mesa_append_uniform(struct gl_uniform_list *list,
- const char *name, GLenum target, GLuint progPos);
-
extern GLint
_mesa_lookup_uniform(const struct gl_uniform_list *list, const char *name);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
index e2b29fe30..7fa1672fd 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
@@ -387,6 +387,8 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
GLsizei i, j;
GLint yStep, dfStride;
GLfloat *df;
+ GLuint *dui;
+ GLint *di;
struct st_renderbuffer *strb;
struct gl_pixelstore_attrib clippedPacking = *pack;
struct pipe_transfer *trans;
@@ -454,10 +456,13 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
}
else {
/* write tile(row) into temp row buffer */
- df = (GLfloat *) temp;
+ df = (GLfloat *)temp;
dfStride = 0;
}
+ dui = (GLuint *)df;
+ di = (GLint *)df;
+
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
/* convert GL Y to Gallium Y */
y = strb->Base.Height - y - height;
@@ -611,7 +616,38 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
dst += dstStride;
}
}
- else {
+ else if (util_format_is_pure_sint(pformat)) {
+ for (i = 0; i < height; i++) {
+ if (type == GL_UNSIGNED_INT)
+ pipe_get_tile_ui_format(pipe, trans, 0, y, width, 1,
+ pformat, dui);
+ else
+ pipe_get_tile_i_format(pipe, trans, 0, y, width, 1,
+ pformat, di);
+ y += yStep;
+ if (!dfStride) {
+ _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4])temp,
+ format, type, dst);
+ dst += dstStride;
+ }
+ }
+ } else if (util_format_is_pure_uint(pformat)) {
+ for (i = 0; i < height; i++) {
+ if (type == GL_UNSIGNED_INT)
+ pipe_get_tile_ui_format(pipe, trans, 0, y, width, 1,
+ pformat, dui);
+ else
+ pipe_get_tile_i_format(pipe, trans, 0, y, width, 1,
+ pformat, di);
+ y += yStep;
+ df += dfStride;
+ if (!dfStride) {
+ _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4])temp,
+ format, type, dst);
+ dst += dstStride;
+ }
+ }
+ } else {
/* RGBA format */
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 6eb8a506b..6e8ab94f4 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -291,20 +291,112 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_R16G16B16A16_UNORM;
/* signed int formats */
+ case MESA_FORMAT_ALPHA_UINT8:
+ return PIPE_FORMAT_A8_UINT;
+ case MESA_FORMAT_ALPHA_UINT16:
+ return PIPE_FORMAT_A16_UINT;
+ case MESA_FORMAT_ALPHA_UINT32:
+ return PIPE_FORMAT_A32_UINT;
+
+ case MESA_FORMAT_ALPHA_INT8:
+ return PIPE_FORMAT_A8_SINT;
+ case MESA_FORMAT_ALPHA_INT16:
+ return PIPE_FORMAT_A16_SINT;
+ case MESA_FORMAT_ALPHA_INT32:
+ return PIPE_FORMAT_A32_SINT;
+
+ case MESA_FORMAT_INTENSITY_UINT8:
+ return PIPE_FORMAT_I8_UINT;
+ case MESA_FORMAT_INTENSITY_UINT16:
+ return PIPE_FORMAT_I16_UINT;
+ case MESA_FORMAT_INTENSITY_UINT32:
+ return PIPE_FORMAT_I32_UINT;
+
+ case MESA_FORMAT_INTENSITY_INT8:
+ return PIPE_FORMAT_I8_SINT;
+ case MESA_FORMAT_INTENSITY_INT16:
+ return PIPE_FORMAT_I16_SINT;
+ case MESA_FORMAT_INTENSITY_INT32:
+ return PIPE_FORMAT_I32_SINT;
+
+ case MESA_FORMAT_LUMINANCE_UINT8:
+ return PIPE_FORMAT_L8_UINT;
+ case MESA_FORMAT_LUMINANCE_UINT16:
+ return PIPE_FORMAT_L16_UINT;
+ case MESA_FORMAT_LUMINANCE_UINT32:
+ return PIPE_FORMAT_L32_UINT;
+
+ case MESA_FORMAT_LUMINANCE_INT8:
+ return PIPE_FORMAT_L8_SINT;
+ case MESA_FORMAT_LUMINANCE_INT16:
+ return PIPE_FORMAT_L16_SINT;
+ case MESA_FORMAT_LUMINANCE_INT32:
+ return PIPE_FORMAT_L32_SINT;
+
+ case MESA_FORMAT_LUMINANCE_ALPHA_UINT8:
+ return PIPE_FORMAT_L8A8_UINT;
+ case MESA_FORMAT_LUMINANCE_ALPHA_UINT16:
+ return PIPE_FORMAT_L16A16_UINT;
+ case MESA_FORMAT_LUMINANCE_ALPHA_UINT32:
+ return PIPE_FORMAT_L32A32_UINT;
+
+ case MESA_FORMAT_LUMINANCE_ALPHA_INT8:
+ return PIPE_FORMAT_L8A8_SINT;
+ case MESA_FORMAT_LUMINANCE_ALPHA_INT16:
+ return PIPE_FORMAT_L16A16_SINT;
+ case MESA_FORMAT_LUMINANCE_ALPHA_INT32:
+ return PIPE_FORMAT_L32A32_SINT;
+
+ case MESA_FORMAT_R_INT8:
+ return PIPE_FORMAT_R8_SINT;
+ case MESA_FORMAT_RG_INT8:
+ return PIPE_FORMAT_R8G8_SINT;
+ case MESA_FORMAT_RGB_INT8:
+ return PIPE_FORMAT_R8G8B8_SINT;
case MESA_FORMAT_RGBA_INT8:
- return PIPE_FORMAT_R8G8B8A8_SSCALED;
+ return PIPE_FORMAT_R8G8B8A8_SINT;
+ case MESA_FORMAT_R_INT16:
+ return PIPE_FORMAT_R16_SINT;
+ case MESA_FORMAT_RG_INT16:
+ return PIPE_FORMAT_R16G16_SINT;
+ case MESA_FORMAT_RGB_INT16:
+ return PIPE_FORMAT_R16G16B16_SINT;
case MESA_FORMAT_RGBA_INT16:
- return PIPE_FORMAT_R16G16B16A16_SSCALED;
+ return PIPE_FORMAT_R16G16B16A16_SINT;
+ case MESA_FORMAT_R_INT32:
+ return PIPE_FORMAT_R32_SINT;
+ case MESA_FORMAT_RG_INT32:
+ return PIPE_FORMAT_R32G32_SINT;
+ case MESA_FORMAT_RGB_INT32:
+ return PIPE_FORMAT_R32G32B32_SINT;
case MESA_FORMAT_RGBA_INT32:
- return PIPE_FORMAT_R32G32B32A32_SSCALED;
+ return PIPE_FORMAT_R32G32B32A32_SINT;
/* unsigned int formats */
+ case MESA_FORMAT_R_UINT8:
+ return PIPE_FORMAT_R8_UINT;
+ case MESA_FORMAT_RG_UINT8:
+ return PIPE_FORMAT_R8G8_UINT;
+ case MESA_FORMAT_RGB_UINT8:
+ return PIPE_FORMAT_R8G8B8_UINT;
case MESA_FORMAT_RGBA_UINT8:
- return PIPE_FORMAT_R8G8B8A8_USCALED;
+ return PIPE_FORMAT_R8G8B8A8_UINT;
+ case MESA_FORMAT_R_UINT16:
+ return PIPE_FORMAT_R16_UINT;
+ case MESA_FORMAT_RG_UINT16:
+ return PIPE_FORMAT_R16G16_UINT;
+ case MESA_FORMAT_RGB_UINT16:
+ return PIPE_FORMAT_R16G16B16_UINT;
case MESA_FORMAT_RGBA_UINT16:
- return PIPE_FORMAT_R16G16B16A16_USCALED;
+ return PIPE_FORMAT_R16G16B16A16_UINT;
+ case MESA_FORMAT_R_UINT32:
+ return PIPE_FORMAT_R32_UINT;
+ case MESA_FORMAT_RG_UINT32:
+ return PIPE_FORMAT_R32G32_UINT;
+ case MESA_FORMAT_RGB_UINT32:
+ return PIPE_FORMAT_R32G32B32_UINT;
case MESA_FORMAT_RGBA_UINT32:
- return PIPE_FORMAT_R32G32B32A32_USCALED;
+ return PIPE_FORMAT_R32G32B32A32_UINT;
case MESA_FORMAT_RED_RGTC1:
return PIPE_FORMAT_RGTC1_UNORM;
@@ -519,20 +611,111 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
case PIPE_FORMAT_R16G16_UNORM:
return MESA_FORMAT_RG1616;
- /* signed int formats */
- case PIPE_FORMAT_R8G8B8A8_SSCALED:
+ case PIPE_FORMAT_A8_UINT:
+ return MESA_FORMAT_ALPHA_UINT8;
+ case PIPE_FORMAT_A16_UINT:
+ return MESA_FORMAT_ALPHA_UINT16;
+ case PIPE_FORMAT_A32_UINT:
+ return MESA_FORMAT_ALPHA_UINT32;
+ case PIPE_FORMAT_A8_SINT:
+ return MESA_FORMAT_ALPHA_INT8;
+ case PIPE_FORMAT_A16_SINT:
+ return MESA_FORMAT_ALPHA_INT16;
+ case PIPE_FORMAT_A32_SINT:
+ return MESA_FORMAT_ALPHA_INT32;
+
+ case PIPE_FORMAT_I8_UINT:
+ return MESA_FORMAT_INTENSITY_UINT8;
+ case PIPE_FORMAT_I16_UINT:
+ return MESA_FORMAT_INTENSITY_UINT16;
+ case PIPE_FORMAT_I32_UINT:
+ return MESA_FORMAT_INTENSITY_UINT32;
+ case PIPE_FORMAT_I8_SINT:
+ return MESA_FORMAT_INTENSITY_INT8;
+ case PIPE_FORMAT_I16_SINT:
+ return MESA_FORMAT_INTENSITY_INT16;
+ case PIPE_FORMAT_I32_SINT:
+ return MESA_FORMAT_INTENSITY_INT32;
+
+ case PIPE_FORMAT_L8_UINT:
+ return MESA_FORMAT_LUMINANCE_UINT8;
+ case PIPE_FORMAT_L16_UINT:
+ return MESA_FORMAT_LUMINANCE_UINT16;
+ case PIPE_FORMAT_L32_UINT:
+ return MESA_FORMAT_LUMINANCE_UINT32;
+ case PIPE_FORMAT_L8_SINT:
+ return MESA_FORMAT_LUMINANCE_INT8;
+ case PIPE_FORMAT_L16_SINT:
+ return MESA_FORMAT_LUMINANCE_INT16;
+ case PIPE_FORMAT_L32_SINT:
+ return MESA_FORMAT_LUMINANCE_INT32;
+
+ case PIPE_FORMAT_L8A8_UINT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT8;
+ case PIPE_FORMAT_L16A16_UINT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT16;
+ case PIPE_FORMAT_L32A32_UINT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT32;
+ case PIPE_FORMAT_L8A8_SINT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+ case PIPE_FORMAT_L16A16_SINT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT16;
+ case PIPE_FORMAT_L32A32_SINT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT32;
+
+ case PIPE_FORMAT_R8_SINT:
+ return MESA_FORMAT_R_INT8;
+ case PIPE_FORMAT_R8G8_SINT:
+ return MESA_FORMAT_RG_INT8;
+ case PIPE_FORMAT_R8G8B8_SINT:
+ return MESA_FORMAT_RGB_INT8;
+ case PIPE_FORMAT_R8G8B8A8_SINT:
return MESA_FORMAT_RGBA_INT8;
- case PIPE_FORMAT_R16G16B16A16_SSCALED:
+
+ case PIPE_FORMAT_R16_SINT:
+ return MESA_FORMAT_R_INT16;
+ case PIPE_FORMAT_R16G16_SINT:
+ return MESA_FORMAT_RG_INT16;
+ case PIPE_FORMAT_R16G16B16_SINT:
+ return MESA_FORMAT_RGB_INT16;
+ case PIPE_FORMAT_R16G16B16A16_SINT:
return MESA_FORMAT_RGBA_INT16;
- case PIPE_FORMAT_R32G32B32A32_SSCALED:
+
+ case PIPE_FORMAT_R32_SINT:
+ return MESA_FORMAT_R_INT32;
+ case PIPE_FORMAT_R32G32_SINT:
+ return MESA_FORMAT_RG_INT32;
+ case PIPE_FORMAT_R32G32B32_SINT:
+ return MESA_FORMAT_RGB_INT32;
+ case PIPE_FORMAT_R32G32B32A32_SINT:
return MESA_FORMAT_RGBA_INT32;
/* unsigned int formats */
- case PIPE_FORMAT_R8G8B8A8_USCALED:
+ case PIPE_FORMAT_R8_UINT:
+ return MESA_FORMAT_R_UINT8;
+ case PIPE_FORMAT_R8G8_UINT:
+ return MESA_FORMAT_RG_UINT8;
+ case PIPE_FORMAT_R8G8B8_UINT:
+ return MESA_FORMAT_RGB_UINT8;
+ case PIPE_FORMAT_R8G8B8A8_UINT:
return MESA_FORMAT_RGBA_UINT8;
- case PIPE_FORMAT_R16G16B16A16_USCALED:
+
+ case PIPE_FORMAT_R16_UINT:
+ return MESA_FORMAT_R_UINT16;
+ case PIPE_FORMAT_R16G16_UINT:
+ return MESA_FORMAT_RG_UINT16;
+ case PIPE_FORMAT_R16G16B16_UINT:
+ return MESA_FORMAT_RGB_UINT16;
+ case PIPE_FORMAT_R16G16B16A16_UINT:
return MESA_FORMAT_RGBA_UINT16;
- case PIPE_FORMAT_R32G32B32A32_USCALED:
+
+ case PIPE_FORMAT_R32_UINT:
+ return MESA_FORMAT_R_UINT32;
+ case PIPE_FORMAT_R32G32_UINT:
+ return MESA_FORMAT_RG_UINT32;
+ case PIPE_FORMAT_R32G32B32_UINT:
+ return MESA_FORMAT_RGB_UINT32;
+ case PIPE_FORMAT_R32G32B32A32_UINT:
return MESA_FORMAT_RGBA_UINT32;
case PIPE_FORMAT_RGTC1_UNORM:
@@ -996,79 +1179,215 @@ static const struct format_mapping format_map[] = {
},
/* signed/unsigned integer formats.
- * XXX Mesa only has formats for RGBA signed/unsigned integer formats.
- * If/when new formats are added this code should be updated.
*/
{
{ GL_RED_INTEGER_EXT,
GL_GREEN_INTEGER_EXT,
GL_BLUE_INTEGER_EXT,
- GL_ALPHA_INTEGER_EXT,
- GL_RGB_INTEGER_EXT,
GL_RGBA_INTEGER_EXT,
- GL_BGR_INTEGER_EXT,
GL_BGRA_INTEGER_EXT,
- GL_LUMINANCE_INTEGER_EXT,
- GL_LUMINANCE_ALPHA_INTEGER_EXT,
- GL_RGBA8I_EXT,
- GL_RGB8I_EXT,
- GL_ALPHA8I_EXT,
- GL_INTENSITY8I_EXT,
- GL_LUMINANCE8I_EXT,
+ GL_RGBA8I_EXT, 0 },
+ { PIPE_FORMAT_R8G8B8A8_SINT, 0 }
+ },
+ {
+ { GL_RGB_INTEGER_EXT,
+ GL_BGR_INTEGER_EXT,
+ GL_RGB8I_EXT, 0 },
+ { PIPE_FORMAT_R8G8B8_SINT,
+ PIPE_FORMAT_R8G8B8A8_SINT, 0 }
+ },
+ {
+ { GL_ALPHA_INTEGER_EXT,
+ GL_ALPHA8I_EXT, 0 },
+ { PIPE_FORMAT_A8_SINT, 0 }
+ },
+ {
+ { GL_ALPHA16I_EXT, 0 },
+ { PIPE_FORMAT_A16_SINT, 0 }
+ },
+ {
+ { GL_ALPHA32I_EXT, 0 },
+ { PIPE_FORMAT_A32_SINT, 0 }
+ },
+ {
+ { GL_ALPHA8UI_EXT, 0 },
+ { PIPE_FORMAT_A8_UINT, 0 }
+ },
+ {
+ { GL_ALPHA16UI_EXT, 0 },
+ { PIPE_FORMAT_A16_UINT, 0 }
+ },
+ {
+ { GL_ALPHA32UI_EXT, 0 },
+ { PIPE_FORMAT_A32_UINT, 0 }
+ },
+ {
+ { GL_INTENSITY8I_EXT, 0 },
+ { PIPE_FORMAT_I8_SINT, 0 }
+ },
+ {
+ { GL_INTENSITY16I_EXT, 0 },
+ { PIPE_FORMAT_I16_SINT, 0 }
+ },
+ {
+ { GL_INTENSITY32I_EXT, 0 },
+ { PIPE_FORMAT_I32_SINT, 0 }
+ },
+ {
+ { GL_INTENSITY8UI_EXT, 0 },
+ { PIPE_FORMAT_I8_UINT, 0 }
+ },
+ {
+ { GL_INTENSITY16UI_EXT, 0 },
+ { PIPE_FORMAT_I16_UINT, 0 }
+ },
+ {
+ { GL_INTENSITY32UI_EXT, 0 },
+ { PIPE_FORMAT_I32_UINT, 0 }
+ },
+ {
+ { GL_LUMINANCE8I_EXT, 0 },
+ { PIPE_FORMAT_L8_SINT, 0 }
+ },
+ {
+ { GL_LUMINANCE16I_EXT, 0 },
+ { PIPE_FORMAT_L16_SINT, 0 }
+ },
+ {
+ { GL_LUMINANCE32I_EXT, 0 },
+ { PIPE_FORMAT_L32_SINT, 0 }
+ },
+ {
+ { GL_LUMINANCE_INTEGER_EXT,
+ GL_LUMINANCE8UI_EXT, 0 },
+ { PIPE_FORMAT_L8_UINT, 0 }
+ },
+ {
+ { GL_LUMINANCE16UI_EXT, 0 },
+ { PIPE_FORMAT_L16_UINT, 0 }
+ },
+ {
+ { GL_LUMINANCE32UI_EXT, 0 },
+ { PIPE_FORMAT_L32_UINT, 0 }
+ },
+ {
+ { GL_LUMINANCE_ALPHA_INTEGER_EXT,
GL_LUMINANCE_ALPHA8I_EXT, 0 },
- { PIPE_FORMAT_R8G8B8A8_SSCALED, 0 }
+ { PIPE_FORMAT_L8A8_SINT, 0 }
},
{
- {
- GL_RGBA16I_EXT,
- GL_RGB16I_EXT,
- GL_ALPHA16I_EXT,
- GL_INTENSITY16I_EXT,
- GL_LUMINANCE16I_EXT,
- GL_LUMINANCE_ALPHA16I_EXT, 0 },
- { PIPE_FORMAT_R16G16B16A16_SSCALED, 0 },
+ { GL_LUMINANCE_ALPHA16I_EXT, 0 },
+ { PIPE_FORMAT_L16A16_SINT, 0 }
},
{
- {
- GL_RGBA32I_EXT,
- GL_RGB32I_EXT,
- GL_ALPHA32I_EXT,
- GL_INTENSITY32I_EXT,
- GL_LUMINANCE32I_EXT,
- GL_LUMINANCE_ALPHA32I_EXT, 0 },
- { PIPE_FORMAT_R32G32B32A32_SSCALED, 0 }
+ { GL_LUMINANCE_ALPHA32I_EXT, 0 },
+ { PIPE_FORMAT_L32A32_SINT, 0 }
},
{
- {
- GL_RGBA8UI_EXT,
- GL_RGB8UI_EXT,
- GL_ALPHA8UI_EXT,
- GL_INTENSITY8UI_EXT,
- GL_LUMINANCE8UI_EXT,
- GL_LUMINANCE_ALPHA8UI_EXT, 0 },
- { PIPE_FORMAT_R8G8B8A8_USCALED, 0 }
+ { GL_LUMINANCE_ALPHA8UI_EXT, 0 },
+ { PIPE_FORMAT_L8A8_UINT, 0 }
},
{
- {
- GL_RGBA16UI_EXT,
- GL_RGB16UI_EXT,
- GL_ALPHA16UI_EXT,
- GL_INTENSITY16UI_EXT,
- GL_LUMINANCE16UI_EXT,
- GL_LUMINANCE_ALPHA16UI_EXT, 0 },
- { PIPE_FORMAT_R16G16B16A16_USCALED, 0 }
+ { GL_LUMINANCE_ALPHA16UI_EXT, 0 },
+ { PIPE_FORMAT_L16A16_UINT, 0 }
},
{
- {
- GL_RGBA32UI_EXT,
- GL_RGB32UI_EXT,
- GL_ALPHA32UI_EXT,
- GL_INTENSITY32UI_EXT,
- GL_LUMINANCE32UI_EXT,
- GL_LUMINANCE_ALPHA32UI_EXT, 0 },
- { PIPE_FORMAT_R32G32B32A32_USCALED, 0 }
+ { GL_LUMINANCE_ALPHA32UI_EXT, 0 },
+ { PIPE_FORMAT_L32A32_UINT, 0 }
+ },
+ {
+ { GL_RGB16I_EXT, 0 },
+ { PIPE_FORMAT_R16G16B16_SINT,
+ PIPE_FORMAT_R16G16B16A16_SINT, 0 },
+ },
+ {
+ { GL_RGBA16I_EXT, 0 },
+ { PIPE_FORMAT_R16G16B16A16_SINT, 0 },
+ },
+ {
+ { GL_RGB32I_EXT, 0 },
+ { PIPE_FORMAT_R32G32B32_SINT,
+ PIPE_FORMAT_R32G32B32A32_SINT, 0 },
+ },
+ {
+ { GL_RGBA32I_EXT, 0 },
+ { PIPE_FORMAT_R32G32B32A32_SINT, 0 }
+ },
+ {
+ { GL_RGBA8UI_EXT, 0 },
+ { PIPE_FORMAT_R8G8B8A8_UINT, 0 }
+ },
+ {
+ { GL_RGB8UI_EXT, 0 },
+ { PIPE_FORMAT_R8G8B8_UINT,
+ PIPE_FORMAT_R8G8B8A8_UINT, 0 }
+ },
+ {
+ { GL_RGB16UI_EXT, 0 },
+ { PIPE_FORMAT_R16G16B16_UINT,
+ PIPE_FORMAT_R16G16B16A16_UINT, 0 }
+ },
+ {
+ { GL_RGBA16UI_EXT, 0 },
+ { PIPE_FORMAT_R16G16B16A16_UINT, 0 }
+ },
+ {
+ { GL_RGB32UI_EXT, 0},
+ { PIPE_FORMAT_R32G32B32_UINT,
+ PIPE_FORMAT_R32G32B32A32_UINT, 0 }
+ },
+ {
+ { GL_RGBA32UI_EXT, 0},
+ { PIPE_FORMAT_R32G32B32A32_UINT, 0 }
+ },
+ {
+ { GL_R8I, 0},
+ { PIPE_FORMAT_R8_SINT, 0},
+ },
+ {
+ { GL_R16I, 0},
+ { PIPE_FORMAT_R16_SINT, 0},
+ },
+ {
+ { GL_R32I, 0},
+ { PIPE_FORMAT_R32_SINT, 0},
+ },
+ {
+ { GL_R8UI, 0},
+ { PIPE_FORMAT_R8_UINT, 0},
+ },
+ {
+ { GL_R16UI, 0},
+ { PIPE_FORMAT_R16_UINT, 0},
+ },
+ {
+ { GL_R32UI, 0},
+ { PIPE_FORMAT_R32_UINT, 0},
+ },
+ {
+ { GL_RG8I, 0},
+ { PIPE_FORMAT_R8G8_SINT, 0},
+ },
+ {
+ { GL_RG16I, 0},
+ { PIPE_FORMAT_R16G16_SINT, 0},
+ },
+ {
+ { GL_RG32I, 0},
+ { PIPE_FORMAT_R32G32_SINT, 0},
+ },
+ {
+ { GL_RG8UI, 0},
+ { PIPE_FORMAT_R8G8_UINT, 0},
+ },
+ {
+ { GL_RG16UI, 0},
+ { PIPE_FORMAT_R16G16_UINT, 0},
+ },
+ {
+ { GL_RG32UI, 0},
+ { PIPE_FORMAT_R32G32_UINT, 0},
},
-
/* signed normalized formats */
{
{ GL_RED_SNORM, GL_R8_SNORM, 0 },
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index d8ef8a3ce..fe65ae539 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5180,39 +5180,17 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
if (linked_prog) {
- bool ok = true;
-
- switch (prog->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER:
- _mesa_reference_vertprog(ctx, &prog->VertexProgram,
- (struct gl_vertex_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
- linked_prog);
- if (!ok) {
- _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
- }
- break;
- case GL_FRAGMENT_SHADER:
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
- (struct gl_fragment_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
- linked_prog);
- if (!ok) {
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
- }
- break;
- case GL_GEOMETRY_SHADER:
- _mesa_reference_geomprog(ctx, &prog->GeometryProgram,
- (struct gl_geometry_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
- linked_prog);
- if (!ok) {
- _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
- }
- break;
- }
- if (!ok) {
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, NULL);
+ static const GLenum targets[] = {
+ GL_VERTEX_PROGRAM_ARB,
+ GL_FRAGMENT_PROGRAM_ARB,
+ GL_GEOMETRY_PROGRAM_NV
+ };
+
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ linked_prog);
+ if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ NULL);
_mesa_reference_program(ctx, &linked_prog, NULL);
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index a4f47edfc..acd3b56b9 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -1153,12 +1153,9 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
destroy_program_variants(st, shProg->Shaders[i]->Program);
}
- destroy_program_variants(st, (struct gl_program *)
- shProg->VertexProgram);
- destroy_program_variants(st, (struct gl_program *)
- shProg->FragmentProgram);
- destroy_program_variants(st, (struct gl_program *)
- shProg->GeometryProgram);
+ for (i = 0; i < Elements(shProg->_LinkedShaders); i++) {
+ destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
+ }
}
break;
case GL_VERTEX_SHADER:
diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h
index 12ad688b0..ec8451eb8 100644
--- a/mesalib/src/mesa/swrast/s_context.h
+++ b/mesalib/src/mesa/swrast/s_context.h
@@ -112,18 +112,12 @@ typedef void (*validate_texture_image_func)(struct gl_context *ctx,
struct swrast_texture_image;
-typedef void (*FetchTexelFuncC)(const struct swrast_texture_image *texImage,
- GLint col, GLint row, GLint img,
- GLchan *texelOut);
-
/**
- * As above, but returns floats.
- * Used for depth component images and for upcoming signed/float
- * texture images.
+ * Fetch a texel from texture image at given position.
*/
-typedef void (*FetchTexelFuncF)(const struct swrast_texture_image *texImage,
- GLint col, GLint row, GLint img,
- GLfloat *texelOut);
+typedef void (*FetchTexelFunc)(const struct swrast_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLfloat *texelOut);
typedef void (*StoreTexelFunc)(struct swrast_texture_image *texImage,
@@ -150,8 +144,7 @@ struct swrast_texture_image
GLint TexelSize; /**< bytes per texel block */
#endif
- FetchTexelFuncC FetchTexelc;
- FetchTexelFuncF FetchTexelf;
+ FetchTexelFunc FetchTexel;
StoreTexelFunc Store;
#if 0
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 7573abda6..a854c3efd 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -121,9 +121,9 @@ static void store_null_texel(struct swrast_texture_image *texImage,
*/
static struct {
gl_format Name;
- FetchTexelFuncF Fetch1D;
- FetchTexelFuncF Fetch2D;
- FetchTexelFuncF Fetch3D;
+ FetchTexelFunc Fetch1D;
+ FetchTexelFunc Fetch2D;
+ FetchTexelFunc Fetch3D;
StoreTexelFunc StoreTexel;
}
texfetch_funcs[MESA_FORMAT_COUNT] =
@@ -1250,7 +1250,7 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
};
-FetchTexelFuncF
+FetchTexelFunc
_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
{
#ifdef DEBUG
@@ -1287,63 +1287,7 @@ _mesa_get_texel_store_func(gl_format format)
/**
- * Adaptor for fetching a GLchan texel from a float-valued texture.
- */
-static void
-fetch_texel_float_to_chan(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLchan *texelOut)
-{
- GLfloat temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->Base.TexFormat);
-
- ASSERT(texImage->FetchTexelf);
- texImage->FetchTexelf(texImage, i, j, k, temp);
- if (baseFormat == GL_DEPTH_COMPONENT ||
- baseFormat == GL_DEPTH_STENCIL_EXT) {
- /* just one channel */
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
- }
- else {
- /* four channels */
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
- }
-}
-
-
-#if 0
-/**
- * Adaptor for fetching a float texel from a GLchan-valued texture.
- */
-static void
-fetch_texel_chan_to_float(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texelOut)
-{
- GLchan temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
- ASSERT(texImage->FetchTexelc);
- texImage->FetchTexelc(texImage, i, j, k, temp);
- if (baseFormat == GL_DEPTH_COMPONENT ||
- baseFormat == GL_DEPTH_STENCIL_EXT) {
- /* just one channel */
- texelOut[0] = CHAN_TO_FLOAT(temp[0]);
- }
- else {
- /* four channels */
- texelOut[0] = CHAN_TO_FLOAT(temp[0]);
- texelOut[1] = CHAN_TO_FLOAT(temp[1]);
- texelOut[2] = CHAN_TO_FLOAT(temp[2]);
- texelOut[3] = CHAN_TO_FLOAT(temp[3]);
- }
-}
-#endif
-
-
-/**
- * Initialize the texture image's FetchTexelc and FetchTexelf methods.
+ * Initialize the texture image's FetchTexel methods.
*/
static void
set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
@@ -1357,12 +1301,8 @@ set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
format = _mesa_get_srgb_format_linear(format);
}
- texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims);
-
- texImage->FetchTexelc = fetch_texel_float_to_chan;
-
- ASSERT(texImage->FetchTexelc);
- ASSERT(texImage->FetchTexelf);
+ texImage->FetchTexel = _mesa_get_texel_fetch_func(format, dims);
+ ASSERT(texImage->FetchTexel);
}
void
diff --git a/mesalib/src/mesa/swrast/s_texfetch.h b/mesalib/src/mesa/swrast/s_texfetch.h
index 19b196a5a..c98aa5c5a 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.h
+++ b/mesalib/src/mesa/swrast/s_texfetch.h
@@ -32,7 +32,7 @@
extern StoreTexelFunc
_mesa_get_texel_store_func(gl_format format);
-extern FetchTexelFuncF
+extern FetchTexelFunc
_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
void
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index ca9133b21..f8b0fa1aa 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/src/mesa/swrast/s_texfilter.c
@@ -815,7 +815,7 @@ sample_1d_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- swImg->FetchTexelf(swImg, i, 0, 0, rgba);
+ swImg->FetchTexel(swImg, i, 0, 0, rgba);
}
}
@@ -852,13 +852,13 @@ sample_1d_linear(struct gl_context *ctx,
get_border_color(tObj, img, t0);
}
else {
- swImg->FetchTexelf(swImg, i0, 0, 0, t0);
+ swImg->FetchTexel(swImg, i0, 0, 0, t0);
}
if (useBorderColor & I1BIT) {
get_border_color(tObj, img, t1);
}
else {
- swImg->FetchTexelf(swImg, i1, 0, 0, t1);
+ swImg->FetchTexel(swImg, i1, 0, 0, t1);
}
lerp_rgba(rgba, a, t0, t1);
@@ -1082,7 +1082,7 @@ sample_2d_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- swImg->FetchTexelf(swImg, i, j, 0, rgba);
+ swImg->FetchTexel(swImg, i, j, 0, rgba);
}
}
@@ -1127,25 +1127,25 @@ sample_2d_linear(struct gl_context *ctx,
get_border_color(tObj, img, t00);
}
else {
- swImg->FetchTexelf(swImg, i0, j0, 0, t00);
+ swImg->FetchTexel(swImg, i0, j0, 0, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
get_border_color(tObj, img, t10);
}
else {
- swImg->FetchTexelf(swImg, i1, j0, 0, t10);
+ swImg->FetchTexel(swImg, i1, j0, 0, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
get_border_color(tObj, img, t01);
}
else {
- swImg->FetchTexelf(swImg, i0, j1, 0, t01);
+ swImg->FetchTexel(swImg, i0, j1, 0, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
get_border_color(tObj, img, t11);
}
else {
- swImg->FetchTexelf(swImg, i1, j1, 0, t11);
+ swImg->FetchTexel(swImg, i1, j1, 0, t11);
}
lerp_rgba_2d(rgba, a, b, t00, t10, t01, t11);
@@ -1180,10 +1180,10 @@ sample_2d_linear_repeat(struct gl_context *ctx,
linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi);
linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj);
- swImg->FetchTexelf(swImg, i0, j0, 0, t00);
- swImg->FetchTexelf(swImg, i1, j0, 0, t10);
- swImg->FetchTexelf(swImg, i0, j1, 0, t01);
- swImg->FetchTexelf(swImg, i1, j1, 0, t11);
+ swImg->FetchTexel(swImg, i0, j0, 0, t00);
+ swImg->FetchTexel(swImg, i1, j0, 0, t10);
+ swImg->FetchTexel(swImg, i0, j1, 0, t01);
+ swImg->FetchTexel(swImg, i1, j1, 0, t11);
lerp_rgba_2d(rgba, wi, wj, t00, t10, t01, t11);
}
@@ -1369,6 +1369,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
ASSERT(img->Border==0);
ASSERT(img->TexFormat == MESA_FORMAT_RGB888);
ASSERT(swImg->_IsPowerOfTwo);
+ (void) swImg;
for (k=0; k<n; k++) {
GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
@@ -1412,6 +1413,7 @@ opt_sample_rgba_2d(struct gl_context *ctx,
ASSERT(img->Border==0);
ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888);
ASSERT(swImg->_IsPowerOfTwo);
+ (void) swImg;
for (i = 0; i < n; i++) {
const GLint col = IFLOOR(texcoords[i][0] * width) & colMask;
@@ -1966,7 +1968,7 @@ sample_3d_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- swImg->FetchTexelf(swImg, i, j, k, rgba);
+ swImg->FetchTexel(swImg, i, j, k, rgba);
}
}
@@ -2018,50 +2020,50 @@ sample_3d_linear(struct gl_context *ctx,
get_border_color(tObj, img, t000);
}
else {
- swImg->FetchTexelf(swImg, i0, j0, k0, t000);
+ swImg->FetchTexel(swImg, i0, j0, k0, t000);
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
get_border_color(tObj, img, t100);
}
else {
- swImg->FetchTexelf(swImg, i1, j0, k0, t100);
+ swImg->FetchTexel(swImg, i1, j0, k0, t100);
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
get_border_color(tObj, img, t010);
}
else {
- swImg->FetchTexelf(swImg, i0, j1, k0, t010);
+ swImg->FetchTexel(swImg, i0, j1, k0, t010);
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
get_border_color(tObj, img, t110);
}
else {
- swImg->FetchTexelf(swImg, i1, j1, k0, t110);
+ swImg->FetchTexel(swImg, i1, j1, k0, t110);
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
get_border_color(tObj, img, t001);
}
else {
- swImg->FetchTexelf(swImg, i0, j0, k1, t001);
+ swImg->FetchTexel(swImg, i0, j0, k1, t001);
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
get_border_color(tObj, img, t101);
}
else {
- swImg->FetchTexelf(swImg, i1, j0, k1, t101);
+ swImg->FetchTexel(swImg, i1, j0, k1, t101);
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
get_border_color(tObj, img, t011);
}
else {
- swImg->FetchTexelf(swImg, i0, j1, k1, t011);
+ swImg->FetchTexel(swImg, i0, j1, k1, t011);
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
get_border_color(tObj, img, t111);
}
else {
- swImg->FetchTexelf(swImg, i1, j1, k1, t111);
+ swImg->FetchTexel(swImg, i1, j1, k1, t111);
}
/* trilinear interpolation of samples */
@@ -2582,7 +2584,7 @@ sample_nearest_rect(struct gl_context *ctx,
if (col < 0 || col >= width || row < 0 || row >= height)
get_border_color(tObj, img, rgba[i]);
else
- swImg->FetchTexelf(swImg, col, row, 0, rgba[i]);
+ swImg->FetchTexel(swImg, col, row, 0, rgba[i]);
}
}
@@ -2630,22 +2632,22 @@ sample_linear_rect(struct gl_context *ctx,
if (useBorderColor & (I0BIT | J0BIT))
get_border_color(tObj, img, t00);
else
- swImg->FetchTexelf(swImg, i0, j0, 0, t00);
+ swImg->FetchTexel(swImg, i0, j0, 0, t00);
if (useBorderColor & (I1BIT | J0BIT))
get_border_color(tObj, img, t10);
else
- swImg->FetchTexelf(swImg, i1, j0, 0, t10);
+ swImg->FetchTexel(swImg, i1, j0, 0, t10);
if (useBorderColor & (I0BIT | J1BIT))
get_border_color(tObj, img, t01);
else
- swImg->FetchTexelf(swImg, i0, j1, 0, t01);
+ swImg->FetchTexel(swImg, i0, j1, 0, t01);
if (useBorderColor & (I1BIT | J1BIT))
get_border_color(tObj, img, t11);
else
- swImg->FetchTexelf(swImg, i1, j1, 0, t11);
+ swImg->FetchTexel(swImg, i1, j1, 0, t11);
lerp_rgba_2d(rgba[i], a, b, t00, t10, t01, t11);
}
@@ -2723,7 +2725,7 @@ sample_2d_array_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- swImg->FetchTexelf(swImg, i, j, array, rgba);
+ swImg->FetchTexel(swImg, i, j, array, rgba);
}
}
@@ -2775,25 +2777,25 @@ sample_2d_array_linear(struct gl_context *ctx,
get_border_color(tObj, img, t00);
}
else {
- swImg->FetchTexelf(swImg, i0, j0, array, t00);
+ swImg->FetchTexel(swImg, i0, j0, array, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
get_border_color(tObj, img, t10);
}
else {
- swImg->FetchTexelf(swImg, i1, j0, array, t10);
+ swImg->FetchTexel(swImg, i1, j0, array, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
get_border_color(tObj, img, t01);
}
else {
- swImg->FetchTexelf(swImg, i0, j1, array, t01);
+ swImg->FetchTexel(swImg, i0, j1, array, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
get_border_color(tObj, img, t11);
}
else {
- swImg->FetchTexelf(swImg, i1, j1, array, t11);
+ swImg->FetchTexel(swImg, i1, j1, array, t11);
}
/* trilinear interpolation of samples */
@@ -3032,7 +3034,7 @@ sample_1d_array_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- swImg->FetchTexelf(swImg, i, array, 0, rgba);
+ swImg->FetchTexel(swImg, i, array, 0, rgba);
}
}
@@ -3076,13 +3078,13 @@ sample_1d_array_linear(struct gl_context *ctx,
get_border_color(tObj, img, t0);
}
else {
- swImg->FetchTexelf(swImg, i0, array, 0, t0);
+ swImg->FetchTexel(swImg, i0, array, 0, t0);
}
if (useBorderColor & (I1BIT | K0BIT)) {
get_border_color(tObj, img, t1);
}
else {
- swImg->FetchTexelf(swImg, i1, array, 0, t1);
+ swImg->FetchTexel(swImg, i1, array, 0, t1);
}
/* bilinear interpolation of samples */
@@ -3446,7 +3448,7 @@ sample_depth_texture( struct gl_context *ctx,
if (col >= 0 && row >= 0 && col < width && row < height &&
slice >= 0 && slice < depth) {
- swImg->FetchTexelf(swImg, col, row, slice, &depthSample);
+ swImg->FetchTexel(swImg, col, row, slice, &depthSample);
}
else {
depthSample = tObj->Sampler.BorderColor.f[0];
@@ -3515,13 +3517,13 @@ sample_depth_texture( struct gl_context *ctx,
depth00 = tObj->Sampler.BorderColor.f[0];
}
else {
- swImg->FetchTexelf(swImg, i0, j0, slice, &depth00);
+ swImg->FetchTexel(swImg, i0, j0, slice, &depth00);
}
if (useBorderTexel & (I1BIT | J0BIT)) {
depth10 = tObj->Sampler.BorderColor.f[0];
}
else {
- swImg->FetchTexelf(swImg, i1, j0, slice, &depth10);
+ swImg->FetchTexel(swImg, i1, j0, slice, &depth10);
}
if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) {
@@ -3529,13 +3531,13 @@ sample_depth_texture( struct gl_context *ctx,
depth01 = tObj->Sampler.BorderColor.f[0];
}
else {
- swImg->FetchTexelf(swImg, i0, j1, slice, &depth01);
+ swImg->FetchTexel(swImg, i0, j1, slice, &depth01);
}
if (useBorderTexel & (I1BIT | J1BIT)) {
depth11 = tObj->Sampler.BorderColor.f[0];
}
else {
- swImg->FetchTexelf(swImg, i1, j1, slice, &depth11);
+ swImg->FetchTexel(swImg, i1, j1, slice, &depth11);
}
}
else {
diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c
index 643952875..47e458e1c 100644
--- a/mesalib/src/mesa/swrast/s_texrender.c
+++ b/mesalib/src/mesa/swrast/s_texrender.c
@@ -23,7 +23,7 @@ struct texture_renderbuffer
struct gl_renderbuffer Base; /**< Base class object */
struct swrast_texture_image *TexImage;
StoreTexelFunc Store;
- FetchTexelFuncF Fetchf;
+ FetchTexelFunc Fetch;
GLint Yoffset; /**< Layer for 1D array textures. */
GLint Zoffset; /**< Layer for 2D array textures, or slice
* for 3D textures
@@ -52,7 +52,7 @@ texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count
GLchan *rgbaOut = (GLchan *) values;
for (i = 0; i < count; i++) {
GLfloat rgba[4];
- trb->Fetchf(trb->TexImage, x + i, y, z, rgba);
+ trb->Fetch(trb->TexImage, x + i, y, z, rgba);
UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba);
}
}
@@ -60,7 +60,7 @@ texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count
GLushort *zValues = (GLushort *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x + i, y, z, &flt);
+ trb->Fetch(trb->TexImage, x + i, y, z, &flt);
zValues[i] = (GLushort) (flt * 0xffff);
}
}
@@ -71,7 +71,7 @@ texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count
*/
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x + i, y, z, &flt);
+ trb->Fetch(trb->TexImage, x + i, y, z, &flt);
#if 0
/* this should work, but doesn't (overflow due to low precision) */
zValues[i] = (GLuint) (flt * scale);
@@ -85,7 +85,7 @@ texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count
GLuint *zValues = (GLuint *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x + i, y, z, &flt);
+ trb->Fetch(trb->TexImage, x + i, y, z, &flt);
zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
}
}
@@ -93,7 +93,7 @@ texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count
GLuint *zValues = (GLuint *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x + i, y, z, &flt);
+ trb->Fetch(trb->TexImage, x + i, y, z, &flt);
zValues[i] = (GLuint) (flt * 0xffffff);
}
}
@@ -116,7 +116,7 @@ texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint co
GLchan *rgbaOut = (GLchan *) values;
for (i = 0; i < count; i++) {
GLfloat rgba[4];
- trb->Fetchf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+ trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
z, rgba);
UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba);
}
@@ -125,7 +125,7 @@ texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint co
GLushort *zValues = (GLushort *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+ trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
z, &flt);
zValues[i] = (GLushort) (flt * 0xffff);
}
@@ -134,7 +134,7 @@ texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint co
GLuint *zValues = (GLuint *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+ trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
z, &flt);
#if 0
zValues[i] = (GLuint) (flt * 0xffffffff);
@@ -147,7 +147,7 @@ texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint co
GLuint *zValues = (GLuint *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+ trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
z, &flt);
zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
}
@@ -156,7 +156,7 @@ texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint co
GLuint *zValues = (GLuint *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
- trb->Fetchf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+ trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset,
z, &flt);
zValues[i] = (GLuint) (flt * 0xffffff);
}
@@ -544,11 +544,11 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
trb->Store = store_nop;
}
- if (!trb->TexImage->FetchTexelf) {
+ if (!trb->TexImage->FetchTexel) {
_mesa_update_fetch_functions(trb->TexImage->Base.TexObject);
}
- trb->Fetchf = trb->TexImage->FetchTexelf;
- assert(trb->Fetchf);
+ trb->Fetch = trb->TexImage->FetchTexel;
+ assert(trb->Fetch);
if (att->Texture->Target == GL_TEXTURE_1D_ARRAY_EXT) {
trb->Yoffset = att->Zoffset;
@@ -592,17 +592,17 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
break;
/* SRGB formats pre EXT_framebuffer_sRGB don't do sRGB translations on FBO readback */
case MESA_FORMAT_SRGB8:
- trb->Fetchf = _mesa_get_texel_fetch_func(MESA_FORMAT_RGB888, _mesa_get_texture_dimensions(att->Texture->Target));
+ trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_RGB888, _mesa_get_texture_dimensions(att->Texture->Target));
trb->Base.DataType = CHAN_TYPE;
trb->Base._BaseFormat = GL_RGBA;
break;
case MESA_FORMAT_SRGBA8:
- trb->Fetchf = _mesa_get_texel_fetch_func(MESA_FORMAT_RGBA8888, _mesa_get_texture_dimensions(att->Texture->Target));
+ trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_RGBA8888, _mesa_get_texture_dimensions(att->Texture->Target));
trb->Base.DataType = CHAN_TYPE;
trb->Base._BaseFormat = GL_RGBA;
break;
case MESA_FORMAT_SARGB8:
- trb->Fetchf = _mesa_get_texel_fetch_func(MESA_FORMAT_ARGB8888, _mesa_get_texture_dimensions(att->Texture->Target));
+ trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_ARGB8888, _mesa_get_texture_dimensions(att->Texture->Target));
trb->Base.DataType = CHAN_TYPE;
trb->Base._BaseFormat = GL_RGBA;
break;
diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c
index cc5e85634..367dfd5bb 100644
--- a/mesalib/src/mesa/tnl/t_vb_program.c
+++ b/mesalib/src/mesa/tnl/t_vb_program.c
@@ -336,11 +336,17 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
for (i = 0; i < VERT_RESULT_MAX; i++) {
if (program->Base.OutputsWritten & BITFIELD64_BIT(i)) {
outputs[numOutputs++] = i;
+ }
+ }
- if (!store->results[i].data) {
- _mesa_vector4f_alloc( &store->results[i], 0, VB->Size, 32 );
- store->results[i].size = 4;
- }
+ /* Allocate result vectors. We delay this until now to avoid allocating
+ * memory that would never be used if we don't run the software tnl pipeline.
+ */
+ if (!store->results[0].storage) {
+ for (i = 0; i < VERT_RESULT_MAX; i++) {
+ assert(!store->results[i].storage);
+ _mesa_vector4f_alloc( &store->results[i], 0, VB->Size, 32 );
+ store->results[i].size = 4;
}
}