summaryrefslogtreecommitdiff
path: root/src/til_fb.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-06-27 12:01:59 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-08-07 06:54:53 -0700
commit206251e387038697c013e7efea3782d81fd910b8 (patch)
tree204b28be6aa04f8a96623865777cbc76f8c9d3d2 /src/til_fb.h
parent5a0776f1fdc6b7780cd21d568150e804347a6f8a (diff)
til: experimentally fragment-centric page api
It seems like it might be most ergonomic and convenient for everything to just use til_fb_fragment_t and rely on ops.submit to determine if the fragment is a page or not, and if it is how to submit it. This commit brings things into that state of the world, it feels kind of gross at the til_fb_page_*() API. See the large comment in til_fb.c added by this commit for more information. I'm probably going to just run with this for now, it can always get cleaned up later. What's important is to get the general snapshotting concept and functionality in place so modules can make use of it. There will always be things to cleanup in this messy tangle of a program.
Diffstat (limited to 'src/til_fb.h')
-rw-r--r--src/til_fb.h47
1 files changed, 18 insertions, 29 deletions
diff --git a/src/til_fb.h b/src/til_fb.h
index ff9b3ec..da86605 100644
--- a/src/til_fb.h
+++ b/src/til_fb.h
@@ -10,42 +10,29 @@
#include "til_util.h"
typedef struct til_fb_fragment_t til_fb_fragment_t;
+typedef struct til_fb_fragment_ops_t til_fb_fragment_ops_t;
#define TIL_FB_DRAW_FLAG_TEXTURABLE 0x1
-typedef struct til_fb_fragment_ops_t {
- til_fb_fragment_t * (*snapshot)(til_fb_fragment_t **fragment_ptr);
- void (*submit)(til_fb_fragment_t *fragment);
- void (*free)(til_fb_fragment_t *fragment);
-} til_fb_fragment_ops_t;
-
/* All renderers should target fb_fragment_t, which may or may not represent
* a full-screen mmap. Helpers are provided for subdividing fragments for
* concurrent renderers.
*/
typedef struct til_fb_fragment_t {
- til_fb_fragment_ops_t ops; /* ops applicable to this fragment */
- til_fb_fragment_t *texture; /* optional source texture when drawing to this fragment */
- uint32_t *buf; /* pointer to the first pixel in the fragment */
- unsigned x, y; /* absolute coordinates of the upper left corner of this fragment */
- unsigned width, height; /* width and height of this fragment */
- unsigned frame_width; /* width of the frame this fragment is part of */
- unsigned frame_height; /* height of the frame this fragment is part of */
- unsigned stride; /* number of 32-bit words from the end of one row to the start of the next */
- unsigned pitch; /* number of 32-bit words separating y from y + 1, including any padding */
- unsigned number; /* this fragment's number as produced by fragmenting */
- unsigned cleared:1; /* if this fragment has been cleared since last flip */
+ const til_fb_fragment_ops_t *ops; /* optional opaque ops for physical fragments, NULL for strictly logical fragments */
+
+ til_fb_fragment_t *texture; /* optional source texture when drawing to this fragment */
+ uint32_t *buf; /* pointer to the first pixel in the fragment */
+ unsigned x, y; /* absolute coordinates of the upper left corner of this fragment */
+ unsigned width, height; /* width and height of this fragment */
+ unsigned frame_width; /* width of the frame this fragment is part of */
+ unsigned frame_height; /* height of the frame this fragment is part of */
+ unsigned stride; /* number of 32-bit words from the end of one row to the start of the next */
+ unsigned pitch; /* number of 32-bit words separating y from y + 1, including any padding */
+ unsigned number; /* this fragment's number as produced by fragmenting */
+ unsigned cleared:1; /* if this fragment has been cleared since last flip */
} til_fb_fragment_t;
-/* This is a page handle object for page flip submission/life-cycle.
- * Outside of fb_page_get()/fb_page_put(), you're going to be interested in
- * fb_fragment_t. The fragment included here describes the whole page,
- * it may be divided via fb_fragment_divide().
- */
-typedef struct til_fb_page_t {
- til_fb_fragment_t fragment;
-} til_fb_page_t;
-
typedef struct til_fb_t til_fb_t;
/* Supply this struct to fb_new() with the appropriate context */
@@ -55,13 +42,15 @@ typedef struct til_fb_ops_t {
void (*shutdown)(til_fb_t *fb, void *context);
int (*acquire)(til_fb_t *fb, void *context, void *page);
void (*release)(til_fb_t *fb, void *context);
- void * (*page_alloc)(til_fb_t *fb, void *context, til_fb_page_t *res_page);
+ void * (*page_alloc)(til_fb_t *fb, void *context, til_fb_fragment_t *res_page_fragment);
int (*page_free)(til_fb_t *fb, void *context, void *page);
int (*page_flip)(til_fb_t *fb, void *context, void *page);
} til_fb_ops_t;
-til_fb_page_t * til_fb_page_get(til_fb_t *fb);
-void til_fb_page_put(til_fb_t *fb, til_fb_page_t *page);
+til_fb_fragment_t * til_fb_page_get(til_fb_t *fb);
+void til_fb_fragment_submit(til_fb_fragment_t *fragment);
+til_fb_fragment_t * til_fb_fragment_snapshot(til_fb_fragment_t **fragment_ptr, int preserve_original);
+til_fb_fragment_t * til_fb_fragment_reclaim(til_fb_fragment_t *fragment);
til_fb_t * til_fb_free(til_fb_t *fb);
void til_fb_get_put_pages_count(til_fb_t *fb, unsigned *count);
int til_fb_new(const til_fb_ops_t *ops, const til_setup_t *setup, int n_pages, til_fb_t **res_fb);
© All Rights Reserved