gallium/hud: do not use texture-rect for font

RECT textures used to be required to be supported by drivers. But since
the state-tracker learned how to lower these to 2D textures, some
drivers no longer support them.

While we have lowering in place for this, lowering it involves some
needless overhead. So let's just use a 2D texture instead of a RECT
texture.

Because having two versions and switching between them is more
complicated than it needs to be, let's just always use a 2D texture.
Similarly, let's just always multiply the reciprocal here, so we don't
have to test for PIPE_CAP_TGSI_DIV first.

Cc: mesa-stable
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17707>
This commit is contained in:
Erik Faye-Lund 2022-07-22 09:14:09 +02:00 committed by Marge Bot
parent 7ef76dec73
commit ba2146f93f
3 changed files with 8 additions and 7 deletions

View file

@ -390,7 +390,7 @@ util_font_create_fixed_8x13(struct pipe_context *pipe,
for (i = 0; i < ARRAY_SIZE(formats); i++) {
if (screen->is_format_supported(screen, formats[i],
PIPE_TEXTURE_RECT, 0, 0,
PIPE_TEXTURE_2D, 0, 0,
PIPE_BIND_SAMPLER_VIEW)) {
tex_format = formats[i];
break;
@ -403,7 +403,7 @@ util_font_create_fixed_8x13(struct pipe_context *pipe,
}
memset(&tex_templ, 0, sizeof(tex_templ));
tex_templ.target = PIPE_TEXTURE_RECT;
tex_templ.target = PIPE_TEXTURE_2D;
tex_templ.format = tex_format;
tex_templ.width0 = 128;
tex_templ.height0 = 256;

View file

@ -37,7 +37,7 @@ enum util_font_name {
UTIL_FONT_FIXED_8X13
};
/* The font is stored in a RECT texture. There are 256 glyphs
/* The font is stored in a 2D texture. There are 256 glyphs
* drawn in a 16x16 matrix. The texture coordinates of a glyph
* within the matrix should be calculated as follows:
*

View file

@ -1682,11 +1682,11 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso,
"FRAG\n"
"DCL IN[0], GENERIC[0], LINEAR\n"
"DCL SAMP[0]\n"
"DCL SVIEW[0], RECT, FLOAT\n"
"DCL SVIEW[0], 2D, FLOAT\n"
"DCL OUT[0], COLOR[0]\n"
"DCL TEMP[0]\n"
"TEX TEMP[0], IN[0], SAMP[0], RECT\n"
"TEX TEMP[0], IN[0], SAMP[0], 2D\n"
"MOV OUT[0], TEMP[0].xxxx\n"
"END\n"
};
@ -1753,6 +1753,7 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso,
"DCL CONST[0][0..2]\n"
"DCL TEMP[0]\n"
"IMM[0] FLT32 { -1, 0, 0, 1 }\n"
"IMM[1] FLT32 { 0.0078125, 0.00390625, 1, 1 }\n" // 1.0 / 128, 1.0 / 256, 1, 1
/* v = in * (xscale, yscale) + (xoffset, yoffset) */
"MAD TEMP[0].xy, IN[0], CONST[0][2].xyyy, CONST[0][1].zwww\n"
@ -1760,7 +1761,7 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso,
"MAD OUT[0].xy, TEMP[0], CONST[0][1].xyyy, IMM[0].xxxx\n"
"MOV OUT[0].zw, IMM[0]\n"
"MOV OUT[1], IN[1]\n"
"MUL OUT[1], IN[1], IMM[1]\n"
"END\n"
};
@ -1935,7 +1936,7 @@ hud_create(struct cso_context *cso, struct st_context_iface *st,
hud->font_sampler_state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
hud->font_sampler_state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
hud->font_sampler_state.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
hud->font_sampler_state.normalized_coords = 0;
hud->font_sampler_state.normalized_coords = 1;
/* constants */
hud->constbuf.buffer_size = sizeof(hud->constants);