mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
gpu: [compute] pre-transform images before rendering
We're about to change the last stage of the compute pipeline to only accept images, not sampled textures. This change prepares materials for pixel-aligned image copying by pre-rendering images to a texture, applying transforms. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+21
-35
@@ -6,7 +6,7 @@ struct AnnoFillRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct AnnoFillTextureRef {
|
||||
struct AnnoFillImageRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
@@ -33,17 +33,16 @@ AnnoFillRef AnnoFill_index(AnnoFillRef ref, uint index) {
|
||||
return AnnoFillRef(ref.offset + index * AnnoFill_size);
|
||||
}
|
||||
|
||||
struct AnnoFillTexture {
|
||||
struct AnnoFillImage {
|
||||
vec4 bbox;
|
||||
vec4 mat;
|
||||
vec2 translate;
|
||||
uvec2 uv_bounds;
|
||||
uint index;
|
||||
ivec2 offset;
|
||||
};
|
||||
|
||||
#define AnnoFillTexture_size 48
|
||||
#define AnnoFillImage_size 24
|
||||
|
||||
AnnoFillTextureRef AnnoFillTexture_index(AnnoFillTextureRef ref, uint index) {
|
||||
return AnnoFillTextureRef(ref.offset + index * AnnoFillTexture_size);
|
||||
AnnoFillImageRef AnnoFillImage_index(AnnoFillImageRef ref, uint index) {
|
||||
return AnnoFillImageRef(ref.offset + index * AnnoFillImage_size);
|
||||
}
|
||||
|
||||
struct AnnoStroke {
|
||||
@@ -71,10 +70,10 @@ AnnoClipRef AnnoClip_index(AnnoClipRef ref, uint index) {
|
||||
#define Annotated_Nop 0
|
||||
#define Annotated_Stroke 1
|
||||
#define Annotated_Fill 2
|
||||
#define Annotated_FillTexture 3
|
||||
#define Annotated_FillImage 3
|
||||
#define Annotated_BeginClip 4
|
||||
#define Annotated_EndClip 5
|
||||
#define Annotated_size 52
|
||||
#define Annotated_size 28
|
||||
|
||||
AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) {
|
||||
return AnnotatedRef(ref.offset + index * Annotated_size);
|
||||
@@ -102,7 +101,7 @@ void AnnoFill_write(Alloc a, AnnoFillRef ref, AnnoFill s) {
|
||||
write_mem(a, ix + 4, s.rgba_color);
|
||||
}
|
||||
|
||||
AnnoFillTexture AnnoFillTexture_read(Alloc a, AnnoFillTextureRef ref) {
|
||||
AnnoFillImage AnnoFillImage_read(Alloc a, AnnoFillImageRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = read_mem(a, ix + 0);
|
||||
uint raw1 = read_mem(a, ix + 1);
|
||||
@@ -110,34 +109,21 @@ AnnoFillTexture AnnoFillTexture_read(Alloc a, AnnoFillTextureRef ref) {
|
||||
uint raw3 = read_mem(a, ix + 3);
|
||||
uint raw4 = read_mem(a, ix + 4);
|
||||
uint raw5 = read_mem(a, ix + 5);
|
||||
uint raw6 = read_mem(a, ix + 6);
|
||||
uint raw7 = read_mem(a, ix + 7);
|
||||
uint raw8 = read_mem(a, ix + 8);
|
||||
uint raw9 = read_mem(a, ix + 9);
|
||||
uint raw10 = read_mem(a, ix + 10);
|
||||
uint raw11 = read_mem(a, ix + 11);
|
||||
AnnoFillTexture s;
|
||||
AnnoFillImage s;
|
||||
s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.mat = vec4(uintBitsToFloat(raw4), uintBitsToFloat(raw5), uintBitsToFloat(raw6), uintBitsToFloat(raw7));
|
||||
s.translate = vec2(uintBitsToFloat(raw8), uintBitsToFloat(raw9));
|
||||
s.uv_bounds = uvec2(raw10, raw11);
|
||||
s.index = raw4;
|
||||
s.offset = ivec2(int(raw5 << 16) >> 16, int(raw5) >> 16);
|
||||
return s;
|
||||
}
|
||||
|
||||
void AnnoFillTexture_write(Alloc a, AnnoFillTextureRef ref, AnnoFillTexture s) {
|
||||
void AnnoFillImage_write(Alloc a, AnnoFillImageRef ref, AnnoFillImage s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
write_mem(a, ix + 0, floatBitsToUint(s.bbox.x));
|
||||
write_mem(a, ix + 1, floatBitsToUint(s.bbox.y));
|
||||
write_mem(a, ix + 2, floatBitsToUint(s.bbox.z));
|
||||
write_mem(a, ix + 3, floatBitsToUint(s.bbox.w));
|
||||
write_mem(a, ix + 4, floatBitsToUint(s.mat.x));
|
||||
write_mem(a, ix + 5, floatBitsToUint(s.mat.y));
|
||||
write_mem(a, ix + 6, floatBitsToUint(s.mat.z));
|
||||
write_mem(a, ix + 7, floatBitsToUint(s.mat.w));
|
||||
write_mem(a, ix + 8, floatBitsToUint(s.translate.x));
|
||||
write_mem(a, ix + 9, floatBitsToUint(s.translate.y));
|
||||
write_mem(a, ix + 10, s.uv_bounds.x);
|
||||
write_mem(a, ix + 11, s.uv_bounds.y);
|
||||
write_mem(a, ix + 4, s.index);
|
||||
write_mem(a, ix + 5, (uint(s.offset.x) & 0xffff) | (uint(s.offset.y) << 16));
|
||||
}
|
||||
|
||||
AnnoStroke AnnoStroke_read(Alloc a, AnnoStrokeRef ref) {
|
||||
@@ -196,8 +182,8 @@ AnnoFill Annotated_Fill_read(Alloc a, AnnotatedRef ref) {
|
||||
return AnnoFill_read(a, AnnoFillRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
AnnoFillTexture Annotated_FillTexture_read(Alloc a, AnnotatedRef ref) {
|
||||
return AnnoFillTexture_read(a, AnnoFillTextureRef(ref.offset + 4));
|
||||
AnnoFillImage Annotated_FillImage_read(Alloc a, AnnotatedRef ref) {
|
||||
return AnnoFillImage_read(a, AnnoFillImageRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
AnnoClip Annotated_BeginClip_read(Alloc a, AnnotatedRef ref) {
|
||||
@@ -222,9 +208,9 @@ void Annotated_Fill_write(Alloc a, AnnotatedRef ref, AnnoFill s) {
|
||||
AnnoFill_write(a, AnnoFillRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Annotated_FillTexture_write(Alloc a, AnnotatedRef ref, AnnoFillTexture s) {
|
||||
write_mem(a, ref.offset >> 2, Annotated_FillTexture);
|
||||
AnnoFillTexture_write(a, AnnoFillTextureRef(ref.offset + 4), s);
|
||||
void Annotated_FillImage_write(Alloc a, AnnotatedRef ref, AnnoFillImage s) {
|
||||
write_mem(a, ref.offset >> 2, Annotated_FillImage);
|
||||
AnnoFillImage_write(a, AnnoFillImageRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Annotated_BeginClip_write(Alloc a, AnnotatedRef ref, AnnoClip s) {
|
||||
|
||||
Reference in New Issue
Block a user