zink: reference renderpass and framebuffer from cmdbuf
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Tue, 26 Mar 2019 17:25:02 +0000 (18:25 +0100)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:44 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_cmdbuf.c
src/gallium/drivers/zink/zink_cmdbuf.h
src/gallium/drivers/zink/zink_context.c

index ab07069128ddf2765b6fc7b188791c2e077af431..aab898f84b1ac85d4980c35968d3c0af43f3a2cd 100644 (file)
@@ -2,6 +2,8 @@
 
 #include "zink_context.h"
 #include "zink_fence.h"
+#include "zink_framebuffer.h"
+#include "zink_render_pass.h"
 #include "zink_screen.h"
 
 #include "util/u_debug.h"
@@ -15,6 +17,9 @@ reset_cmdbuf(struct zink_screen *screen, struct zink_cmdbuf *cmdbuf)
 
    zink_fence_finish(screen, cmdbuf->fence, PIPE_TIMEOUT_INFINITE);
    zink_fence_reference(screen, &cmdbuf->fence, NULL);
+
+   zink_render_pass_reference(screen, &cmdbuf->rp, NULL);
+   zink_framebuffer_reference(screen, &cmdbuf->fb, NULL);
 }
 
 struct zink_cmdbuf *
index 822878d30286cfc8542937a22a6d74ee6f64e48f..ff5f4729760219a2f391a7c9f2d9500e478e1aba 100644 (file)
 
 struct zink_context;
 struct zink_fence;
+struct zink_framebuffer;
+struct zink_render_pass;
 
 struct zink_cmdbuf {
    VkCommandBuffer cmdbuf;
    struct zink_fence *fence;
+
+   struct zink_render_pass *rp;
+   struct zink_framebuffer *fb;
 };
 
 struct zink_cmdbuf *
index 30ac725d079b000d949152d04b83a965502a6d5c..af9fc3c5fe991aaa89f49046b30abe85e53c62b2 100644 (file)
@@ -760,8 +760,9 @@ zink_bind_vertex_buffers(VkCommandBuffer cmdbuf, struct zink_context *ctx)
 }
 
 static void
-begin_render_pass(struct zink_cmdbuf *cmdbuf, struct zink_render_pass *rp,
-                  struct zink_framebuffer *fb, unsigned width, unsigned height)
+begin_render_pass(struct zink_screen *screen, struct zink_cmdbuf *cmdbuf,
+                  struct zink_render_pass *rp, struct zink_framebuffer *fb,
+                  unsigned width, unsigned height)
 {
    VkRenderPassBeginInfo rpbi = {};
    rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
@@ -774,6 +775,11 @@ begin_render_pass(struct zink_cmdbuf *cmdbuf, struct zink_render_pass *rp,
    rpbi.pClearValues = NULL;
    rpbi.framebuffer = fb->fb;
 
+   assert(rp && fb);
+   assert(!cmdbuf->rp && !cmdbuf->fb);
+   zink_render_pass_reference(screen, &cmdbuf->rp, rp);
+   zink_framebuffer_reference(screen, &cmdbuf->fb, fb);
+
    vkCmdBeginRenderPass(cmdbuf->cmdbuf, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
 }
 
@@ -872,7 +878,7 @@ zink_draw_vbo(struct pipe_context *pctx,
    if (!cmdbuf)
       return;
 
-   begin_render_pass(cmdbuf, ctx->gfx_pipeline_state.render_pass,
+   begin_render_pass(screen, cmdbuf, ctx->gfx_pipeline_state.render_pass,
                      ctx->framebuffer,
                      ctx->fb_state.width, ctx->fb_state.height);