Mesa (gallium-rect-textures): mesa/st: support using PIPE_TEXTURE_RECT internally
Module: Mesa Branch: gallium-rect-textures Commit: 03f2330be75239d8c0f0d1ec0337107e643d9a2a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=03f2330be75239d8c0f0d1ec0337107e643d9a2a Author: Luca Barbieri l...@luca-barbieri.com Date: Fri Aug 6 07:39:21 2010 +0200 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. --- src/mesa/state_tracker/st_cb_bitmap.c | 23 ++- src/mesa/state_tracker/st_cb_drawpixels.c | 42 ++-- src/mesa/state_tracker/st_cb_fbo.c|2 +- src/mesa/state_tracker/st_context.c |5 +++ src/mesa/state_tracker/st_context.h |3 +- 5 files changed, 32 insertions(+), 43 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)); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 69a3dd4..d934fdc 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -304,34 +304,9 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height, struct pipe_context *pipe = st-pipe; struct
Mesa (gallium-rect-textures): mesa/st: support using PIPE_TEXTURE_RECT internally
Module: Mesa Branch: gallium-rect-textures Commit: 6d09c51a358a70d107e682fa6d4f3ba1938579ae URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d09c51a358a70d107e682fa6d4f3ba1938579ae Author: Luca Barbieri l...@luca-barbieri.com Date: Fri Aug 6 07:39:21 2010 +0200 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. --- src/mesa/state_tracker/st_cb_bitmap.c | 23 ++- src/mesa/state_tracker/st_cb_drawpixels.c | 42 ++-- src/mesa/state_tracker/st_context.c |5 +++ src/mesa/state_tracker/st_context.h |3 +- 4 files changed, 31 insertions(+), 42 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)); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 69a3dd4..d934fdc 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -304,34 +304,9 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height, struct pipe_context *pipe = st-pipe; struct pipe_screen *screen = pipe-screen; struct
Mesa (gallium-rect-textures): mesa/st: support using PIPE_TEXTURE_RECT internally
Module: Mesa Branch: gallium-rect-textures Commit: 655c1ad637523c9fc9f90bfff9fdeb393bf20253 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=655c1ad637523c9fc9f90bfff9fdeb393bf20253 Author: Luca Barbieri l...@luca-barbieri.com Date: Fri Aug 6 07:39:21 2010 +0200 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. --- src/mesa/state_tracker/st_cb_bitmap.c | 23 ++- src/mesa/state_tracker/st_cb_drawpixels.c | 42 ++-- src/mesa/state_tracker/st_cb_fbo.c|2 +- src/mesa/state_tracker/st_context.c |5 +++ src/mesa/state_tracker/st_context.h |3 +- 5 files changed, 32 insertions(+), 43 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)); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 69a3dd4..d934fdc 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -304,34 +304,9 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height, struct pipe_context *pipe = st-pipe; struct