Module: Mesa
Branch: main
Commit: f74648f91248da8033539c5ed5949275df498b57
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f74648f91248da8033539c5ed5949275df498b57

Author: Dave Airlie <[email protected]>
Date:   Tue Dec 21 16:22:53 2021 +1000

mesa/st: move last of renderbuffer functionality into mesa

Reviewed-by: Kristian H. Kristensen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>

---

 src/gallium/frontends/dri/dri2.c             |   2 +-
 src/gallium/frontends/dri/dri_helpers.c      |   1 -
 src/mesa/main/blit.c                         |   6 +-
 src/mesa/main/buffers.c                      |   1 -
 src/mesa/main/fbobject.c                     |   3 +-
 src/mesa/main/framebuffer.c                  |   1 -
 src/mesa/main/readpix.c                      |   1 -
 src/mesa/main/renderbuffer.c                 | 138 ++++++++++++++++++-
 src/mesa/main/renderbuffer.h                 |   6 +
 src/mesa/meson.build                         |   2 -
 src/mesa/state_tracker/st_atom_framebuffer.c |  14 +-
 src/mesa/state_tracker/st_cb_clear.c         |   1 -
 src/mesa/state_tracker/st_cb_copyimage.c     |   1 -
 src/mesa/state_tracker/st_cb_drawpixels.c    |   2 -
 src/mesa/state_tracker/st_cb_eglimage.c      |   1 -
 src/mesa/state_tracker/st_cb_fbo.c           | 193 ---------------------------
 src/mesa/state_tracker/st_cb_fbo.h           |  49 -------
 src/mesa/state_tracker/st_cb_flush.c         |   1 -
 src/mesa/state_tracker/st_cb_readpixels.c    |   1 -
 src/mesa/state_tracker/st_cb_texture.c       |   1 -
 src/mesa/state_tracker/st_manager.c          |   1 -
 src/mesa/state_tracker/st_texture.c          |   1 -
 22 files changed, 154 insertions(+), 273 deletions(-)

diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index 4b3e7a2397f..4b77601a82c 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -36,7 +36,7 @@
 #include "util/format/u_format.h"
 #include "util/u_debug.h"
 #include "frontend/drm_driver.h"
-#include "state_tracker/st_cb_fbo.h"
+#include "state_tracker/st_format.h"
 #include "state_tracker/st_cb_texture.h"
 #include "state_tracker/st_texture.h"
 #include "state_tracker/st_context.h"
diff --git a/src/gallium/frontends/dri/dri_helpers.c 
b/src/gallium/frontends/dri/dri_helpers.c
index 44fa5bee81a..215fb4e4e3a 100644
--- a/src/gallium/frontends/dri/dri_helpers.c
+++ b/src/gallium/frontends/dri/dri_helpers.c
@@ -26,7 +26,6 @@
 #include "pipe/p_screen.h"
 #include "state_tracker/st_texture.h"
 #include "state_tracker/st_context.h"
-#include "state_tracker/st_cb_fbo.h"
 #include "main/texobj.h"
 
 #include "dri_helpers.h"
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index da76a463ff0..7d1623a1e01 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -40,11 +40,11 @@
 #include "mtypes.h"
 #include "macros.h"
 #include "readpix.h"
+#include "renderbuffer.h"
 #include "state.h"
 #include "api_exec_decl.h"
 
 #include "state_tracker/st_cb_bitmap.h"
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_cb_texture.h"
 #include "state_tracker/st_manager.h"
 #include "state_tracker/st_scissor.h"
