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:
Elias Naur
2021-02-08 17:35:31 +01:00
parent 87ffaaf8c4
commit c9a8265126
13 changed files with 533 additions and 241 deletions
+14 -12
View File
@@ -18,7 +18,7 @@ struct FillRef {
uint offset;
};
struct FillTextureRef {
struct FillImageRef {
uint offset;
};
@@ -88,14 +88,15 @@ FillRef Fill_index(FillRef ref, uint index) {
return FillRef(ref.offset + index * Fill_size);
}
struct FillTexture {
uvec2 uv_bounds;
struct FillImage {
uint index;
ivec2 offset;
};
#define FillTexture_size 8
#define FillImage_size 8
FillTextureRef FillTexture_index(FillTextureRef ref, uint index) {
return FillTextureRef(ref.offset + index * FillTexture_size);
FillImageRef FillImage_index(FillImageRef ref, uint index) {
return FillImageRef(ref.offset + index * FillImage_size);
}
struct Stroke {
@@ -152,7 +153,7 @@ ClipRef Clip_index(ClipRef ref, uint index) {
#define Element_Transform 10
#define Element_BeginClip 11
#define Element_EndClip 12
#define Element_FillTexture 13
#define Element_FillImage 13
#define Element_size 36
ElementRef Element_index(ElementRef ref, uint index) {
@@ -212,12 +213,13 @@ Fill Fill_read(FillRef ref) {
return s;
}
FillTexture FillTexture_read(FillTextureRef ref) {
FillImage FillImage_read(FillImageRef ref) {
uint ix = ref.offset >> 2;
uint raw0 = scene[ix + 0];
uint raw1 = scene[ix + 1];
FillTexture s;
s.uv_bounds = uvec2(raw0, raw1);
FillImage s;
s.index = raw0;
s.offset = ivec2(int(raw1 << 16) >> 16, int(raw1) >> 16);
return s;
}
@@ -314,7 +316,7 @@ Clip Element_EndClip_read(ElementRef ref) {
return Clip_read(ClipRef(ref.offset + 4));
}
FillTexture Element_FillTexture_read(ElementRef ref) {
return FillTexture_read(FillTextureRef(ref.offset + 4));
FillImage Element_FillImage_read(ElementRef ref) {
return FillImage_read(FillImageRef(ref.offset + 4));
}