v2: Unsigned floats are allowed regardless of the configure switch.
#include "u_memory.h"
#include "u_rect.h"
#include "u_format.h"
+#include "u_format_s3tc.h"
+
+#include "pipe/p_defines.h"
+
+
+boolean
+util_format_is_float(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ unsigned i;
+
+ assert(desc);
+ if (!desc) {
+ return FALSE;
+ }
+
+ /* Find the first non-void channel. */
+ for (i = 0; i < 4; i++) {
+ if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
+ break;
+ }
+ }
+
+ if (i == 4) {
+ return FALSE;
+ }
+
+ return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? TRUE : FALSE;
+}
+
+
+boolean
+util_format_is_supported(enum pipe_format format, unsigned bind)
+{
+ if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) {
+ return FALSE;
+ }
+
+#ifndef TEXTURE_FLOAT_ENABLED
+ if ((bind & PIPE_BIND_RENDER_TARGET) &&
+ format != PIPE_FORMAT_R9G9B9E5_FLOAT &&
+ format != PIPE_FORMAT_R11G11B10_FLOAT &&
+ util_format_is_float(format)) {
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}
void
}
+boolean
+util_format_is_float(enum pipe_format format);
+
+
/**
* Whether the src format can be blitted to destation format with a simple
* memcpy.
util_is_format_compatible(const struct util_format_description *src_desc,
const struct util_format_description *dst_desc);
+/**
+ * Whether the format is supported by Gallium for the given bindings.
+ * This covers S3TC textures and floating-point render targets.
+ */
+boolean
+util_format_is_supported(enum pipe_format format, unsigned bind);
/**
* Whether this format is a rgab8 variant.
const enum pipe_format *list;
uint i;
+ if (!util_format_is_supported(format, tex_usage))
+ return FALSE;
+
if (sample_count > 1)
return FALSE;
const enum pipe_format *list;
uint i;
+ if (!util_format_is_supported(format, tex_usage))
+ return FALSE;
+
if (sample_count > 1)
return FALSE;
if (sample_count > 1)
return FALSE;
- if (!util_format_s3tc_enabled) {
- switch (format) {
- case PIPE_FORMAT_DXT1_RGB:
- case PIPE_FORMAT_DXT1_RGBA:
- case PIPE_FORMAT_DXT3_RGBA:
- case PIPE_FORMAT_DXT5_RGBA:
- return FALSE;
- default:
- break;
- }
- }
+ if (!util_format_is_supported(format, bindings))
+ return FALSE;
switch (format) {
case PIPE_FORMAT_Z16_UNORM:
if (sample_count > 1)
return FALSE;
- if (!util_format_s3tc_enabled) {
- switch (format) {
- case PIPE_FORMAT_DXT1_RGB:
- case PIPE_FORMAT_DXT1_RGBA:
- case PIPE_FORMAT_DXT3_RGBA:
- case PIPE_FORMAT_DXT5_RGBA:
- return FALSE;
- default:
- break;
- }
- }
+ if (!util_format_is_supported(format, bindings))
+ return FALSE;
/* transfers & shared are always supported */
bindings &= ~(PIPE_BIND_TRANSFER_READ |
{
struct nvfx_screen *screen = nvfx_screen(pscreen);
+ if (!util_format_is_supported(format, bind))
+ return FALSE;
+
if (sample_count > 1)
return FALSE;
format == PIPE_FORMAT_R16G16B16_FLOAT ||
format == PIPE_FORMAT_R16G16B16A16_FLOAT;
+ if (!util_format_is_supported(format, usage))
+ return FALSE;
+
/* Check multisampling support. */
switch (sample_count) {
case 0:
return uc.ui;
}
-static boolean util_format_is_float(enum pipe_format format)
-{
- const struct util_format_description *desc = util_format_description(format);
- unsigned i;
-
- if (!format)
- return FALSE;
-
- /* Find the first non-void channel. */
- for (i = 0; i < 4; i++)
- if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
- break;
-
- if (i == 4)
- return FALSE;
-
- return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? TRUE : FALSE;
-}
-
static void r300_merge_textures_and_samplers(struct r300_context* r300)
{
struct r300_textures_state *state =
return FALSE;
}
+ if (!util_format_is_supported(format, usage))
+ return FALSE;
+
/* Multisample */
if (sample_count > 1)
return FALSE;