intel/perf: create a vtable entry for emit_report_count
[mesa.git] / src / mesa / state_tracker / st_format.c
index 16a18c272dc5ec9e9c709199d34441ee28380c28..4edb678247340308f39f3ae529127451cd35b478 100644 (file)
@@ -169,6 +169,8 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
       return PIPE_FORMAT_AL88_SRGB;
    case MESA_FORMAT_L_SRGB8:
       return PIPE_FORMAT_L8_SRGB;
+   case MESA_FORMAT_R_SRGB8:
+      return PIPE_FORMAT_R8_SRGB;
    case MESA_FORMAT_BGR_SRGB8:
       return PIPE_FORMAT_R8G8B8_SRGB;
    case MESA_FORMAT_A8B8G8R8_SRGB:
@@ -600,6 +602,13 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
          return PIPE_FORMAT_R8G8B8A8_SRGB;
       return PIPE_FORMAT_ASTC_12x12_SRGB;
 
+   case MESA_FORMAT_ATC_RGB:
+      return PIPE_FORMAT_ATC_RGB;
+   case MESA_FORMAT_ATC_RGBA_EXPLICIT:
+      return PIPE_FORMAT_ATC_RGBA_EXPLICIT;
+   case MESA_FORMAT_ATC_RGBA_INTERPOLATED:
+      return PIPE_FORMAT_ATC_RGBA_INTERPOLATED;
+
    default:
       return PIPE_FORMAT_NONE;
    }
@@ -719,6 +728,8 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_A8L8_SRGB;
    case PIPE_FORMAT_L8_SRGB:
       return MESA_FORMAT_L_SRGB8;
+   case PIPE_FORMAT_R8_SRGB:
+      return MESA_FORMAT_R_SRGB8;
    case PIPE_FORMAT_R8G8B8_SRGB:
       return MESA_FORMAT_BGR_SRGB8;
    case PIPE_FORMAT_ABGR8888_SRGB:
@@ -1084,50 +1095,18 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
    case PIPE_FORMAT_ASTC_12x12_SRGB:
       return MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12;
 
+   case PIPE_FORMAT_ATC_RGB:
+      return MESA_FORMAT_ATC_RGB;
+   case PIPE_FORMAT_ATC_RGBA_EXPLICIT:
+      return MESA_FORMAT_ATC_RGBA_EXPLICIT;
+   case PIPE_FORMAT_ATC_RGBA_INTERPOLATED:
+      return MESA_FORMAT_ATC_RGBA_INTERPOLATED;
+
    default:
       return MESA_FORMAT_NONE;
    }
 }
 
-
-/**
- * Debug only: check that the two functions above correctly map
- * Mesa formats to Gallium formats and back again.
- */
-static void
-test_format_conversion(struct st_context *st)
-{
-   GLuint i;
-
-   /* test all Mesa formats */
-   for (i = 1; i < MESA_FORMAT_COUNT; i++) {
-      enum pipe_format pf;
-
-      if (st_compressed_format_fallback(st, i))
-         continue;
-
-      pf = st_mesa_format_to_pipe_format(st, i);
-      if (pf != PIPE_FORMAT_NONE) {
-         mesa_format MAYBE_UNUSED mf = st_pipe_format_to_mesa_format(pf);
-         assert(mf == i);
-      }
-   }
-
-   /* Test all Gallium formats */
-   for (i = 1; i < PIPE_FORMAT_COUNT; i++) {
-      mesa_format mf = st_pipe_format_to_mesa_format(i);
-      if (st_compressed_format_fallback(st, mf))
-         continue;
-
-      if (mf != MESA_FORMAT_NONE) {
-         enum pipe_format MAYBE_UNUSED pf =
-            st_mesa_format_to_pipe_format(st, mf);
-         assert(pf == i);
-      }
-   }
-}
-
-
 /**
  * Map GL texture formats to Gallium pipe formats.
  */
@@ -1423,6 +1402,10 @@ static const struct format_mapping format_map[] = {
         0 },
       { PIPE_FORMAT_L8_SRGB, DEFAULT_SRGBA_FORMATS }
    },
+   {
+      { GL_SR8_EXT, 0 },
+      { PIPE_FORMAT_R8_SRGB, 0 }
+   },
 
    /* 16-bit float formats */
    {
@@ -2174,18 +2157,6 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
    int j;
    enum pipe_format pf;
 
-#ifdef DEBUG
-   {
-      static boolean firstCall = TRUE;
-      if (firstCall) {
-         test_format_conversion(st);
-         firstCall = FALSE;
-      }
-   }
-#else
-   (void) test_format_conversion;
-#endif
-
    /* can't render to compressed formats at this time */
    if (_mesa_is_compressed_format(st->ctx, internalFormat)
        && (bindings & ~PIPE_BIND_SAMPLER_VIEW)) {
@@ -2280,7 +2251,7 @@ st_choose_matching_format(struct st_context *st, unsigned bind,
    mesa_format mesa_format;
 
    for (mesa_format = 1; mesa_format < MESA_FORMAT_COUNT; mesa_format++) {
-      if (_mesa_get_format_color_encoding(mesa_format) == GL_SRGB) {
+      if (_mesa_is_format_srgb(mesa_format)) {
          continue;
       }
       if (_mesa_get_format_bits(mesa_format, GL_TEXTURE_INTENSITY_SIZE) > 0) {
@@ -2348,6 +2319,8 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
       bindings |= PIPE_BIND_DEPTH_STENCIL;
    else if (is_renderbuffer || internalFormat == 3 || internalFormat == 4 ||
             internalFormat == GL_RGB || internalFormat == GL_RGBA ||
+            internalFormat == GL_RGBA2 ||
+            internalFormat == GL_RGB4 || internalFormat == GL_RGBA4 ||
             internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
             internalFormat == GL_BGRA ||
             internalFormat == GL_RGB16F ||
@@ -2449,7 +2422,7 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
    /* If an sRGB framebuffer is unsupported, sRGB formats behave like linear
     * formats.
     */
-   if (!ctx->Extensions.EXT_framebuffer_sRGB) {
+   if (!ctx->Extensions.EXT_sRGB) {
       internalFormat = _mesa_get_linear_internalformat(internalFormat);
    }