diff options
author | Luca Barbieri <luca@luca-barbieri.com> | 2010-08-06 07:39:21 +0200 |
---|---|---|
committer | Luca Barbieri <luca@luca-barbieri.com> | 2010-08-20 12:04:03 +0200 |
commit | 3070e0ea41ab4aa24804e8fd26895924a8583830 (patch) | |
tree | c9f0edec8e9a61a642f4d5068ea7a9047eb11ec5 /src/mesa/state_tracker/st_cb_bitmap.c | |
parent | 4a9bfb24eb907080b2e3e49215ad9912758d56c6 (diff) | |
download | external_mesa3d-3070e0ea41ab4aa24804e8fd26895924a8583830.zip external_mesa3d-3070e0ea41ab4aa24804e8fd26895924a8583830.tar.gz external_mesa3d-3070e0ea41ab4aa24804e8fd26895924a8583830.tar.bz2 |
mesa/st: support using PIPE_TEXTURE_RECT internally
Currently Gallium internals always use PIPE_TEXTURE_2D and normalized
coordinates to access textures.
However, PIPE_TEXTURE_2D is not always supported for NPOT textures,
and PIPE_TEXTURE_RECT requires unnormalized coordinates.
Hence, this change adds support for both kinds of normalization.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_bitmap.c')
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 91037ab..d40e413 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -275,7 +275,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /** * Create texture to hold bitmap pattern. */ - pt = st_texture_create(st, PIPE_TEXTURE_2D, st->bitmap.tex_format, + pt = st_texture_create(st, st->internal_target, st->bitmap.tex_format, 0, width, height, 1, PIPE_BIND_SAMPLER_VIEW); if (!pt) { @@ -304,7 +304,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, } static GLuint -setup_bitmap_vertex_data(struct st_context *st, +setup_bitmap_vertex_data(struct st_context *st, bool normalized, int x, int y, int width, int height, float z, const float color[4]) { @@ -316,13 +316,19 @@ setup_bitmap_vertex_data(struct st_context *st, const GLfloat x1 = (GLfloat)(x + width); const GLfloat y0 = (GLfloat)y; const GLfloat y1 = (GLfloat)(y + height); - const GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0; - const GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop; + GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0; + GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop; const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0); const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0); const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0); const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0); + if(!normalized) + { + sRight = width; + tBot = height; + } + /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as * no_flush) updates to buffers where we know there is no conflict * with previous data. Currently using max_slots > 1 will cause @@ -462,7 +468,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, for (i = 0; i < st->state.num_samplers; i++) { samplers[i] = &st->state.samplers[i]; } - samplers[stfp->bitmap_sampler] = &st->bitmap.sampler; + samplers[stfp->bitmap_sampler] = &st->bitmap.samplers[sv->texture->target != PIPE_TEXTURE_RECT]; cso_set_samplers(cso, num, (const struct pipe_sampler_state **) samplers); } @@ -499,7 +505,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, z = z * 2.0 - 1.0; /* draw textured quad */ - offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color); + offset = setup_bitmap_vertex_data(st, sv->texture->target != PIPE_TEXTURE_RECT, x, y, width, height, z, color); util_draw_vertex_buffer(pipe, st->bitmap.vbuf, offset, PIPE_PRIM_TRIANGLE_FAN, @@ -789,7 +795,7 @@ st_init_bitmap_functions(struct dd_function_table *functions) void st_init_bitmap(struct st_context *st) { - struct pipe_sampler_state *sampler = &st->bitmap.sampler; + struct pipe_sampler_state *sampler = &st->bitmap.samplers[0]; struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; @@ -801,7 +807,8 @@ st_init_bitmap(struct st_context *st) sampler->min_img_filter = PIPE_TEX_FILTER_NEAREST; sampler->min_mip_filter = PIPE_TEX_MIPFILTER_NONE; sampler->mag_img_filter = PIPE_TEX_FILTER_NEAREST; - sampler->normalized_coords = 1; + st->bitmap.samplers[1] = *sampler; + st->bitmap.samplers[1].normalized_coords = 1; /* init baseline rasterizer state once */ memset(&st->bitmap.rasterizer, 0, sizeof(st->bitmap.rasterizer)); |