mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
st/mesa: fix bitmap texture target code and simplify tex sampler state
Bitmaps may be drawn with a PIPE_TEXTURE_2D or PIPE_TEXTURE_RECT resource as determined at context creation by checking if PIPE_CAP_NPOT_TEXTURES is supported. But many places in the bitmap code were hard-coded to use PIPE_TEXTURE_2D. Use st->internal_target instead. I think an older NV chip is the only case where a gallium driver does not support NPOT textures. Bitmap drawing was probably broken for that GPU. Also, we only need one sampler state with texcoord normalization set up according to st->internal_target. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
parent
9e2a9d5743
commit
5e4de781fa
2 changed files with 17 additions and 17 deletions
|
|
@ -251,8 +251,7 @@ setup_render_state(struct gl_context *ctx,
|
|||
for (i = 0; i < st->state.num_samplers[PIPE_SHADER_FRAGMENT]; i++) {
|
||||
samplers[i] = &st->state.samplers[PIPE_SHADER_FRAGMENT][i];
|
||||
}
|
||||
samplers[fpv->bitmap_sampler] =
|
||||
&st->bitmap.samplers[sv->texture->target != PIPE_TEXTURE_RECT];
|
||||
samplers[fpv->bitmap_sampler] = &st->bitmap.sampler;
|
||||
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num,
|
||||
(const struct pipe_sampler_state **) samplers);
|
||||
}
|
||||
|
|
@ -438,7 +437,7 @@ reset_cache(struct st_context *st)
|
|||
assert(!cache->texture);
|
||||
|
||||
/* allocate a new texture */
|
||||
cache->texture = st_texture_create(st, PIPE_TEXTURE_2D,
|
||||
cache->texture = st_texture_create(st, st->internal_target,
|
||||
st->bitmap.tex_format, 0,
|
||||
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
|
||||
1, 1, 0,
|
||||
|
|
@ -624,26 +623,27 @@ accum_bitmap(struct gl_context *ctx,
|
|||
static void
|
||||
init_bitmap_state(struct st_context *st)
|
||||
{
|
||||
struct pipe_sampler_state *sampler = &st->bitmap.samplers[0];
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
|
||||
/* This function should only be called once */
|
||||
assert(st->bitmap.cache == NULL);
|
||||
|
||||
assert(st->internal_target == PIPE_TEXTURE_2D ||
|
||||
st->internal_target == PIPE_TEXTURE_RECT);
|
||||
|
||||
/* alloc bitmap cache object */
|
||||
st->bitmap.cache = ST_CALLOC_STRUCT(bitmap_cache);
|
||||
|
||||
/* init sampler state once */
|
||||
memset(sampler, 0, sizeof(*sampler));
|
||||
sampler->wrap_s = PIPE_TEX_WRAP_CLAMP;
|
||||
sampler->wrap_t = PIPE_TEX_WRAP_CLAMP;
|
||||
sampler->wrap_r = PIPE_TEX_WRAP_CLAMP;
|
||||
sampler->min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
sampler->min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
sampler->mag_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
st->bitmap.samplers[1] = *sampler;
|
||||
st->bitmap.samplers[1].normalized_coords = 1;
|
||||
memset(&st->bitmap.sampler, 0, sizeof(st->bitmap.sampler));
|
||||
st->bitmap.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
|
||||
st->bitmap.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP;
|
||||
st->bitmap.sampler.wrap_r = PIPE_TEX_WRAP_CLAMP;
|
||||
st->bitmap.sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
st->bitmap.sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
st->bitmap.sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
st->bitmap.sampler.normalized_coords = st->internal_target == PIPE_TEXTURE_2D;
|
||||
|
||||
/* init baseline rasterizer state once */
|
||||
memset(&st->bitmap.rasterizer, 0, sizeof(st->bitmap.rasterizer));
|
||||
|
|
@ -653,17 +653,17 @@ init_bitmap_state(struct st_context *st)
|
|||
|
||||
/* find a usable texture format */
|
||||
if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM,
|
||||
PIPE_TEXTURE_2D, 0,
|
||||
st->internal_target, 0,
|
||||
PIPE_BIND_SAMPLER_VIEW)) {
|
||||
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
|
||||
}
|
||||
else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM,
|
||||
PIPE_TEXTURE_2D, 0,
|
||||
st->internal_target, 0,
|
||||
PIPE_BIND_SAMPLER_VIEW)) {
|
||||
st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM;
|
||||
}
|
||||
else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM,
|
||||
PIPE_TEXTURE_2D, 0,
|
||||
st->internal_target, 0,
|
||||
PIPE_BIND_SAMPLER_VIEW)) {
|
||||
st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ struct st_context
|
|||
/** for glBitmap */
|
||||
struct {
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
struct pipe_sampler_state samplers[2];
|
||||
struct pipe_sampler_state sampler;
|
||||
enum pipe_format tex_format;
|
||||
void *vs;
|
||||
struct bitmap_cache *cache;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue