v3dv: add a concept of a command list

Just barebones for now, will expand as necessary as we start emitting
actual commands into command lists.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga 2019-12-11 10:10:27 +01:00 committed by Marge Bot
parent dc005f2677
commit 9ac3261076
4 changed files with 114 additions and 9 deletions

View file

@ -53,6 +53,7 @@ v3dv_extensions_h = custom_target(
libv3dv_files = files(
'v3dv_bo.c',
'v3dv_cl.c',
'v3dv_cmd_buffer.c',
'v3dv_debug.c',
'v3dv_debug.h',

View file

@ -0,0 +1,54 @@
/*
* Copyright © 2019 Raspberry Pi
*
* 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 "v3dv_private.h"
void
v3dv_cl_init(struct v3dv_cmd_buffer *cmd_buffer, struct v3dv_cl *cl)
{
cl->base = NULL;
cl->next = cl->base;
cl->bo = NULL;
cl->size = 0;
cl->cmd_buffer = cmd_buffer;
}
void
v3dv_cl_reset(struct v3dv_cl *cl)
{
/* FIXME: consider keeping the BO when the command buffer is reset with
* flag VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT.
*/
v3dv_cl_destroy(cl);
v3dv_cl_init(cl->cmd_buffer, cl);
}
void
v3dv_cl_destroy(struct v3dv_cl *cl)
{
assert(cl);
if (cl->bo) {
assert(cl->cmd_buffer && cl->cmd_buffer->device);
v3dv_bo_free(cl->cmd_buffer->device, cl->bo);
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright © 2019 Raspberry Pi
*
* 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 V3DV_CL_H
#define V3DV_CL_H
struct v3dv_bo;
struct v3dv_cmd_buffer;
struct v3dv_cl;
/**
* Undefined structure, used for typechecking that you're passing the pointers
* to these functions correctly.
*/
struct v3dv_cl_out;
struct v3dv_cl {
void *base;
struct v3dv_cmd_buffer *cmd_buffer;
struct v3dv_cl_out *next;
struct v3dv_bo *bo;
uint32_t size;
};
void v3dv_cl_init(struct v3dv_cmd_buffer *cmd_buffer, struct v3dv_cl *cl);
void v3dv_cl_reset(struct v3dv_cl *cl);
void v3dv_cl_destroy(struct v3dv_cl *cl);
#endif /* V3DV_CL_H */

View file

@ -55,6 +55,16 @@
#include "v3dv_extensions.h"
#include "v3dv_bo.h"
/* FIXME: hooks for the packet definition functions. */
static inline void
pack_emit_reloc(void *cl, const void *reloc) {}
#define __gen_user_data char
#define __gen_address_type char
#define __gen_emit_reloc pack_emit_reloc
#define __gen_address_offset(reloc) (0)
#include "v3dv_cl.h"
#include "vk_alloc.h"
#include "simulator/v3d_simulator.h"
@ -74,15 +84,6 @@
#define v3dv_assert(x)
#endif
/* FIXME: hooks for the packet definition functions. */
static inline void
pack_emit_reloc(void *cl, const void *reloc) {}
#define __gen_user_data char
#define __gen_address_type char
#define __gen_emit_reloc pack_emit_reloc
#define __gen_address_offset(reloc) (0)
struct v3dv_instance;
#ifdef USE_V3D_SIMULATOR