Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
deac3152
Commit
deac3152
authored
Sep 1, 2023
by
pippin
Browse files
Options
Downloads
Patches
Plain Diff
st3m_gfx: allow rasterize to run in paralell with draw
parent
cd998a51
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/st3m/st3m_gfx.c
+28
-26
28 additions, 26 deletions
components/st3m/st3m_gfx.c
with
28 additions
and
26 deletions
components/st3m/st3m_gfx.c
+
28
−
26
View file @
deac3152
...
@@ -46,6 +46,7 @@ EXT_RAM_BSS_ATTR uint16_t st3m_overlay_backup[OVERLAY_WIDTH * OVERLAY_HEIGHT];
...
@@ -46,6 +46,7 @@ EXT_RAM_BSS_ATTR uint16_t st3m_overlay_backup[OVERLAY_WIDTH * OVERLAY_HEIGHT];
// drawlist ctx
// drawlist ctx
static
Ctx
*
user_ctx
=
NULL
;
static
Ctx
*
user_ctx
=
NULL
;
static
Ctx
*
user_copy_ctx
=
NULL
;
// RGB565_byteswapped framebuffer ctx - our global ctx
// RGB565_byteswapped framebuffer ctx - our global ctx
// user_ctx gets replayed on this
// user_ctx gets replayed on this
...
@@ -210,7 +211,7 @@ static void st3m_gfx_task(void *_arg) {
...
@@ -210,7 +211,7 @@ static void st3m_gfx_task(void *_arg) {
flow3r_bsp_display_send_fb
(
st3m_overlay_fb
,
32
);
flow3r_bsp_display_send_fb
(
st3m_overlay_fb
,
32
);
break
;
break
;
case
st3m_gfx_default
:
case
st3m_gfx_default
:
ctx_render_ctx
(
user_ctx
,
fb_ctx
);
ctx_render_ctx
(
user_
copy_
ctx
,
fb_ctx
);
if
(
_st3m_overlay_y1
!=
_st3m_overlay_y0
)
if
(
_st3m_overlay_y1
!=
_st3m_overlay_y0
)
st3m_ctx_merge_overlay
(
st3m_ctx_merge_overlay
(
fb
,
fb
,
...
@@ -233,7 +234,7 @@ static void st3m_gfx_task(void *_arg) {
...
@@ -233,7 +234,7 @@ static void st3m_gfx_task(void *_arg) {
flow3r_bsp_display_send_fb
(
fb
,
16
);
flow3r_bsp_display_send_fb
(
fb
,
16
);
break
;
break
;
}
}
ctx_drawlist_clear
(
user_ctx
);
ctx_drawlist_clear
(
user_
copy_
ctx
);
xQueueSend
(
user_ctx_freeq
,
&
descno
,
portMAX_DELAY
);
xQueueSend
(
user_ctx_freeq
,
&
descno
,
portMAX_DELAY
);
st3m_counter_rate_sample
(
&
rast_rate
);
st3m_counter_rate_sample
(
&
rast_rate
);
...
@@ -481,9 +482,9 @@ void st3m_gfx_init(void) {
...
@@ -481,9 +482,9 @@ void st3m_gfx_init(void) {
flow3r_bsp_display_init
();
flow3r_bsp_display_init
();
// Create drawlist ctx queues.
// Create drawlist ctx queues.
user_ctx_freeq
=
xQueueCreate
(
1
+
1
,
sizeof
(
int
));
user_ctx_freeq
=
xQueueCreate
(
2
+
1
,
sizeof
(
int
));
assert
(
user_ctx_freeq
!=
NULL
);
assert
(
user_ctx_freeq
!=
NULL
);
user_ctx_rastq
=
xQueueCreate
(
1
+
1
,
sizeof
(
int
));
user_ctx_rastq
=
xQueueCreate
(
2
+
1
,
sizeof
(
int
));
assert
(
user_ctx_rastq
!=
NULL
);
assert
(
user_ctx_rastq
!=
NULL
);
// Setup framebuffer descriptor.
// Setup framebuffer descriptor.
...
@@ -499,36 +500,42 @@ void st3m_gfx_init(void) {
...
@@ -499,36 +500,42 @@ void st3m_gfx_init(void) {
// Setup user_ctx descriptor.
// Setup user_ctx descriptor.
user_ctx
=
user_ctx
=
ctx_new_drawlist
(
FLOW3R_BSP_DISPLAY_WIDTH
,
FLOW3R_BSP_DISPLAY_HEIGHT
);
ctx_new_drawlist
(
FLOW3R_BSP_DISPLAY_WIDTH
,
FLOW3R_BSP_DISPLAY_HEIGHT
);
user_copy_ctx
=
ctx_new_drawlist
(
FLOW3R_BSP_DISPLAY_WIDTH
,
FLOW3R_BSP_DISPLAY_HEIGHT
);
assert
(
user_ctx
!=
NULL
);
assert
(
user_ctx
!=
NULL
);
ctx_set_texture_cache
(
user_ctx
,
fb_ctx
);
ctx_set_texture_cache
(
user_ctx
,
fb_ctx
);
ctx_set_texture_cache
(
user_copy_ctx
,
fb_ctx
);
// Push descriptor to freeq.
// Push descriptor to freeq.
int
i
=
0
;
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
BaseType_t
res
=
xQueueSend
(
user_ctx_freeq
,
&
i
,
0
);
BaseType_t
res
=
xQueueSend
(
user_ctx_freeq
,
&
i
,
0
);
assert
(
res
==
pdTRUE
);
assert
(
res
==
pdTRUE
);
}
// Start rasterization, compositing and scan-out
// Start rasterization, compositing and scan-out
res
=
xTaskCreate
(
st3m_gfx_task
,
"graphics"
,
8192
,
NULL
,
BaseType_t
res
=
xTaskCreate
(
st3m_gfx_task
,
"graphics"
,
8192
,
NULL
,
ESP_TASK_PRIO_MIN
+
1
,
&
graphics_task
);
ESP_TASK_PRIO_MIN
+
1
,
&
graphics_task
);
assert
(
res
==
pdPASS
);
assert
(
res
==
pdPASS
);
}
}
static
int
descno
=
0
;
static
Ctx
*
st3m_gfx_drawctx_free_get
(
TickType_t
ticks_to_wait
)
{
static
Ctx
*
st3m_gfx_drawctx_free_get
(
TickType_t
ticks_to_wait
)
{
int
descno
;
BaseType_t
res
=
xQueueReceive
(
user_ctx_freeq
,
&
descno
,
portMAX_DELAY
);
BaseType_t
res
=
xQueueReceive
(
user_ctx_freeq
,
&
descno
,
ticks_to_wait
);
if
(
res
!=
pdTRUE
)
return
NULL
;
if
(
res
!=
pdTRUE
)
{
return
NULL
;
}
return
user_ctx
;
return
user_ctx
;
}
}
static
void
st3m_gfx_drawctx_pipe_put
(
void
)
{
static
void
st3m_gfx_drawctx_pipe_put
(
void
)
{
int
i
=
0
;
Ctx
*
tmp
=
user_ctx
;
xQueueSend
(
user_ctx_rastq
,
&
i
,
portMAX_DELAY
);
user_ctx
=
user_copy_ctx
;
user_copy_ctx
=
tmp
;
xQueueSend
(
user_ctx_rastq
,
&
descno
,
portMAX_DELAY
);
}
}
void
st3m_ctx_end_frame
(
Ctx
*
ctx
)
{
st3m_gfx_drawctx_pipe_put
();
}
uint8_t
st3m_gfx_drawctx_pipe_full
(
void
)
{
uint8_t
st3m_gfx_drawctx_pipe_full
(
void
)
{
return
uxQueue
SpacesAvailable
(
user_ctx_
rast
q
)
==
0
;
return
uxQueue
MessagesWaiting
(
user_ctx_
free
q
)
==
0
;
}
}
void
st3m_gfx_flush
(
void
)
{
void
st3m_gfx_flush
(
void
)
{
...
@@ -544,14 +551,13 @@ void st3m_gfx_flush(void) {
...
@@ -544,14 +551,13 @@ void st3m_gfx_flush(void) {
// And drain again.
// And drain again.
xQueueReset
(
user_ctx_freeq
);
xQueueReset
(
user_ctx_freeq
);
int
i
=
0
;
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
BaseType_t
res
=
xQueueSend
(
user_ctx_freeq
,
&
i
,
0
);
BaseType_t
res
=
xQueueSend
(
user_ctx_freeq
,
&
i
,
0
);
assert
(
res
==
pdTRUE
);
assert
(
res
==
pdTRUE
);
}
ESP_LOGW
(
TAG
,
"Pipeline flush/reset done."
);
ESP_LOGW
(
TAG
,
"Pipeline flush/reset done."
);
}
}
static
int
st3m_user_ctx_no
=
0
;
// always 0 - but this keeps pipelined
// rendering working as a compile time opt-in
Ctx
*
st3m_ctx
(
TickType_t
ticks_to_wait
)
{
Ctx
*
st3m_ctx
(
TickType_t
ticks_to_wait
)
{
Ctx
*
ctx
=
st3m_gfx_drawctx_free_get
(
ticks_to_wait
);
Ctx
*
ctx
=
st3m_gfx_drawctx_free_get
(
ticks_to_wait
);
if
(
!
ctx
)
return
NULL
;
if
(
!
ctx
)
return
NULL
;
...
@@ -580,10 +586,6 @@ Ctx *st3m_overlay_ctx(void) {
...
@@ -580,10 +586,6 @@ Ctx *st3m_overlay_ctx(void) {
return
overlay_ctx
;
return
overlay_ctx
;
}
}
void
st3m_ctx_end_frame
(
Ctx
*
ctx
)
{
xQueueSend
(
user_ctx_rastq
,
&
st3m_user_ctx_no
,
portMAX_DELAY
);
}
void
st3m_gfx_overlay_clip
(
int
x0
,
int
y0
,
int
x1
,
int
y1
)
{
void
st3m_gfx_overlay_clip
(
int
x0
,
int
y0
,
int
x1
,
int
y1
)
{
if
(
y1
<
OVERLAY_Y
)
y1
=
OVERLAY_Y
;
if
(
y1
<
OVERLAY_Y
)
y1
=
OVERLAY_Y
;
if
(
y1
>
OVERLAY_Y
+
OVERLAY_HEIGHT
)
y1
=
OVERLAY_Y
+
OVERLAY_HEIGHT
;
if
(
y1
>
OVERLAY_Y
+
OVERLAY_HEIGHT
)
y1
=
OVERLAY_Y
+
OVERLAY_HEIGHT
;
...
...
This diff is collapsed.
Click to expand it.
dos
@dos
mentioned in commit
c5807712
·
Sep 2, 2023
mentioned in commit
c5807712
mentioned in commit c5807712aa92a159b9afa4fe5e8e369f780b8948
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment