diff options
author | marha <marha@users.sourceforge.net> | 2012-10-01 12:04:07 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-10-01 12:04:07 +0200 |
commit | 7305d42f2ad0462ca3916a73df49cc6b70b41fe4 (patch) | |
tree | 4de7ec9601f83c61d84e9b8cda40ca0f5ca6bc91 /mesalib/src | |
parent | c86fbbd2c3bb30e96a614456bbb7688e0387cf8c (diff) | |
parent | 7ed9dbafdbc724c1030404f29678559134de559b (diff) | |
download | vcxsrv-7305d42f2ad0462ca3916a73df49cc6b70b41fe4.tar.gz vcxsrv-7305d42f2ad0462ca3916a73df49cc6b70b41fe4.tar.bz2 vcxsrv-7305d42f2ad0462ca3916a73df49cc6b70b41fe4.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
libxcb mesa pixman xkeyboard-config git update 1 oct 2012
Conflicts:
libxcb/src/man/.gitignore
Diffstat (limited to 'mesalib/src')
33 files changed, 1330 insertions, 852 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index 35b8edba7..4ad7a6be4 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -27,7 +27,7 @@ /** * @file * Blitter utility to facilitate acceleration of the clear, clear_render_target, - * clear_depth_stencil, and resource_copy_region functions. + * clear_depth_stencil, resource_copy_region, and blit functions. * * @author Marek Olšák */ @@ -88,8 +88,7 @@ struct blitter_context_priv void *fs_texfetch_stencil_msaa[PIPE_MAX_TEXTURE_TYPES]; /* Blend state. */ - void *blend_write_color; /**< blend state with writemask of RGBA */ - void *blend_keep_color; /**< blend state with writemask of 0 */ + void *blend[PIPE_MASK_RGBA+1]; /**< blend state with writemask */ /* Depth stencil alpha state. */ void *dsa_write_depth_stencil; @@ -104,11 +103,10 @@ struct blitter_context_priv void *velem_state_readbuf; /* Sampler state. */ - void *sampler_state; + void *sampler_state, *sampler_state_linear; /* Rasterizer state. */ - void *rs_state; - void *rs_discard_state; + void *rs_state, *rs_state_scissor, *rs_discard_state; /* Viewport state. */ struct pipe_viewport_state viewport; @@ -121,8 +119,13 @@ struct blitter_context_priv boolean vertex_has_integers; boolean has_stream_out; boolean has_stencil_export; -}; + boolean has_texture_multisample; + /* The Draw module overrides these functions. + * Always create the blitter before Draw. */ + void (*bind_fs_state)(struct pipe_context *, void *); + void (*delete_fs_state)(struct pipe_context *, void *); +}; struct blitter_context *util_blitter_create(struct pipe_context *pipe) { @@ -141,6 +144,9 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) ctx->base.pipe = pipe; ctx->base.draw_rectangle = util_blitter_draw_rectangle; + ctx->bind_fs_state = pipe->bind_fs_state; + ctx->delete_fs_state = pipe->delete_fs_state; + /* init state objects for them to be considered invalid */ ctx->base.saved_blend_state = INVALID_PTR; ctx->base.saved_dsa_state = INVALID_PTR; @@ -169,12 +175,16 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT); + ctx->has_texture_multisample = + pipe->screen->get_param(pipe->screen, PIPE_CAP_TEXTURE_MULTISAMPLE); + /* blend state objects */ memset(&blend, 0, sizeof(blend)); - ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend); - blend.rt[0].colormask = PIPE_MASK_RGBA; - ctx->blend_write_color = pipe->create_blend_state(pipe, &blend); + for (i = 0; i <= PIPE_MASK_RGBA; i++) { + blend.rt[0].colormask = i; + ctx->blend[i] = pipe->create_blend_state(pipe, &blend); + } /* depth stencil alpha state objects */ memset(&dsa, 0, sizeof(dsa)); @@ -210,6 +220,10 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) sampler_state.normalized_coords = 1; ctx->sampler_state = pipe->create_sampler_state(pipe, &sampler_state); + sampler_state.min_img_filter = PIPE_TEX_FILTER_LINEAR; + sampler_state.mag_img_filter = PIPE_TEX_FILTER_LINEAR; + ctx->sampler_state_linear = pipe->create_sampler_state(pipe, &sampler_state); + /* rasterizer state */ memset(&rs_state, 0, sizeof(rs_state)); rs_state.cull_face = PIPE_FACE_NONE; @@ -218,7 +232,11 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) rs_state.depth_clip = 1; ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); + rs_state.scissor = 1; + ctx->rs_state_scissor = pipe->create_rasterizer_state(pipe, &rs_state); + if (ctx->has_stream_out) { + rs_state.scissor = 0; rs_state.rasterizer_discard = 1; ctx->rs_discard_state = pipe->create_rasterizer_state(pipe, &rs_state); } @@ -293,8 +311,9 @@ void util_blitter_destroy(struct blitter_context *blitter) struct pipe_context *pipe = blitter->pipe; int i; - pipe->delete_blend_state(pipe, ctx->blend_write_color); - pipe->delete_blend_state(pipe, ctx->blend_keep_color); + for (i = 0; i <= PIPE_MASK_RGBA; i++) { + pipe->delete_blend_state(pipe, ctx->blend[i]); + } pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_keep_stencil); @@ -302,6 +321,7 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_write_stencil); pipe->delete_rasterizer_state(pipe, ctx->rs_state); + pipe->delete_rasterizer_state(pipe, ctx->rs_state_scissor); if (ctx->rs_discard_state) pipe->delete_rasterizer_state(pipe, ctx->rs_discard_state); pipe->delete_vs_state(pipe, ctx->vs); @@ -317,23 +337,24 @@ void util_blitter_destroy(struct blitter_context *blitter) for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) { if (ctx->fs_texfetch_col[i]) - pipe->delete_fs_state(pipe, ctx->fs_texfetch_col[i]); + ctx->delete_fs_state(pipe, ctx->fs_texfetch_col[i]); if (ctx->fs_texfetch_depth[i]) - pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]); + ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]); if (ctx->fs_texfetch_depthstencil[i]) - pipe->delete_fs_state(pipe, ctx->fs_texfetch_depthstencil[i]); + ctx->delete_fs_state(pipe, ctx->fs_texfetch_depthstencil[i]); if (ctx->fs_texfetch_stencil[i]) - pipe->delete_fs_state(pipe, ctx->fs_texfetch_stencil[i]); + ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil[i]); } for (i = 0; i <= PIPE_MAX_COLOR_BUFS; i++) { if (ctx->fs_col[i]) - pipe->delete_fs_state(pipe, ctx->fs_col[i]); + ctx->delete_fs_state(pipe, ctx->fs_col[i]); if (ctx->fs_col_int[i]) - pipe->delete_fs_state(pipe, ctx->fs_col_int[i]); + ctx->delete_fs_state(pipe, ctx->fs_col_int[i]); } pipe->delete_sampler_state(pipe, ctx->sampler_state); + pipe->delete_sampler_state(pipe, ctx->sampler_state_linear); u_upload_destroy(ctx->upload); FREE(ctx); } @@ -427,7 +448,7 @@ 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->bind_fs_state(pipe, ctx->base.saved_fs); ctx->base.saved_fs = INVALID_PTR; /* Depth, stencil, alpha. */ @@ -456,6 +477,26 @@ static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx) assert(ctx->base.saved_fb_state.nr_cbufs != ~0); } +static void blitter_disable_render_cond(struct blitter_context_priv *ctx) +{ + struct pipe_context *pipe = ctx->base.pipe; + + if (ctx->base.saved_render_cond_query) { + pipe->render_condition(pipe, NULL, 0); + } +} + +static void blitter_restore_render_cond(struct blitter_context_priv *ctx) +{ + struct pipe_context *pipe = ctx->base.pipe; + + if (ctx->base.saved_render_cond_query) { + pipe->render_condition(pipe, ctx->base.saved_render_cond_query, + ctx->base.saved_render_cond_mode); + ctx->base.saved_render_cond_query = NULL; + } +} + static void blitter_restore_fb_state(struct blitter_context_priv *ctx) { struct pipe_context *pipe = ctx->base.pipe; @@ -493,8 +534,7 @@ static void blitter_restore_textures(struct blitter_context_priv *ctx) } static void blitter_set_rectangle(struct blitter_context_priv *ctx, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2, + int x1, int y1, int x2, int y2, float depth) { int i; @@ -552,8 +592,7 @@ static void blitter_set_clear_color(struct blitter_context_priv *ctx, static void get_texcoords(struct pipe_sampler_view *src, unsigned src_width0, unsigned src_height0, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2, + int x1, int y1, int x2, int y2, float out[4]) { struct pipe_resource *tex = src->texture; @@ -594,8 +633,7 @@ static void blitter_set_texcoords(struct blitter_context_priv *ctx, struct pipe_sampler_view *src, unsigned src_width0, unsigned src_height0, unsigned layer, unsigned sample, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2) + int x1, int y1, int x2, int y2) { unsigned i; float coord[4]; @@ -653,9 +691,8 @@ static void blitter_set_dst_dimensions(struct blitter_context_priv *ctx, ctx->dst_height = height; } -static INLINE -void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs, - boolean int_format) +static void *blitter_get_fs_col(struct blitter_context_priv *ctx, + unsigned num_cbufs, boolean int_format) { struct pipe_context *pipe = ctx->base.pipe; @@ -678,32 +715,32 @@ void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs, } } -static INLINE -void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, - struct pipe_resource *tex) +static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, + enum pipe_texture_target target, + unsigned nr_samples) { struct pipe_context *pipe = ctx->base.pipe; - assert(tex->target < PIPE_MAX_TEXTURE_TYPES); + assert(target < PIPE_MAX_TEXTURE_TYPES); - if (tex->nr_samples > 1) { - void **shader = &ctx->fs_texfetch_col_msaa[tex->target]; + if (nr_samples > 1) { + void **shader = &ctx->fs_texfetch_col_msaa[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, - tex->nr_samples); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, + nr_samples); *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex); } return *shader; } else { - void **shader = &ctx->fs_texfetch_col[tex->target]; + void **shader = &ctx->fs_texfetch_col[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, 0); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader(pipe, tgsi_tex, @@ -716,19 +753,20 @@ void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, static INLINE void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx, - struct pipe_resource *tex) + enum pipe_texture_target target, + unsigned nr_samples) { struct pipe_context *pipe = ctx->base.pipe; - assert(tex->target < PIPE_MAX_TEXTURE_TYPES); + assert(target < PIPE_MAX_TEXTURE_TYPES); - if (tex->nr_samples > 1) { - void **shader = &ctx->fs_texfetch_depth_msaa[tex->target]; + if (nr_samples > 1) { + void **shader = &ctx->fs_texfetch_depth_msaa[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, - tex->nr_samples); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, + nr_samples); *shader = util_make_fs_blit_msaa_depth(pipe, tgsi_tex); @@ -736,11 +774,11 @@ void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx, return *shader; } else { - void **shader = &ctx->fs_texfetch_depth[tex->target]; + void **shader = &ctx->fs_texfetch_depth[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, 0); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader_writedepth(pipe, tgsi_tex, @@ -753,19 +791,20 @@ void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx, static INLINE void *blitter_get_fs_texfetch_depthstencil(struct blitter_context_priv *ctx, - struct pipe_resource *tex) + enum pipe_texture_target target, + unsigned nr_samples) { struct pipe_context *pipe = ctx->base.pipe; - assert(tex->target < PIPE_MAX_TEXTURE_TYPES); + assert(target < PIPE_MAX_TEXTURE_TYPES); - if (tex->nr_samples > 1) { - void **shader = &ctx->fs_texfetch_depthstencil_msaa[tex->target]; + if (nr_samples > 1) { + void **shader = &ctx->fs_texfetch_depthstencil_msaa[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, - tex->nr_samples); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, + nr_samples); *shader = util_make_fs_blit_msaa_depthstencil(pipe, tgsi_tex); @@ -773,11 +812,11 @@ void *blitter_get_fs_texfetch_depthstencil(struct blitter_context_priv *ctx, return *shader; } else { - void **shader = &ctx->fs_texfetch_depthstencil[tex->target]; + void **shader = &ctx->fs_texfetch_depthstencil[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, 0); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader_writedepthstencil(pipe, tgsi_tex, @@ -790,19 +829,20 @@ void *blitter_get_fs_texfetch_depthstencil(struct blitter_context_priv *ctx, static INLINE void *blitter_get_fs_texfetch_stencil(struct blitter_context_priv *ctx, - struct pipe_resource *tex) + enum pipe_texture_target target, + unsigned nr_samples) { struct pipe_context *pipe = ctx->base.pipe; - assert(tex->target < PIPE_MAX_TEXTURE_TYPES); + assert(target < PIPE_MAX_TEXTURE_TYPES); - if (tex->nr_samples > 1) { - void **shader = &ctx->fs_texfetch_stencil_msaa[tex->target]; + if (nr_samples > 1) { + void **shader = &ctx->fs_texfetch_stencil_msaa[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, - tex->nr_samples); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, + nr_samples); *shader = util_make_fs_blit_msaa_stencil(pipe, tgsi_tex); @@ -810,11 +850,11 @@ void *blitter_get_fs_texfetch_stencil(struct blitter_context_priv *ctx, return *shader; } else { - void **shader = &ctx->fs_texfetch_stencil[tex->target]; + void **shader = &ctx->fs_texfetch_stencil[target]; /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex->target, 0); + unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader_writestencil(pipe, tgsi_tex, @@ -825,11 +865,50 @@ void *blitter_get_fs_texfetch_stencil(struct blitter_context_priv *ctx, } } -static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx) +void util_blitter_cache_all_shaders(struct blitter_context *blitter) +{ + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + struct pipe_screen *screen = blitter->pipe->screen; + unsigned num_cbufs, i, target, max_samples; + boolean has_arraytex; + + num_cbufs = MAX2(screen->get_param(screen, + PIPE_CAP_MAX_RENDER_TARGETS), 1); + max_samples = ctx->has_texture_multisample ? 2 : 1; + has_arraytex = screen->get_param(screen, + PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS) != 0; + + for (i = 0; i < num_cbufs; i++) { + blitter_get_fs_col(ctx, i, FALSE); + blitter_get_fs_col(ctx, i, TRUE); + } + + /* It only matters if i <= 1 or > 1. */ + for (i = 1; i <= max_samples; i++) { + for (target = PIPE_TEXTURE_1D; target < PIPE_MAX_TEXTURE_TYPES; target++) { + if (!has_arraytex && + (target == PIPE_TEXTURE_1D_ARRAY || + target == PIPE_TEXTURE_2D_ARRAY)) { + continue; + } + + blitter_get_fs_texfetch_col(ctx, target, i); + blitter_get_fs_texfetch_depth(ctx, target, i); + if (ctx->has_stencil_export) { + blitter_get_fs_texfetch_depthstencil(ctx, target, i); + blitter_get_fs_texfetch_stencil(ctx, target, i); + } + } + } +} + +static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx, + boolean scissor) { struct pipe_context *pipe = ctx->base.pipe; - pipe->bind_rasterizer_state(pipe, ctx->rs_state); + pipe->bind_rasterizer_state(pipe, scissor ? ctx->rs_state_scissor + : ctx->rs_state); pipe->bind_vs_state(pipe, ctx->vs); if (ctx->has_geometry_shader) pipe->bind_gs_state(pipe, NULL); @@ -838,9 +917,7 @@ static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx) } static void blitter_draw(struct blitter_context_priv *ctx, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2, - float depth) + int x1, int y1, int x2, int y2, float depth) { struct pipe_resource *buf = NULL; unsigned offset = 0; @@ -856,9 +933,7 @@ static void blitter_draw(struct blitter_context_priv *ctx, } void util_blitter_draw_rectangle(struct blitter_context *blitter, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2, - float depth, + int x1, int y1, int x2, int y2, float depth, enum blitter_attrib_type type, const union pipe_color_union *attrib) { @@ -897,14 +972,15 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, blitter_set_running_flag(ctx); blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); + blitter_disable_render_cond(ctx); /* bind states */ if (custom_blend) { pipe->bind_blend_state(pipe, custom_blend); } else if (clear_buffers & PIPE_CLEAR_COLOR) { - pipe->bind_blend_state(pipe, ctx->blend_write_color); + pipe->bind_blend_state(pipe, ctx->blend[PIPE_MASK_RGBA]); } else { - pipe->bind_blend_state(pipe, ctx->blend_keep_color); + pipe->bind_blend_state(pipe, ctx->blend[0]); } if (custom_dsa) { @@ -929,16 +1005,17 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, } else { pipe->bind_vertex_elements_state(pipe, ctx->velem_state); } - pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs, int_format)); + ctx->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs, int_format)); pipe->set_sample_mask(pipe, ~0); - blitter_set_common_draw_rect_state(ctx); + blitter_set_common_draw_rect_state(ctx, FALSE); blitter_set_dst_dimensions(ctx, width, height); blitter->draw_rectangle(blitter, 0, 0, width, height, depth, UTIL_BLITTER_ATTRIB_COLOR, color); blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); } @@ -965,7 +1042,7 @@ void util_blitter_custom_clear_depth(struct blitter_context *blitter, } static -boolean is_overlap(unsigned dstx, unsigned dsty, unsigned dstz, +boolean is_overlap(int dstx, int dsty, int dstz, const struct pipe_box *srcbox) { struct pipe_box src = *srcbox; @@ -1024,10 +1101,12 @@ void util_blitter_default_src_texture(struct pipe_sampler_view *src_templ, src_templ->swizzle_a = PIPE_SWIZZLE_ALPHA; } -boolean util_blitter_is_copy_supported(struct blitter_context *blitter, - const struct pipe_resource *dst, - const struct pipe_resource *src, - unsigned mask) +static boolean is_blit_generic_supported(struct blitter_context *blitter, + const struct pipe_resource *dst, + enum pipe_format dst_format, + const struct pipe_resource *src, + enum pipe_format src_format, + unsigned mask) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_screen *screen = ctx->base.pipe->screen; @@ -1036,7 +1115,7 @@ boolean util_blitter_is_copy_supported(struct blitter_context *blitter, unsigned bind; boolean is_stencil; const struct util_format_description *desc = - util_format_description(dst->format); + util_format_description(dst_format); is_stencil = util_format_has_stencil(desc); @@ -1050,25 +1129,29 @@ boolean util_blitter_is_copy_supported(struct blitter_context *blitter, else bind = PIPE_BIND_RENDER_TARGET; - if (!screen->is_format_supported(screen, dst->format, dst->target, + if (!screen->is_format_supported(screen, dst_format, dst->target, dst->nr_samples, bind)) { return FALSE; } } if (src) { - if (!screen->is_format_supported(screen, src->format, src->target, + if (src->nr_samples > 1 && !ctx->has_texture_multisample) { + return FALSE; + } + + if (!screen->is_format_supported(screen, src_format, src->target, src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) { return FALSE; } /* Check stencil sampler support for stencil copy. */ - if (util_format_has_stencil(util_format_description(src->format))) { + if (util_format_has_stencil(util_format_description(src_format))) { enum pipe_format stencil_format = - util_format_stencil_only(src->format); + util_format_stencil_only(src_format); assert(stencil_format != PIPE_FORMAT_NONE); - if (stencil_format != src->format && + if (stencil_format != src_format && !screen->is_format_supported(screen, stencil_format, src->target, src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) { return FALSE; @@ -1079,13 +1162,32 @@ boolean util_blitter_is_copy_supported(struct blitter_context *blitter, return TRUE; } +boolean util_blitter_is_copy_supported(struct blitter_context *blitter, + const struct pipe_resource *dst, + const struct pipe_resource *src, + unsigned mask) +{ + return is_blit_generic_supported(blitter, dst, dst->format, + src, src->format, mask); +} + +boolean util_blitter_is_blit_supported(struct blitter_context *blitter, + const struct pipe_blit_info *info) +{ + return is_blit_generic_supported(blitter, + info->dst.resource, info->dst.format, + info->src.resource, info->src.format, + info->mask); +} + void util_blitter_copy_texture(struct blitter_context *blitter, struct pipe_resource *dst, - unsigned dst_level, unsigned dst_sample_mask, + unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, - unsigned src_level, unsigned src_sample, - const struct pipe_box *srcbox) + unsigned src_level, + const struct pipe_box *srcbox, unsigned mask, + boolean copy_all_samples) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; @@ -1104,44 +1206,53 @@ void util_blitter_copy_texture(struct blitter_context *blitter, src_view = pipe->create_sampler_view(pipe, src, &src_templ); /* Copy. */ - util_blitter_copy_texture_view(blitter, dst_view, dst_sample_mask, dstx, - dsty, src_view, src_sample, srcbox, - src->width0, src->height0, PIPE_MASK_RGBAZS); + util_blitter_blit_generic(blitter, dst_view, dstx, dsty, + abs(srcbox->width), abs(srcbox->height), + src_view, srcbox, src->width0, src->height0, + mask, PIPE_TEX_FILTER_NEAREST, NULL, + copy_all_samples); pipe_surface_reference(&dst_view, NULL); pipe_sampler_view_reference(&src_view, NULL); } -void util_blitter_copy_texture_view(struct blitter_context *blitter, - struct pipe_surface *dst, - unsigned dst_sample_mask, - unsigned dstx, unsigned dsty, - struct pipe_sampler_view *src, - unsigned src_sample, - const struct pipe_box *srcbox, - unsigned src_width0, unsigned src_height0, - unsigned mask) +void util_blitter_blit_generic(struct blitter_context *blitter, + struct pipe_surface *dst, + int dstx, int dsty, + unsigned dst_width, unsigned dst_height, + struct pipe_sampler_view *src, + const struct pipe_box *srcbox, + unsigned src_width0, unsigned src_height0, + unsigned mask, unsigned filter, + const struct pipe_scissor_state *scissor, + boolean copy_all_samples) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; struct pipe_framebuffer_state fb_state; enum pipe_texture_target src_target = src->texture->target; - int abs_width = abs(srcbox->width); - int abs_height = abs(srcbox->height); - boolean blit_stencil, blit_depth; + boolean has_depth, has_stencil, has_color; + boolean blit_stencil, blit_depth, blit_color; + void *sampler_state; const struct util_format_description *src_desc = util_format_description(src->format); - - blit_depth = util_format_has_depth(src_desc) && (mask & PIPE_MASK_Z); - blit_stencil = util_format_has_stencil(src_desc) && (mask & PIPE_MASK_S); - - /* If you want a fallback for stencil copies, - * use util_blitter_copy_texture. */ - if (blit_stencil && !ctx->has_stencil_export) { - blit_stencil = FALSE; - - if (!blit_depth) - return; + const struct util_format_description *dst_desc = + util_format_description(dst->format); + + has_color = src_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS && + dst_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS; + has_depth = util_format_has_depth(src_desc) && + util_format_has_depth(dst_desc); + has_stencil = util_format_has_stencil(src_desc) && + util_format_has_stencil(dst_desc); + + blit_color = has_color && (mask & PIPE_MASK_RGBA); + blit_depth = has_depth && (mask & PIPE_MASK_Z); + blit_stencil = has_stencil && (mask & PIPE_MASK_S) && + ctx->has_stencil_export; + + if (!blit_stencil && !blit_depth && !blit_color) { + return; } /* Sanity checks. */ @@ -1158,49 +1269,65 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, blitter_check_saved_fragment_states(ctx); blitter_check_saved_textures(ctx); blitter_check_saved_fb_state(ctx); + blitter_disable_render_cond(ctx); /* Initialize framebuffer state. */ fb_state.width = dst->width; fb_state.height = dst->height; if (blit_depth || blit_stencil) { - pipe->bind_blend_state(pipe, ctx->blend_keep_color); + pipe->bind_blend_state(pipe, ctx->blend[0]); if (blit_depth && blit_stencil) { pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil); - pipe->bind_fs_state(pipe, - blitter_get_fs_texfetch_depthstencil(ctx, src->texture)); + ctx->bind_fs_state(pipe, + blitter_get_fs_texfetch_depthstencil(ctx, src->texture->target, + src->texture->nr_samples)); } else if (blit_depth) { pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_keep_stencil); - pipe->bind_fs_state(pipe, - blitter_get_fs_texfetch_depth(ctx, src->texture)); + ctx->bind_fs_state(pipe, + blitter_get_fs_texfetch_depth(ctx, src->texture->target, + src->texture->nr_samples)); } else { /* is_stencil */ pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_write_stencil); - pipe->bind_fs_state(pipe, - blitter_get_fs_texfetch_stencil(ctx, src->texture)); + ctx->bind_fs_state(pipe, + blitter_get_fs_texfetch_stencil(ctx, src->texture->target, + src->texture->nr_samples)); } fb_state.nr_cbufs = 0; fb_state.zsbuf = dst; } else { - pipe->bind_blend_state(pipe, ctx->blend_write_color); + pipe->bind_blend_state(pipe, ctx->blend[mask & PIPE_MASK_RGBA]); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); - pipe->bind_fs_state(pipe, - blitter_get_fs_texfetch_col(ctx, src->texture)); + ctx->bind_fs_state(pipe, + blitter_get_fs_texfetch_col(ctx, src->texture->target, + src->texture->nr_samples)); fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dst; fb_state.zsbuf = 0; } + /* Set the linear filter only for scaled color non-MSAA blits. */ + if (filter == PIPE_TEX_FILTER_LINEAR && + !blit_depth && !blit_stencil && + src->texture->nr_samples <= 1 && + (dst_width != abs(srcbox->width) || dst_height != abs(srcbox->height))) { + sampler_state = ctx->sampler_state_linear; + } else { + sampler_state = ctx->sampler_state; + } + + /* Set samplers. */ if (blit_depth && blit_stencil) { /* Setup two samplers, one for depth and the other one for stencil. */ struct pipe_sampler_view templ; struct pipe_sampler_view *views[2]; - void *samplers[2] = {ctx->sampler_state, ctx->sampler_state}; + void *samplers[2] = {sampler_state, sampler_state}; templ = *src; templ.format = util_format_stencil_only(templ.format); @@ -1225,19 +1352,22 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, view = pipe->create_sampler_view(pipe, src->texture, &templ); pipe->set_fragment_sampler_views(pipe, 1, &view); - pipe->bind_fragment_sampler_states(pipe, 1, &ctx->sampler_state); + pipe->bind_fragment_sampler_states(pipe, 1, &sampler_state); pipe_sampler_view_reference(&view, NULL); } else { pipe->set_fragment_sampler_views(pipe, 1, &src); - pipe->bind_fragment_sampler_states(pipe, 1, &ctx->sampler_state); + pipe->bind_fragment_sampler_states(pipe, 1, &sampler_state); } pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->set_framebuffer_state(pipe, &fb_state); - pipe->set_sample_mask(pipe, dst_sample_mask); - blitter_set_common_draw_rect_state(ctx); + if (scissor) { + pipe->set_scissor_state(pipe, scissor); + } + + blitter_set_common_draw_rect_state(ctx, scissor != NULL); blitter_set_dst_dimensions(ctx, dst->width, dst->height); if ((src_target == PIPE_TEXTURE_1D || @@ -1256,24 +1386,82 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, srcbox->x+srcbox->width, srcbox->y+srcbox->height, coord.f); /* Draw. */ - blitter->draw_rectangle(blitter, dstx, dsty, dstx+abs_width, dsty+abs_height, 0, + pipe->set_sample_mask(pipe, ~0); + blitter->draw_rectangle(blitter, dstx, dsty, + dstx+dst_width, dsty+dst_height, 0, UTIL_BLITTER_ATTRIB_TEXCOORD, &coord); } else { /* Draw the quad with the generic codepath. */ - blitter_set_texcoords(ctx, src, src_width0, src_height0, srcbox->z, - src_sample, - srcbox->x, srcbox->y, - srcbox->x + srcbox->width, srcbox->y + srcbox->height); - blitter_draw(ctx, dstx, dsty, dstx+abs_width, dsty+abs_height, 0); + if (copy_all_samples && + src->texture->nr_samples == dst->texture->nr_samples && + dst->texture->nr_samples > 1) { + /* MSAA copy. */ + unsigned i, max_sample = MAX2(dst->texture->nr_samples, 1) - 1; + + for (i = 0; i <= max_sample; i++) { + pipe->set_sample_mask(pipe, 1 << i); + blitter_set_texcoords(ctx, src, src_width0, src_height0, srcbox->z, + i, srcbox->x, srcbox->y, + srcbox->x + srcbox->width, + srcbox->y + srcbox->height); + blitter_draw(ctx, dstx, dsty, + dstx+dst_width, dsty+dst_height, 0); + } + } else { + pipe->set_sample_mask(pipe, ~0); + blitter_set_texcoords(ctx, src, src_width0, src_height0, srcbox->z, 0, + srcbox->x, srcbox->y, + srcbox->x + srcbox->width, + srcbox->y + srcbox->height); + blitter_draw(ctx, dstx, dsty, dstx+dst_width, dsty+dst_height, 0); + } } blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); blitter_restore_textures(ctx); blitter_restore_fb_state(ctx); + if (scissor) { + pipe->set_scissor_state(pipe, &ctx->base.saved_scissor); + } + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); } +void +util_blitter_blit(struct blitter_context *blitter, + const struct pipe_blit_info *info) +{ + struct pipe_resource *dst = info->dst.resource; + struct pipe_resource *src = info->src.resource; + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + struct pipe_context *pipe = ctx->base.pipe; + struct pipe_surface *dst_view, dst_templ; + struct pipe_sampler_view src_templ, *src_view; + + /* Initialize the surface. */ + util_blitter_default_dst_texture(&dst_templ, dst, info->dst.level, + info->dst.box.z, &info->src.box); + dst_templ.format = info->dst.format; + dst_view = pipe->create_surface(pipe, dst, &dst_templ); + + /* Initialize the sampler view. */ + util_blitter_default_src_texture(&src_templ, src, info->src.level); + src_templ.format = info->src.format; + src_view = pipe->create_sampler_view(pipe, src, &src_templ); + + /* Copy. */ + util_blitter_blit_generic(blitter, dst_view, + info->dst.box.x, info->dst.box.y, + info->dst.box.width, info->dst.box.height, + src_view, &info->src.box, src->width0, src->height0, + info->mask, info->filter, + info->scissor_enable ? &info->scissor : NULL, TRUE); + + pipe_surface_reference(&dst_view, NULL); + pipe_sampler_view_reference(&src_view, NULL); +} + /* Clear a region of a color surface to a constant value. */ void util_blitter_clear_render_target(struct blitter_context *blitter, struct pipe_surface *dstsurf, @@ -1294,11 +1482,12 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); blitter_check_saved_fb_state(ctx); + blitter_disable_render_cond(ctx); /* bind states */ - pipe->bind_blend_state(pipe, ctx->blend_write_color); + pipe->bind_blend_state(pipe, ctx->blend[PIPE_MASK_RGBA]); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); - pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); + ctx->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ @@ -1310,7 +1499,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, pipe->set_framebuffer_state(pipe, &fb_state); pipe->set_sample_mask(pipe, ~0); - blitter_set_common_draw_rect_state(ctx); + blitter_set_common_draw_rect_state(ctx, FALSE); 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); @@ -1318,6 +1507,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); blitter_restore_fb_state(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); } @@ -1344,9 +1534,10 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); blitter_check_saved_fb_state(ctx); + blitter_disable_render_cond(ctx); /* bind states */ - pipe->bind_blend_state(pipe, ctx->blend_keep_color); + pipe->bind_blend_state(pipe, ctx->blend[0]); if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) == PIPE_CLEAR_DEPTHSTENCIL) { sr.ref_value[0] = stencil & 0xff; pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil); @@ -1364,7 +1555,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, /* hmm that should be illegal probably, or make it a no-op somewhere */ pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); - pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE)); + ctx->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE)); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ @@ -1376,7 +1567,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, pipe->set_framebuffer_state(pipe, &fb_state); pipe->set_sample_mask(pipe, ~0); - blitter_set_common_draw_rect_state(ctx); + blitter_set_common_draw_rect_state(ctx, FALSE); 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); @@ -1384,6 +1575,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); blitter_restore_fb_state(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); } @@ -1407,11 +1599,12 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); blitter_check_saved_fb_state(ctx); + blitter_disable_render_cond(ctx); /* bind states */ - pipe->bind_blend_state(pipe, ctx->blend_write_color); + pipe->bind_blend_state(pipe, ctx->blend[PIPE_MASK_RGBA]); pipe->bind_depth_stencil_alpha_state(pipe, dsa_stage); - pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE)); + ctx->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE)); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ @@ -1429,7 +1622,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, pipe->set_framebuffer_state(pipe, &fb_state); pipe->set_sample_mask(pipe, sample_mask); - blitter_set_common_draw_rect_state(ctx); + blitter_set_common_draw_rect_state(ctx, FALSE); 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); @@ -1437,6 +1630,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); blitter_restore_fb_state(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); } @@ -1478,6 +1672,7 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, blitter_set_running_flag(ctx); blitter_check_saved_vertex_states(ctx); + blitter_disable_render_cond(ctx); vb.buffer = src; vb.buffer_offset = srcx; @@ -1496,6 +1691,7 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, util_draw_arrays(pipe, PIPE_PRIM_POINTS, 0, size / 4); blitter_restore_vertex_states(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); pipe_so_target_reference(&so_target, NULL); } @@ -1518,12 +1714,13 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, blitter_set_running_flag(ctx); blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); + blitter_disable_render_cond(ctx); /* bind states */ pipe->bind_blend_state(pipe, custom_blend); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); - pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); + ctx->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); pipe->set_sample_mask(pipe, sample_mask); memset(&surf_tmpl, 0, sizeof(surf_tmpl)); @@ -1550,13 +1747,14 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, fb_state.zsbuf = NULL; pipe->set_framebuffer_state(pipe, &fb_state); - blitter_set_common_draw_rect_state(ctx); + blitter_set_common_draw_rect_state(ctx, FALSE); blitter_set_dst_dimensions(ctx, src->width0, src->height0); blitter->draw_rectangle(blitter, 0, 0, src->width0, src->height0, 0, 0, NULL); blitter_restore_fb_state(ctx); blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); pipe_surface_reference(&srcsurf, NULL); @@ -1580,11 +1778,12 @@ void util_blitter_custom_color(struct blitter_context *blitter, blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); blitter_check_saved_fb_state(ctx); + blitter_disable_render_cond(ctx); /* bind states */ pipe->bind_blend_state(pipe, custom_blend); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); - pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); + ctx->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->set_sample_mask(pipe, (1ull << MAX2(1, dstsurf->texture->nr_samples)) - 1); @@ -1597,7 +1796,7 @@ void util_blitter_custom_color(struct blitter_context *blitter, pipe->set_framebuffer_state(pipe, &fb_state); pipe->set_sample_mask(pipe, ~0); - blitter_set_common_draw_rect_state(ctx); + blitter_set_common_draw_rect_state(ctx, FALSE); blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); blitter->draw_rectangle(blitter, 0, 0, dstsurf->width, dstsurf->height, 0, 0, NULL); @@ -1605,5 +1804,146 @@ void util_blitter_custom_color(struct blitter_context *blitter, blitter_restore_vertex_states(ctx); blitter_restore_fragment_states(ctx); blitter_restore_fb_state(ctx); + blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); } + +/* Return whether this is an RGBA, Z, S, or combined ZS format. + */ +static unsigned get_format_mask(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + + assert(desc); + + if (util_format_has_depth(desc)) { + if (util_format_has_stencil(desc)) { + return PIPE_MASK_ZS; + } else { + return PIPE_MASK_Z; + } + } else { + if (util_format_has_stencil(desc)) { + return PIPE_MASK_S; + } else { + return PIPE_MASK_RGBA; + } + } +} + +/* Return if the box is totally inside the resource. + */ +static boolean is_box_inside_resource(const struct pipe_resource *res, + const struct pipe_box *box, + unsigned level) +{ + unsigned width = 1, height = 1, depth = 1; + + switch (res->target) { + case PIPE_BUFFER: + width = res->width0; + height = 1; + depth = 1; + break; + case PIPE_TEXTURE_1D: + width = u_minify(res->width0, level); + height = 1; + depth = 1; + break; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_RECT: + width = u_minify(res->width0, level); + height = u_minify(res->height0, level); + depth = 1; + break; + case PIPE_TEXTURE_3D: + width = u_minify(res->width0, level); + height = u_minify(res->height0, level); + depth = u_minify(res->depth0, level); + break; + case PIPE_TEXTURE_CUBE: + width = u_minify(res->width0, level); + height = u_minify(res->height0, level); + depth = 6; + break; + case PIPE_TEXTURE_1D_ARRAY: + width = u_minify(res->width0, level); + height = 1; + depth = res->array_size; + break; + case PIPE_TEXTURE_2D_ARRAY: + width = u_minify(res->width0, level); + height = u_minify(res->height0, level); + depth = res->array_size; + break; + case PIPE_MAX_TEXTURE_TYPES:; + } + + return box->x >= 0 && + box->x + box->width <= width && + box->y >= 0 && + box->y + box->height <= height && + box->z >= 0 && + box->z + box->depth <= depth; +} + +static unsigned get_sample_count(const struct pipe_resource *res) +{ + return res->nr_samples ? res->nr_samples : 1; +} + +boolean util_try_blit_via_copy_region(struct pipe_context *ctx, + const struct pipe_blit_info *blit) +{ + unsigned mask = get_format_mask(blit->dst.format); + + /* No format conversions. */ + if (blit->src.resource->format != blit->src.format || + blit->dst.resource->format != blit->dst.format || + !util_is_format_compatible( + util_format_description(blit->src.resource->format), + util_format_description(blit->dst.resource->format))) { + return FALSE; + } + + /* No masks, no filtering, no scissor. */ + if ((blit->mask & mask) != mask || + blit->filter != PIPE_TEX_FILTER_NEAREST || + blit->scissor_enable) { + return FALSE; + } + + /* No flipping. */ + if (blit->src.box.width < 0 || + blit->src.box.height < 0 || + blit->src.box.depth < 0) { + return FALSE; + } + + /* No scaling. */ + if (blit->src.box.width != blit->dst.box.width || + blit->src.box.height != blit->dst.box.height || + blit->src.box.depth != blit->dst.box.depth) { + return FALSE; + } + + /* No out-of-bounds access. */ + if (!is_box_inside_resource(blit->src.resource, &blit->src.box, + blit->src.level) || + !is_box_inside_resource(blit->dst.resource, &blit->dst.box, + blit->dst.level)) { + return FALSE; + } + + /* Sample counts must match. */ + if (get_sample_count(blit->src.resource) != + get_sample_count(blit->dst.resource)) { + return FALSE; + } + + ctx->resource_copy_region(ctx, blit->dst.resource, blit->dst.level, + blit->dst.box.x, blit->dst.box.y, blit->dst.box.z, + blit->src.resource, blit->src.level, + &blit->src.box); + return TRUE; +} diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h index 680407381..40636c616 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.h +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h @@ -74,7 +74,7 @@ struct blitter_context * a rectangular point sprite. */ void (*draw_rectangle)(struct blitter_context *blitter, - unsigned x1, unsigned y1, unsigned x2, unsigned y2, + int x1, int y1, int x2, int y2, float depth, enum blitter_attrib_type type, const union pipe_color_union *color); @@ -94,6 +94,7 @@ struct blitter_context struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */ struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ struct pipe_viewport_state saved_viewport; + struct pipe_scissor_state saved_scissor; boolean is_sample_mask_saved; unsigned saved_sample_mask; @@ -108,6 +109,9 @@ struct blitter_context int saved_num_so_targets; struct pipe_stream_output_target *saved_so_targets[PIPE_MAX_SO_BUFFERS]; + + struct pipe_query *saved_render_cond_query; + uint saved_render_cond_mode; }; /** @@ -120,6 +124,8 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe); */ void util_blitter_destroy(struct blitter_context *blitter); +void util_blitter_cache_all_shaders(struct blitter_context *blitter); + /** * Return the pipe context associated with a blitter context. */ @@ -132,12 +138,22 @@ struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter) /* The default function to draw a rectangle. This can only be used * inside of the draw_rectangle callback if the driver overrides it. */ void util_blitter_draw_rectangle(struct blitter_context *blitter, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2, - float depth, + int x1, int y1, int x2, int y2, float depth, enum blitter_attrib_type type, const union pipe_color_union *attrib); +/** + * Try to do a blit using resource_copy_region. The function calls + * resource_copy_region if the blit description is compatible with it. + * + * It returns TRUE if the blit was done using resource_copy_region. + * + * It returns FALSE otherwise and the caller must fall back to a more generic + * codepath for the blit operation. (e.g. by using u_blitter) + */ +boolean util_try_blit_via_copy_region(struct pipe_context *ctx, + const struct pipe_blit_info *blit); + /* * These states must be saved before any of the following functions are called: * - vertex buffers @@ -175,19 +191,13 @@ boolean util_blitter_is_copy_supported(struct blitter_context *blitter, const struct pipe_resource *dst, const struct pipe_resource *src, unsigned mask); + +boolean util_blitter_is_blit_supported(struct blitter_context *blitter, + const struct pipe_blit_info *info); + /** * 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 from and the latter can be rendered to. Otherwise, - * a software fallback path is taken and both surfaces must be of the same - * format. - * - * Only one sample of a multisample texture can be copied and is specified by - * src_sample. If the destination is a multisample resource, dst_sample_mask - * specifies the sample mask. For single-sample resources, set dst_sample_mask - * to ~0. - * * These states must be saved in the blitter in addition to the state objects * already required to be saved: * - fragment shader @@ -196,19 +206,21 @@ boolean util_blitter_is_copy_supported(struct blitter_context *blitter, * - fragment sampler states * - fragment sampler textures * - framebuffer state + * - sample mask */ void util_blitter_copy_texture(struct blitter_context *blitter, struct pipe_resource *dst, - unsigned dst_level, unsigned dst_sample_mask, + unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, - unsigned src_level, unsigned src_sample, - const struct pipe_box *srcbox); + unsigned src_level, + const struct pipe_box *srcbox, unsigned mask, + boolean copy_all_samples); /** - * Same as util_blitter_copy_texture, but dst and src are pipe_surface and - * pipe_sampler_view, respectively. The mipmap level and dstz are part of - * the views. + * Same as util_blitter_copy_texture with the capabilities of util_blitter_blit, + * but dst and src are pipe_surface and pipe_sampler_view, respectively. + * The mipmap level and dstz are part of the views. * * Drivers can use this to change resource properties (like format, width, * height) by changing how the views interpret them, instead of changing @@ -222,18 +234,20 @@ void util_blitter_copy_texture(struct blitter_context *blitter, * * The mask is a combination of the PIPE_MASK_* flags. * Set to PIPE_MASK_RGBAZS if unsure. - * - * NOTE: There are no checks whether the blit is actually supported. */ -void util_blitter_copy_texture_view(struct blitter_context *blitter, - struct pipe_surface *dst, - unsigned dst_sample_mask, - unsigned dstx, unsigned dsty, - struct pipe_sampler_view *src, - unsigned src_sample, - const struct pipe_box *srcbox, - unsigned src_width0, unsigned src_height0, - unsigned mask); +void util_blitter_blit_generic(struct blitter_context *blitter, + struct pipe_surface *dst, + int dstx, int dsty, + unsigned dst_width, unsigned dst_height, + struct pipe_sampler_view *src, + const struct pipe_box *srcbox, + unsigned src_width0, unsigned src_height0, + unsigned mask, unsigned filter, + const struct pipe_scissor_state *scissor, + boolean copy_all_samples); + +void util_blitter_blit(struct blitter_context *blitter, + const struct pipe_blit_info *info); /** * Helper function to initialize a view for copy_texture_view. @@ -411,6 +425,13 @@ void util_blitter_save_viewport(struct blitter_context *blitter, } static INLINE +void util_blitter_save_scissor(struct blitter_context *blitter, + struct pipe_scissor_state *state) +{ + blitter->saved_scissor = *state; +} + +static INLINE void util_blitter_save_fragment_sampler_states( struct blitter_context *blitter, int num_sampler_states, @@ -473,6 +494,15 @@ util_blitter_save_sample_mask(struct blitter_context *blitter, blitter->saved_sample_mask = sample_mask; } +static INLINE void +util_blitter_save_render_condition(struct blitter_context *blitter, + struct pipe_query *query, + uint mode) +{ + blitter->saved_render_cond_query = query; + blitter->saved_render_cond_mode = mode; +} + #ifdef __cplusplus } #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_dump.h b/mesalib/src/gallium/auxiliary/util/u_dump.h index 87d84bead..71750a635 100644 --- a/mesalib/src/gallium/auxiliary/util/u_dump.h +++ b/mesalib/src/gallium/auxiliary/util/u_dump.h @@ -165,6 +165,12 @@ util_dump_vertex_element(FILE *stream, void util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state); +void +util_dump_box(FILE *stream, const struct pipe_box *box); + +void +util_dump_blit_info(FILE *stream, const struct pipe_blit_info *info); + /* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */ diff --git a/mesalib/src/gallium/auxiliary/util/u_dump_state.c b/mesalib/src/gallium/auxiliary/util/u_dump_state.c index c346a0ba5..f5d8b4373 100644 --- a/mesalib/src/gallium/auxiliary/util/u_dump_state.c +++ b/mesalib/src/gallium/auxiliary/util/u_dump_state.c @@ -762,3 +762,76 @@ util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state) util_dump_struct_end(stream); } + +void util_dump_box(FILE *stream, const struct pipe_box *box) +{ + if(!box) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_box"); + + util_dump_member(stream, int, box, x); + util_dump_member(stream, int, box, y); + util_dump_member(stream, int, box, z); + util_dump_member(stream, int, box, width); + util_dump_member(stream, int, box, height); + util_dump_member(stream, int, box, depth); + + util_dump_struct_end(stream); +} + +void util_dump_blit_info(FILE *stream, const struct pipe_blit_info *info) +{ + char mask[7]; + + if (!info) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_blit_info"); + + util_dump_member_begin(stream, "dst"); + util_dump_struct_begin(stream, "dst"); + util_dump_member(stream, ptr, &info->dst, resource); + util_dump_member(stream, uint, &info->dst, level); + util_dump_member(stream, format, &info->dst, format); + util_dump_member_begin(stream, "box"); + util_dump_box(stream, &info->dst.box); + util_dump_member_end(stream); + util_dump_struct_end(stream); + util_dump_member_end(stream); + + util_dump_member_begin(stream, "src"); + util_dump_struct_begin(stream, "src"); + util_dump_member(stream, ptr, &info->src, resource); + util_dump_member(stream, uint, &info->src, level); + util_dump_member(stream, format, &info->src, format); + util_dump_member_begin(stream, "box"); + util_dump_box(stream, &info->src.box); + util_dump_member_end(stream); + util_dump_struct_end(stream); + util_dump_member_end(stream); + + mask[0] = (info->mask & PIPE_MASK_R) ? 'R' : '-'; + mask[1] = (info->mask & PIPE_MASK_G) ? 'G' : '-'; + mask[2] = (info->mask & PIPE_MASK_B) ? 'B' : '-'; + mask[3] = (info->mask & PIPE_MASK_A) ? 'A' : '-'; + mask[4] = (info->mask & PIPE_MASK_Z) ? 'Z' : '-'; + mask[5] = (info->mask & PIPE_MASK_S) ? 'S' : '-'; + mask[6] = 0; + + util_dump_member_begin(stream, "mask"); + util_dump_string(stream, mask); + util_dump_member_end(stream); + util_dump_member(stream, uint, info, filter); + + util_dump_member(stream, bool, info, scissor_enable); + util_dump_member_begin(stream, "scissor"); + util_dump_scissor_state(stream, &info->scissor); + util_dump_member_end(stream); + + util_dump_struct_end(stream); +} diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c index fcfff148f..7fd6b3675 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.c +++ b/mesalib/src/gallium/auxiliary/util/u_surface.c @@ -66,11 +66,9 @@ u_surface_default_template(struct pipe_surface *surf, * \return TRUE for success, FALSE if failure */ boolean -util_create_rgba_surface(struct pipe_context *pipe, - uint width, uint height, - uint bind, - struct pipe_resource **textureOut, - struct pipe_surface **surfaceOut) +util_create_rgba_texture(struct pipe_context *pipe, + uint width, uint height, uint bind, + struct pipe_resource **textureOut) { static const enum pipe_format rgbaFormats[] = { PIPE_FORMAT_B8G8R8A8_UNORM, @@ -113,33 +111,11 @@ util_create_rgba_surface(struct pipe_context *pipe, /* create surface */ u_surface_default_template(&surf_templ, *textureOut, bind); - /* create surface / view into texture */ - *surfaceOut = pipe->create_surface(pipe, - *textureOut, - &surf_templ); - if (!*surfaceOut) { - pipe_resource_reference(textureOut, NULL); - return FALSE; - } - return TRUE; } /** - * Release the surface and texture from util_create_rgba_surface(). - */ -void -util_destroy_rgba_surface(struct pipe_resource *texture, - struct pipe_surface *surface) -{ - pipe_surface_reference(&surface, NULL); - pipe_resource_reference(&texture, NULL); -} - - - -/** * Fallback function for pipe->resource_copy_region(). * Note: (X,Y)=(0,0) is always the upper-left corner. */ diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.h b/mesalib/src/gallium/auxiliary/util/u_surface.h index 1117b78da..6bcb63f3d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.h +++ b/mesalib/src/gallium/auxiliary/util/u_surface.h @@ -44,16 +44,9 @@ u_surface_default_template(struct pipe_surface *view, unsigned bind); extern boolean -util_create_rgba_surface(struct pipe_context *ctx, +util_create_rgba_texture(struct pipe_context *ctx, uint width, uint height, uint bind, - struct pipe_resource **textureOut, - struct pipe_surface **surfaceOut); - - -extern void -util_destroy_rgba_surface(struct pipe_resource *texture, - struct pipe_surface *surface); - + struct pipe_resource **textureOut); extern void diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript index b034f3b06..6314c7551 100644 --- a/mesalib/src/glsl/SConscript +++ b/mesalib/src/glsl/SConscript @@ -87,7 +87,7 @@ else: command = python_cmd + ' $SCRIPT $SOURCE > $TARGET' ) - env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*')) + env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', '#src/glsl/builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*')) Export('builtin_glsl_function') diff --git a/mesalib/src/glsl/opt_structure_splitting.cpp b/mesalib/src/glsl/opt_structure_splitting.cpp index 60eec53b7..9b3f048e4 100644 --- a/mesalib/src/glsl/opt_structure_splitting.cpp +++ b/mesalib/src/glsl/opt_structure_splitting.cpp @@ -42,14 +42,10 @@ namespace { static bool debug = false; -// XXX using variable_entry2 here to avoid collision (MSVC multiply-defined -// function) with the variable_entry class seen in ir_variable_refcount.h -// Perhaps we can use the one in ir_variable_refcount.h and make this class -// here go away? -class variable_entry2 : public exec_node +class variable_entry : public exec_node { public: - variable_entry2(ir_variable *var) + variable_entry(ir_variable *var) { this->var = var; this->whole_structure_access = 0; @@ -95,7 +91,7 @@ public: virtual ir_visitor_status visit_enter(ir_assignment *); virtual ir_visitor_status visit_enter(ir_function_signature *); - variable_entry2 *get_variable_entry2(ir_variable *var); + variable_entry *get_variable_entry(ir_variable *var); /* List of variable_entry */ exec_list variable_list; @@ -103,8 +99,8 @@ public: void *mem_ctx; }; -variable_entry2 * -ir_structure_reference_visitor::get_variable_entry2(ir_variable *var) +variable_entry * +ir_structure_reference_visitor::get_variable_entry(ir_variable *var) { assert(var); @@ -112,12 +108,12 @@ ir_structure_reference_visitor::get_variable_entry2(ir_variable *var) return NULL; foreach_iter(exec_list_iterator, iter, this->variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); + variable_entry *entry = (variable_entry *)iter.get(); if (entry->var == var) return entry; } - variable_entry2 *entry = new(mem_ctx) variable_entry2(var); + variable_entry *entry = new(mem_ctx) variable_entry(var); this->variable_list.push_tail(entry); return entry; } @@ -126,7 +122,7 @@ ir_structure_reference_visitor::get_variable_entry2(ir_variable *var) ir_visitor_status ir_structure_reference_visitor::visit(ir_variable *ir) { - variable_entry2 *entry = this->get_variable_entry2(ir); + variable_entry *entry = this->get_variable_entry(ir); if (entry) entry->declaration = true; @@ -138,7 +134,7 @@ ir_visitor_status ir_structure_reference_visitor::visit(ir_dereference_variable *ir) { ir_variable *const var = ir->variable_referenced(); - variable_entry2 *entry = this->get_variable_entry2(var); + variable_entry *entry = this->get_variable_entry(var); if (entry) entry->whole_structure_access++; @@ -200,12 +196,12 @@ public: void split_deref(ir_dereference **deref); void handle_rvalue(ir_rvalue **rvalue); - variable_entry2 *get_splitting_entry(ir_variable *var); + variable_entry *get_splitting_entry(ir_variable *var); exec_list *variable_list; }; -variable_entry2 * +variable_entry * ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) { assert(var); @@ -214,7 +210,7 @@ ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) return NULL; foreach_iter(exec_list_iterator, iter, *this->variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); + variable_entry *entry = (variable_entry *)iter.get(); if (entry->var == var) { return entry; } @@ -234,7 +230,7 @@ ir_structure_splitting_visitor::split_deref(ir_dereference **deref) if (!deref_var) return; - variable_entry2 *entry = get_splitting_entry(deref_var->var); + variable_entry *entry = get_splitting_entry(deref_var->var); if (!entry) return; @@ -269,8 +265,8 @@ ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) { ir_dereference_variable *lhs_deref = ir->lhs->as_dereference_variable(); ir_dereference_variable *rhs_deref = ir->rhs->as_dereference_variable(); - variable_entry2 *lhs_entry = lhs_deref ? get_splitting_entry(lhs_deref->var) : NULL; - variable_entry2 *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL; + variable_entry *lhs_entry = lhs_deref ? get_splitting_entry(lhs_deref->var) : NULL; + variable_entry *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL; const glsl_type *type = ir->rhs->type; if ((lhs_entry || rhs_entry) && !ir->condition) { @@ -320,7 +316,7 @@ do_structure_splitting(exec_list *instructions) /* Trim out variables we can't split. */ foreach_iter(exec_list_iterator, iter, refs.variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); + variable_entry *entry = (variable_entry *)iter.get(); if (debug) { printf("structure %s@%p: decl %d, whole_access %d\n", @@ -342,7 +338,7 @@ do_structure_splitting(exec_list *instructions) * components. */ foreach_iter(exec_list_iterator, iter, refs.variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); + variable_entry *entry = (variable_entry *)iter.get(); const struct glsl_type *type = entry->var->type; entry->mem_ctx = ralloc_parent(entry->var); diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript index ad007a6f4..c336c2510 100644 --- a/mesalib/src/mapi/glapi/SConscript +++ b/mesalib/src/mapi/glapi/SConscript @@ -48,7 +48,7 @@ for s in mapi_sources: # # Assembly sources # -if env['gcc'] and env['platform'] not in ('darwin', 'windows'): +if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows'): GLAPI = '#src/mapi/glapi/' if env['machine'] == 'x86': diff --git a/mesalib/src/mapi/glapi/gen/es_EXT.xml b/mesalib/src/mapi/glapi/gen/es_EXT.xml index fc2ec621e..c38e65a24 100644 --- a/mesalib/src/mapi/glapi/gen/es_EXT.xml +++ b/mesalib/src/mapi/glapi/gen/es_EXT.xml @@ -718,7 +718,7 @@ <!-- 93. GL_NV_read_buffer --> <category name="NV_read_buffer"> - <function name="ReadBufferNV" offset="assign"> + <function name="ReadBufferNV" alias="ReadBuffer"> <param name="mode" type="GLenum"/> </function> </category> diff --git a/mesalib/src/mapi/glapi/gen/glX_proto_send.py b/mesalib/src/mapi/glapi/gen/glX_proto_send.py index 34aa2c31f..0e4b420fd 100644 --- a/mesalib/src/mapi/glapi/gen/glX_proto_send.py +++ b/mesalib/src/mapi/glapi/gen/glX_proto_send.py @@ -423,7 +423,7 @@ __indirect_get_proc_address(const char *name) print '' print '#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)' print ' if (gc->isDirect) {' - print ' const _glapi_proc *const disp_table = GET_DISPATCH();' + print ' const _glapi_proc *const disp_table = (_glapi_proc *)GET_DISPATCH();' print ' PFNGL%sPROC p =' % (name.upper()) print ' (PFNGL%sPROC) disp_table[%d];' % (name.upper(), func.offset) print ' %sp(%s);' % (ret_string, func.get_called_parameter_string()) diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index dba75a264..981908217 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -371,7 +371,7 @@ if env['gles']: # # Assembly sources # -if env['gcc'] and env['platform'] not in ('darwin', 'windows'): +if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows'): if env['machine'] == 'x86': env.Append(CPPDEFINES = [ 'USE_X86_ASM', diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 6689337e3..d0bb5e0ae 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -3489,12 +3489,16 @@ get_temp_image_type(struct gl_context *ctx, gl_format format) case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: case GL_INTENSITY: - if (ctx->DrawBuffer->Visual.redBits <= 8) + if (ctx->DrawBuffer->Visual.redBits <= 8) { return GL_UNSIGNED_BYTE; - else if (ctx->DrawBuffer->Visual.redBits <= 16) + } else if (ctx->DrawBuffer->Visual.redBits <= 16) { return GL_UNSIGNED_SHORT; - else - return _mesa_get_format_datatype(format); + } else { + GLenum datatype = _mesa_get_format_datatype(format); + if (datatype == GL_INT || datatype == GL_UNSIGNED_INT) + return datatype; + return GL_FLOAT; + } case GL_DEPTH_COMPONENT: return GL_UNSIGNED_INT; case GL_DEPTH_STENCIL: diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index 4276ad981..983bbea49 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -272,7 +272,7 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, return NULL; } - context = malloc(sizeof *context); + context = calloc(1, sizeof *context); if (!context) { *error = __DRI_CTX_ERROR_NO_MEMORY; return NULL; diff --git a/mesalib/src/mesa/main/APIspecutil.py b/mesalib/src/mesa/main/APIspecutil.py index 9e604bb84..3c1552809 100644 --- a/mesalib/src/mesa/main/APIspecutil.py +++ b/mesalib/src/mesa/main/APIspecutil.py @@ -189,7 +189,7 @@ def _MaxVecSize(func, param): need_conv = __aliases[func.name][1] if need_conv: print >>sys.stderr, \ - "Error: unable to dicide the max size of %s in %s" % \ + "Error: unable to decide the max size of %s in %s" % \ (param.name, func.name) return size diff --git a/mesalib/src/mesa/main/api_exec.c b/mesalib/src/mesa/main/api_exec.c index 1da041545..ddf7c7fc1 100644 --- a/mesalib/src/mesa/main/api_exec.c +++ b/mesalib/src/mesa/main/api_exec.c @@ -114,7 +114,7 @@ _mesa_create_exec_table(struct gl_context *ctx) return NULL; #if _HAVE_FULL_GL - _mesa_loopback_init_api_table( exec ); + _mesa_loopback_init_api_table(ctx, exec); #endif /* load the dispatch slots we understand */ @@ -188,7 +188,10 @@ _mesa_create_exec_table(struct gl_context *ctx) _mesa_init_dlist_dispatch(exec); } - SET_ClearDepth(exec, _mesa_ClearDepth); + if (ctx->API != API_OPENGLES2) { + SET_ClearDepth(exec, _mesa_ClearDepth); + } + if (ctx->API == API_OPENGL) { SET_ClearIndex(exec, _mesa_ClearIndex); SET_ClipPlane(exec, _mesa_ClipPlane); @@ -196,7 +199,10 @@ _mesa_create_exec_table(struct gl_context *ctx) } SET_DepthFunc(exec, _mesa_DepthFunc); SET_DepthMask(exec, _mesa_DepthMask); - SET_DepthRange(exec, _mesa_DepthRange); + + if (ctx->API != API_OPENGLES2) { + SET_DepthRange(exec, _mesa_DepthRange); + } if (ctx->API != API_OPENGLES2 && ctx->API != API_OPENGL_CORE) { _mesa_init_drawpix_dispatch(exec); @@ -214,7 +220,9 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_GetClipPlane(exec, _mesa_GetClipPlane); } SET_GetBooleanv(exec, _mesa_GetBooleanv); - SET_GetDoublev(exec, _mesa_GetDoublev); + if (ctx->API != API_OPENGLES2) { + SET_GetDoublev(exec, _mesa_GetDoublev); + } SET_GetIntegerv(exec, _mesa_GetIntegerv); if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { SET_GetLightfv(exec, _mesa_GetLightfv); @@ -259,11 +267,9 @@ _mesa_create_exec_table(struct gl_context *ctx) if (ctx->API != API_OPENGLES2) { SET_PixelStoref(exec, _mesa_PixelStoref); - } - SET_PointSize(exec, _mesa_PointSize); + SET_PointSize(exec, _mesa_PointSize); - if (ctx->API != API_OPENGLES2) { SET_PolygonMode(exec, _mesa_PolygonMode); } @@ -358,8 +364,8 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate); SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate); - _mesa_init_shader_dispatch(exec); - _mesa_init_shader_uniform_dispatch(exec); + _mesa_init_shader_dispatch(ctx, exec); + _mesa_init_shader_uniform_dispatch(ctx, exec); /* 2. GL_EXT_blend_color */ #if 0 @@ -422,8 +428,10 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 54. GL_EXT_point_parameters */ #if _HAVE_FULL_GL - SET_PointParameterfEXT(exec, _mesa_PointParameterf); - SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); + if (ctx->API != API_OPENGLES2) { + SET_PointParameterfEXT(exec, _mesa_PointParameterf); + SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); + } #endif /* 95. GL_ARB_ES2_compatibility */ @@ -450,7 +458,9 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 196. GL_MESA_resize_buffers */ #if _HAVE_FULL_GL - SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA); + if (_mesa_is_desktop_gl(ctx)) { + SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA); + } #endif /* 197. GL_MESA_window_pos */ @@ -521,8 +531,10 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 262. GL_NV_point_sprite */ #if _HAVE_FULL_GL - SET_PointParameteriNV(exec, _mesa_PointParameteri); - SET_PointParameterivNV(exec, _mesa_PointParameteriv); + if (_mesa_is_desktop_gl(ctx)) { + SET_PointParameteriNV(exec, _mesa_PointParameteri); + SET_PointParameterivNV(exec, _mesa_PointParameteriv); + } #endif /* 268. GL_EXT_stencil_two_side */ @@ -662,11 +674,11 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramivARB(exec, _mesa_GetProgramivARB); SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); } - SET_GetProgramivARB(exec, _mesa_GetProgramivARB); /* ARB 28. GL_ARB_vertex_buffer_object */ _mesa_init_bufferobj_dispatch(ctx, exec); @@ -862,10 +874,12 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_TexStorage1D(exec, _mesa_TexStorage1D); SET_TextureStorage1DEXT(exec, _mesa_TextureStorage1DEXT); } - SET_TexStorage2D(exec, _mesa_TexStorage2D); - SET_TexStorage3D(exec, _mesa_TexStorage3D); - SET_TextureStorage2DEXT(exec, _mesa_TextureStorage2DEXT); - SET_TextureStorage3DEXT(exec, _mesa_TextureStorage3DEXT); + if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) { + SET_TexStorage2D(exec, _mesa_TexStorage2D); + SET_TexStorage3D(exec, _mesa_TexStorage3D); + SET_TextureStorage2DEXT(exec, _mesa_TextureStorage2DEXT); + SET_TextureStorage3DEXT(exec, _mesa_TextureStorage3DEXT); + } if (ctx->API != API_OPENGLES2) { _mesa_init_sampler_object_dispatch(exec); diff --git a/mesalib/src/mesa/main/api_loopback.c b/mesalib/src/mesa/main/api_loopback.c index a5fbe8ebf..330eb22f7 100644 --- a/mesalib/src/mesa/main/api_loopback.c +++ b/mesalib/src/mesa/main/api_loopback.c @@ -1499,221 +1499,228 @@ loopback_VertexAttribI4usv(GLuint index, const GLushort *v) * listed in vtxfmt.h. */ void -_mesa_loopback_init_api_table( struct _glapi_table *dest ) -{ - SET_Color3b(dest, loopback_Color3b_f); - SET_Color3d(dest, loopback_Color3d_f); - SET_Color3i(dest, loopback_Color3i_f); - SET_Color3s(dest, loopback_Color3s_f); - SET_Color3ui(dest, loopback_Color3ui_f); - SET_Color3us(dest, loopback_Color3us_f); - SET_Color3ub(dest, loopback_Color3ub_f); - SET_Color4b(dest, loopback_Color4b_f); - SET_Color4d(dest, loopback_Color4d_f); - SET_Color4i(dest, loopback_Color4i_f); - SET_Color4s(dest, loopback_Color4s_f); - SET_Color4ui(dest, loopback_Color4ui_f); - SET_Color4us(dest, loopback_Color4us_f); - SET_Color4ub(dest, loopback_Color4ub_f); - SET_Color3bv(dest, loopback_Color3bv_f); - SET_Color3dv(dest, loopback_Color3dv_f); - SET_Color3iv(dest, loopback_Color3iv_f); - SET_Color3sv(dest, loopback_Color3sv_f); - SET_Color3uiv(dest, loopback_Color3uiv_f); - SET_Color3usv(dest, loopback_Color3usv_f); - SET_Color3ubv(dest, loopback_Color3ubv_f); - SET_Color4bv(dest, loopback_Color4bv_f); - SET_Color4dv(dest, loopback_Color4dv_f); - SET_Color4iv(dest, loopback_Color4iv_f); - SET_Color4sv(dest, loopback_Color4sv_f); - SET_Color4uiv(dest, loopback_Color4uiv_f); - SET_Color4usv(dest, loopback_Color4usv_f); - SET_Color4ubv(dest, loopback_Color4ubv_f); - - SET_SecondaryColor3bEXT(dest, loopback_SecondaryColor3bEXT_f); - SET_SecondaryColor3dEXT(dest, loopback_SecondaryColor3dEXT_f); - SET_SecondaryColor3iEXT(dest, loopback_SecondaryColor3iEXT_f); - SET_SecondaryColor3sEXT(dest, loopback_SecondaryColor3sEXT_f); - SET_SecondaryColor3uiEXT(dest, loopback_SecondaryColor3uiEXT_f); - SET_SecondaryColor3usEXT(dest, loopback_SecondaryColor3usEXT_f); - SET_SecondaryColor3ubEXT(dest, loopback_SecondaryColor3ubEXT_f); - SET_SecondaryColor3bvEXT(dest, loopback_SecondaryColor3bvEXT_f); - SET_SecondaryColor3dvEXT(dest, loopback_SecondaryColor3dvEXT_f); - SET_SecondaryColor3ivEXT(dest, loopback_SecondaryColor3ivEXT_f); - SET_SecondaryColor3svEXT(dest, loopback_SecondaryColor3svEXT_f); - SET_SecondaryColor3uivEXT(dest, loopback_SecondaryColor3uivEXT_f); - SET_SecondaryColor3usvEXT(dest, loopback_SecondaryColor3usvEXT_f); - SET_SecondaryColor3ubvEXT(dest, loopback_SecondaryColor3ubvEXT_f); +_mesa_loopback_init_api_table(const struct gl_context *ctx, + struct _glapi_table *dest) +{ + if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { + SET_Color3b(dest, loopback_Color3b_f); + SET_Color3d(dest, loopback_Color3d_f); + SET_Color3i(dest, loopback_Color3i_f); + SET_Color3s(dest, loopback_Color3s_f); + SET_Color3ui(dest, loopback_Color3ui_f); + SET_Color3us(dest, loopback_Color3us_f); + SET_Color3ub(dest, loopback_Color3ub_f); + SET_Color4b(dest, loopback_Color4b_f); + SET_Color4d(dest, loopback_Color4d_f); + SET_Color4i(dest, loopback_Color4i_f); + SET_Color4s(dest, loopback_Color4s_f); + SET_Color4ui(dest, loopback_Color4ui_f); + SET_Color4us(dest, loopback_Color4us_f); + SET_Color4ub(dest, loopback_Color4ub_f); + SET_Color3bv(dest, loopback_Color3bv_f); + SET_Color3dv(dest, loopback_Color3dv_f); + SET_Color3iv(dest, loopback_Color3iv_f); + SET_Color3sv(dest, loopback_Color3sv_f); + SET_Color3uiv(dest, loopback_Color3uiv_f); + SET_Color3usv(dest, loopback_Color3usv_f); + SET_Color3ubv(dest, loopback_Color3ubv_f); + SET_Color4bv(dest, loopback_Color4bv_f); + SET_Color4dv(dest, loopback_Color4dv_f); + SET_Color4iv(dest, loopback_Color4iv_f); + SET_Color4sv(dest, loopback_Color4sv_f); + SET_Color4uiv(dest, loopback_Color4uiv_f); + SET_Color4usv(dest, loopback_Color4usv_f); + SET_Color4ubv(dest, loopback_Color4ubv_f); + + SET_SecondaryColor3bEXT(dest, loopback_SecondaryColor3bEXT_f); + SET_SecondaryColor3dEXT(dest, loopback_SecondaryColor3dEXT_f); + SET_SecondaryColor3iEXT(dest, loopback_SecondaryColor3iEXT_f); + SET_SecondaryColor3sEXT(dest, loopback_SecondaryColor3sEXT_f); + SET_SecondaryColor3uiEXT(dest, loopback_SecondaryColor3uiEXT_f); + SET_SecondaryColor3usEXT(dest, loopback_SecondaryColor3usEXT_f); + SET_SecondaryColor3ubEXT(dest, loopback_SecondaryColor3ubEXT_f); + SET_SecondaryColor3bvEXT(dest, loopback_SecondaryColor3bvEXT_f); + SET_SecondaryColor3dvEXT(dest, loopback_SecondaryColor3dvEXT_f); + SET_SecondaryColor3ivEXT(dest, loopback_SecondaryColor3ivEXT_f); + SET_SecondaryColor3svEXT(dest, loopback_SecondaryColor3svEXT_f); + SET_SecondaryColor3uivEXT(dest, loopback_SecondaryColor3uivEXT_f); + SET_SecondaryColor3usvEXT(dest, loopback_SecondaryColor3usvEXT_f); + SET_SecondaryColor3ubvEXT(dest, loopback_SecondaryColor3ubvEXT_f); - SET_EdgeFlagv(dest, loopback_EdgeFlagv); - - SET_Indexd(dest, loopback_Indexd); - SET_Indexi(dest, loopback_Indexi); - SET_Indexs(dest, loopback_Indexs); - SET_Indexub(dest, loopback_Indexub); - SET_Indexdv(dest, loopback_Indexdv); - SET_Indexiv(dest, loopback_Indexiv); - SET_Indexsv(dest, loopback_Indexsv); - SET_Indexubv(dest, loopback_Indexubv); - SET_Normal3b(dest, loopback_Normal3b); - SET_Normal3d(dest, loopback_Normal3d); - SET_Normal3i(dest, loopback_Normal3i); - SET_Normal3s(dest, loopback_Normal3s); - SET_Normal3bv(dest, loopback_Normal3bv); - SET_Normal3dv(dest, loopback_Normal3dv); - SET_Normal3iv(dest, loopback_Normal3iv); - SET_Normal3sv(dest, loopback_Normal3sv); - SET_TexCoord1d(dest, loopback_TexCoord1d); - SET_TexCoord1i(dest, loopback_TexCoord1i); - SET_TexCoord1s(dest, loopback_TexCoord1s); - SET_TexCoord2d(dest, loopback_TexCoord2d); - SET_TexCoord2s(dest, loopback_TexCoord2s); - SET_TexCoord2i(dest, loopback_TexCoord2i); - SET_TexCoord3d(dest, loopback_TexCoord3d); - SET_TexCoord3i(dest, loopback_TexCoord3i); - SET_TexCoord3s(dest, loopback_TexCoord3s); - SET_TexCoord4d(dest, loopback_TexCoord4d); - SET_TexCoord4i(dest, loopback_TexCoord4i); - SET_TexCoord4s(dest, loopback_TexCoord4s); - SET_TexCoord1dv(dest, loopback_TexCoord1dv); - SET_TexCoord1iv(dest, loopback_TexCoord1iv); - SET_TexCoord1sv(dest, loopback_TexCoord1sv); - SET_TexCoord2dv(dest, loopback_TexCoord2dv); - SET_TexCoord2iv(dest, loopback_TexCoord2iv); - SET_TexCoord2sv(dest, loopback_TexCoord2sv); - SET_TexCoord3dv(dest, loopback_TexCoord3dv); - SET_TexCoord3iv(dest, loopback_TexCoord3iv); - SET_TexCoord3sv(dest, loopback_TexCoord3sv); - SET_TexCoord4dv(dest, loopback_TexCoord4dv); - SET_TexCoord4iv(dest, loopback_TexCoord4iv); - SET_TexCoord4sv(dest, loopback_TexCoord4sv); - SET_Vertex2d(dest, loopback_Vertex2d); - SET_Vertex2i(dest, loopback_Vertex2i); - SET_Vertex2s(dest, loopback_Vertex2s); - SET_Vertex3d(dest, loopback_Vertex3d); - SET_Vertex3i(dest, loopback_Vertex3i); - SET_Vertex3s(dest, loopback_Vertex3s); - SET_Vertex4d(dest, loopback_Vertex4d); - SET_Vertex4i(dest, loopback_Vertex4i); - SET_Vertex4s(dest, loopback_Vertex4s); - SET_Vertex2dv(dest, loopback_Vertex2dv); - SET_Vertex2iv(dest, loopback_Vertex2iv); - SET_Vertex2sv(dest, loopback_Vertex2sv); - SET_Vertex3dv(dest, loopback_Vertex3dv); - SET_Vertex3iv(dest, loopback_Vertex3iv); - SET_Vertex3sv(dest, loopback_Vertex3sv); - SET_Vertex4dv(dest, loopback_Vertex4dv); - SET_Vertex4iv(dest, loopback_Vertex4iv); - SET_Vertex4sv(dest, loopback_Vertex4sv); - SET_MultiTexCoord1dARB(dest, loopback_MultiTexCoord1dARB); - SET_MultiTexCoord1dvARB(dest, loopback_MultiTexCoord1dvARB); - SET_MultiTexCoord1iARB(dest, loopback_MultiTexCoord1iARB); - SET_MultiTexCoord1ivARB(dest, loopback_MultiTexCoord1ivARB); - SET_MultiTexCoord1sARB(dest, loopback_MultiTexCoord1sARB); - SET_MultiTexCoord1svARB(dest, loopback_MultiTexCoord1svARB); - SET_MultiTexCoord2dARB(dest, loopback_MultiTexCoord2dARB); - SET_MultiTexCoord2dvARB(dest, loopback_MultiTexCoord2dvARB); - SET_MultiTexCoord2iARB(dest, loopback_MultiTexCoord2iARB); - SET_MultiTexCoord2ivARB(dest, loopback_MultiTexCoord2ivARB); - SET_MultiTexCoord2sARB(dest, loopback_MultiTexCoord2sARB); - SET_MultiTexCoord2svARB(dest, loopback_MultiTexCoord2svARB); - SET_MultiTexCoord3dARB(dest, loopback_MultiTexCoord3dARB); - SET_MultiTexCoord3dvARB(dest, loopback_MultiTexCoord3dvARB); - SET_MultiTexCoord3iARB(dest, loopback_MultiTexCoord3iARB); - SET_MultiTexCoord3ivARB(dest, loopback_MultiTexCoord3ivARB); - SET_MultiTexCoord3sARB(dest, loopback_MultiTexCoord3sARB); - SET_MultiTexCoord3svARB(dest, loopback_MultiTexCoord3svARB); - SET_MultiTexCoord4dARB(dest, loopback_MultiTexCoord4dARB); - SET_MultiTexCoord4dvARB(dest, loopback_MultiTexCoord4dvARB); - SET_MultiTexCoord4iARB(dest, loopback_MultiTexCoord4iARB); - SET_MultiTexCoord4ivARB(dest, loopback_MultiTexCoord4ivARB); - SET_MultiTexCoord4sARB(dest, loopback_MultiTexCoord4sARB); - SET_MultiTexCoord4svARB(dest, loopback_MultiTexCoord4svARB); - SET_EvalCoord2dv(dest, loopback_EvalCoord2dv); - SET_EvalCoord2fv(dest, loopback_EvalCoord2fv); - SET_EvalCoord2d(dest, loopback_EvalCoord2d); - SET_EvalCoord1dv(dest, loopback_EvalCoord1dv); - SET_EvalCoord1fv(dest, loopback_EvalCoord1fv); - SET_EvalCoord1d(dest, loopback_EvalCoord1d); - SET_Materialf(dest, loopback_Materialf); - SET_Materiali(dest, loopback_Materiali); - SET_Materialiv(dest, loopback_Materialiv); - SET_Rectd(dest, loopback_Rectd); - SET_Rectdv(dest, loopback_Rectdv); - SET_Rectfv(dest, loopback_Rectfv); - SET_Recti(dest, loopback_Recti); - SET_Rectiv(dest, loopback_Rectiv); - SET_Rects(dest, loopback_Rects); - SET_Rectsv(dest, loopback_Rectsv); - SET_FogCoorddEXT(dest, loopback_FogCoorddEXT); - SET_FogCoorddvEXT(dest, loopback_FogCoorddvEXT); - - SET_VertexAttrib1sNV(dest, loopback_VertexAttrib1sNV); - SET_VertexAttrib1dNV(dest, loopback_VertexAttrib1dNV); - SET_VertexAttrib2sNV(dest, loopback_VertexAttrib2sNV); - SET_VertexAttrib2dNV(dest, loopback_VertexAttrib2dNV); - SET_VertexAttrib3sNV(dest, loopback_VertexAttrib3sNV); - SET_VertexAttrib3dNV(dest, loopback_VertexAttrib3dNV); - SET_VertexAttrib4sNV(dest, loopback_VertexAttrib4sNV); - SET_VertexAttrib4dNV(dest, loopback_VertexAttrib4dNV); - SET_VertexAttrib4ubNV(dest, loopback_VertexAttrib4ubNV); - SET_VertexAttrib1svNV(dest, loopback_VertexAttrib1svNV); - SET_VertexAttrib1dvNV(dest, loopback_VertexAttrib1dvNV); - SET_VertexAttrib2svNV(dest, loopback_VertexAttrib2svNV); - SET_VertexAttrib2dvNV(dest, loopback_VertexAttrib2dvNV); - SET_VertexAttrib3svNV(dest, loopback_VertexAttrib3svNV); - SET_VertexAttrib3dvNV(dest, loopback_VertexAttrib3dvNV); - SET_VertexAttrib4svNV(dest, loopback_VertexAttrib4svNV); - SET_VertexAttrib4dvNV(dest, loopback_VertexAttrib4dvNV); - SET_VertexAttrib4ubvNV(dest, loopback_VertexAttrib4ubvNV); - SET_VertexAttribs1svNV(dest, loopback_VertexAttribs1svNV); - SET_VertexAttribs1fvNV(dest, loopback_VertexAttribs1fvNV); - SET_VertexAttribs1dvNV(dest, loopback_VertexAttribs1dvNV); - SET_VertexAttribs2svNV(dest, loopback_VertexAttribs2svNV); - SET_VertexAttribs2fvNV(dest, loopback_VertexAttribs2fvNV); - SET_VertexAttribs2dvNV(dest, loopback_VertexAttribs2dvNV); - SET_VertexAttribs3svNV(dest, loopback_VertexAttribs3svNV); - SET_VertexAttribs3fvNV(dest, loopback_VertexAttribs3fvNV); - SET_VertexAttribs3dvNV(dest, loopback_VertexAttribs3dvNV); - SET_VertexAttribs4svNV(dest, loopback_VertexAttribs4svNV); - SET_VertexAttribs4fvNV(dest, loopback_VertexAttribs4fvNV); - SET_VertexAttribs4dvNV(dest, loopback_VertexAttribs4dvNV); - SET_VertexAttribs4ubvNV(dest, loopback_VertexAttribs4ubvNV); - - SET_VertexAttrib1sARB(dest, loopback_VertexAttrib1sARB); - SET_VertexAttrib1dARB(dest, loopback_VertexAttrib1dARB); - SET_VertexAttrib2sARB(dest, loopback_VertexAttrib2sARB); - SET_VertexAttrib2dARB(dest, loopback_VertexAttrib2dARB); - SET_VertexAttrib3sARB(dest, loopback_VertexAttrib3sARB); - SET_VertexAttrib3dARB(dest, loopback_VertexAttrib3dARB); - SET_VertexAttrib4sARB(dest, loopback_VertexAttrib4sARB); - SET_VertexAttrib4dARB(dest, loopback_VertexAttrib4dARB); - SET_VertexAttrib1svARB(dest, loopback_VertexAttrib1svARB); - SET_VertexAttrib1dvARB(dest, loopback_VertexAttrib1dvARB); - SET_VertexAttrib2svARB(dest, loopback_VertexAttrib2svARB); - SET_VertexAttrib2dvARB(dest, loopback_VertexAttrib2dvARB); - SET_VertexAttrib3svARB(dest, loopback_VertexAttrib3svARB); - SET_VertexAttrib3dvARB(dest, loopback_VertexAttrib3dvARB); - SET_VertexAttrib4svARB(dest, loopback_VertexAttrib4svARB); - SET_VertexAttrib4dvARB(dest, loopback_VertexAttrib4dvARB); - SET_VertexAttrib4NubARB(dest, loopback_VertexAttrib4NubARB); - SET_VertexAttrib4NubvARB(dest, loopback_VertexAttrib4NubvARB); - SET_VertexAttrib4bvARB(dest, loopback_VertexAttrib4bvARB); - SET_VertexAttrib4ivARB(dest, loopback_VertexAttrib4ivARB); - SET_VertexAttrib4ubvARB(dest, loopback_VertexAttrib4ubvARB); - SET_VertexAttrib4usvARB(dest, loopback_VertexAttrib4usvARB); - SET_VertexAttrib4uivARB(dest, loopback_VertexAttrib4uivARB); - SET_VertexAttrib4NbvARB(dest, loopback_VertexAttrib4NbvARB); - SET_VertexAttrib4NsvARB(dest, loopback_VertexAttrib4NsvARB); - SET_VertexAttrib4NivARB(dest, loopback_VertexAttrib4NivARB); - SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB); - SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB); - - /* GL_EXT_gpu_shader4, GL 3.0 */ - SET_VertexAttribI1ivEXT(dest, loopback_VertexAttribI1iv); - SET_VertexAttribI1uivEXT(dest, loopback_VertexAttribI1uiv); - SET_VertexAttribI4bvEXT(dest, loopback_VertexAttribI4bv); - SET_VertexAttribI4svEXT(dest, loopback_VertexAttribI4sv); - SET_VertexAttribI4ubvEXT(dest, loopback_VertexAttribI4ubv); - SET_VertexAttribI4usvEXT(dest, loopback_VertexAttribI4usv); + SET_EdgeFlagv(dest, loopback_EdgeFlagv); + + SET_Indexd(dest, loopback_Indexd); + SET_Indexi(dest, loopback_Indexi); + SET_Indexs(dest, loopback_Indexs); + SET_Indexub(dest, loopback_Indexub); + SET_Indexdv(dest, loopback_Indexdv); + SET_Indexiv(dest, loopback_Indexiv); + SET_Indexsv(dest, loopback_Indexsv); + SET_Indexubv(dest, loopback_Indexubv); + SET_Normal3b(dest, loopback_Normal3b); + SET_Normal3d(dest, loopback_Normal3d); + SET_Normal3i(dest, loopback_Normal3i); + SET_Normal3s(dest, loopback_Normal3s); + SET_Normal3bv(dest, loopback_Normal3bv); + SET_Normal3dv(dest, loopback_Normal3dv); + SET_Normal3iv(dest, loopback_Normal3iv); + SET_Normal3sv(dest, loopback_Normal3sv); + SET_TexCoord1d(dest, loopback_TexCoord1d); + SET_TexCoord1i(dest, loopback_TexCoord1i); + SET_TexCoord1s(dest, loopback_TexCoord1s); + SET_TexCoord2d(dest, loopback_TexCoord2d); + SET_TexCoord2s(dest, loopback_TexCoord2s); + SET_TexCoord2i(dest, loopback_TexCoord2i); + SET_TexCoord3d(dest, loopback_TexCoord3d); + SET_TexCoord3i(dest, loopback_TexCoord3i); + SET_TexCoord3s(dest, loopback_TexCoord3s); + SET_TexCoord4d(dest, loopback_TexCoord4d); + SET_TexCoord4i(dest, loopback_TexCoord4i); + SET_TexCoord4s(dest, loopback_TexCoord4s); + SET_TexCoord1dv(dest, loopback_TexCoord1dv); + SET_TexCoord1iv(dest, loopback_TexCoord1iv); + SET_TexCoord1sv(dest, loopback_TexCoord1sv); + SET_TexCoord2dv(dest, loopback_TexCoord2dv); + SET_TexCoord2iv(dest, loopback_TexCoord2iv); + SET_TexCoord2sv(dest, loopback_TexCoord2sv); + SET_TexCoord3dv(dest, loopback_TexCoord3dv); + SET_TexCoord3iv(dest, loopback_TexCoord3iv); + SET_TexCoord3sv(dest, loopback_TexCoord3sv); + SET_TexCoord4dv(dest, loopback_TexCoord4dv); + SET_TexCoord4iv(dest, loopback_TexCoord4iv); + SET_TexCoord4sv(dest, loopback_TexCoord4sv); + SET_Vertex2d(dest, loopback_Vertex2d); + SET_Vertex2i(dest, loopback_Vertex2i); + SET_Vertex2s(dest, loopback_Vertex2s); + SET_Vertex3d(dest, loopback_Vertex3d); + SET_Vertex3i(dest, loopback_Vertex3i); + SET_Vertex3s(dest, loopback_Vertex3s); + SET_Vertex4d(dest, loopback_Vertex4d); + SET_Vertex4i(dest, loopback_Vertex4i); + SET_Vertex4s(dest, loopback_Vertex4s); + SET_Vertex2dv(dest, loopback_Vertex2dv); + SET_Vertex2iv(dest, loopback_Vertex2iv); + SET_Vertex2sv(dest, loopback_Vertex2sv); + SET_Vertex3dv(dest, loopback_Vertex3dv); + SET_Vertex3iv(dest, loopback_Vertex3iv); + SET_Vertex3sv(dest, loopback_Vertex3sv); + SET_Vertex4dv(dest, loopback_Vertex4dv); + SET_Vertex4iv(dest, loopback_Vertex4iv); + SET_Vertex4sv(dest, loopback_Vertex4sv); + SET_MultiTexCoord1dARB(dest, loopback_MultiTexCoord1dARB); + SET_MultiTexCoord1dvARB(dest, loopback_MultiTexCoord1dvARB); + SET_MultiTexCoord1iARB(dest, loopback_MultiTexCoord1iARB); + SET_MultiTexCoord1ivARB(dest, loopback_MultiTexCoord1ivARB); + SET_MultiTexCoord1sARB(dest, loopback_MultiTexCoord1sARB); + SET_MultiTexCoord1svARB(dest, loopback_MultiTexCoord1svARB); + SET_MultiTexCoord2dARB(dest, loopback_MultiTexCoord2dARB); + SET_MultiTexCoord2dvARB(dest, loopback_MultiTexCoord2dvARB); + SET_MultiTexCoord2iARB(dest, loopback_MultiTexCoord2iARB); + SET_MultiTexCoord2ivARB(dest, loopback_MultiTexCoord2ivARB); + SET_MultiTexCoord2sARB(dest, loopback_MultiTexCoord2sARB); + SET_MultiTexCoord2svARB(dest, loopback_MultiTexCoord2svARB); + SET_MultiTexCoord3dARB(dest, loopback_MultiTexCoord3dARB); + SET_MultiTexCoord3dvARB(dest, loopback_MultiTexCoord3dvARB); + SET_MultiTexCoord3iARB(dest, loopback_MultiTexCoord3iARB); + SET_MultiTexCoord3ivARB(dest, loopback_MultiTexCoord3ivARB); + SET_MultiTexCoord3sARB(dest, loopback_MultiTexCoord3sARB); + SET_MultiTexCoord3svARB(dest, loopback_MultiTexCoord3svARB); + SET_MultiTexCoord4dARB(dest, loopback_MultiTexCoord4dARB); + SET_MultiTexCoord4dvARB(dest, loopback_MultiTexCoord4dvARB); + SET_MultiTexCoord4iARB(dest, loopback_MultiTexCoord4iARB); + SET_MultiTexCoord4ivARB(dest, loopback_MultiTexCoord4ivARB); + SET_MultiTexCoord4sARB(dest, loopback_MultiTexCoord4sARB); + SET_MultiTexCoord4svARB(dest, loopback_MultiTexCoord4svARB); + SET_EvalCoord2dv(dest, loopback_EvalCoord2dv); + SET_EvalCoord2fv(dest, loopback_EvalCoord2fv); + SET_EvalCoord2d(dest, loopback_EvalCoord2d); + SET_EvalCoord1dv(dest, loopback_EvalCoord1dv); + SET_EvalCoord1fv(dest, loopback_EvalCoord1fv); + SET_EvalCoord1d(dest, loopback_EvalCoord1d); + SET_Materialf(dest, loopback_Materialf); + SET_Materiali(dest, loopback_Materiali); + SET_Materialiv(dest, loopback_Materialiv); + SET_Rectd(dest, loopback_Rectd); + SET_Rectdv(dest, loopback_Rectdv); + SET_Rectfv(dest, loopback_Rectfv); + SET_Recti(dest, loopback_Recti); + SET_Rectiv(dest, loopback_Rectiv); + SET_Rects(dest, loopback_Rects); + SET_Rectsv(dest, loopback_Rectsv); + SET_FogCoorddEXT(dest, loopback_FogCoorddEXT); + SET_FogCoorddvEXT(dest, loopback_FogCoorddvEXT); + } + + if (ctx->API == API_OPENGL) { + SET_VertexAttrib1sNV(dest, loopback_VertexAttrib1sNV); + SET_VertexAttrib1dNV(dest, loopback_VertexAttrib1dNV); + SET_VertexAttrib2sNV(dest, loopback_VertexAttrib2sNV); + SET_VertexAttrib2dNV(dest, loopback_VertexAttrib2dNV); + SET_VertexAttrib3sNV(dest, loopback_VertexAttrib3sNV); + SET_VertexAttrib3dNV(dest, loopback_VertexAttrib3dNV); + SET_VertexAttrib4sNV(dest, loopback_VertexAttrib4sNV); + SET_VertexAttrib4dNV(dest, loopback_VertexAttrib4dNV); + SET_VertexAttrib4ubNV(dest, loopback_VertexAttrib4ubNV); + SET_VertexAttrib1svNV(dest, loopback_VertexAttrib1svNV); + SET_VertexAttrib1dvNV(dest, loopback_VertexAttrib1dvNV); + SET_VertexAttrib2svNV(dest, loopback_VertexAttrib2svNV); + SET_VertexAttrib2dvNV(dest, loopback_VertexAttrib2dvNV); + SET_VertexAttrib3svNV(dest, loopback_VertexAttrib3svNV); + SET_VertexAttrib3dvNV(dest, loopback_VertexAttrib3dvNV); + SET_VertexAttrib4svNV(dest, loopback_VertexAttrib4svNV); + SET_VertexAttrib4dvNV(dest, loopback_VertexAttrib4dvNV); + SET_VertexAttrib4ubvNV(dest, loopback_VertexAttrib4ubvNV); + SET_VertexAttribs1svNV(dest, loopback_VertexAttribs1svNV); + SET_VertexAttribs1fvNV(dest, loopback_VertexAttribs1fvNV); + SET_VertexAttribs1dvNV(dest, loopback_VertexAttribs1dvNV); + SET_VertexAttribs2svNV(dest, loopback_VertexAttribs2svNV); + SET_VertexAttribs2fvNV(dest, loopback_VertexAttribs2fvNV); + SET_VertexAttribs2dvNV(dest, loopback_VertexAttribs2dvNV); + SET_VertexAttribs3svNV(dest, loopback_VertexAttribs3svNV); + SET_VertexAttribs3fvNV(dest, loopback_VertexAttribs3fvNV); + SET_VertexAttribs3dvNV(dest, loopback_VertexAttribs3dvNV); + SET_VertexAttribs4svNV(dest, loopback_VertexAttribs4svNV); + SET_VertexAttribs4fvNV(dest, loopback_VertexAttribs4fvNV); + SET_VertexAttribs4dvNV(dest, loopback_VertexAttribs4dvNV); + SET_VertexAttribs4ubvNV(dest, loopback_VertexAttribs4ubvNV); + } + + if (ctx->API != API_OPENGLES2) { + SET_VertexAttrib1sARB(dest, loopback_VertexAttrib1sARB); + SET_VertexAttrib1dARB(dest, loopback_VertexAttrib1dARB); + SET_VertexAttrib2sARB(dest, loopback_VertexAttrib2sARB); + SET_VertexAttrib2dARB(dest, loopback_VertexAttrib2dARB); + SET_VertexAttrib3sARB(dest, loopback_VertexAttrib3sARB); + SET_VertexAttrib3dARB(dest, loopback_VertexAttrib3dARB); + SET_VertexAttrib4sARB(dest, loopback_VertexAttrib4sARB); + SET_VertexAttrib4dARB(dest, loopback_VertexAttrib4dARB); + SET_VertexAttrib1svARB(dest, loopback_VertexAttrib1svARB); + SET_VertexAttrib1dvARB(dest, loopback_VertexAttrib1dvARB); + SET_VertexAttrib2svARB(dest, loopback_VertexAttrib2svARB); + SET_VertexAttrib2dvARB(dest, loopback_VertexAttrib2dvARB); + SET_VertexAttrib3svARB(dest, loopback_VertexAttrib3svARB); + SET_VertexAttrib3dvARB(dest, loopback_VertexAttrib3dvARB); + SET_VertexAttrib4svARB(dest, loopback_VertexAttrib4svARB); + SET_VertexAttrib4dvARB(dest, loopback_VertexAttrib4dvARB); + SET_VertexAttrib4NubARB(dest, loopback_VertexAttrib4NubARB); + SET_VertexAttrib4NubvARB(dest, loopback_VertexAttrib4NubvARB); + SET_VertexAttrib4bvARB(dest, loopback_VertexAttrib4bvARB); + SET_VertexAttrib4ivARB(dest, loopback_VertexAttrib4ivARB); + SET_VertexAttrib4ubvARB(dest, loopback_VertexAttrib4ubvARB); + SET_VertexAttrib4usvARB(dest, loopback_VertexAttrib4usvARB); + SET_VertexAttrib4uivARB(dest, loopback_VertexAttrib4uivARB); + SET_VertexAttrib4NbvARB(dest, loopback_VertexAttrib4NbvARB); + SET_VertexAttrib4NsvARB(dest, loopback_VertexAttrib4NsvARB); + SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB); + SET_VertexAttrib4NivARB(dest, loopback_VertexAttrib4NivARB); + SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB); + + /* GL_EXT_gpu_shader4, GL 3.0 */ + SET_VertexAttribI1ivEXT(dest, loopback_VertexAttribI1iv); + SET_VertexAttribI1uivEXT(dest, loopback_VertexAttribI1uiv); + SET_VertexAttribI4bvEXT(dest, loopback_VertexAttribI4bv); + SET_VertexAttribI4svEXT(dest, loopback_VertexAttribI4sv); + SET_VertexAttribI4ubvEXT(dest, loopback_VertexAttribI4ubv); + SET_VertexAttribI4usvEXT(dest, loopback_VertexAttribI4usv); + } } diff --git a/mesalib/src/mesa/main/api_loopback.h b/mesalib/src/mesa/main/api_loopback.h index a99c30962..3e43286d2 100644 --- a/mesalib/src/mesa/main/api_loopback.h +++ b/mesalib/src/mesa/main/api_loopback.h @@ -32,6 +32,8 @@ struct _glapi_table; -extern void _mesa_loopback_init_api_table( struct _glapi_table *dest ); +extern void +_mesa_loopback_init_api_table(const struct gl_context *ctx, + struct _glapi_table *dest); #endif /* API_LOOPBACK_H */ diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 9c1e0bf52..efb8df894 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -2332,7 +2332,9 @@ _mesa_init_bufferobj_dispatch(struct gl_context *ctx, struct _glapi_table *disp) SET_GenBuffersARB(disp, _mesa_GenBuffersARB); SET_GetBufferParameterivARB(disp, _mesa_GetBufferParameterivARB); SET_GetBufferPointervARB(disp, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(disp, _mesa_GetBufferSubDataARB); + if (ctx->API != API_OPENGLES2) { + SET_GetBufferSubDataARB(disp, _mesa_GetBufferSubDataARB); + } SET_IsBufferARB(disp, _mesa_IsBufferARB); SET_MapBufferARB(disp, _mesa_MapBufferARB); SET_UnmapBufferARB(disp, _mesa_UnmapBufferARB); diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index abce52e58..c50504d19 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -797,8 +797,8 @@ init_attrib_groups(struct gl_context *ctx) /* Miscellaneous */ ctx->NewState = _NEW_ALL; ctx->NewDriverState = ~0; - ctx->ErrorValue = (GLenum) GL_NO_ERROR; - ctx->ResetStatus = (GLenum) GL_NO_ERROR; + ctx->ErrorValue = GL_NO_ERROR; + ctx->ResetStatus = GL_NO_ERROR; ctx->varying_vp_inputs = VERT_BIT_ALL; return GL_TRUE; @@ -832,8 +832,8 @@ update_default_objects(struct gl_context *ctx) * This helps prevents a segfault when someone calls a GL function without * first checking if the extension's supported. */ -static int -generic_nop(void) +int +_mesa_generic_nop(void) { GET_CURRENT_CONTEXT(ctx); _mesa_error(ctx, GL_INVALID_OPERATION, @@ -865,7 +865,7 @@ _mesa_alloc_dispatch_table(int size) _glapi_proc *entry = (_glapi_proc *) table; GLint i; for (i = 0; i < numEntries; i++) { - entry[i] = (_glapi_proc) generic_nop; + entry[i] = (_glapi_proc) _mesa_generic_nop; } } return table; @@ -921,6 +921,10 @@ _mesa_initialize_context(struct gl_context *ctx, ctx->WinSysDrawBuffer = NULL; ctx->WinSysReadBuffer = NULL; + if (_mesa_is_desktop_gl(ctx)) { + _mesa_override_gl_version(ctx); + } + /* misc one-time initializations */ one_time_init(ctx); @@ -995,7 +999,7 @@ _mesa_initialize_context(struct gl_context *ctx, switch (ctx->API) { case API_OPENGL: - ctx->Save = _mesa_create_save_table(); + ctx->Save = _mesa_create_save_table(ctx); if (!ctx->Save) { _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); free(ctx->Exec); @@ -1003,6 +1007,7 @@ _mesa_initialize_context(struct gl_context *ctx, } _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); + /* fall-through */ case API_OPENGL_CORE: break; case API_OPENGLES: diff --git a/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h index e2387521f..f0b4471b1 100644 --- a/mesalib/src/mesa/main/context.h +++ b/mesalib/src/mesa/main/context.h @@ -179,6 +179,8 @@ _mesa_finish(struct gl_context *ctx); extern void _mesa_flush(struct gl_context *ctx); +extern int +_mesa_generic_nop(void); extern void GLAPIENTRY _mesa_Finish( void ); diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index b663e364c..99519120a 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -9875,7 +9875,7 @@ exec_MultiModeDrawElementsIBM(const GLenum * mode, * struct. */ struct _glapi_table * -_mesa_create_save_table(void) +_mesa_create_save_table(const struct gl_context *ctx) { struct _glapi_table *table; @@ -9883,7 +9883,7 @@ _mesa_create_save_table(void) if (table == NULL) return NULL; - _mesa_loopback_init_api_table(table); + _mesa_loopback_init_api_table(ctx, table); /* GL 1.0 */ SET_Accum(table, save_Accum); @@ -10410,7 +10410,7 @@ _mesa_create_save_table(void) SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); /* GL_ARB_shader_objects */ - _mesa_init_shader_dispatch(table); /* Plug in glCreate/Delete/Get, etc */ + _mesa_init_shader_dispatch(ctx, table); /* Plug in glCreate/Delete/Get, etc */ SET_UseProgramObjectARB(table, save_UseProgramObjectARB); SET_Uniform1fARB(table, save_Uniform1fARB); SET_Uniform2fARB(table, save_Uniform2fARB); diff --git a/mesalib/src/mesa/main/dlist.h b/mesalib/src/mesa/main/dlist.h index 992a089f1..137245161 100644 --- a/mesalib/src/mesa/main/dlist.h +++ b/mesalib/src/mesa/main/dlist.h @@ -61,7 +61,7 @@ extern void _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dl extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt ); -extern struct _glapi_table *_mesa_create_save_table(void); +extern struct _glapi_table *_mesa_create_save_table(const struct gl_context *); extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt); diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c index 91b720373..52804bd8b 100644 --- a/mesalib/src/mesa/main/image.c +++ b/mesalib/src/mesa/main/image.c @@ -822,7 +822,7 @@ clip_left_or_bottom(GLint *srcX0, GLint *srcX1, /* chop off [0, t] part */ ASSERT(t >= 0.0 && t <= 1.0); *dstX0 = minValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */ + bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); } else if (*dstX1 < minValue) { @@ -832,7 +832,7 @@ clip_left_or_bottom(GLint *srcX0, GLint *srcX1, /* chop off [0, t] part */ ASSERT(t >= 0.0 && t <= 1.0); *dstX1 = minValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; + bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F; *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); } } diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index c2ec1fa42..6ee41f2b6 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -1686,25 +1686,29 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) * Plug in shader-related functions into API dispatch table. */ void -_mesa_init_shader_dispatch(struct _glapi_table *exec) +_mesa_init_shader_dispatch(const struct gl_context *ctx, + struct _glapi_table *exec) { #if FEATURE_GL /* GL_ARB_vertex/fragment_shader */ - SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); - SET_GetHandleARB(exec, _mesa_GetHandleARB); - SET_DetachObjectARB(exec, _mesa_DetachObjectARB); - SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); + if (ctx->API != API_OPENGLES2) { + SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); + SET_GetHandleARB(exec, _mesa_GetHandleARB); + SET_DetachObjectARB(exec, _mesa_DetachObjectARB); + SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); + SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); + SET_AttachObjectARB(exec, _mesa_AttachObjectARB); + SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); + SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); + SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); + SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); + } + SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB); SET_CompileShaderARB(exec, _mesa_CompileShaderARB); - SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); - SET_AttachObjectARB(exec, _mesa_AttachObjectARB); SET_LinkProgramARB(exec, _mesa_LinkProgramARB); SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB); SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB); - SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); - SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); - SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); - SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB); /* OpenGL 2.0 */ @@ -1727,23 +1731,32 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec) SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB); SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB); - SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB); + if (ctx->API != API_OPENGLES2) { + SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB); - SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); - SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); - SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); + SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); + SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); + SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); + } /* GL_EXT_gpu_shader4 / GL 3.0 */ - SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); - SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); + if (ctx->API != API_OPENGLES2) { + SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); + } + if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { + SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); + } /* GL_ARB_ES2_compatibility */ SET_ReleaseShaderCompiler(exec, _mesa_ReleaseShaderCompiler); SET_GetShaderPrecisionFormat(exec, _mesa_GetShaderPrecisionFormat); + SET_ShaderBinary(exec, _mesa_ShaderBinary); /* GL_ARB_blend_func_extended */ - SET_BindFragDataLocationIndexed(exec, _mesa_BindFragDataLocationIndexed); - SET_GetFragDataIndex(exec, _mesa_GetFragDataIndex); + if (ctx->API != API_OPENGLES2) { + SET_BindFragDataLocationIndexed(exec, _mesa_BindFragDataLocationIndexed); + SET_GetFragDataIndex(exec, _mesa_GetFragDataIndex); + } #endif /* FEATURE_GL */ } diff --git a/mesalib/src/mesa/main/shaderapi.h b/mesalib/src/mesa/main/shaderapi.h index 00c7d7f2a..d6382e04a 100644 --- a/mesalib/src/mesa/main/shaderapi.h +++ b/mesalib/src/mesa/main/shaderapi.h @@ -51,7 +51,8 @@ _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, const char *caller); extern void -_mesa_init_shader_dispatch(struct _glapi_table *exec); +_mesa_init_shader_dispatch(const struct gl_context *ctx, + struct _glapi_table *exec); extern unsigned _mesa_count_active_attribs(struct gl_shader_program *shProg); diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index 04cf0a2b0..39fac1534 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -804,7 +804,8 @@ _mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex, * Plug in shader uniform-related functions into API dispatch table. */ void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) +_mesa_init_shader_uniform_dispatch(const struct gl_context *ctx, + struct _glapi_table *exec) { #if FEATURE_GL SET_Uniform1fARB(exec, _mesa_Uniform1fARB); @@ -833,38 +834,39 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) SET_GetUniformivARB(exec, _mesa_GetUniformivARB); /* OpenGL 2.1 */ - SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); - - /* OpenGL 3.0 */ - SET_Uniform1uiEXT(exec, _mesa_Uniform1ui); - SET_Uniform2uiEXT(exec, _mesa_Uniform2ui); - SET_Uniform3uiEXT(exec, _mesa_Uniform3ui); - SET_Uniform4uiEXT(exec, _mesa_Uniform4ui); - SET_Uniform1uivEXT(exec, _mesa_Uniform1uiv); - SET_Uniform2uivEXT(exec, _mesa_Uniform2uiv); - SET_Uniform3uivEXT(exec, _mesa_Uniform3uiv); - SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv); - SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv); - - /* GL_ARB_robustness */ - SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB); - SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB); - SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB); - SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */ - - /* GL_ARB_uniform_buffer_object / GL 3.1 */ - SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex); - SET_GetUniformIndices(exec, _mesa_GetUniformIndices); - SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv); - SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv); - SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName); - SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName); - SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding); - + if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { + SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); + SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); + SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); + SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); + SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); + SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); + + /* OpenGL 3.0 */ + SET_Uniform1uiEXT(exec, _mesa_Uniform1ui); + SET_Uniform2uiEXT(exec, _mesa_Uniform2ui); + SET_Uniform3uiEXT(exec, _mesa_Uniform3ui); + SET_Uniform4uiEXT(exec, _mesa_Uniform4ui); + SET_Uniform1uivEXT(exec, _mesa_Uniform1uiv); + SET_Uniform2uivEXT(exec, _mesa_Uniform2uiv); + SET_Uniform3uivEXT(exec, _mesa_Uniform3uiv); + SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv); + SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv); + + /* GL_ARB_robustness */ + SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB); + SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB); + SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB); + SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */ + + /* GL_ARB_uniform_buffer_object / GL 3.1 */ + SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex); + SET_GetUniformIndices(exec, _mesa_GetUniformIndices); + SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv); + SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv); + SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName); + SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName); + SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding); + } #endif /* FEATURE_GL */ } diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index e84964c6f..3fe7d4402 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -227,7 +227,8 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg, char *errMsg, size_t errMsgLength); extern void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); +_mesa_init_shader_uniform_dispatch(const struct gl_context *ctx, + struct _glapi_table *exec); extern const struct gl_program_parameter * get_uniform_parameter(struct gl_shader_program *shProg, GLint index); diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 7ee662714..8d69c3a05 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -28,30 +28,25 @@ /*#include "git_sha1.h"*/ /** - * Override the context's GL version if the environment variable - * MESA_GL_VERSION_OVERRIDE is set. Valid values of MESA_GL_VERSION_OVERRIDE - * are point-separated version numbers, such as "3.0". + * Scans 'string' to see if it ends with 'ending'. */ -static void -override_version(struct gl_context *ctx) +static GLboolean +check_for_ending(const char *string, const char *ending) { - const char *env_var = "MESA_GL_VERSION_OVERRIDE"; - const char *version; - int n; - int major, minor; + int len1, len2; - version = getenv(env_var); - if (!version) { - return; - } + len1 = strlen(string); + len2 = strlen(ending); - n = sscanf(version, "%u.%u", &major, &minor); - if (n != 2) { - fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); - return; + if (len2 > len1) { + return GL_FALSE; } - ctx->Version = major * 10 + minor; + if (strcmp(string + (len1 - len2), ending) == 0) { + return GL_TRUE; + } else { + return GL_FALSE; + } } /** @@ -65,13 +60,64 @@ create_version_string(struct gl_context *ctx, const char *prefix) ctx->VersionString = malloc(max); if (ctx->VersionString) { _mesa_snprintf(ctx->VersionString, max, - "%s%u.%u Mesa " MESA_VERSION_STRING + "%s%u.%u%s Mesa " MESA_VERSION_STRING #ifdef MESA_GIT_SHA1 " (" MESA_GIT_SHA1 ")" #endif , prefix, - ctx->Version / 10, ctx->Version % 10); + ctx->Version / 10, ctx->Version % 10, + (ctx->API == API_OPENGL_CORE) ? " (Core Profile)" : "" + ); + } +} + +/** + * Override the context's version and/or API type if the + * environment variable MESA_GL_VERSION_OVERRIDE is set. + * + * Example uses of MESA_GL_VERSION_OVERRIDE: + * + * 2.1: select a compatibility (non-Core) profile with GL version 2.1 + * 3.0: select a compatibility (non-Core) profile with GL version 3.0 + * 3.0FC: select a Core+Forward Compatible profile with GL version 3.0 + * 3.1: select a Core profile with GL version 3.1 + * 3.1FC: select a Core+Forward Compatible profile with GL version 3.1 + */ +void +_mesa_override_gl_version(struct gl_context *ctx) +{ + const char *env_var = "MESA_GL_VERSION_OVERRIDE"; + const char *version; + int n; + int major, minor; + GLboolean fc_suffix; + + version = getenv(env_var); + if (!version) { + return; + } + + fc_suffix = check_for_ending(version, "FC"); + + n = sscanf(version, "%u.%u", &major, &minor); + if (n != 2) { + fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); + } else { + ctx->Version = major * 10 + minor; + if (ctx->Version < 30 && fc_suffix) { + fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); + } else { + if (ctx->Version >= 30 && fc_suffix) { + ctx->API = API_OPENGL_CORE; + ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; + } else if (ctx->Version >= 31) { + ctx->API = API_OPENGL_CORE; + } else { + ctx->API = API_OPENGL; + } + create_version_string(ctx, ""); + } } } @@ -242,8 +288,6 @@ compute_version(struct gl_context *ctx) ctx->Version = major * 10 + minor; - override_version(ctx); - create_version_string(ctx, ""); } diff --git a/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h index f0ba6f267..1aab37d69 100644 --- a/mesalib/src/mesa/main/version.h +++ b/mesalib/src/mesa/main/version.h @@ -46,6 +46,9 @@ extern void _mesa_compute_version(struct gl_context *ctx); extern void +_mesa_override_gl_version(struct gl_context *ctx); + +extern void _mesa_override_glsl_version(struct gl_context *ctx); #endif /* VERSION_H */ diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c index 725ac2047..aa6cf286a 100644 --- a/mesalib/src/mesa/main/vtxfmt.c +++ b/mesalib/src/mesa/main/vtxfmt.c @@ -46,7 +46,7 @@ static void install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, const GLvertexformat *vfmt) { - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { _mesa_install_arrayelt_vtxfmt(tab, vfmt); SET_Color3f(tab, vfmt->Color3f); SET_Color3fv(tab, vfmt->Color3fv); @@ -59,7 +59,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, _mesa_install_eval_vtxfmt(tab, vfmt); } - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); SET_Indexf(tab, vfmt->Indexf); @@ -95,9 +95,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, if (ctx->API == API_OPENGL) { _mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */ - } - if (ctx->API != API_OPENGL_CORE) { SET_Begin(tab, vfmt->Begin); SET_End(tab, vfmt->End); SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV); @@ -107,33 +105,48 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_DrawArrays(tab, vfmt->DrawArrays); SET_DrawElements(tab, vfmt->DrawElements); - SET_DrawRangeElements(tab, vfmt->DrawRangeElements); + if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { + SET_DrawRangeElements(tab, vfmt->DrawRangeElements); + } + SET_MultiDrawElementsEXT(tab, vfmt->MultiDrawElementsEXT); - SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex); - SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex); - SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex); - SET_DrawArraysInstancedARB(tab, vfmt->DrawArraysInstanced); - SET_DrawArraysInstancedBaseInstance(tab, vfmt->DrawArraysInstancedBaseInstance); - SET_DrawElementsInstancedARB(tab, vfmt->DrawElementsInstanced); - SET_DrawElementsInstancedBaseInstance(tab, vfmt->DrawElementsInstancedBaseInstance); - SET_DrawElementsInstancedBaseVertex(tab, vfmt->DrawElementsInstancedBaseVertex); - SET_DrawElementsInstancedBaseVertexBaseInstance(tab, vfmt->DrawElementsInstancedBaseVertexBaseInstance); - SET_DrawTransformFeedback(tab, vfmt->DrawTransformFeedback); - SET_DrawTransformFeedbackStream(tab, vfmt->DrawTransformFeedbackStream); - SET_DrawTransformFeedbackInstanced(tab, - vfmt->DrawTransformFeedbackInstanced); - SET_DrawTransformFeedbackStreamInstanced(tab, - vfmt->DrawTransformFeedbackStreamInstanced); + + if (ctx->API != API_OPENGLES2) { + SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex); + SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex); + SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex); + SET_DrawArraysInstancedBaseInstance(tab, vfmt->DrawArraysInstancedBaseInstance); + SET_DrawElementsInstancedBaseInstance(tab, vfmt->DrawElementsInstancedBaseInstance); + SET_DrawElementsInstancedBaseVertex(tab, vfmt->DrawElementsInstancedBaseVertex); + SET_DrawElementsInstancedBaseVertexBaseInstance(tab, vfmt->DrawElementsInstancedBaseVertexBaseInstance); + } + + if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { + SET_DrawArraysInstancedARB(tab, vfmt->DrawArraysInstanced); + SET_DrawElementsInstancedARB(tab, vfmt->DrawElementsInstanced); + } + + if (ctx->API != API_OPENGLES2) { + SET_DrawTransformFeedback(tab, vfmt->DrawTransformFeedback); + SET_DrawTransformFeedbackStream(tab, vfmt->DrawTransformFeedbackStream); + SET_DrawTransformFeedbackInstanced(tab, + vfmt->DrawTransformFeedbackInstanced); + SET_DrawTransformFeedbackStreamInstanced(tab, + vfmt->DrawTransformFeedbackStreamInstanced); + } /* GL_NV_vertex_program */ - SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); - SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); - SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); - SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); - SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); - SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); - SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); - SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); + if (ctx->API == API_OPENGL) { + SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); + SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); + SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); + SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); + SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); + SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); + SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); + SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); + } + SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB); SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB); SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB); @@ -144,23 +157,28 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB); /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ - SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i); - SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i); - SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i); - SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i); - SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv); - SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv); - SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv); - - SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui); - SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui); - SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui); - SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui); - SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv); - SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv); - SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); - - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API != API_OPENGLES2) { + SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i); + SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i); + SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i); + SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv); + SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv); + + SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui); + SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui); + SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui); + SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv); + SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv); + } + + if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) { + SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i); + SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv); + SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui); + SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); + } + + if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) { /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */ SET_VertexP2ui(tab, vfmt->VertexP2ui); SET_VertexP2uiv(tab, vfmt->VertexP2uiv); @@ -199,15 +217,17 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_SecondaryColorP3uiv(tab, vfmt->SecondaryColorP3uiv); } - SET_VertexAttribP1ui(tab, vfmt->VertexAttribP1ui); - SET_VertexAttribP2ui(tab, vfmt->VertexAttribP2ui); - SET_VertexAttribP3ui(tab, vfmt->VertexAttribP3ui); - SET_VertexAttribP4ui(tab, vfmt->VertexAttribP4ui); + if (ctx->API != API_OPENGLES2) { + SET_VertexAttribP1ui(tab, vfmt->VertexAttribP1ui); + SET_VertexAttribP2ui(tab, vfmt->VertexAttribP2ui); + SET_VertexAttribP3ui(tab, vfmt->VertexAttribP3ui); + SET_VertexAttribP4ui(tab, vfmt->VertexAttribP4ui); - SET_VertexAttribP1uiv(tab, vfmt->VertexAttribP1uiv); - SET_VertexAttribP2uiv(tab, vfmt->VertexAttribP2uiv); - SET_VertexAttribP3uiv(tab, vfmt->VertexAttribP3uiv); - SET_VertexAttribP4uiv(tab, vfmt->VertexAttribP4uiv); + SET_VertexAttribP1uiv(tab, vfmt->VertexAttribP1uiv); + SET_VertexAttribP2uiv(tab, vfmt->VertexAttribP2uiv); + SET_VertexAttribP3uiv(tab, vfmt->VertexAttribP3uiv); + SET_VertexAttribP4uiv(tab, vfmt->VertexAttribP4uiv); + } } diff --git a/mesalib/src/mesa/state_tracker/st_cb_blit.c b/mesalib/src/mesa/state_tracker/st_cb_blit.c index c2d756813..603c8d4b4 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_blit.c +++ b/mesalib/src/mesa/state_tracker/st_cb_blit.c @@ -42,6 +42,7 @@ #include "st_atom.h" #include "util/u_blit.h" +#include "util/u_format.h" void @@ -60,84 +61,6 @@ st_destroy_blit(struct st_context *st) static void -st_BlitFramebuffer_resolve(struct gl_context *ctx, - GLbitfield mask, - struct pipe_resolve_info *info) -{ - const GLbitfield depthStencil = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; - - struct st_context *st = st_context(ctx); - - struct st_renderbuffer *srcRb, *dstRb; - - if (mask & GL_COLOR_BUFFER_BIT) { - srcRb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); - dstRb = st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]); - - info->mask = PIPE_MASK_RGBA; - - info->src.res = srcRb->texture; - info->src.layer = srcRb->surface->u.tex.first_layer; - info->dst.res = dstRb->texture; - info->dst.level = dstRb->surface->u.tex.level; - info->dst.layer = dstRb->surface->u.tex.first_layer; - - st->pipe->resource_resolve(st->pipe, info); - } - - if (mask & depthStencil) { - struct gl_renderbuffer_attachment *srcDepth, *srcStencil; - struct gl_renderbuffer_attachment *dstDepth, *dstStencil; - boolean combined; - - srcDepth = &ctx->ReadBuffer->Attachment[BUFFER_DEPTH]; - dstDepth = &ctx->DrawBuffer->Attachment[BUFFER_DEPTH]; - srcStencil = &ctx->ReadBuffer->Attachment[BUFFER_STENCIL]; - dstStencil = &ctx->DrawBuffer->Attachment[BUFFER_STENCIL]; - - combined = - st_is_depth_stencil_combined(srcDepth, srcStencil) && - st_is_depth_stencil_combined(dstDepth, dstStencil); - - if ((mask & GL_DEPTH_BUFFER_BIT) || combined) { - /* resolve depth and, if combined and requested, stencil as well */ - srcRb = st_renderbuffer(srcDepth->Renderbuffer); - dstRb = st_renderbuffer(dstDepth->Renderbuffer); - - info->mask = (mask & GL_DEPTH_BUFFER_BIT) ? PIPE_MASK_Z : 0; - if (combined && (mask & GL_STENCIL_BUFFER_BIT)) { - mask &= ~GL_STENCIL_BUFFER_BIT; - info->mask |= PIPE_MASK_S; - } - - info->src.res = srcRb->texture; - info->src.layer = srcRb->surface->u.tex.first_layer; - info->dst.res = dstRb->texture; - info->dst.level = dstRb->surface->u.tex.level; - info->dst.layer = dstRb->surface->u.tex.first_layer; - - st->pipe->resource_resolve(st->pipe, info); - } - - if (mask & GL_STENCIL_BUFFER_BIT) { - /* resolve separate stencil buffer */ - srcRb = st_renderbuffer(srcStencil->Renderbuffer); - dstRb = st_renderbuffer(dstStencil->Renderbuffer); - - info->mask = PIPE_MASK_S; - - info->src.res = srcRb->texture; - info->src.layer = srcRb->surface->u.tex.first_layer; - info->dst.res = dstRb->texture; - info->dst.level = dstRb->surface->u.tex.level; - info->dst.layer = dstRb->surface->u.tex.first_layer; - - st->pipe->resource_resolve(st->pipe, info); - } - } -} - -static void st_BlitFramebuffer(struct gl_context *ctx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, @@ -147,22 +70,62 @@ st_BlitFramebuffer(struct gl_context *ctx, GL_STENCIL_BUFFER_BIT); struct st_context *st = st_context(ctx); const uint pFilter = ((filter == GL_NEAREST) - ? PIPE_TEX_MIPFILTER_NEAREST - : PIPE_TEX_MIPFILTER_LINEAR); + ? PIPE_TEX_FILTER_NEAREST + : PIPE_TEX_FILTER_LINEAR); struct gl_framebuffer *readFB = ctx->ReadBuffer; struct gl_framebuffer *drawFB = ctx->DrawBuffer; + struct { + GLint srcX0, srcY0, srcX1, srcY1; + GLint dstX0, dstY0, dstX1, dstY1; + } clip; + struct pipe_blit_info blit; st_validate_state(st); - if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1, - &dstX0, &dstY0, &dstX1, &dstY1)) { + clip.srcX0 = srcX0; + clip.srcY0 = srcY0; + clip.srcX1 = srcX1; + clip.srcY1 = srcY1; + clip.dstX0 = dstX0; + clip.dstY0 = dstY0; + clip.dstX1 = dstX1; + clip.dstY1 = dstY1; + + /* NOTE: If the src and dst dimensions don't match, we cannot simply adjust + * the integer coordinates to account for clipping (or scissors) because that + * would make us cut off fractional parts, affecting the result of the blit. + * + * XXX: This should depend on mask ! + */ + if (!_mesa_clip_blit(ctx, + &clip.srcX0, &clip.srcY0, &clip.srcX1, &clip.srcY1, + &clip.dstX0, &clip.dstY0, &clip.dstX1, &clip.dstY1)) { return; /* nothing to draw/blit */ } + blit.scissor_enable = + (dstX0 != clip.dstX0) || + (dstY0 != clip.dstY0) || + (dstX1 != clip.dstX1) || + (dstY1 != clip.dstY1); if (st_fb_orientation(drawFB) == Y_0_TOP) { /* invert Y for dest */ dstY0 = drawFB->Height - dstY0; dstY1 = drawFB->Height - dstY1; + /* invert Y for clip */ + clip.dstY0 = drawFB->Height - clip.dstY0; + clip.dstY1 = drawFB->Height - clip.dstY1; + } + if (blit.scissor_enable) { + blit.scissor.minx = MIN2(clip.dstX0, clip.dstX1); + blit.scissor.miny = MIN2(clip.dstY0, clip.dstY1); + blit.scissor.maxx = MAX2(clip.dstX0, clip.dstX1); + blit.scissor.maxy = MAX2(clip.dstY0, clip.dstY1); +#if 0 + debug_printf("scissor = (%i,%i)-(%i,%i)\n", + blit.scissor.minx,blit.scissor.miny, + blit.scissor.maxx,blit.scissor.maxy); +#endif } if (st_fb_orientation(readFB) == Y_0_TOP) { @@ -171,43 +134,6 @@ st_BlitFramebuffer(struct gl_context *ctx, srcY1 = readFB->Height - srcY1; } - /* Disable conditional rendering. */ - if (st->render_condition) { - st->pipe->render_condition(st->pipe, NULL, 0); - } - - if (readFB->Visual.sampleBuffers > drawFB->Visual.sampleBuffers && - readFB->Visual.samples > 1) { - struct pipe_resolve_info info; - - if (dstX0 < dstX1) { - info.dst.x0 = dstX0; - info.dst.x1 = dstX1; - info.src.x0 = srcX0; - info.src.x1 = srcX1; - } else { - info.dst.x0 = dstX1; - info.dst.x1 = dstX0; - info.src.x0 = srcX1; - info.src.x1 = srcX0; - } - if (dstY0 < dstY1) { - info.dst.y0 = dstY0; - info.dst.y1 = dstY1; - info.src.y0 = srcY0; - info.src.y1 = srcY1; - } else { - info.dst.y0 = dstY1; - info.dst.y1 = dstY0; - info.src.y0 = srcY1; - info.src.y1 = srcY0; - } - - st_BlitFramebuffer_resolve(ctx, mask, &info); /* filter doesn't apply */ - - goto done; - } - if (srcY0 > srcY1 && dstY0 > dstY1) { /* Both src and dst are upside down. Swap Y to make it * right-side up to increase odds of using a fast path. @@ -222,25 +148,64 @@ st_BlitFramebuffer(struct gl_context *ctx, dstY1 = tmp; } + blit.src.box.depth = 1; + blit.dst.box.depth = 1; + + /* Destination dimensions have to be positive: */ + if (dstX0 < dstX1) { + blit.dst.box.x = dstX0; + blit.src.box.x = srcX0; + blit.dst.box.width = dstX1 - dstX0; + blit.src.box.width = srcX1 - srcX0; + } else { + blit.dst.box.x = dstX1; + blit.src.box.x = srcX1; + blit.dst.box.width = dstX0 - dstX1; + blit.src.box.width = srcX0 - srcX1; + } + if (dstY0 < dstY1) { + blit.dst.box.y = dstY0; + blit.src.box.y = srcY0; + blit.dst.box.height = dstY1 - dstY0; + blit.src.box.height = srcY1 - srcY0; + } else { + blit.dst.box.y = dstY1; + blit.src.box.y = srcY1; + blit.dst.box.height = dstY0 - dstY1; + blit.src.box.height = srcY0 - srcY1; + } + + blit.filter = pFilter; + if (mask & GL_COLOR_BUFFER_BIT) { struct gl_renderbuffer_attachment *srcAtt = &readFB->Attachment[readFB->_ColorReadBufferIndex]; - if(srcAtt->Type == GL_TEXTURE) { + blit.mask = PIPE_MASK_RGBA; + + if (srcAtt->Type == GL_TEXTURE) { struct st_texture_object *srcObj = st_texture_object(srcAtt->Texture); struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[0]); struct pipe_surface *dstSurf = dstRb->surface; - if (!srcObj->pt) - goto done; + assert(srcObj->pt); + if (!srcObj->pt) { + return; + } + + blit.dst.resource = dstSurf->texture; + blit.dst.level = dstSurf->u.tex.level; + blit.dst.box.z = dstSurf->u.tex.first_layer; + blit.dst.format = util_format_linear(dstSurf->format); - util_blit_pixels(st->blit, srcObj->pt, srcAtt->TextureLevel, - srcX0, srcY0, srcX1, srcY1, - srcAtt->Zoffset + srcAtt->CubeMapFace, - dstSurf, dstX0, dstY0, dstX1, dstY1, - 0.0, pFilter, TGSI_WRITEMASK_XYZW, 0); + blit.src.resource = srcObj->pt; + blit.src.level = srcAtt->TextureLevel; + blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace; + blit.src.format = util_format_linear(srcObj->pt->format); + + st->pipe->blit(st->pipe, &blit); } else { struct st_renderbuffer *srcRb = @@ -250,12 +215,17 @@ st_BlitFramebuffer(struct gl_context *ctx, struct pipe_surface *srcSurf = srcRb->surface; struct pipe_surface *dstSurf = dstRb->surface; - util_blit_pixels(st->blit, - srcRb->texture, srcSurf->u.tex.level, - srcX0, srcY0, srcX1, srcY1, - srcSurf->u.tex.first_layer, - dstSurf, dstX0, dstY0, dstX1, dstY1, - 0.0, pFilter, TGSI_WRITEMASK_XYZW, 0); + blit.dst.resource = dstSurf->texture; + blit.dst.level = dstSurf->u.tex.level; + blit.dst.box.z = dstSurf->u.tex.first_layer; + blit.dst.format = util_format_linear(dstSurf->format); + + blit.src.resource = srcSurf->texture; + blit.src.level = srcSurf->u.tex.level; + blit.src.box.z = srcSurf->u.tex.first_layer; + blit.src.format = util_format_linear(srcSurf->format); + + st->pipe->blit(st->pipe, &blit); } } @@ -286,64 +256,62 @@ st_BlitFramebuffer(struct gl_context *ctx, struct pipe_surface *dstStencilSurf = dstStencilRb ? dstStencilRb->surface : NULL; - if ((mask & depthStencil) == depthStencil && - st_is_depth_stencil_combined(srcDepth, srcStencil) && + if (st_is_depth_stencil_combined(srcDepth, srcStencil) && st_is_depth_stencil_combined(dstDepth, dstStencil)) { - - /* Blitting depth and stencil values between combined - * depth/stencil buffers. This is the ideal case for such buffers. - */ - util_blit_pixels(st->blit, - srcDepthRb->texture, - srcDepthRb->surface->u.tex.level, - srcX0, srcY0, srcX1, srcY1, - srcDepthRb->surface->u.tex.first_layer, - dstDepthSurf, dstX0, dstY0, dstX1, dstY1, - 0.0, pFilter, 0, - BLIT_WRITEMASK_Z | - (st->has_stencil_export ? BLIT_WRITEMASK_STENCIL - : 0)); - - if (!st->has_stencil_export) { - _mesa_problem(ctx, "st_BlitFramebuffer(STENCIL) " - "software fallback not implemented"); - } + blit.mask = 0; + if (mask & GL_DEPTH_BUFFER_BIT) + blit.mask |= PIPE_MASK_Z; + if (mask & GL_STENCIL_BUFFER_BIT) + blit.mask |= PIPE_MASK_S; + + blit.dst.resource = dstDepthSurf->texture; + blit.dst.level = dstDepthSurf->u.tex.level; + blit.dst.box.z = dstDepthSurf->u.tex.first_layer; + blit.dst.format = dstDepthSurf->format; + + blit.src.resource = srcDepthRb->texture; + blit.src.level = srcDepthRb->surface->u.tex.level; + blit.src.box.z = srcDepthRb->surface->u.tex.first_layer; + blit.src.format = srcDepthRb->surface->format; + + st->pipe->blit(st->pipe, &blit); } else { /* blitting depth and stencil separately */ if (mask & GL_DEPTH_BUFFER_BIT) { - util_blit_pixels(st->blit, srcDepthRb->texture, - srcDepthRb->surface->u.tex.level, - srcX0, srcY0, srcX1, srcY1, - srcDepthRb->surface->u.tex.first_layer, - dstDepthSurf, dstX0, dstY0, dstX1, dstY1, - 0.0, pFilter, 0, BLIT_WRITEMASK_Z); + blit.mask = PIPE_MASK_Z; + + blit.dst.resource = dstDepthSurf->texture; + blit.dst.level = dstDepthSurf->u.tex.level; + blit.dst.box.z = dstDepthSurf->u.tex.first_layer; + blit.dst.format = dstDepthSurf->format; + + blit.src.resource = srcDepthRb->texture; + blit.src.level = srcDepthRb->surface->u.tex.level; + blit.src.box.z = srcDepthRb->surface->u.tex.first_layer; + blit.src.format = srcDepthRb->surface->format; + + st->pipe->blit(st->pipe, &blit); } if (mask & GL_STENCIL_BUFFER_BIT) { - if (st->has_stencil_export) { - util_blit_pixels(st->blit, srcStencilRb->texture, - srcStencilRb->surface->u.tex.level, - srcX0, srcY0, srcX1, srcY1, - srcStencilRb->surface->u.tex.first_layer, - dstStencilSurf, dstX0, dstY0, dstX1, dstY1, - 0.0, pFilter, 0, BLIT_WRITEMASK_STENCIL); - } - else { - _mesa_problem(ctx, "st_BlitFramebuffer(STENCIL) " - "software fallback not implemented"); - } + blit.mask = PIPE_MASK_S; + + blit.dst.resource = dstStencilSurf->texture; + blit.dst.level = dstStencilSurf->u.tex.level; + blit.dst.box.z = dstStencilSurf->u.tex.first_layer; + blit.dst.format = dstStencilSurf->format; + + blit.src.resource = srcStencilRb->texture; + blit.src.level = srcStencilRb->surface->u.tex.level; + blit.src.box.z = srcStencilRb->surface->u.tex.first_layer; + blit.src.format = srcStencilRb->surface->format; + + st->pipe->blit(st->pipe, &blit); } } } - -done: - /* Restore conditional rendering state. */ - if (st->render_condition) { - st->pipe->render_condition(st->pipe, st->render_condition, - st->condition_mode); - } } diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 5634a3e6e..473ff3a94 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -575,61 +575,40 @@ decompress_with_blit(struct gl_context * ctx, struct pipe_context *pipe = st->pipe; struct st_texture_image *stImage = st_texture_image(texImage); struct st_texture_object *stObj = st_texture_object(texImage->TexObject); - struct pipe_sampler_view *src_view; const GLuint width = texImage->Width; const GLuint height = texImage->Height; - struct pipe_surface *dst_surface; struct pipe_resource *dst_texture; struct pipe_transfer *tex_xfer; - unsigned bind = (PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */ - PIPE_BIND_TRANSFER_READ); + struct pipe_blit_info blit; + unsigned bind = (PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_READ); /* create temp / dest surface */ - if (!util_create_rgba_surface(pipe, width, height, bind, - &dst_texture, &dst_surface)) { - _mesa_problem(ctx, "util_create_rgba_surface() failed " + if (!util_create_rgba_texture(pipe, width, height, bind, + &dst_texture)) { + _mesa_problem(ctx, "util_create_rgba_texture() failed " "in decompress_with_blit()"); return; } - /* Disable conditional rendering. */ - if (st->render_condition) { - pipe->render_condition(pipe, NULL, 0); - } - - /* Create sampler view that limits fetches to the source mipmap level */ - { - struct pipe_sampler_view sv_temp; - - u_sampler_view_default_template(&sv_temp, stObj->pt, stObj->pt->format); - - sv_temp.format = util_format_linear(sv_temp.format); - sv_temp.u.tex.first_level = - sv_temp.u.tex.last_level = texImage->Level; - - src_view = pipe->create_sampler_view(pipe, stObj->pt, &sv_temp); - if (!src_view) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - return; - } - } + blit.src.resource = stObj->pt; + blit.src.level = texImage->Level; + blit.src.format = util_format_linear(stObj->pt->format); + blit.dst.resource = dst_texture; + blit.dst.level = 0; + blit.dst.format = dst_texture->format; + blit.src.box.x = blit.dst.box.x = 0; + blit.src.box.y = blit.dst.box.y = 0; + blit.src.box.z = 0; /* XXX compressed array textures? */ + blit.dst.box.z = 0; + blit.src.box.width = blit.dst.box.width = width; + blit.src.box.height = blit.dst.box.height = height; + blit.src.box.depth = blit.dst.box.depth = 1; + blit.mask = PIPE_MASK_RGBA; + blit.filter = PIPE_TEX_FILTER_NEAREST; + blit.scissor_enable = FALSE; /* blit/render/decompress */ - util_blit_pixels_tex(st->blit, - src_view, /* pipe_resource (src) */ - 0, 0, /* src x0, y0 */ - width, height, /* src x1, y1 */ - dst_surface, /* pipe_surface (dst) */ - 0, 0, /* dst x0, y0 */ - width, height, /* dst x1, y1 */ - 0.0, /* z */ - PIPE_TEX_MIPFILTER_NEAREST); - - /* Restore conditional rendering state. */ - if (st->render_condition) { - pipe->render_condition(pipe, st->render_condition, - st->condition_mode); - } + st->pipe->blit(st->pipe, &blit); /* map the dst_surface so we can read from it */ tex_xfer = pipe_get_transfer(pipe, @@ -691,10 +670,7 @@ end: pipe->transfer_destroy(pipe, tex_xfer); - /* destroy the temp / dest surface */ - util_destroy_rgba_surface(dst_texture, dst_surface); - - pipe_sampler_view_release(pipe, &src_view); + pipe_resource_reference(&dst_texture, NULL); } |