From 6b3fe1bbdb54f2e55fc32afa0bede3bfc1df9ed0 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Mon, 13 Oct 2025 18:41:42 -0500 Subject: [PATCH] drm: rename main to single_color --- drm/.gitignore | 4 ++++ drm/Makefile | 24 ++++++++++++++++++++++ drm/command_processor.h | 37 ++++++++++++++++++++++++++++++++++ drm/{main.c => single_color.c} | 37 +--------------------------------- 4 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 drm/.gitignore create mode 100644 drm/Makefile create mode 100644 drm/command_processor.h rename drm/{main.c => single_color.c} (91%) diff --git a/drm/.gitignore b/drm/.gitignore new file mode 100644 index 0000000..7880914 --- /dev/null +++ b/drm/.gitignore @@ -0,0 +1,4 @@ +* +!*.* +!*/ +!Makefile \ No newline at end of file diff --git a/drm/Makefile b/drm/Makefile new file mode 100644 index 0000000..61d6182 --- /dev/null +++ b/drm/Makefile @@ -0,0 +1,24 @@ +OPT = -O0 + +CFLAGS += -g +CFLAGS += -Wall -Werror -Wfatal-errors +CFLAGS += $(shell pkg-config --cflags libdrm) + +LDFLAGS += $(shell pkg-config --libs libdrm) + +%: %.c + $(CC) $(ARCH) $(CFLAGS) $(LDFLAGS) $(OPT) $< -o $@ + +clean: + find . -type f ! -name "*.*" -delete + +.SUFFIXES: +.INTERMEDIATE: +.SECONDARY: +.PHONY: all clean phony + +%: RCS/%,v +%: RCS/% +%: %,v +%: s.% +%: SCCS/s.% diff --git a/drm/command_processor.h b/drm/command_processor.h new file mode 100644 index 0000000..9e7362b --- /dev/null +++ b/drm/command_processor.h @@ -0,0 +1,37 @@ +#pragma once + +#define TYPE_0_COUNT(c) (((c) & 0x3fff) << 16) +#define TYPE_0_ONE_REG (1 << 15) +#define TYPE_0_BASE_INDEX(i) (((i) & 0x1fff) << 0) + +#define TYPE_3_COUNT(c) (((c) & 0x3fff) << 16) +#define TYPE_3_OPCODE(o) (((o) & 0xff) << 8) + +#define T0(address, count) \ + do { \ + ib[ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_BASE_INDEX(address >> 2); \ + } while (0); + +#define T0_ONE_REG(address, count) \ + do { \ + ib[ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_ONE_REG | TYPE_0_BASE_INDEX(address >> 2); \ + } while (0); + +#define T0V(address, value) \ + do { \ + ib[ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX(address >> 2); \ + ib[ix++].u32 = value; \ + } while (0); + +#define T0Vf(address, value) \ + do { \ + ib[ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX(address >> 2); \ + ib[ix++].f32 = value; \ + } while (0); + +#define T3(opcode, count) \ + do { \ + ib[ix++].u32 = (0b11 << 30) | TYPE_3_COUNT(count) | TYPE_3_OPCODE(opcode); \ + } while (0); + +#define _3D_DRAW_IMMD_2 0x35 diff --git a/drm/main.c b/drm/single_color.c similarity index 91% rename from drm/main.c rename to drm/single_color.c index c22fe16..0c12350 100644 --- a/drm/main.c +++ b/drm/single_color.c @@ -14,6 +14,7 @@ #include "3d_registers.h" #include "3d_registers_undocumented.h" #include "3d_registers_bits.h" +#include "command_processor.h" union u32_f32 { uint32_t u32; @@ -22,42 +23,6 @@ union u32_f32 { static union u32_f32 ib[16384]; -#define TYPE_0_COUNT(c) (((c) & 0x3fff) << 16) -#define TYPE_0_ONE_REG (1 << 15) -#define TYPE_0_BASE_INDEX(i) (((i) & 0x1fff) << 0) - -#define TYPE_3_COUNT(c) (((c) & 0x3fff) << 16) -#define TYPE_3_OPCODE(o) (((o) & 0xff) << 8) - -#define T0(address, count) \ - do { \ - ib[ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_BASE_INDEX(address >> 2); \ - } while (0); - -#define T0_ONE_REG(address, count) \ - do { \ - ib[ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_ONE_REG | TYPE_0_BASE_INDEX(address >> 2); \ - } while (0); - -#define T0V(address, value) \ - do { \ - ib[ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX(address >> 2); \ - ib[ix++].u32 = value; \ - } while (0); - -#define T0Vf(address, value) \ - do { \ - ib[ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX(address >> 2); \ - ib[ix++].f32 = value; \ - } while (0); - -#define T3(opcode, count) \ - do { \ - ib[ix++].u32 = (0b11 << 30) | TYPE_3_COUNT(count) | TYPE_3_OPCODE(opcode); \ - } while (0); - -#define _3D_DRAW_IMMD_2 0x35 - int indirect_buffer() { int ix = 0;