summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2015-02-04 13:44:48 -0700
committerBrian Paul <[email protected]>2015-02-07 11:03:37 -0700
commitd1e21325cf3c394f5fb28808a113826ea3b7f54b (patch)
treec751f0c6b9843e8946e2dd0077f01859a3571448 /src/gallium/auxiliary
parent6447e9dbfad851f700266dda8003b76e172ae92b (diff)
gallium/hud: also try R8_UNORM format for font texture10.5-branchpoint
Convert the code to try formats from an array rather than a bunch of if/else cases. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/hud/font.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/hud/font.c b/src/gallium/auxiliary/hud/font.c
index 03e35d945aa..60e8ae514a5 100644
--- a/src/gallium/auxiliary/hud/font.c
+++ b/src/gallium/auxiliary/hud/font.c
@@ -57,6 +57,7 @@
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
+#include "util/u_memory.h"
typedef unsigned char GLubyte; /* 1-byte unsigned */
typedef struct tagSFG_Font SFG_Font;
@@ -373,24 +374,29 @@ static boolean
util_font_create_fixed_8x13(struct pipe_context *pipe,
struct util_font *out_font)
{
+ static const enum pipe_format formats[] = {
+ PIPE_FORMAT_I8_UNORM,
+ PIPE_FORMAT_L8_UNORM,
+ PIPE_FORMAT_R8_UNORM
+ };
struct pipe_screen *screen = pipe->screen;
struct pipe_resource tex_templ, *tex;
struct pipe_transfer *transfer = NULL;
char *map;
- enum pipe_format tex_format;
+ enum pipe_format tex_format = PIPE_FORMAT_NONE;
int i;
- if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM,
+ for (i = 0; i < Elements(formats); i++) {
+ if (screen->is_format_supported(screen, formats[i],
PIPE_TEXTURE_RECT, 0,
PIPE_BIND_SAMPLER_VIEW)) {
- tex_format = PIPE_FORMAT_I8_UNORM;
- }
- else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM,
- PIPE_TEXTURE_RECT, 0,
- PIPE_BIND_SAMPLER_VIEW)) {
- tex_format = PIPE_FORMAT_L8_UNORM;
+ tex_format = formats[i];
+ break;
+ }
}
- else {
+
+ if (tex_format == PIPE_FORMAT_NONE) {
+ debug_printf("Unable to find texture format for font.\n");
return FALSE;
}