#include "zink_context.h"
#include "zink_fence.h"
#include "zink_framebuffer.h"
+#include "zink_query.h"
+#include "zink_program.h"
#include "zink_render_pass.h"
#include "zink_resource.h"
#include "zink_screen.h"
#include "util/set.h"
static void
-reset_batch(struct zink_screen *screen, struct zink_batch *batch)
+reset_batch(struct zink_context *ctx, struct zink_batch *batch)
{
+ struct zink_screen *screen = zink_screen(ctx->base.screen);
batch->descs_left = ZINK_BATCH_DESC_SIZE;
// cmdbuf hasn't been submitted before
zink_render_pass_reference(screen, &batch->rp, NULL);
zink_framebuffer_reference(screen, &batch->fb, NULL);
+ set_foreach(batch->programs, entry) {
+ struct zink_gfx_program *prog = (struct zink_gfx_program*)entry->key;
+ zink_gfx_program_reference(screen, &prog, NULL);
+ }
+ _mesa_set_clear(batch->programs, NULL);
/* unref all used resources */
set_foreach(batch->resources, entry) {
void
zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
{
- reset_batch(zink_screen(ctx->base.screen), batch);
+ reset_batch(ctx, batch);
VkCommandBufferBeginInfo cbbi = {};
cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cbbi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
if (vkBeginCommandBuffer(batch->cmdbuf, &cbbi) != VK_SUCCESS)
debug_printf("vkBeginCommandBuffer failed\n");
+
+ if (!ctx->queries_disabled)
+ zink_resume_queries(ctx, batch);
}
void
zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
{
+ if (!ctx->queries_disabled)
+ zink_suspend_queries(ctx, batch);
+
if (vkEndCommandBuffer(batch->cmdbuf) != VK_SUCCESS) {
debug_printf("vkEndCommandBuffer failed\n");
return;
}
assert(batch->fence == NULL);
- batch->fence = zink_create_fence(ctx->base.screen);
+ batch->fence = zink_create_fence(ctx->base.screen, batch);
if (!batch->fence)
return;
si.commandBufferCount = 1;
si.pCommandBuffers = &batch->cmdbuf;
- if (vkQueueSubmit(ctx->queue, 1, &si, batch->fence->fence) != VK_SUCCESS)
+ if (vkQueueSubmit(ctx->queue, 1, &si, batch->fence->fence) != VK_SUCCESS) {
debug_printf("vkQueueSubmit failed\n");
+ abort();
+ }
}
void
{
struct set_entry *entry = _mesa_set_search(batch->resources, res);
if (!entry) {
- struct pipe_resource *tmp = NULL;
entry = _mesa_set_add(batch->resources, res);
- pipe_resource_reference(&tmp, &res->base);
+ pipe_reference(NULL, &res->base.reference);
}
}
{
struct set_entry *entry = _mesa_set_search(batch->sampler_views, sv);
if (!entry) {
- struct pipe_sampler_view *tmp = NULL;
entry = _mesa_set_add(batch->sampler_views, sv);
- pipe_sampler_view_reference(&tmp, &sv->base);
+ pipe_reference(NULL, &sv->base.reference);
+ }
+}
+
+void
+zink_batch_reference_program(struct zink_batch *batch,
+ struct zink_gfx_program *prog)
+{
+ struct set_entry *entry = _mesa_set_search(batch->programs, prog);
+ if (!entry) {
+ entry = _mesa_set_add(batch->programs, prog);
+ pipe_reference(NULL, &prog->reference);
}
}