Skip to content

Commit

Permalink
line masking using vector instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
vroland committed Feb 6, 2024
1 parent 69b7af0 commit 54a63ca
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/demo/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(app_sources "main.c")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
idf_component_register(SRCS ${app_sources} REQUIRES epdiy)
34 changes: 34 additions & 0 deletions src/diff.S
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,37 @@ epd_interlace_4bpp_line_VE:
//l8ui a10, a10, 0

retw.n


.global epd_apply_line_mask_VE
.type epd_apply_line_mask_VE,@function

// void epd_apply_line_mask_VE(
// uint8_t *line,
// const uint8_t *mask,
// int mask_len
// )
epd_apply_line_mask_VE:
// line - a2
// mask - a3
// mask_len - a4

entry a1, 32

// divide by 16 for loop count
srli a4, a4, 4

// Instructions sometimes are in an unexpected order
// for best pipeline utilization
loopnez a4, .loop_end_mask

EE.VLD.128.IP q0, a2, 0
EE.VLD.128.IP q1, a3, 16

EE.ANDQ q0, q0, q1

EE.VST.128.IP q0, a2, 16

.loop_end_mask:

retw.n
6 changes: 6 additions & 0 deletions src/output_common/line_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <esp_heap_caps.h>

#include "line_queue.h"
#include "render_method.h"

static inline int ceil_div(int x, int y) { return x / y + (x % y != 0); }

Expand Down Expand Up @@ -65,9 +66,14 @@ void IRAM_ATTR lq_commit(LineQueue_t* queue) {
atomic_fetch_add(&queue->current, 1);
}

#ifdef RENDER_METHOD_LCD
void epd_apply_line_mask_VE(uint8_t *line, const uint8_t *mask, int mask_len);
epd_apply_line_mask_VE(queue->bufs[current], queue->mask_buffer, queue->mask_buffer_len);
#else
for (int i=0; i < queue->mask_buffer_len / 4; i++) {
((uint32_t*)(queue->bufs[current]))[i] &= ((uint32_t*)(queue->mask_buffer))[i];
}
#endif
}

int IRAM_ATTR lq_read(LineQueue_t* queue, uint8_t* dst) {
Expand Down

0 comments on commit 54a63ca

Please sign in to comment.