st/mesa: add st_context parameter to st_mesa_format_to_pipe_format
authorMarek Olšák <marek.olsak@amd.com>
Sat, 2 Aug 2014 19:00:41 +0000 (21:00 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 11 Aug 2014 19:53:57 +0000 (21:53 +0200)
This will be used by the next commit.

Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h
src/mesa/state_tracker/st_texture.c
src/mesa/state_tracker/st_texture.h

index 2e10bc3e2411e9be86be552c0dcdfd75e4053133..03d05932a240b76e8246545b1bf9978a32c92666 100644 (file)
@@ -338,7 +338,7 @@ update_single_texture(struct st_context *st,
    /* Determine the format of the texture sampler view */
    if (texObj->Target == GL_TEXTURE_BUFFER) {
       view_format =
-         st_mesa_format_to_pipe_format(stObj->base._BufferObjectFormat);
+         st_mesa_format_to_pipe_format(st, stObj->base._BufferObjectFormat);
    }
    else {
       view_format =
index d13a17f5002ce519d65468aeb0d3e35d697c886b..5ae092b94fbf0eb290d7c96aed691541ecc6a5a1 100644 (file)
@@ -491,7 +491,7 @@ make_texture(struct st_context *st,
    /* Choose a pixel format for the temp texture which will hold the
     * image to draw.
     */
-   pipeFormat = st_choose_matching_format(pipe->screen, PIPE_BIND_SAMPLER_VIEW,
+   pipeFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
                                           format, type, unpack->SwapBytes);
 
    if (pipeFormat == PIPE_FORMAT_NONE) {
index ce8d91514d807190d2721a660bd48c0941478bf5..7cfd3dadefaca8c24b328725dd30aa0ce3945d9d 100644 (file)
@@ -588,7 +588,7 @@ st_validate_attachment(struct gl_context *ctx,
    if (!ctx->Extensions.EXT_framebuffer_sRGB &&
        _mesa_get_format_color_encoding(texFormat) == GL_SRGB) {
       const mesa_format linearFormat = _mesa_get_srgb_format_linear(texFormat);
-      format = st_mesa_format_to_pipe_format(linearFormat);
+      format = st_mesa_format_to_pipe_format(st_context(ctx), linearFormat);
    }
 
    valid = screen->is_format_supported(screen, format,
index 3f7bbd9738cb33310a29fa08e139472d24ab1567..d95a608d32e47bf72d02e737350864c54b0fe02c 100644 (file)
@@ -143,7 +143,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
 
    /* Choose the destination format by finding the best match
     * for the format+type combo. */
-   dst_format = st_choose_matching_format(screen, bind, format, type,
+   dst_format = st_choose_matching_format(st, bind, format, type,
                                           pack->SwapBytes);
    if (dst_format == PIPE_FORMAT_NONE) {
       goto fallback;
index 62075c67463bbc8a64818525526d5f6d3bd3bdba..1b065e4f04b021a9ae53b4566e11c4afd9b94215 100644 (file)
@@ -442,7 +442,7 @@ guess_and_alloc_texture(struct st_context *st,
    stObj->height0 = height;
    stObj->depth0 = depth;
 
-   fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat);
+   fmt = st_mesa_format_to_pipe_format(st, stImage->base.TexFormat);
 
    bindings = default_bindings(st, fmt);
 
@@ -493,7 +493,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
    /* Look if the parent texture object has space for this image */
    if (stObj->pt &&
        level <= stObj->pt->last_level &&
-       st_texture_match_image(stObj->pt, texImage)) {
+       st_texture_match_image(st, stObj->pt, texImage)) {
       /* this image will fit in the existing texture object's memory */
       pipe_resource_reference(&stImage->pt, stObj->pt);
       return GL_TRUE;
@@ -516,7 +516,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
    }
 
    if (stObj->pt &&
-       st_texture_match_image(stObj->pt, texImage)) {
+       st_texture_match_image(st, stObj->pt, texImage)) {
       /* The image will live in the object's mipmap memory */
       pipe_resource_reference(&stImage->pt, stObj->pt);
       assert(stImage->pt);
@@ -530,7 +530,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
        * level.
        */
       enum pipe_format format =
-         st_mesa_format_to_pipe_format(texImage->TexFormat);
+         st_mesa_format_to_pipe_format(st, texImage->TexFormat);
       GLuint bindings = default_bindings(st, format);
       GLuint ptWidth, ptHeight, ptDepth, ptLayers;
 
@@ -706,7 +706,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
    }
 
    /* Choose the source format. */
-   src_format = st_choose_matching_format(screen, PIPE_BIND_SAMPLER_VIEW,
+   src_format = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
                                           format, type, unpack->SwapBytes);
    if (!src_format) {
       goto fallback;
@@ -982,7 +982,7 @@ st_GetTexImage(struct gl_context * ctx,
 
    /* Choose the destination format by finding the best match
     * for the format+type combo. */
-   dst_format = st_choose_matching_format(screen, bind, format, type,
+   dst_format = st_choose_matching_format(st, bind, format, type,
                                          ctx->Pack.SwapBytes);
 
    if (dst_format == PIPE_FORMAT_NONE) {
@@ -1581,7 +1581,8 @@ st_finalize_texture(struct gl_context *ctx,
    }
 
    /* Find gallium format for the Mesa texture */
-   firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
+   firstImageFormat =
+      st_mesa_format_to_pipe_format(st, firstImage->base.TexFormat);
 
    /* Find size of level=0 Gallium mipmap image, plus number of texture layers */
    {
@@ -1699,7 +1700,7 @@ st_AllocTextureStorage(struct gl_context *ctx,
    stObj->depth0 = depth;
    stObj->lastLevel = levels - 1;
 
-   fmt = st_mesa_format_to_pipe_format(texImage->TexFormat);
+   fmt = st_mesa_format_to_pipe_format(st, texImage->TexFormat);
 
    bindings = default_bindings(st, fmt);
 
@@ -1778,7 +1779,7 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target,
       memset(&pt, 0, sizeof(pt));
 
       pt.target = gl_target_to_pipe(target);
-      pt.format = st_mesa_format_to_pipe_format(format);
+      pt.format = st_mesa_format_to_pipe_format(st, format);
 
       st_gl_texture_dims_to_pipe_dims(target,
                                       width, height, depth,
index ff3f494f39f8a348053cf20d709c1b910e4bc59b..3d822a5a4e4fa7e7025bf6fc6b5f264c822c7c37 100644 (file)
@@ -54,7 +54,7 @@
  * Translate Mesa format to Gallium format.
  */
 enum pipe_format
-st_mesa_format_to_pipe_format(mesa_format mesaFormat)
+st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
 {
    switch (mesaFormat) {
    case MESA_FORMAT_A8B8G8R8_UNORM:
@@ -795,7 +795,7 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
  * Mesa formats to Gallium formats and back again.
  */
 static void
-test_format_conversion(void)
+test_format_conversion(struct st_context *st)
 {
    GLuint i;
 
@@ -805,7 +805,7 @@ test_format_conversion(void)
       if (_mesa_is_format_etc2(i))
          continue;
 
-      enum pipe_format pf = st_mesa_format_to_pipe_format(i);
+      enum pipe_format pf = st_mesa_format_to_pipe_format(st, i);
       if (pf != PIPE_FORMAT_NONE) {
          mesa_format mf = st_pipe_format_to_mesa_format(pf);
          assert(mf == i);
@@ -816,7 +816,7 @@ test_format_conversion(void)
    for (i = 1; i < PIPE_FORMAT_COUNT; i++) {
       mesa_format mf = st_pipe_format_to_mesa_format(i);
       if (mf != MESA_FORMAT_NONE) {
-         enum pipe_format pf = st_mesa_format_to_pipe_format(mf);
+         enum pipe_format pf = st_mesa_format_to_pipe_format(st, mf);
          assert(pf == i);
       }
    }
@@ -1704,7 +1704,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
    {
       static boolean firstCall = TRUE;
       if (firstCall) {
-         test_format_conversion();
+         test_format_conversion(st);
          firstCall = FALSE;
       }
    }
@@ -1770,9 +1770,10 @@ st_choose_renderbuffer_format(struct st_context *st,
  * If no format is supported, return PIPE_FORMAT_NONE.
  */
 enum pipe_format
-st_choose_matching_format(struct pipe_screen *screen, unsigned bind,
+st_choose_matching_format(struct st_context *st, unsigned bind,
                          GLenum format, GLenum type, GLboolean swapBytes)
 {
+   struct pipe_screen *screen = st->pipe->screen;
    mesa_format mesa_format;
 
    for (mesa_format = 1; mesa_format < MESA_FORMAT_COUNT; mesa_format++) {
@@ -1788,7 +1789,8 @@ st_choose_matching_format(struct pipe_screen *screen, unsigned bind,
 
       if (_mesa_format_matches_format_and_type(mesa_format, format, type,
                                                swapBytes)) {
-         enum pipe_format format = st_mesa_format_to_pipe_format(mesa_format);
+         enum pipe_format format =
+            st_mesa_format_to_pipe_format(st, mesa_format);
 
          if (format &&
              screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0,
@@ -1858,16 +1860,14 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
        * with the "format".
        */
       if (iformat == baseFormat && iformat == basePackFormat) {
-         pFormat = st_choose_matching_format(st->pipe->screen, bindings,
-                                             format, type,
+         pFormat = st_choose_matching_format(st, bindings, format, type,
                                              ctx->Unpack.SwapBytes);
 
          if (pFormat != PIPE_FORMAT_NONE)
             return st_pipe_format_to_mesa_format(pFormat);
 
          /* try choosing format again, this time without render target bindings */
-         pFormat = st_choose_matching_format(st->pipe->screen,
-                                             PIPE_BIND_SAMPLER_VIEW,
+         pFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
                                              format, type,
                                              ctx->Unpack.SwapBytes);
          if (pFormat != PIPE_FORMAT_NONE)
index ce1e2306dd255542b20bd3d1d32614c6d66bdd2a..90e00e8ebf62857ffe81d217f9045c8e096cbc75 100644 (file)
@@ -41,7 +41,7 @@ struct pipe_screen;
 
 
 extern enum pipe_format
-st_mesa_format_to_pipe_format(mesa_format mesaFormat);
+st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat);
 
 extern mesa_format
 st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
@@ -58,7 +58,7 @@ st_choose_renderbuffer_format(struct st_context *st,
                               GLenum internalFormat, unsigned sample_count);
 
 extern enum pipe_format
-st_choose_matching_format(struct pipe_screen *screen, unsigned bind,
+st_choose_matching_format(struct st_context *st, unsigned bind,
                          GLenum format, GLenum type, GLboolean swapBytes);
 
 extern mesa_format
index 9f57cfb3d964713204715cb79589b8ef32c53333..af9b7675f10d61f90ba6e1f4ffc422eb3c75d5c6 100644 (file)
@@ -197,7 +197,8 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture,
  * Check if a texture image can be pulled into a unified mipmap texture.
  */
 GLboolean
-st_texture_match_image(const struct pipe_resource *pt,
+st_texture_match_image(struct st_context *st,
+                       const struct pipe_resource *pt,
                        const struct gl_texture_image *image)
 {
    GLuint ptWidth, ptHeight, ptDepth, ptLayers;
@@ -209,7 +210,7 @@ st_texture_match_image(const struct pipe_resource *pt,
 
    /* Check if this image's format matches the established texture's format.
     */
-   if (st_mesa_format_to_pipe_format(image->TexFormat) != pt->format)
+   if (st_mesa_format_to_pipe_format(st, image->TexFormat) != pt->format)
       return GL_FALSE;
 
    st_gl_texture_dims_to_pipe_dims(image->TexObject->Target,
index 04b886ee39fff013f114eda52c811a831f3aef39..ce1cf8b0a94b8d0c9f57a72d7bcb96afc1906d26 100644 (file)
@@ -199,7 +199,8 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture,
 /* Check if an image fits into an existing texture object.
  */
 extern GLboolean
-st_texture_match_image(const struct pipe_resource *pt,
+st_texture_match_image(struct st_context *st,
+                       const struct pipe_resource *pt,
                        const struct gl_texture_image *image);
 
 /* Return a pointer to an image within a texture.  Return image stride as