@@ -512,7 +512,7 @@ do_blit_framebuffer(struct gl_context *ctx,
          if (!srcRb)
             return;
 
-         st_update_renderbuffer_surface(st, srcRb);
+         _mesa_update_renderbuffer_surface(ctx, srcRb);
 
          if (!srcRb->surface)
             return;
@@ -531,7 +531,7 @@ do_blit_framebuffer(struct gl_context *ctx,
          if (dstRb) {
             struct pipe_surface *dstSurf;
 
-            st_update_renderbuffer_surface(st, dstRb);
+            _mesa_update_renderbuffer_surface(ctx, dstRb);
 
             dstSurf = dstRb->surface;
 
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 9c4fb37a6cb..c27ab1a854d 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -43,7 +43,6 @@
 #include "util/u_math.h"
 #include "api_exec_decl.h"
 
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_manager.h"
 #include "state_tracker/st_atom.h"
 #include "state_tracker/st_context.h"
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 43b1cd78f90..0a99b2da0e7 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -53,7 +53,6 @@
 #include "api_exec_decl.h"
 
 #include "util/u_memory.h"
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_cb_eglimage.h"
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_format.h"
@@ -449,7 +448,7 @@ render_texture(struct gl_context *ctx,
    rb->rtt_nr_samples = att->NumSamples;
    pipe_resource_reference(&rb->texture, pt);
 
-   st_update_renderbuffer_surface(st, rb);
+   _mesa_update_renderbuffer_surface(ctx, rb);
 
    /* Invalidate buffer state so that the pipe's framebuffer state
     * gets updated.
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 38723c8581b..d1facd80b17 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -48,7 +48,6 @@
 #include "state.h"
 #include "util/u_memory.h"
 
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_manager.h"
 
 /**
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index f9c5f23301e..05c2ad0c4ac 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -45,7 +45,6 @@
 #include "pixeltransfer.h"
 #include "api_exec_decl.h"
 
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_cb_readpixels.h"
 
 /**
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index c69a5572eec..13bb27bf210 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -35,9 +35,8 @@
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
 
-#include "state_tracker/st_format.h"
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_context.h"
+#include "state_tracker/st_format.h"
 
 /**
  * Delete a gl_framebuffer.
@@ -270,7 +269,7 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
    if (!rb->texture)
       return FALSE;
 
-   st_update_renderbuffer_surface(st, rb);
+   _mesa_update_renderbuffer_surface(ctx, rb);
    return rb->surface != NULL;
 }
 
@@ -508,3 +507,136 @@ _mesa_unmap_renderbuffer(struct gl_context *ctx,
    pipe_texture_unmap(pipe, rb->transfer);
    rb->transfer = NULL;
 }
+
+void
+_mesa_regen_renderbuffer_surface(struct gl_context *ctx,
+                                 struct gl_renderbuffer *rb)
+{
+   struct pipe_context *pipe = ctx->pipe;
+   struct pipe_resource *resource = rb->texture;
+
+   struct pipe_surface **psurf =
+      rb->surface_srgb ? &rb->surface_srgb : &rb->surface_linear;
+   struct pipe_surface *surf = *psurf;
+   /* create a new pipe_surface */
+   struct pipe_surface surf_tmpl;
+   memset(&surf_tmpl, 0, sizeof(surf_tmpl));
+   surf_tmpl.format = surf->format;
+   surf_tmpl.nr_samples = rb->rtt_nr_samples;
+   surf_tmpl.u.tex.level = surf->u.tex.level;
+   surf_tmpl.u.tex.first_layer = surf->u.tex.first_layer;
+   surf_tmpl.u.tex.last_layer = surf->u.tex.last_layer;
+
+   /* create -> destroy to avoid blowing up cached surfaces */
+   surf = pipe->create_surface(pipe, resource, &surf_tmpl);
+   pipe_surface_release(pipe, psurf);
+   *psurf = surf;
+
+   rb->surface = *psurf;
+}
+
+/**
+ * Create or update the pipe_surface of a FBO renderbuffer.
+ * This is usually called after st_finalize_texture.
+ */
+void
+_mesa_update_renderbuffer_surface(struct gl_context *ctx,
+                                  struct gl_renderbuffer *rb)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = ctx->pipe;
+   struct pipe_resource *resource = rb->texture;
+   const struct gl_texture_object *stTexObj = NULL;
+   unsigned rtt_width = rb->Width;
+   unsigned rtt_height = rb->Height;
+   unsigned rtt_depth = rb->Depth;
+
+   /*
+    * For winsys fbo, it is possible that the renderbuffer is sRGB-capable but
+    * the format of rb->texture is linear (because we have no control over
+    * the format).  Check rb->Format instead of rb->texture->format
+    * to determine if the rb is sRGB-capable.
+    */
+   boolean enable_srgb = ctx->Color.sRGBEnabled &&
+      _mesa_is_format_srgb(rb->Format);
+   enum pipe_format format = resource->format;
+
+   if (rb->is_rtt) {
+      stTexObj = rb->TexImage->TexObject;
+      if (stTexObj->surface_based)
+         format = stTexObj->surface_format;
+   }
+
+   format = enable_srgb ? util_format_srgb(format) : 
util_format_linear(format);
+
+   if (resource->target == PIPE_TEXTURE_1D_ARRAY) {
+      rtt_depth = rtt_height;
+      rtt_height = 1;
+   }
+
+   /* find matching mipmap level size */
+   unsigned level;
+   for (level = 0; level <= resource->last_level; level++) {
+      if (u_minify(resource->width0, level) == rtt_width &&
+          u_minify(resource->height0, level) == rtt_height &&
+          (resource->target != PIPE_TEXTURE_3D ||
+           u_minify(resource->depth0, level) == rtt_depth)) {
+         break;
+      }
+   }
+   assert(level <= resource->last_level);
+
+   /* determine the layer bounds */
+   unsigned first_layer, last_layer;
+   if (rb->rtt_layered) {
+      first_layer = 0;
+      last_layer = util_max_layer(rb->texture, level);
+   }
+   else {
+      first_layer =
+      last_layer = rb->rtt_face + rb->rtt_slice;
+   }
+
+   /* Adjust for texture views */
+   if (rb->is_rtt && resource->array_size > 1 &&
+       stTexObj->Immutable) {
+      const struct gl_texture_object *tex = stTexObj;
+      first_layer += tex->Attrib.MinLayer;
+      if (!rb->rtt_layered)
+         last_layer += tex->Attrib.MinLayer;
+      else
+         last_layer = MIN2(first_layer + tex->Attrib.NumLayers - 1,
+                           last_layer);
+   }
+
+   struct pipe_surface **psurf =
+      enable_srgb ? &rb->surface_srgb : &rb->surface_linear;
+   struct pipe_surface *surf = *psurf;
+
+   if (!surf ||
+       surf->texture->nr_samples != rb->NumSamples ||
+       surf->texture->nr_storage_samples != rb->NumStorageSamples ||
+       surf->format != format ||
+       surf->texture != resource ||
+       surf->width != rtt_width ||
+       surf->height != rtt_height ||
+       surf->nr_samples != rb->rtt_nr_samples ||
+       surf->u.tex.level != level ||
+       surf->u.tex.first_layer != first_layer ||
+       surf->u.tex.last_layer != last_layer) {
+      /* create a new pipe_surface */
+      struct pipe_surface surf_tmpl;
+      memset(&surf_tmpl, 0, sizeof(surf_tmpl));
+      surf_tmpl.format = format;
+      surf_tmpl.nr_samples = rb->rtt_nr_samples;
+      surf_tmpl.u.tex.level = level;
+      surf_tmpl.u.tex.first_layer = first_layer;
+      surf_tmpl.u.tex.last_layer = last_layer;
+
+      /* create -> destroy to avoid blowing up cached surfaces */
+      struct pipe_surface *surf = pipe->create_surface(pipe, resource, 
&surf_tmpl);
+      pipe_surface_release(pipe, psurf);
+      *psurf = surf;
+   }
+   rb->surface = *psurf;
+}
diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h
index 7ba2c1a8219..8ac97520057 100644
--- a/src/mesa/main/renderbuffer.h
+++ b/src/mesa/main/renderbuffer.h
@@ -78,6 +78,12 @@ void
 _mesa_unmap_renderbuffer(struct gl_context *ctx,
                          struct gl_renderbuffer *rb);
 
+void
+_mesa_regen_renderbuffer_surface(struct gl_context *ctx,
+                                 struct gl_renderbuffer *rb);
+void
+_mesa_update_renderbuffer_surface(struct gl_context *ctx,
+                                  struct gl_renderbuffer *rb);
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index c7a1ec867ea..af9a5fcac27 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -334,8 +334,6 @@ files_libmesa = files(
   'state_tracker/st_cb_drawtex.h',
   'state_tracker/st_cb_eglimage.c',
   'state_tracker/st_cb_eglimage.h',
-  'state_tracker/st_cb_fbo.c',
-  'state_tracker/st_cb_fbo.h',
   'state_tracker/st_cb_feedback.c',
   'state_tracker/st_cb_feedback.h',
   'state_tracker/st_cb_flush.c',
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c 
b/src/mesa/state_tracker/st_atom_framebuffer.c
index 34b2713bb4f..ad30581e4dd 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -36,7 +36,6 @@
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_cb_bitmap.h"
-#include "st_cb_fbo.h"
 #include "st_texture.h"
 #include "st_util.h"
 #include "pipe/p_context.h"
@@ -47,6 +46,7 @@
 #include "util/u_framebuffer.h"
 #include "main/framebuffer.h"
 
+#include "main/renderbuffer.h"
 
 /**
  * Update framebuffer size.
@@ -109,6 +109,7 @@ framebuffer_quantize_num_samples(struct st_context *st, 
unsigned num_samples)
 void
 st_update_framebuffer_state( struct st_context *st )
 {
+   struct gl_context *ctx = st->ctx;
    struct pipe_framebuffer_state framebuffer;
    struct gl_framebuffer *fb = st->ctx->DrawBuffer;
    struct gl_renderbuffer *rb;
@@ -148,12 +149,13 @@ st_update_framebuffer_state( struct st_context *st )
          if (rb->is_rtt || (rb->texture &&
              _mesa_is_format_srgb(rb->Format))) {
             /* rendering to a GL texture, may have to update surface */
-            st_update_renderbuffer_surface(st, rb);
+
+            _mesa_update_renderbuffer_surface(ctx, rb);
          }
 
          if (rb->surface) {
             if (rb->surface->context != st->pipe) {
-               st_regen_renderbuffer_surface(st, rb);
+               _mesa_regen_renderbuffer_surface(ctx, rb);
             }
             framebuffer.cbufs[i] = rb->surface;
             update_framebuffer_size(&framebuffer, rb->surface);
@@ -182,10 +184,10 @@ st_update_framebuffer_state( struct st_context *st )
    if (rb) {
       if (rb->is_rtt) {
          /* rendering to a GL texture, may have to update surface */
-         st_update_renderbuffer_surface(st, rb);
+         _mesa_update_renderbuffer_surface(ctx, rb);
       }
-      if (rb->surface && rb->surface->context != st->pipe) {
-         st_regen_renderbuffer_surface(st, rb);
+      if (rb->surface && rb->surface->context != ctx->pipe) {
+         _mesa_regen_renderbuffer_surface(ctx, rb);
       }
       framebuffer.zsbuf = rb->surface;
       if (rb->surface)
diff --git a/src/mesa/state_tracker/st_cb_clear.c 
b/src/mesa/state_tracker/st_cb_clear.c
index 3da9cc10ca9..b221419740e 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -45,7 +45,6 @@
 #include "st_atom.h"
 #include "st_cb_bitmap.h"
 #include "st_cb_clear.h"
-#include "st_cb_fbo.h"
 #include "st_draw.h"
 #include "st_format.h"
 #include "st_nir.h"
diff --git a/src/mesa/state_tracker/st_cb_copyimage.c 
b/src/mesa/state_tracker/st_cb_copyimage.c
index 74431d49af3..25ae78045b2 100644
--- a/src/mesa/state_tracker/st_cb_copyimage.c
+++ b/src/mesa/state_tracker/st_cb_copyimage.c
@@ -25,7 +25,6 @@
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_cb_bitmap.h"
 #include "state_tracker/st_cb_copyimage.h"
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_cb_texture.h"
 #include "state_tracker/st_texture.h"
 #include "state_tracker/st_util.h"
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index c195113b341..eecc1b2dedb 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -54,8 +54,6 @@
 #include "st_atom_constbuf.h"
 #include "st_cb_bitmap.h"
 #include "st_cb_drawpixels.h"
-#include "st_cb_readpixels.h"
-#include "st_cb_fbo.h"
 #include "st_context.h"
 #include "st_debug.h"
 #include "st_draw.h"
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c 
b/src/mesa/state_tracker/st_cb_eglimage.c
index b56bb17e578..0768db8cf7c 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -31,7 +31,6 @@
 #include "util/u_inlines.h"
 #include "util/format/u_format.h"
 #include "st_cb_eglimage.h"
-#include "st_cb_fbo.h"
 #include "st_context.h"
 #include "st_texture.h"
 #include "st_format.h"
diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
deleted file mode 100644
index a96fc2c3e4a..00000000000
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/**
- * Framebuffer/renderbuffer functions.
- *
- * \author Brian Paul
- */
-
-
-
-#include "main/context.h"
-#include "main/bufferobj.h"
-#include "main/fbobject.h"
-#include "main/framebuffer.h"
-#include "main/glformats.h"
-#include "main/macros.h"
-#include "main/renderbuffer.h"
-#include "main/state.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-#include "st_atom.h"
-#include "st_context.h"
-#include "st_cb_fbo.h"
-#include "st_cb_flush.h"
-#include "st_cb_texture.h"
-#include "st_format.h"
-#include "st_texture.h"
-#include "st_util.h"
-#include "st_manager.h"
-
-#include "util/format/u_format.h"
-#include "util/u_inlines.h"
-#include "util/u_surface.h"
-
-void
-st_regen_renderbuffer_surface(struct st_context *st,
-                              struct gl_renderbuffer *rb)
-{
-   struct pipe_context *pipe = st->pipe;
-   struct pipe_resource *resource = rb->texture;
-
-   struct pipe_surface **psurf =
-      rb->surface_srgb ? &rb->surface_srgb : &rb->surface_linear;
-   struct pipe_surface *surf = *psurf;
-   /* create a new pipe_surface */
-   struct pipe_surface surf_tmpl;
-   memset(&surf_tmpl, 0, sizeof(surf_tmpl));
-   surf_tmpl.format = surf->format;
-   surf_tmpl.nr_samples = rb->rtt_nr_samples;
-   surf_tmpl.u.tex.level = surf->u.tex.level;
-   surf_tmpl.u.tex.first_layer = surf->u.tex.first_layer;
-   surf_tmpl.u.tex.last_layer = surf->u.tex.last_layer;
-
-   /* create -> destroy to avoid blowing up cached surfaces */
-   surf = pipe->create_surface(pipe, resource, &surf_tmpl);
-   pipe_surface_release(pipe, psurf);
-   *psurf = surf;
-
-   rb->surface = *psurf;
-}
-
-/**
- * Create or update the pipe_surface of a FBO renderbuffer.
- * This is usually called after st_finalize_texture.
- */
-void
-st_update_renderbuffer_surface(struct st_context *st,
-                               struct gl_renderbuffer *rb)
-{
-   struct pipe_context *pipe = st->pipe;
-   struct pipe_resource *resource = rb->texture;
-   const struct gl_texture_object *stTexObj = NULL;
-   unsigned rtt_width = rb->Width;
-   unsigned rtt_height = rb->Height;
-   unsigned rtt_depth = rb->Depth;
-
-   /*
-    * For winsys fbo, it is possible that the renderbuffer is sRGB-capable but
-    * the format of rb->texture is linear (because we have no control over
-    * the format).  Check rb->Format instead of rb->texture->format
-    * to determine if the rb is sRGB-capable.
-    */
-   boolean enable_srgb = st->ctx->Color.sRGBEnabled &&
-      _mesa_is_format_srgb(rb->Format);
-   enum pipe_format format = resource->format;
-
-   if (rb->is_rtt) {
-      stTexObj = rb->TexImage->TexObject;
-      if (stTexObj->surface_based)
-         format = stTexObj->surface_format;
-   }
-
-   format = enable_srgb ? util_format_srgb(format) : 
util_format_linear(format);
-
-   if (resource->target == PIPE_TEXTURE_1D_ARRAY) {
-      rtt_depth = rtt_height;
-      rtt_height = 1;
-   }
-
-   /* find matching mipmap level size */
-   unsigned level;
-   for (level = 0; level <= resource->last_level; level++) {
-      if (u_minify(resource->width0, level) == rtt_width &&
-          u_minify(resource->height0, level) == rtt_height &&
-          (resource->target != PIPE_TEXTURE_3D ||
-           u_minify(resource->depth0, level) == rtt_depth)) {
-         break;
-      }
-   }
-   assert(level <= resource->last_level);
-
-   /* determine the layer bounds */
-   unsigned first_layer, last_layer;
-   if (rb->rtt_layered) {
-      first_layer = 0;
-      last_layer = util_max_layer(rb->texture, level);
-   }
-   else {
-      first_layer =
-      last_layer = rb->rtt_face + rb->rtt_slice;
-   }
-
-   /* Adjust for texture views */
-   if (rb->is_rtt && resource->array_size > 1 &&
-       stTexObj->Immutable) {
-      const struct gl_texture_object *tex = stTexObj;
-      first_layer += tex->Attrib.MinLayer;
-      if (!rb->rtt_layered)
-         last_layer += tex->Attrib.MinLayer;
-      else
-         last_layer = MIN2(first_layer + tex->Attrib.NumLayers - 1,
-                           last_layer);
-   }
-
-   struct pipe_surface **psurf =
-      enable_srgb ? &rb->surface_srgb : &rb->surface_linear;
-   struct pipe_surface *surf = *psurf;
-
-   if (!surf ||
-       surf->texture->nr_samples != rb->NumSamples ||
-       surf->texture->nr_storage_samples != rb->NumStorageSamples ||
-       surf->format != format ||
-       surf->texture != resource ||
-       surf->width != rtt_width ||
-       surf->height != rtt_height ||
-       surf->nr_samples != rb->rtt_nr_samples ||
-       surf->u.tex.level != level ||
-       surf->u.tex.first_layer != first_layer ||
-       surf->u.tex.last_layer != last_layer) {
-      /* create a new pipe_surface */
-      struct pipe_surface surf_tmpl;
-      memset(&surf_tmpl, 0, sizeof(surf_tmpl));
-      surf_tmpl.format = format;
-      surf_tmpl.nr_samples = rb->rtt_nr_samples;
-      surf_tmpl.u.tex.level = level;
-      surf_tmpl.u.tex.first_layer = first_layer;
-      surf_tmpl.u.tex.last_layer = last_layer;
-
-      /* create -> destroy to avoid blowing up cached surfaces */
-      struct pipe_surface *surf = pipe->create_surface(pipe, resource, 
&surf_tmpl);
-      pipe_surface_release(pipe, psurf);
-      *psurf = surf;
-   }
-   rb->surface = *psurf;
-}
diff --git a/src/mesa/state_tracker/st_cb_fbo.h 
b/src/mesa/state_tracker/st_cb_fbo.h
deleted file mode 100644
index 8e19185d666..00000000000
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 VMware, Inc.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-
-#ifndef ST_CB_FBO_H
-#define ST_CB_FBO_H
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/fbobject.h"
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-
-struct pipe_context;
-
-extern void
-st_update_renderbuffer_surface(struct st_context *st,
-                               struct gl_renderbuffer *strb);
-
-extern void
-st_regen_renderbuffer_surface(struct st_context *st,
-                              struct gl_renderbuffer *strb);
-
-#endif /* ST_CB_FBO_H */
diff --git a/src/mesa/state_tracker/st_cb_flush.c 
b/src/mesa/state_tracker/st_cb_flush.c
index a0107cc6b45..32032e363e8 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -38,7 +38,6 @@
 #include "st_cb_bitmap.h"
 #include "st_cb_flush.h"
 #include "st_cb_clear.h"
-#include "st_cb_fbo.h"
 #include "st_context.h"
 #include "st_manager.h"
 #include "pipe/p_context.h"
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c 
b/src/mesa/state_tracker/st_cb_readpixels.c
index 742a2e68ab4..5b04f66598b 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -36,7 +36,6 @@
 #include "util/format/u_format.h"
 #include "cso_cache/cso_context.h"
 
-#include "st_cb_fbo.h"
 #include "st_atom.h"
 #include "st_context.h"
 #include "st_cb_bitmap.h"
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 3251b91b02e..5985b9f2cc1 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -53,7 +53,6 @@
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_cb_bitmap.h"
 #include "state_tracker/st_cb_drawpixels.h"
-#include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_cb_flush.h"
 #include "state_tracker/st_cb_texture.h"
 #include "state_tracker/st_format.h"
diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index cb27f7a8a7b..ca92e57aa43 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -47,7 +47,6 @@
 #include "st_extensions.h"
 #include "st_format.h"
 #include "st_cb_bitmap.h"
-#include "st_cb_fbo.h"
 #include "st_cb_flush.h"
 #include "st_manager.h"
 #include "st_sampler_view.h"
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index 23dbd85cb39..0e72491e1b7 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -30,7 +30,6 @@
 #include "st_context.h"
 #include "st_format.h"
 #include "st_texture.h"
-#include "st_cb_fbo.h"
 #include "main/enums.h"
 
 #include "pipe/p_state.h"

Reply via email to