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

Author: Dave Airlie <[email protected]>
Date:   Tue Dec 21 15:38:18 2021 +1000

mesa/st: move render/finish_render texture in to mesa.

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

---

 src/mesa/main/fbobject.c           | 68 +++++++++++++++++++++++++++++++---
 src/mesa/state_tracker/st_cb_fbo.c | 75 --------------------------------------
 src/mesa/state_tracker/st_cb_fbo.h |  4 --
 3 files changed, 63 insertions(+), 84 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 96ca680393a..48c64ae1386 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -413,7 +413,65 @@ get_fb0_attachment(struct gl_context *ctx, struct 
gl_framebuffer *fb,
    }
 }
 
+/**
+ * Return the pipe_resource which stores a particular texture image.
+ */
+static struct pipe_resource *
+get_teximage_resource(struct gl_texture_object *texObj,
+                      unsigned face, unsigned level)
+{
+   struct gl_texture_image *stImg =
+      texObj->Image[face][level];
+
+   return stImg->pt;
+}
+
+static void
+render_texture(struct gl_context *ctx,
+               struct gl_framebuffer *fb,
+               struct gl_renderbuffer_attachment *att)
+{
+   struct st_context *st = st_context(ctx);
+   struct gl_renderbuffer *rb = att->Renderbuffer;
+   struct pipe_resource *pt;
+
+   pt = get_teximage_resource(att->Texture,
+                              att->CubeMapFace,
+                              att->TextureLevel);
+   assert(pt);
+
+   /* point renderbuffer at texobject */
+   rb->is_rtt = TRUE;
+   rb->rtt_face = att->CubeMapFace;
+   rb->rtt_slice = att->Zoffset;
+   rb->rtt_layered = att->Layered;
+   rb->rtt_nr_samples = att->NumSamples;
+   pipe_resource_reference(&rb->texture, pt);
+
+   st_update_renderbuffer_surface(st, rb);
+
+   /* Invalidate buffer state so that the pipe's framebuffer state
+    * gets updated.
+    * That's where the new renderbuffer (which we just created) gets
+    * passed to the pipe as a (color/depth) render target.
+    */
+   st_invalidate_buffers(st);
+
+
+   /* Need to trigger a call to update_framebuffer() since we just
+    * attached a new renderbuffer.
+    */
+   ctx->NewState |= _NEW_BUFFERS;
+}
 
+static void
+finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+   rb->is_rtt = FALSE;
+
+   /* restore previous framebuffer state */
+   st_invalidate_buffers(st_context(ctx));
+}
 
 /**
  * Remove any texture or renderbuffer attached to the given attachment
@@ -427,7 +485,7 @@ remove_attachment(struct gl_context *ctx,
 
    /* tell driver that we're done rendering to this texture. */
    if (rb)
-      st_finish_render_texture(ctx, rb);
+      finish_render_texture(ctx, rb);
 
    if (att->Type == GL_TEXTURE) {
       assert(att->Texture);
@@ -531,7 +589,7 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
    rb->TexImage = texImage;
 
    if (driver_RenderTexture_is_safe(att))
-      st_render_texture(ctx, fb, att);
+      render_texture(ctx, fb, att);
 }
 
 /**
@@ -549,7 +607,7 @@ set_texture_attachment(struct gl_context *ctx,
    struct gl_renderbuffer *rb = att->Renderbuffer;
 
    if (rb)
-      st_finish_render_texture(ctx, rb);
+      finish_render_texture(ctx, rb);
 
    if (att->Texture == texObj) {
       /* re-attaching same texture */
@@ -3032,7 +3090,7 @@ check_begin_texture_render(struct gl_context *ctx, struct 
gl_framebuffer *fb)
       struct gl_renderbuffer_attachment *att = fb->Attachment + i;
       if (att->Texture && att->Renderbuffer->TexImage
           && driver_RenderTexture_is_safe(att)) {
-         st_render_texture(ctx, fb, att);
+         render_texture(ctx, fb, att);
       }
    }
 }
@@ -3054,7 +3112,7 @@ check_end_texture_render(struct gl_context *ctx, struct 
gl_framebuffer *fb)
       struct gl_renderbuffer_attachment *att = fb->Attachment + i;
       struct gl_renderbuffer *rb = att->Renderbuffer;
       if (rb) {
-         st_finish_render_texture(ctx, rb);
+         finish_render_texture(ctx, rb);
       }
    }
 }
diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index c9e72d3b7b4..213219728fc 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -536,81 +536,6 @@ st_update_renderbuffer_surface(struct st_context *st,
    rb->surface = *psurf;
 }
 
-
-/**
- * Return the pipe_resource which stores a particular texture image.
- */
-static struct pipe_resource *
-get_teximage_resource(struct gl_texture_object *texObj,
-                      unsigned face, unsigned level)
-{
-   struct gl_texture_image *stImg =
-      texObj->Image[face][level];
-
-   return stImg->pt;
-}
-
-
-/**
- * Called by ctx->Driver.RenderTexture
- */
-void
-st_render_texture(struct gl_context *ctx,
-                  struct gl_framebuffer *fb,
-                  struct gl_renderbuffer_attachment *att)
-{
-   struct st_context *st = st_context(ctx);
-   struct gl_renderbuffer *rb = att->Renderbuffer;
-   struct pipe_resource *pt;
-
-   pt = get_teximage_resource(att->Texture,
-                              att->CubeMapFace,
-                              att->TextureLevel);
-   assert(pt);
-
-   /* point renderbuffer at texobject */
-   rb->is_rtt = TRUE;
-   rb->rtt_face = att->CubeMapFace;
-   rb->rtt_slice = att->Zoffset;
-   rb->rtt_layered = att->Layered;
-   rb->rtt_nr_samples = att->NumSamples;
-   pipe_resource_reference(&rb->texture, pt);
-
-   st_update_renderbuffer_surface(st, rb);
-
-   /* Invalidate buffer state so that the pipe's framebuffer state
-    * gets updated.
-    * That's where the new renderbuffer (which we just created) gets
-    * passed to the pipe as a (color/depth) render target.
-    */
-   st_invalidate_buffers(st);
-
-
-   /* Need to trigger a call to update_framebuffer() since we just
-    * attached a new renderbuffer.
-    */
-   ctx->NewState |= _NEW_BUFFERS;
-}
-
-
-/**
- * Called via ctx->Driver.FinishRenderTexture.
- */
-void
-st_finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer *rb)
-{
-   struct st_context *st = st_context(ctx);
-
-   if (!rb)
-      return;
-
-   rb->is_rtt = FALSE;
-
-   /* restore previous framebuffer state */
-   st_invalidate_buffers(st);
-}
-
-
 /** Debug helper */
 static void
 st_fbo_invalid(const char *reason)
diff --git a/src/mesa/state_tracker/st_cb_fbo.h 
b/src/mesa/state_tracker/st_cb_fbo.h
index c4a6c63c912..f3b40a26a47 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -78,10 +78,6 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
                               struct gl_renderbuffer *rb,
                               GLenum internalFormat,
                               GLuint width, GLuint height);
-void st_render_texture(struct gl_context *ctx,
-                       struct gl_framebuffer *fb,
-                       struct gl_renderbuffer_attachment *att);
-void st_finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer 
*rb);
 void st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer 
*fb);
 void st_discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
                             struct gl_renderbuffer_attachment *att);

Reply via email to