panfrost: Import job data structures from v3d
At the moment, Panfrost state is ad hoc, which creates issues for FBOs. This commit imports the skeleton of the v3d_job structure as panfrost_job, in preparation for refactors to organize this state. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
This commit is contained in:
parent
4eec3a2a36
commit
59c9623d0a
|
@ -31,6 +31,7 @@ files_panfrost = files(
|
||||||
'midgard/disassemble.c',
|
'midgard/disassemble.c',
|
||||||
|
|
||||||
'pan_context.c',
|
'pan_context.c',
|
||||||
|
'pan_job.c',
|
||||||
'pan_trace.c',
|
'pan_trace.c',
|
||||||
'pan_drm.c',
|
'pan_drm.c',
|
||||||
'pan_allocate.c',
|
'pan_allocate.c',
|
||||||
|
|
|
@ -1712,11 +1712,6 @@ panfrost_get_index_buffer_mapped(struct panfrost_context *ctx, const struct pipe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
panfrost_draw_vbo(
|
|
||||||
struct pipe_context *pipe,
|
|
||||||
const struct pipe_draw_info *info);
|
|
||||||
|
|
||||||
#define CALCULATE_MIN_MAX_INDEX(T, buffer, start, count) \
|
#define CALCULATE_MIN_MAX_INDEX(T, buffer, start, count) \
|
||||||
for (unsigned _idx = (start); _idx < (start + count); ++_idx) { \
|
for (unsigned _idx = (start); _idx < (start + count); ++_idx) { \
|
||||||
T idx = buffer[_idx]; \
|
T idx = buffer[_idx]; \
|
||||||
|
@ -1753,6 +1748,11 @@ panfrost_draw_vbo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now that we have a guaranteed terminating path, find the job.
|
||||||
|
* Assignment commented out to prevent unused warning */
|
||||||
|
|
||||||
|
/* struct panfrost_job *job = */ panfrost_get_job_for_fbo(ctx);
|
||||||
|
|
||||||
ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode);
|
ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode);
|
||||||
|
|
||||||
ctx->vertex_count = info->count;
|
ctx->vertex_count = info->count;
|
||||||
|
@ -2843,6 +2843,7 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
|
||||||
|
|
||||||
/* Prepare for render! */
|
/* Prepare for render! */
|
||||||
|
|
||||||
|
panfrost_job_init(ctx);
|
||||||
panfrost_emit_vertex_payload(ctx);
|
panfrost_emit_vertex_payload(ctx);
|
||||||
panfrost_emit_tiler_payload(ctx);
|
panfrost_emit_tiler_payload(ctx);
|
||||||
panfrost_invalidate_frame(ctx);
|
panfrost_invalidate_frame(ctx);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "pan_resource.h"
|
#include "pan_resource.h"
|
||||||
|
#include "pan_job.h"
|
||||||
|
|
||||||
#include "pipe/p_compiler.h"
|
#include "pipe/p_compiler.h"
|
||||||
#include "pipe/p_config.h"
|
#include "pipe/p_config.h"
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#include "pipe/p_screen.h"
|
#include "pipe/p_screen.h"
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
#include "util/u_blitter.h"
|
#include "util/u_blitter.h"
|
||||||
|
#include "util/hash_table.h"
|
||||||
|
|
||||||
/* Forward declare to avoid extra header dep */
|
/* Forward declare to avoid extra header dep */
|
||||||
struct prim_convert_context;
|
struct prim_convert_context;
|
||||||
|
@ -95,6 +97,10 @@ struct panfrost_context {
|
||||||
/* Gallium context */
|
/* Gallium context */
|
||||||
struct pipe_context base;
|
struct pipe_context base;
|
||||||
|
|
||||||
|
/* Bound job and map of panfrost_job_key to jobs */
|
||||||
|
struct panfrost_job *job;
|
||||||
|
struct hash_table *jobs;
|
||||||
|
|
||||||
/* Bit mask for supported PIPE_DRAW for this hardware */
|
/* Bit mask for supported PIPE_DRAW for this hardware */
|
||||||
unsigned draw_modes;
|
unsigned draw_modes;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Alyssa Rosenzweig
|
||||||
|
* Copyright (C) 2014-2017 Broadcom
|
||||||
|
*
|
||||||
|
* 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, sublicense,
|
||||||
|
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pan_context.h"
|
||||||
|
#include "util/hash_table.h"
|
||||||
|
#include "util/ralloc.h"
|
||||||
|
|
||||||
|
struct panfrost_job *
|
||||||
|
panfrost_create_job(struct panfrost_context *ctx)
|
||||||
|
{
|
||||||
|
/* TODO: Don't leak */
|
||||||
|
struct panfrost_job *job = rzalloc(NULL, struct panfrost_job);
|
||||||
|
|
||||||
|
job->ctx = ctx;
|
||||||
|
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct panfrost_job *
|
||||||
|
panfrost_get_job(struct panfrost_context *ctx,
|
||||||
|
struct pipe_surface **cbufs, struct pipe_surface *zsbuf)
|
||||||
|
{
|
||||||
|
/* Lookup the job first */
|
||||||
|
|
||||||
|
struct panfrost_job_key key = {
|
||||||
|
.cbufs = {
|
||||||
|
cbufs[0],
|
||||||
|
cbufs[1],
|
||||||
|
cbufs[2],
|
||||||
|
cbufs[3],
|
||||||
|
},
|
||||||
|
.zsbuf = zsbuf
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hash_entry *entry = _mesa_hash_table_search(ctx->jobs, &key);
|
||||||
|
|
||||||
|
if (entry)
|
||||||
|
return entry->data;
|
||||||
|
|
||||||
|
/* Otherwise, let's create a job */
|
||||||
|
|
||||||
|
struct panfrost_job *job = panfrost_create_job(ctx);
|
||||||
|
|
||||||
|
/* Save the created job */
|
||||||
|
|
||||||
|
memcpy(&job->key, &key, sizeof(key));
|
||||||
|
_mesa_hash_table_insert(ctx->jobs, &job->key, job);
|
||||||
|
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the job corresponding to the FBO we're currently rendering into */
|
||||||
|
|
||||||
|
struct panfrost_job *
|
||||||
|
panfrost_get_job_for_fbo(struct panfrost_context *ctx)
|
||||||
|
{
|
||||||
|
/* If we already began rendering, use that */
|
||||||
|
|
||||||
|
if (ctx->job)
|
||||||
|
return ctx->job;
|
||||||
|
|
||||||
|
/* If not, look up the job */
|
||||||
|
|
||||||
|
struct pipe_surface **cbufs = ctx->pipe_framebuffer.cbufs;
|
||||||
|
struct pipe_surface *zsbuf = ctx->pipe_framebuffer.zsbuf;
|
||||||
|
struct panfrost_job *job = panfrost_get_job(ctx, cbufs, zsbuf);
|
||||||
|
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
panfrost_job_compare(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return memcmp(a, b, sizeof(struct panfrost_job_key)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t
|
||||||
|
panfrost_job_hash(const void *key)
|
||||||
|
{
|
||||||
|
return _mesa_hash_data(key, sizeof(struct panfrost_job_key));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
panfrost_job_init(struct panfrost_context *ctx)
|
||||||
|
{
|
||||||
|
/* TODO: Don't leak */
|
||||||
|
ctx->jobs = _mesa_hash_table_create(NULL,
|
||||||
|
panfrost_job_hash,
|
||||||
|
panfrost_job_compare);
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Alyssa Rosenzweig
|
||||||
|
* Copyright (C) 2014-2017 Broadcom
|
||||||
|
*
|
||||||
|
* 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, sublicense,
|
||||||
|
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS 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 __PAN_JOB_H__
|
||||||
|
#define __PAN_JOB_H__
|
||||||
|
|
||||||
|
/* Used as a hash table key */
|
||||||
|
|
||||||
|
struct panfrost_job_key {
|
||||||
|
struct pipe_surface *cbufs[4];
|
||||||
|
struct pipe_surface *zsbuf;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* A panfrost_job corresponds to a bound FBO we're rendering to,
|
||||||
|
* collecting over multiple draws. */
|
||||||
|
|
||||||
|
struct panfrost_job {
|
||||||
|
struct panfrost_context *ctx;
|
||||||
|
struct panfrost_job_key key;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Functions for managing the above */
|
||||||
|
|
||||||
|
struct panfrost_job *
|
||||||
|
panfrost_create_job(struct panfrost_context *ctx);
|
||||||
|
|
||||||
|
struct panfrost_job *
|
||||||
|
panfrost_get_job(struct panfrost_context *ctx,
|
||||||
|
struct pipe_surface **cbufs, struct pipe_surface *zsbuf);
|
||||||
|
|
||||||
|
struct panfrost_job *
|
||||||
|
panfrost_get_job_for_fbo(struct panfrost_context *ctx);
|
||||||
|
|
||||||
|
void
|
||||||
|
panfrost_job_init(struct panfrost_context *ctx);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue